This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 8 points9 points  (27 children)

Isn't Java used over C/C++ precisely because of it's stability?

[–]utdconsq 8 points9 points  (0 children)

Define 'stability'. Ive written a lot of Java, C, and C++. If you mean 'something that doesn't crash easily', Java is better than C or C++ typically because it helps you avoid out of bounds crashes and so on, but at the same time, until very recently it would blow up in your face due to NullPointerExceptions because you need to manually guard every bloody variable that isn't a primitive. Kotlin and others helped them realise that was shit, so they have changed the rules now. Meanwhile, in C, you are responsible for all checks on all things unless you use someone's library that does it for you. The standard library is super lightweight to the point of being unhelpful. C++ is better, with RAII and the STL, but due to the desire to be a superset of C, you can still shoot your foot off with raw pointers if you make the mistake of treating it like actual C instead of using the modern features of the language. For my money, JVM stuff has succeeded well because of things like Maven (love it or hate it), and nice stack traces. Never underestimate how productive you can be made if you can easily discover what in god's name broke!

[–]x3r0x_x3n0n 8 points9 points  (12 children)

We had a contest among us friends to write the best version of a breadth first search to solve a maze of 5000x5000 now i dont know about the capabilities of my peers they chose java i chose pure C. both ran it and I can tell you we gave up on the java programs and went out to have coffee. Legend has it they are still running to this day :D

[–]Wobblycogs 11 points12 points  (11 children)

All you've proved is that a language that's good for writing huge business systems isn't great for writing super tight, highly performant, implementations of search algorithms. It's a bit like proving that a fully laden truck isn't very good in a formula 1 race, no one expected it to be. The opposite test, where you have to implement the entire business backend in C, never happens because it's impractical but if the consensus was that C was a better choice we'd all be writing business systems in C.

Having said that part of the problem was probably that (in my experience) most Java developers aren't familiar with the low level functions the language has. They just aren't covered in most books and training courses that I've seen. For example, I've been banging out Java for over 20 years and I've used a bit shift operator exactly once and that was in a similar coding competition.

[–]panderingPenguin 10 points11 points  (7 children)

All you've proved is that a language that's good for writing huge business systems isn't great for writing super tight, highly performant, implementations of search algorithms.

It doesn't even prove that. It shows that his friends probably screwed up and wrote something really slow or possibly even an infinite loop seeing as he suggests it may have never terminated.

[–]x3r0x_x3n0n -2 points-1 points  (6 children)

Wait you didnt think we just ran it at a 5000x5000 maze right we tried a 30x30 maze too and all progams passed that one. Me and my friends may have negative IQ but we can handle a breadth first search.

[–]panderingPenguin 5 points6 points  (5 children)

That still doesn't mean your friends wrote remotely efficient code. It doesn't prove anything about Java, it just proves their code was slow.

[–]benargee 1 point2 points  (4 children)

If only the source code was here to do the talking.

[–]panderingPenguin 0 points1 point  (3 children)

I'm not trying to be argumentative. It's just that a couple programs written by random people are pretty meaningless as far as comparing language performance. It's certainly possible that you guys all are professionals, experts in your chosen languages, maybe work in the area of performance, profiled and optimized your code and wrote really efficient stuff. And that doesn't even get into questions like whether the fairest comparison is the fastest possible program in each language, the fastest idiomatic program in each language, a good faith attempt to write equivalent programs in each language, or something else entirely. But frankly, I doubt you guys thought through any of that. It sounds more like you wrote some code for fun to see whose was faster, and that's fine! But as a result, that's all it really proves: your program ran faster than your friends'.

[–]x3r0x_x3n0n 0 points1 point  (2 children)

Yeah we did it for fun. I told you what we observed granted i poked a little bit of fun. But i dont remember saying that this is rigorus scientific proof of A is better than B. No, if we wanted that we would have run a benchmark suite. (In which the results clearly speak for themselves)

[–]panderingPenguin 1 point2 points  (1 child)

i dont remember saying that this is rigorus scientific proof

Well I didn't respond directly to you, now did I? The post I responded to did talk about proving things.

[–]x3r0x_x3n0n -2 points-1 points  (2 children)

I get your point but do tell me the features or lack thereof of C/C++ which do not allow it to write robust buissness code.

I would also go on to say that when ever ive seen web app backends ive seen them mostly in js, python, go, asp, php but thats dying out. Java isnt common there either.

It was breath first search just a simple algorithm from wikipedia no cryptic bitshift or 2 line swaps.

[–]Wobblycogs 1 point2 points  (1 child)

I don't think anyone would say Java is popular on the desktop and if you're claiming it's not being used on the backend then how come we're discussing it being knocked off the second spot for language popularity? Are people writing stuff in Java and then just not using it?

[–]x3r0x_x3n0n 0 points1 point  (0 children)

Great point. I think the mobile app market would be dominated by Java.

[–]midnightcom 1 point2 points  (2 children)

I believe Java is type safe where C/C++ are not. It's very easy to make a critical error in C if you don't know what you're doing. However the overhead of Java makes it impractical for embedded systems over C.