Other Best language for a database server

mseqs

Member

Reaction score: 1
Messages: 21

Hello everyone.

So, I'm writing a little database server/manager (I know, don't reinvent the wheel, but is a research project and I got a good idea, innovative, I hope) and from the beginning I thought to write it in Java, but after some researching about "performance and memory issues" I'm not sure if it's the right choice. Some benchmarks shows very tiny time difference and others shows larger differences.

Is java suitable for a application like this? I've done some tests myself but I don't know how exactly these languages act in a real situation, with hundreds (if not thousands) of connections.

Memory is a concern because I consider running it on a Raspberry Pi, for example, and a database with multiple string operations (Java's string encoding is twice as big than C/C++'s UTF-8 or even ASCII, for example) so it would be a unnecessary cost.

Thanks in advance.
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 10,592
Messages: 36,224

I don't think Java is a good choice for this. The database server itself should be as lean and fast as possible allowing most of the resources to be assigned for the databases. Java itself already uses quiet a lot of resources. So, in my view, the best language would be C.
 

tingo

Daemon

Reaction score: 573
Messages: 2,450

IMHO:
- if it is for learning; don't care about performance.
- if you care about performance, start by running some tests of existing databases on your Raspberry Pi (or other platform of choice) to get numbers to compare your database against.
 
OP
mseqs

mseqs

Member

Reaction score: 1
Messages: 21

Java was my first choice because of the insane portability (one binary, all OSes and architectures I've heard about) and no need to wrappers for different platforms (integers, for example, or socket APIs, etc.). I noticed that the JVM has some startup delay but I don't care about that, what worries me is the memory usage (Java doesn't have structs, meaning that everything being a class (or object) is quite expensive).

The problem is that I don't know how far this project can go, starting with the wrong tool can destroy my chances on making something sucessful. Among the database management itself, the runtime process will depend on more processing than usual (I can't provide more information so soon, but I hope revealing it publicy once the project is somewhat usable), so its a serious concern a powerful tool and less memory usage as possible, to make it run on simpler machines and handle a high amount of requests without being too expensive on efficient hardware.

Some tests I have seen show java using far more memory than the same C program (Java using 31kb while C using 1kb, why?! source), it then became a issue. While using less memory (yes, it depends on the programmer) and being more "powerful" (again) there are many cons, including not being portable as Java (requires compilation on all platforms, which most of them I don't have at home), use of specific APIs (such as threads and sockets) which means non-portable or different code for each platform and multiple binary executable formats (a page full of files/packages to download with all the architectures and platforms that I want to support instead of just a single file/package for all of them) and so on. Based on these characteristics (and others if you'd like to add more to the list) which language is worthwhile using?
 

chrbr

Aspiring Daemon

Reaction score: 339
Messages: 854

Have you considered Python? It might be a compromise between Java and C. At least others say so. I have no experience with Java. In case of Python many extensions are available which can be imported and used for your project.
 
OP
mseqs

mseqs

Member

Reaction score: 1
Messages: 21

Have you considered Python? It might be a compromise between Java and C. At least others say so. I have no experience with Java. In case of Python many extensions are available which can be imported and used for your project.

Thanks for the tip, but the main question is not the largest amount of tools/libraries available, but the balance between usability (tools, libraries, frameworks and paradigms), runtime characteristcs (low memory usage and high performance) and portability (with or without recompilation, number of platforms supported and how well these platforms are supported).
 

chrbr

Aspiring Daemon

Reaction score: 339
Messages: 854

Because of the balance I have suggested Python. It is a scripting language available on lots of platforms. For the stuff I use it (math using numpy) I found it faster than other related scripting languages (octave). Working in the shell is nice. The documentation is good as well.
 
OP
mseqs

mseqs

Member

Reaction score: 1
Messages: 21

I heard that Python is single-threaded, is that true? That could be tricky, handling hundreds of requests on a single thread is quite impossible. Also Python is full interpreted, right? I don't know if the Python interpreter for its source code is faster than the JVM for java bytecode, but I think is possible. I got some parts which need scripting (a lot) and I was considering lua (the only thing created on my country which is useful for someone (joking (?)) after javascript, but I'll take a look at Python. It may have a API to C/C++ like lua, or a engine/interpreter like JavaScript. I'll search these topics and see if it works well. Thanks anyway, any help/tip is really appreciated.
 
OP
mseqs

mseqs

Member

Reaction score: 1
Messages: 21

Sorry about that. I didn't consider Python until now, I just saw a forum discussion (somewhere, I may misunderstood his words) where someone said the Python interpreter was single-threaded. Anyway, I like Python, it's cool, I just haven't used it so far. I googled and it seems just like another scripting language to embed, and it is indeed slower than java (quite obvious) but for scripting is runs reasonably fast. I'll search about before replying next time :)
 

drhowarddrfine

Son of Beastie

Reaction score: 1,984
Messages: 3,980

If you are looking for small size and speed, since you want it on a RPI, C is your only option. You won't get either with Python or Clojure or LISP or Java. Those languages will require an interpreter. Java requires the JVM. Interpreted languages can't run as fast as compiled C.

Unless you want to do it in assembly. I'm up for that.
 

tingo

Daemon

Reaction score: 573
Messages: 2,450

The problem is that I don't know how far this project can go, starting with the wrong tool can destroy my chances on making something sucessful.
Why do you think so?
If your idea / algorithm / whatever really is something (and of course it can be!) you can just re-implement it in a "new tool" if needed for any reason (speed, resource efficiency, ?) after you have proved that it works as intended. Yes, it will cost extra time but that is time well spent if you reach your improvement goals.
 
OP
mseqs

mseqs

Member

Reaction score: 1
Messages: 21

Why do you think so?
If your idea / algorithm / whatever really is something (and of course it can be!) you can just re-implement it in a "new tool" if needed for any reason (speed, resource efficiency, ?) after you have proved that it works as intended. Yes, it will cost extra time but that is time well spent if you reach your improvement goals.
You're right. It does not need to be perfect at V1.0 or at launch, if the idea is good enough it can be "optimized" (including rewriting it) if needed.
I think I'll choose Java (or a JVM-based language, Scala is really interesting). It will support most architectures/platforms for a initial state, meaning that a bigger range of end-users will be capable of using my DB.

Thanks everyone, I'll post more details soon, when the idea gets clear enough and it becomes a little bit usable.
 
Top