File accessing -Java or C++ [closed] - c++

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I have a lot of data kept in a file. Which one would be fastest for accessing some keywords from that file multiple times? Java or C++. Am I going to get some advantage in speed if I keep those data in a database like Sqlite compared to file operation?

Because C++ is a low-level language, while Java runs in a virtual machine, well-written C++ code will typically be faster than well-written Java code, especially for low-level operations (including file accesses). Java has significant overhead whenever it needs to perform an operation outside of its virtual machine.
For large amounts of data, a database will be much faster than direct file operation; it's exactly what a database is designed to do.

Use C++, because it compiles directly to native bytecode. While some JVMs also do that, Java can't be guaranteed to always run that way. A database language would be even better, like the Sqlite you mentioned, because the language is specifically optimized for database stuff.

Related

Should i use std::string in a web server for parsing a client request? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 months ago.
Improve this question
I'm coding a little HTTP 1.1 web server in C++98 (c++ version mandated by my school) and i haven't make a decision about which data type i'm gonna use to perform the request parsing, and how.
Since i'll be receiving read-only (by read-only i mean that i don't have to modify the buffer) data from a user-agent, would it make sense to use std::string to store the incoming data ?
HTTP syntax is very straightforward, and can be parse using a finite state machine. Iterating over a const char * seems enough and doesn't make any allocations, i can use buffer that recv gives me.
On the other hand, i could use std::string facilities like find and substr to parse the request, but that would lead to memory allocations.
My server doesn't need to be as efficient as nginx, but i'm still worried about the performance of my application.
I'm eager to know your thoughts.
Definitely. It's a school project, not a high-performance production server (in which case you'd be using a more modern C++ variant).
The biggest performance problem you'd typically have with std::string is not parsing, but string building. a + b + c + d + e can be rather inefficient. Details, really: just start by writing a correct implementation, and then see which parts are too slow in testing. There are very few projects, even in commercial software development, where that's not the right approach.

Use clojure to develop game server [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
I'm developing a server for a game. You kown in games,many data structures should be mutable. But Clojure's data structures is immutable. Is there some good idea to
do this? Should i use clojure for it?
Mutating data structures allows you to squeeze the last ounces of performance out of your code, but given that you're writing a server, network latency probably has a much greater impact than memory allocations. Clojure should be suitable, certainly as a starting point.
While Clojure's data structures are immutable, application state can be managed via atoms, refs, core.async loop state, and data pipelines. A Clojure application is hardly static just because its data structures are.
The biggest risk you face right now is figuring out what to build, and Clojure's live development model will accelerate the learning loop. You can redefine functions while the server is running and see their effects immediately.
I suggest you prototype your server in Clojure, then, if performance gains need to be made, profile the code. If necessary, you can introduce transients and volatiles, and port performance critical sections to Java.

What are my options for cross program communication? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
A while ago i made a database framework in c++ and have been using it in various places, even made a wrapper for it for vb.net.
Now i have a new project that would require multiple programs accessing a single database and it would be wasteful to load up the database multiple times for every one of them not to mention the syncing horrors.
So I figured i would turn the framework into a standalone application and access to the data would be done in some xx magical way from those other programs. From what I've seen php and mysql do something like this..?
Problem is, I have no clue where to start. The only kind of cross program communication i've done is one program reading and writing directly into the other ones memory, seems kinda hacky though and I'm not sure if that sort of thing is going to fly with managed languages (I want to make it accessible in vb.net too).
Tips?
The most portable way to do IPC (inter-process communication) is probably going to be Sockets.
What about D-Bus? There ist a port for Windows.

Advice on C++ database program [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I want to build a simple program that searches through a local database and returns a list of results. Essentially the program will be a searchable archive. This will be my first project of this type and I'm looking for some advice.
Fast reading of the database is important. Writing can be slow.
There will be at most a few thousand records, and most records will probably contain less than 3 kb in text.
Records should be flexible when it comes to their fields. Some records will have the field "abc", others will not. The number of fields per record may vary.
Should I simply write my data structures in C++, and then serialize them? Does it make sense to use an existing (lightweight) database framework? If so, can you recommend any that are free and easy to use and preferably written in modern C++?
My target platform is Window and I'm using the Visual Studio compiler.
Edit: the consensus is to use SQLite. Any recommendations as to which of the many SQlite C++ wrappers to use?
As commented by #Joachim, I would suggest SQLite. I have used it in C++ projects and it's straightforward to use. You basically put two files in your project sqlite3.c and sqlite3.h and then start coding to the interface (read the last paragraph of http://www.sqlite.org/selfcontained.html). You don't have to worry about configuring a database server. It's fast and lightweight. Read about transactions and SQLite if you need to speed some operations up.

Integrating a program written in C with another one written in C++ [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm working on a project where I need to integrate 2 simulation software packages; as in the output from one is to be used as input for the other one, and vice versa. The exchange of information happens at every time-step of the simulation, so it occurs very frequently. Both simulation packages have support for plugins: one of them supports plugins written in C, and the other supports plugins written in C++. Is there an elegant way to integrate these two plugins to make the software packages talk to each other? I thought about reading/writing files to hard drive, but I'm hoping that there is a better way to do this.
Thanks all!
Is SOAP or RESTful service an option? That would work in both C and C++
You definitely can use files to do that, but I wouldn't recommend writing them to the disk, but to use a Memory-mapped file. There are several libraries that implement this functionality, such as Boost C++. Java has the FileChannel class that handles it