2

As far as I know, many nosql stores are written in java, for example HBase, Cassandra. But according to my experience, many high performance server program are written in c/c++ (e.g. Apache, Opensips, etc.), why can such java-implementing program behave well in production use?Is it because that Java code is easy to read and maintain and distributed system implemented in java scales well?

BTW, I know that writing code in Java is sure more productive, but as someone said, implementation speed is not a question in big company, because once implemented and refactor for several rounds, the program can run very well, so the cost of time is not high for from a long term view.

realjin
  • 1,485
  • 1
  • 19
  • 38
  • 3
    "...implementation speed is not a question in big company..." Wow, I must have worked in another universe in the last decade or so. So I guess this is a YMMV thing ;-) – A.H. Feb 11 '12 at 11:21
  • -1 I don't believe the answer to a broad question like this, even limited to the context of NoSql, is a good fit for this site – Crowie Jan 21 '14 at 20:13

1 Answers1

10

If you follow the first link (Why was Cassandra written in Java) in the "Related" section on the right, you will find answers.

Short summary:

  • It is platform independent.
  • Java code is not necessarily much slower than C/C++, sometimes even faster (see below)
  • Java has built in threading support right from the start - for any platform
  • Security/Safety (no buffer-overflows, core dumps, ...)

EDIT The "C/C++ is faster than Java by definition" myth is just that - a myth. Look at this question for a counter example.

Community
  • 1
  • 1
A.H.
  • 63,967
  • 15
  • 92
  • 126
  • 3
    +1 Good answer to a poor question. – Andrew Thompson Feb 11 '12 at 11:53
  • In fact I've read the article (Why was Cassandra written in Java), but from my experience, some low level networking program(e.g. many networking utilities in linux system) is written in C, do they exist just for historic reason and compatibility reason rather than performance reason? BTW, the reference article about C++/Java exec speed comparasion is very useful! – realjin Feb 11 '12 at 12:07
  • 4
    C/C++ has its advantages and on low-level system (as in OS-level) programming I also don't want to use anything else for good reasons. This will also not change in my lifetime. But application code is better written in a language with not so sharp edges. Between these extremes there is a large grey field where both language styles fight for dominance. Hint: _THAT_ database systems (e.a.) are now written in Java _and_ are successful is a strong sign that both the language itself and the complete runtime infrastructure is _very_ mature. – A.H. Feb 11 '12 at 12:18
  • +1 - so well written. I'll look forward to your answers here if there are more like this. – duffymo Feb 11 '12 at 13:03
  • 1
    The example you're giving of the "C/C++ is faster than Java by definition" being a fallacy turns out to really bad optimization in the Intel C++ compiler. The conclusion is: Java 7 seconds, MSVC 12 miliseconds... – Joakim Dec 02 '13 at 12:51