Choosing the right language

A few months ago I started teaching myself some Java in my spare time, I chose Java because of its architecture and how it compiles itself and because it can be run on any machine regardless of OS so long as you have the runtime executables. However after reading some articles like this one on slashdot;

"At Cassandra Summit opening today, Avi Kivity and Dor Laor (who had previously written KVM and OSv) announced ScyllaDB — an open-source C++ rewrite of Cassandra, the popular NoSQL database. ScyllaDB claims to achieve a whopping 10 times more throughput per node than the original Java code, with sub-millisecond 99%ile latency. They even measured 1 million transactions per second on a single node. The performance of the new code is attributed to writing it in Seastar — a C++ framework for writing complex asynchronous applications with optimal performance on modern hardware."

Should I really just learn C++ instead? Can you use layers and vectors just as effectively or should I stay with Java in that regard. It really just feels like who should I run with, Microsoft or Oracle lol.. I'm going to assume that there will always be a faster language or a language that preforms better at certain things but I really just want a solid general purpose language for making applications using vectors and layers.

Surprised no variation of Basic is mentioned in your picture...

Lol I'm not :P

every language has a purpose... if it were me, I would go ahead and learn both.

I'd say, since you're learning Java already, keep doing that, once you're comfortable with your java knowledge, then you can pick up C++, it'll be much easier to learn a new language that shares the same programming paradigm (imperative and OO [Object Oriented]) and pretty much the same syntax.

Then you can compare the two of them and figure out what language works best for your type of activities and workflow.

Also you're not forced to use Microsoft "implementation" of C++, you can use the g++ compiler if you're under GNU/Linux or set up cygwin.

Also C++ can be portable too (code only) if you don't use platform specific libraries and you can always cross compile from one system to another. For example you can write your code under Linux and from Linux cross compile the source code into a windows executable.

2 Likes

Good advice. I'd suggest you get really good at one language rather than mediocre at a couple. The Cassandra comment reads like a sales pitch so it's always going to sell itself as way better than before or why should anyone change what they're using. I bet if they re-wrote the Java version they could make it way faster too. You learn a lot writing something and generally you'd write it better the second time around.

In my professional time I support/develop business critical Java apps and the biggest problem we face isn't out and out performance of Java it's the speed differences caused by the current style of deployment, i.e. sticking lots of things "virtualised" on to one server. Our app can be running just as efficiently as it was yesterday but if the NAS is doing more work then our app goes slower.

ASM-One or GTFO!

People keep doing the mistake of sticking to one language it seems. If you want to learn to program you need a taste of each kind of languages and technologies and you need to develop a way of thinking that will help you pick up new languages in a matter of days. I suggest learning at least one of each category:
1. Natively compiled language (best use C, knowing Assembly is a huge plus, it's always a bonus to know how stuff works)
2. Popular JIT compiled language (C#, Java, etc)
3. Scipting language (Perl, Python, Lua etc)
4. Functional language (F#, Haskell etc)

Even though I'd recommend learning in that order, Java is a reasonably good start, then you want to learn to work with memory yourself, learn C or C++ (since you will already be familiar with OO). Then you can pick up some scripting language, since it will come in handy way more than a functional language would. And finally the functional language will teach you a new way of writing and designing things, which is nice to know.

And even though you will learn Java, I suggest you learn C# later anyway, as a language it's better than Java by orders of magnitude, I still don't love it too much though as it's not as optimal to run on Linux as Java is.

Why is learning Python learning "the best way"?

Thanks for all the feedback, really appreciate it. I'm just doing this for fun so I think I'll stick with Java and who knows, maybe if I get good enough I can compile my own libraries to speed things up. :D

if you are going to make a statement like this please back it up with some facts...

1 Like

I think Java would be a better choice for "general purpose" programming. You're not always going to want to optimize the way you can in C++, which would have to be one of the major reasons for using such a language. Managing memory can easily double the amount of code you need to write to get the same thing done, and cause more bugs.

easy to learn and very useful.

Ok.

  1. Reflection is simpler to work with.
  2. Extension methods, they are great to have.
  3. Encapsulation is very clean, unlike in Java.
  4. LINQ, I don't need to explain anything here I think.
  5. Testing frameworks offer parameterized tests that don't actually suck, this is due to better reflection.
  6. Serialization libraries are cleaner, offer more functionality, this is due better reflection.
  7. Having a single build system is sometimes a bonus, because it works very well.
  8. No freaky and annoying things with checked and unchecked exceptions, in C# they are all just one type, makes them a lot simpler to handle.

These are some of those arguments that I can give you from the top of my head without researching anything, I'm sure I could find more, and I'm just speaking language wise. The thing is, equivalent C# code is much cleaner than Java code. The under-the-hood wise C#, being a CLI language, has a very solid garbage collector and almost perfect integration with Windows. The GC is so great that you shouldn't even worry about it until your memory reaches 12GB. Java on the other hand starts acting weirdly after >8GB. The Java system in general does have it's perks though. Like being the only proper JIT compiled language on Linux (not speaking about other JVM languages). Mono, performance and Windows framework support wise is lagging behind, but it works at least, making porting applications is an actual option. On the Java system you can also have a very detailed level of customization, like choosing what GC to use, how long stop-the-world pauses should be, having a large choice of JVM's even. These reasons are why I still code with Java even though I think C# is better.

Also you might want to keep in mind that these insights come from me being an actual developer. You will likely not even notice these differences when you don't need to read and deal with millions lines of code.

Java it is then :D lol but really thanks and hopefully someday I will.

Java has it even worse though. Try making a Windows service with it, that should run on a server with no GUI. You have to use leaky wrappers that suck just because you have to use them, because it's not an elegant solution :D. And well, it depends on where will you go with programming, you might never need to :).

i gotta disagree with number 8... knowing what kind of exception it is can be very helpful with debugging. although you make a good point with number 3.

I love how you can over ride operators in c# it just makes so much sense. I hate that java doesn't allow you to do that. A lot of people will tell you that operators aren't overridden in java... they are wrong. += works for all primitive data types for a reason. but java coders cannot programmatically override operators without writing an entire method which uses up more resources when you are constantly making method calls. which is very annoying if you are writing Vector Classes or some other type of class that uses those principles.

I personally never really got into Python all that much, but I think its a good pick for learning how to program. There's a ton of libraries which are easier to install than Java if you're using pip, for example. Lots of beginner tutorials on programming out there showing you Python too. The list goes on.

Only gripe I have with Python is the community fragmentation you have now because of Python 3, etc.

I guess they did that with exceptions because they don't think differentiating types they matter that much. And because it's not so clean when you want to throw an unchecked exception. Like so:

try {
    // whatever
}
catch(Exception ex) {
    throw new RuntimeException();
}

This gets annoying after a while :).

but java coders cannot programmatically override operators without
writing an entire method which uses up more resources when you are
constantly making method calls.

I wouldn't exactly worry about it. Since both JVM and CLI machine are optimizing themselves in runtime, inlining methods etc. I would be way more careful about useless allocations :).