Live data from Hacker News

If Java Is Dying, It Sure Looks Awfully Healthy

drdobbs.com

121–130 of 327 posts

Re: If Java Is Dying, It Sure Looks Awfully Healthy

#121

Earlier quoted context omitted.

> and don't get me started on Objective-C.. itsNotTheLanguagesFaultPerSe:butIfTheFunctions:andTheirParameters:werentNamedLikeThis:itWouldBeBearable

I find the descriptive nature of method signatures to be quite delightful. Unlike other languages like C++, I don't always have to go looking for the function definition to see the types of the parameters it takes, and what exactly was the order again? Combined with Xcode's autocomplete, it saves a lot of time. I shed a small tear every time I have to call a C API with and endless parade of (NULL, NULL, 0, NULL).

In C99 it's possible to use compound literals to implement something like named parameters. You create a struct with all of your parameters, and only include the ones you want to set in the compound literal. Anything not explicitly specified in the compound literal gets set to 0, so the caveat is that 0 can't be a valid value for your parameters.

Re: If Java Is Dying, It Sure Looks Awfully Healthy

#122
post #43

I'm surprised nobody has mentioned Android yet. When you add in the Android factor, Java is probably still one of the most widely used programming languages today. It's funny the article straight away brings up the verbosity argument as well. You want to talk about verbosity - take a look at Objective-C and Cocoa (again, hugely popular today!)! Personally, I quite like Java.

> I'm surprised nobody has mentioned Android yet. When you add in the Android factor, Java is probably still one of the most widely used programming languages today.

Except that Oracle was right into suing Google, after all.

Google hasn't improved the language level beyond Java 6 grammar.

So nowadays one is forced to write in Java 6 when targeting Android, which is really a pain, specially when writing libraries.

This will only get worse when Java 8 gets released. No lambdas or other Java 8 goodies for Android developers.

Plus, they haven't bothered to improved GC and JIT on Dalvik past the Android 2.3 release.

They seem to care only about pushing libraries for Google APIs nowadays.

Re: If Java Is Dying, It Sure Looks Awfully Healthy

#123
post #106
post #71

Earlier quoted context omitted.

I agree that C code is currently faster than Java in most benchmarks: http://benchmarksgame.alioth.debian.org/u32q/benchmark.php?t... There is no contradiction that a compiler written in a language with expensive semantics (say python), could compile a program written in another language (say C) to produce highly efficient machine code. The JVM operations, such as JIT compilation and garbage collection, are bound by…

> There is no contradiction that a compiler written in a language with expensive semantics (say python), could compile a program written in another language (say C) to produce highly efficient machine code. Maybe not a contradiction in logic, no. But in practice the compiler has to solve a problem that is much harder than the problem the programmer would have to solve to write efficient C code for this one case. It's…

Sorry I was not clear enough.

