开发者

Why was Cassandra written in Java? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 12 years ago.

Question about Cassandra

Why the hell on earth would anybody write a database ENGINE in Java ?

I can understand why you would want to have a Java interface, but the engine...

I was under the impression that there's nothing faster than C/C++, and that a database engine shouldn't be any slower than max speed, and certainly not use garbage collection...

Can anybody explain me 开发者_开发知识库what possible sense that makes / why Cassandra can be faster than ordinary SQL that runs on C/C++ code ?

Edit:

Sorry for the "Why the hell on earth" part, but it really didn't make any sense to me.

I neglected to consider that a database, unlike the average garden-varitety user programs, needs to be started only once and then runs for a very long time, and probably also as the only program on the server, which self-evidently makes for an important performance difference.

I was more comparing/referencing to a 'disfunctional' (to put it mildly) Java tax program I was using at the time of writing (or rather would have liked to use).

In fact, unlike using Java for tax programs, using Java for writing a dedicated server program makes perfect sense.


What do you mean, C++? Hand coded assembly would be faster if you have a few decades to spare.


I can see a few reasons:

  • Security: it's easier to write secure software in Java than in C++ (remember the buffer overflows?)
  • Performance: it's not THAT worse. It's definitely worse at startup, but once the code is up and running, it's not a big thing. Actually, you have to remember an important point here: Java code is continually optimized by the VM, so in some circumstances, it gets faster than C++


Why the hell on earth would anybody write a database ENGINE in JAVA ?

Platform independance is a pretty big factor for servers, because you have a lot more hardware and OS heterogenity than with desktop PCs. Another is security. Not having to worry about buffer overflows means most of the worst kind of security holes are simply impossible.

I was under the impression that there's nothing faster than C/C++, and that a database engine shouldn't be any slower than max speed, and certainly not use garbage collection...

Your impression is incorrect. C/C++ is not necessarily faster than Java, and modern garbage collectors have a big part in that because they enable object creation to be incredibly fast.


Don't forget that Java VMs make use of a just-in-time (JIT) engine that perform on-the-fly optimisations to make Java comparable to C++ in terms of speed. Bearing in mind that Java is quite a productive language (despite its naysayers) and portable, together with the JIT optimisation capability, means that Java isn't an unreasonable choice for something like this.


The performance penalty for modern Java runtimes is not that big and programming in Java is less error-prone than in c.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