I am not making any kind of sufficiently smart compiler claim (http://c2.com/cgi/wiki?SufficientlySmartCompiler).

You think I am saying that a compiler can do optimization better than a human.

What I assert is that the implementation language of a the tool that generates machine code guarantees nothing about either the source language, or the quality of the generated code. This was the assertion of the parent that invalid. He said that because the Java JIT compiler was written in C, that necessarily implies that the generated machine code would be slower that C.

Consider an Assembler, written in C, that generates machine code. By your logic you can't argue that assembly code is always less efficient than C.

Or alternatively Fortran compilers, written in C, which produce machine code that outperforms code generated from C for many tasks.

Re: If Java Is Dying, It Sure Looks Awfully Healthy

#124

Earlier quoted context omitted.

I think generally the libraries in Java help programmers use data structures that make the language seem faster (trees/hashes) . These structures exist in c++ but aren't as easy to use so aren't used as frequently. Those processors extensions will make mathy c++ code significantly faster. When I was on an ada project all the mathy code was written in c/c++ for speed. Pretty amazing the difference.

What? C++ comes with robust trees & hashes via the STL, along with a pretty extensive library of algorithms that work on all the STL containers. And, unlike Java, C++ lets you pack value objects contiguously in memory, which can be a massive performance win due to better cache behavior/no pointer chasing.

And, unlike Java, C++ lets you pack value objects contiguously in memory, which can be a massive performance win due to better cache behavior/no pointer chasing.

Certainly, and it is one of the features that I am often missing in Java. Rather than having an array of structs, you need to make n parallel arrays, where n is the number of struct fields. And sometimes such hacks are necessary to make things compact and fast.

But I do understand why they don't provide value types. Say, that I am allocating an array of foobar_t. And foobar_t is defined in another library. If the author of the other library changes the layout of foobar_t, you get ABI breakage. This is what brought the whole PIMPL/d-pointer mess that is often necessary in C++ and to some extend C libraries.

Re: If Java Is Dying, It Sure Looks Awfully Healthy

#125
post #58
post #25

Earlier quoted context omitted.

I'm fairly certain Java and C++ have comparable speeds, and I think in someways Java's faster.

Many painful minutes spent with slow-like-sloth-taking-a-shit Java desktop software lead me to believe that your statement isn't entirely true.

IntelliJ, which is a large Java Swing application, certainly works fine and quick on all of my machines.

Re: If Java Is Dying, It Sure Looks Awfully Healthy

#126
post #111

Earlier quoted context omitted.

This usually seems to be due to bad code, or bad GUI libraries (which Java seems to be the king of)

And bad developers using those libraries.

The fact that this sluggishness is not present in Visual Basic programs implies this is the library, not the programmers or the language.

Re: If Java Is Dying, It Sure Looks Awfully Healthy

#127
post #25

Earlier quoted context omitted.

I'm fairly certain Java and C++ have comparable speeds, and I think in someways Java's faster.

Java runs about 2x slower than C++ for general CPU-bound stuff - (although it does use much more RAM). That sounds slow, but it's faster than most other languages out there. However, C++ does give you the ability to more easily use processor extensions (SSE, AVX, etc), which you can't use from Java AFAIK - which makes a big difference in performance for certain applications.

I've read that you can call asm from java directly using jni (i.e. without a c wrapper) though I've never done it myself.

Re: If Java Is Dying, It Sure Looks Awfully Healthy

#128
post #66
post #51

Earlier quoted context omitted.

What language do you think your favorite C compiler is written in? Now compare that C compiler to the jvm compiler, which has the benefit of using detailed information about the exact system configuration and other runtime behaviours during its compilation phases. Which one has the advantage?

C to both of your questions. The JVM compiler compiles for the JVM, which is written in C. So, how again can something written in C perform faster than...something written in C? I'm not claiming that line by line transcription, C will always perform each particular operation faster than Java. But the fact that you could write the entire JVM in C means that you could recreate the exact platform and replicate the resul…

The JVM compiler compiles for the JVM, which is written in C. So, how again can something written in C perform faster than...something written in C?

Well, first of all, the JVM generates machine code, not C.

Apart from that, you can easily be shown to be wrong. If you are compiling a binary with C, you are compiling for the lowest common denominator. Say, if you are compiling for x86_64, you are probably compiling for all x86_64 CPUs. You can optimize for newer instances of x86_64 (say Core i3), but you cannot use any instructions that are not available on e.g. Core 2, if that is the lowest common denominator that you support.

The Java VM could, on the other hand, decide to use instructions during the compilation of hot spots which are available on a Core i3 and not on a Core 2, when it detects that the CPU is a Core i3.

Re: If Java Is Dying, It Sure Looks Awfully Healthy

#129
post #95
post #56

Earlier quoted context omitted.

Eclipse has something similar, which it calls "code templates." Features like these leave me wondering why "excessive typing" is often cited as a criticism of Java. As far as I can estimate on the fly, I type less than half of the characters that make up my Java code. And as the article points out, for readability, verbosity is arguably a good thing. I sure believe it is, perhaps because I am more distracted by poor…

Excessive typing isn't the issue. The problem with verbose code is that code gets read way more than it gets written. In Java you're often reading 15 lines of code for something that could be 2-3 in other languages.

And still, I have seen plenty of Java code which is perfectly readable and Haskell, Perl, or Ruby code (2-3 lines) that resembled line noise. And I am a Haskell fan :).

The worst offender in Java are IMO anonymous inner classes. But IntelliJ shows them abbreviated. E.g. IIRC Runnables are displayed in Java 8 lambda syntax.

Re: If Java Is Dying, It Sure Looks Awfully Healthy

#130
post #17

There's a lot wrong with Java, but even while having moved on and learned / used professionally many other languages I keep coming back to it and its ecosystem. There is still not another language / platform that provides the same level of a variety of things that are important to me: * platform independence * performance * low level features * simplicity and clarity (for reading, writing not so much) * infrastructur…

You can get all of that and clearer writing in c#, with Intellisense.

Doesn't C# have "magic" getters and setters, where code like "foo.bar = quux;" might mean a function call? To me, that's not clearer at all.
Post reply on HN