News for hackers. Stuff that matters.
Re:If Java Is Dying, It Sure Looks Awfully Healthy by jasallen on Wednesday October 09, 2013 @07:21PM (#6524616)
Java may not be dying, but it does take off early on Fridays for golf.

Java is not dying the same way Cobol was not dying 10 years ago. It has a lot of legs left but nobody is 'hoping' to use it, they are told to do so.

Java is and always has been almost completely a corporate tool. Again, like Cobol, so the 'cool kids' are not going to give it much love. It's too slow to execute to compete with C++, its too slow to write to compete with Groovy or Scala. And all the cool kids pick an extreme and vote that way.

Java is not 'dead', but thought leaders aren't using it right now. The people who inherited the decision of thought leaders of 15 years ago are using it, so the writing is on the wall, its just going to take a while to be read.

Re:If Java Is Dying, It Sure Looks Awfully Healthy by gaius on Thursday October 10, 2013 @05:27AM (#6526515)
Well, yes and no. I'm old enough to remember when Java was launched, and I was getting paid to write Java in '96. At the time it was going to be a whole new way to write software - modular software made of components downloaded on the fly whenever you needed them. That is why package names work like that , com.sun.java.blah meant a class called Blah that you would grab from the server java.sun.com when you first instantiated it. Of course it didn't work out like that, it was only in the late 90s that Java morphed into a corporate back-end language. You can pinpoint when this happened when they rushed out the JDBC spec.
Re:If Java Is Dying, It Sure Looks Awfully Healthy by teh_klev on Thursday October 10, 2013 @06:03AM (#6526623)
I was at that birthing as well....and had the joy of using CORBA, I can see my copy of The CORBA Reference Guide by Alan Pope sitting in the "candidates for landfill" area of my bookshelf.
Re:If Java Is Dying, It Sure Looks Awfully Healthy by jasallen on Thursday October 10, 2013 @09:30AM (#6527501)
Don't get me wrong, the guys at Sun were quality geeks, and they never set out to create the Corporate Back End Language of record. But that's how it gained its huge head of steam.

Another reason I failed to mention that Java is in decline is that the geek / utility-driven folks at Sun had essentially said "Java is a mature language now" and were focusing on other languages for the platform. Then the sales and marketing people at Oracle got involved and realized that was not the best way to bilk their existing customers.

Re:If Java Is Dying, It Sure Looks Awfully Healthy by RivieraKid on Thursday October 10, 2013 @06:31AM (#6526684)
Comparing Java to Cobol is ridiculous. I'm in the cool kids category and I like Java. If you don't want to / can't use C#, there's simply no alternative for bigger projects.

Groovy - slower, much worse toolability

Scala - less readable, slower, slow compilation, worse toolability, too complex.

Re:If Java Is Dying, It Sure Looks Awfully Healthy by gizzlon on Thursday October 10, 2013 @06:54AM (#6526731)
If you don't want to / can't use C#, there's simply no alternative for bigger projects.

People keep repeating this as it was some sort of axiom. My feeling is that people mean that it's hard to write large Java-like projects outside Java. It's not the the problems can't be solved without Java, it's that you "can't" solve them the Java-way without using Java or C#.

Re:If Java Is Dying, It Sure Looks Awfully Healthy by RivieraKid on Thursday October 10, 2013 @07:59AM (#6526931)
What other statically typed language is similarly fast, has massive ecosystem and great tools? (You need static typing to have Java-like tools.)
Re:If Java Is Dying, It Sure Looks Awfully Healthy by gizzlon on Thursday October 10, 2013 @08:02AM (#6526945)
Now you're just adding more axioms :)
Re:If Java Is Dying, It Sure Looks Awfully Healthy by RivieraKid on Thursday October 10, 2013 @08:17AM (#6527004)
You mean that "static typing allow better tools"? That's a fact ;) It allows IDEs to do smarter autocomplete, better refactorings, more static error checks, etc.
Re:If Java Is Dying, It Sure Looks Awfully Healthy by gizzlon on Thursday October 10, 2013 @11:08AM (#6528124)
Here's a dumb analogy to show what I mean:

"You want to switch out the horse? How are you going to get around? Show me something that has at least four legs, can run as fast, eats less and has more stamina!"

The car or the plane looses this comparison.

Point is that all that "stuff" Java programmers are used to might be missing in other languages & ecosystems. And that might be a real issue. But some of that stuff only exists in Java-land to fix issues with Java, and the fact that it's not needed is actually a feature.

I'm sure someone, somewhere, complained that the first cars didn't have feces collection system =)

Re:If Java Is Dying, It Sure Looks Awfully Healthy by wes-exp on Thursday October 10, 2013 @10:20AM (#6527848)
"You need static typing to have Java-like tools"

This is a widely repeated myth. Static typing does enable a few additional autocomplete capabilities, but most of the other things you probably think of as fancy IDE features are completely possible for dynamic languages.

For example, using Common Lisp with emacs and SLIME, I have:

Function/method name completion, Variable name completion, Jump to definition, Show callers, Rename (heuristic, but usually better than static analysis), Extract method, All sorts of interactive debugging capabilities, Documentation lookup, and Numerous compile-time static analysis checks including type errors!

Re:If Java Is Dying, It Sure Looks Awfully Healthy by chromatic on Thursday October 10, 2013 @01:40PM (#6528992)
Did you know that Eclipse had its roots in VisualAge, a Smalltalk IDE?
Re:If Java Is Dying, It Sure Looks Awfully Healthy by room271 on Thursday October 10, 2013 @06:07PM (#6530340)
Scala is a great alternative. The Java interop is great and the tooling is good, certainly good enough. It's statically typed, but much more expressive and productive than Java.
Re:If Java Is Dying, It Sure Looks Awfully Healthy by Tloewald on Thursday October 10, 2013 @06:50AM (#6526725)
What are these bigger projects which can only be implemented in java? The linux kernel? Photoshop? Facebook? Or some kind of godawful tiered corporate thing that's big and unwieldy precisely because it's implemented in java?
Re:If Java Is Dying, It Sure Looks Awfully Healthy by nl on Thursday October 10, 2013 @07:52AM (#6526904)
What are these bigger projects which can only be implemented in java?

can is probably an overreach, but I expect the author was referring to the wide range of projects like Hadoop, Solr, etc.

If you want static typing, decent performance (and especially if you want a wide range of people who can work on your software) then you have C++/C# or Java. Or you are feeling adventurous or are ex-Google then maybe Golang.

There are other languages of course, but for most you are going to be struggling to find programmers who know them and library support isn't there, so you are writing lost of stuff yourself. If that's what you like, then fine.

If you don't want static typing, then there's a much broader range of course.

Or some kind of godawful tiered corporate thing that's big and unwieldy precisely because it's implemented in java?

Believe me, godawful corporate things are unwieldy in whatever language they are written in.

Have you ever seen a corporate Rails app? The saying "it compiles so it must work" is supposed to be a joke, but I've seen Rails apps where a large amount of the app would never have compiled if Ruby had a compile step. But then they did claim that Rails was an improvement because they could develop faster with out the compile cycle. Most of the app didn't work, but yes.. I concede that not having to make sure it worked did let them get in on servers faster.

Scary but true.

Re:If Java Is Dying, It Sure Looks Awfully Healthy by Tloewald on Thursday October 10, 2013 @12:17PM (#6528479)
> Believe me, godawful corporate things are unwieldy in whatever language they are written in.

No question this is generally true. But note that it's no worse for government than the private sector. The thing that bugs me is that government seems to take the worst aspects of the private sector (e.g. secrecy). If we've built a fabulous claims processing engine, why not give it away to other government departments?

Re:If Java Is Dying, It Sure Looks Awfully Healthy by RivieraKid on Thursday October 10, 2013 @07:54AM (#6526909)
IntelliJ IDEA or Android. Of course, you could use any language for a big project but unless you have specific requirenments (usually C-like performance), Java / C# is the best choice.

Photoshop - Needs C-like performance for image processing parts. If they started development today, I think they would go with a C# / C++ hybrid.

Facebook - The fact that they had to write their own PHP compiler is telling. PHP is nowdays quite similar to Java without the tooling, performance and massive ecosystem.

Re:If Java Is Dying, It Sure Looks Awfully Healthy by CmonDev on Thursday October 10, 2013 @12:46PM (#6528663)
Can't go wrong with a multi-paradigm managed C-derived language.
Re:If Java Is Dying, It Sure Looks Awfully Healthy by pjmlp on Thursday October 10, 2013 @07:46AM (#6526883)
Enterprise projects with minimum of three development places, 30 to 100 developers on project, with two to three year duration, lots of off-shoring and attrition among developers.
Re:If Java Is Dying, It Sure Looks Awfully Healthy by klibertp on Thursday October 10, 2013 @03:02PM (#6529429)
> there's simply no alternative for bigger projects

I absolutely, completely don't understand where is this coming from. There are so many languages that there has to be a choice.

It of course depends on a given project, but I'd think that it's bigger projects which are more flexible in choosing the technology. I mean, if you have heaps of cash and many developers, than having to write three or ten additional libraries shouldn't matter. And then suddenly OCaml and Haskell are starting to look nice. Ask Jane Street.

In the projects I was involved in we had different set of constraints - we needed to ship something quickly, with small team and limited financial support. In such case how much more performant the Java would be, how much better tooling it has and so on was irrelevant and sheer speed of development in Python, Ruby or Racket was a win.

I get a feeling that this sentiment that "there is no alternative" for Java comes from people who are being forced to use Java at work (even for things it's not suited for) and who want to console themselves. It's something like "ok, I use Java as a templating language, but that's how it has to be". Well, I think it's not.

On the other hand, if you know what you want is Java - go for it. It's always the same old "best tool for the job". Just don't artificially narrow the choice of tools.

Re:If Java Is Dying, It Sure Looks Awfully Healthy by gaius on Thursday October 10, 2013 @08:24AM (#6527037)
Java is the common, business oriented language of today. How do you you think it's not like the original COmmon Business Oriented Language? It's being used by the same sorts of guys to write the same sorts of apps, no?
Re:If Java Is Dying, It Sure Looks Awfully Healthy by RivieraKid on Thursday October 10, 2013 @10:18AM (#6527830)
Java has some similarities to every programming language including COBOL but it's also totally different.

Java is used by a lot of extremely productive programmers and some brilliant apps are written in it.

Re:If Java Is Dying, It Sure Looks Awfully Healthy by gaius on Thursday October 10, 2013 @11:36AM (#6528259)
Same is true of the original COBOL. If you can imagine back as far as the 1960, COBOL and FORTRAN are the cutting edge, every talented and ambitious programmer is trying to get in on this new tech, they are amazed at the productivity and they are writing apps that do hitherto impossible things.

You are no different from them, you were just born a few decades later (same for me). Except, you can look back and learn from their experiences, if you are wise.

Re:If Java Is Dying, It Sure Looks Awfully Healthy by markokrajnc on Thursday October 10, 2013 @11:28AM (#6528224)
If Google is a "thought leader" why didn't they use another language for Android?

The more you digg into the languages, the more you see, that Java rules them all... I've tried MANY, MANY languages (from assembler, Basic, Pascal, C, C++, Smalltalk, C#, Python, Ruby/Rails, Groovy, PHP, Perl, awful JavaScript which shouldn't be called a language at all, because it has bugs built in it and many others) and nobody is forcing me to use Java, but I program my Rasberry Pi-s only in Java...

With latest Rasbperian Wheezy where Oracle JDK is included I can tell you it is super cool and super fast for this small ARM processor... I will not use Python on it... Either Java or C - nothing else do I need...

Re:If Java Is Dying, It Sure Looks Awfully Healthy by smrtinsert on Wednesday October 09, 2013 @08:25PM (#6524882)
are these the same thought leaders that ditched ruby for scala or node or clojure?

ill be coding with libgdx and pushing to html5 and android while the thought leaders decide their next move.

Re:If Java Is Dying, It Sure Looks Awfully Healthy by kamaal on Thursday October 10, 2013 @04:56AM (#6526425)
You don't become a thought leader by being stuck in the past. You have to evolve and move on, and need to realize that there is zero benefit in tool religion.

Java is so big today because at one point for all the marketing money by Sun and C++ incompetence among programmers, it had a field day. I remember an architect who made Java compulsory in a program because as he was tired of C++, he just couldn't get it and neither any of his team members.

Today Java is, what C++ was at its times. Its showing age, and merely adding features and bloating won't fix it. There is tons of Java around, just like there was tons of C++. So people will be using Java for a while. But the creamy projects will be moving on to newer languages and there won't be growth or progress in Java world anymore. And sooner or later people will realize they don't want to associated with tools on their resume, only to be hired as 'migration engineers'.

Before that happens, its better to move on to something better.

Re:If Java Is Dying, It Sure Looks Awfully Healthy by smrtinsert on Thursday October 10, 2013 @03:35PM (#6529581)
Java is big today because its static typing with a focus on performance led to the some of the best free tooling in the industry married to some of the strongest performance metrics. Religion its not.
Re:If Java Is Dying, It Sure Looks Awfully Healthy by ww520 on Thursday October 10, 2013 @01:36AM (#6525827)
So which hip languages are these "thought leaders" using now?
Re:If Java Is Dying, It Sure Looks Awfully Healthy by jaggederest on Thursday October 10, 2013 @01:45AM (#6525855)
Python, Ruby, Javascript, JVM-hosted languages like Clojure, Scala, and newer languages still in development like Elixir, I'm sure I'm missing some. Haskell is perpetually 10 years ahead in programming research but sadly it functionally lacks support for day-to-day scripting tasks.
Re:If Java Is Dying, It Sure Looks Awfully Healthy by EpicEng on Thursday October 10, 2013 @03:45AM (#6526224)
Javascript? Really?

"Thought leaders" are hopefully just using the best language suited for the job. It often comes down to what kind of code you are writing and what it needs to run on.

Re:If Java Is Dying, It Sure Looks Awfully Healthy by jaggederest on Thursday October 10, 2013 @04:25AM (#6526349)
You're doubting that Javascript is a popular language for people pushing the forefront of software development? I'd cite for you a ton of the work being done on node, ember, knockout, backbone, jquery, even some embeddable hardware thing I read about on here the other day. There's a huge amount of energy in that area, lots of extremely smart people.

Or are you just being snobbish about javascript? It's a pretty solid language, and has interpreters installed on virtually every computer on earth with built-in distribution.

Re:If Java Is Dying, It Sure Looks Awfully Healthy by xerophtye on Thursday October 10, 2013 @05:21AM (#6526494)
My friend, JS has a virtual monopoly on what it does. If there are other client-side browser languages, i have not heard of them.

>It has built-in interpreters (read "Browsers") on every computer.

JS is pretty slow (It uses an interpreter!). The notion of using it on the backend is debatable. "A lot of people are putting a lot of effort in to it" isn't a valid argument. u said it yourself: "people are told to/forced to use it"

As for the hardware thing, didn't you read the HN discussion about that? no body thinks that's a good idea. It just a way to let web devs do something on the hardware without bothering to learn an actual low level language.

Re:If Java Is Dying, It Sure Looks Awfully Healthy by nilliams on Thursday October 10, 2013 @07:41AM (#6526865)
>> JS is pretty slow (It uses an interpreter!) The notion of using it on the backend is debatable.

It is pretty fast. It has a world class VM with an optimising JIT compiler. V8 is considerably faster than many other interpreted language, Ruby, Python etc. It's being used on the backend by many smart companies.

>> As for the hardware thing [...] It just a way to let web devs do something on the hardware without bothering to learn an actual low level language.

I know C. I use it when necessary but I'd rather write JS. Apparently so would plenty of other people. It's not about laziness.

Re:If Java Is Dying, It Sure Looks Awfully Healthy by cmircea on Thursday October 10, 2013 @07:46AM (#6526884)
Expect it doesn't use an interpreter these days, it is JIT compiled (a la V8). It's quite fast now.
Re:If Java Is Dying, It Sure Looks Awfully Healthy by CmonDev on Thursday October 10, 2013 @12:41PM (#6528627)
Is it still single-threaded only using one CPU core?
Re:If Java Is Dying, It Sure Looks Awfully Healthy by olavgg on Thursday October 10, 2013 @05:23PM (#6530134)
Well almost, you can use web workers and create "tasks" that will use more cpu cores. https://developer.mozilla.org/en-US/docs/Web/Guide/Performan...
Re:If Java Is Dying, It Sure Looks Awfully Healthy by CmonDev on Thursday October 10, 2013 @12:40PM (#6528619)
"It's a pretty solid language" - can you remind me what should I use "==" or "===" and why should I care? More here: http://wtfjs.com

"has interpreters installed on virtually every computer on earth with built-in distribution" - which means we are stuck with it, thanks very much for "open" web.

Re:If Java Is Dying, It Sure Looks Awfully Healthy by CmonDev on Thursday October 10, 2013 @12:37PM (#6528601)
"pushing the forefront of software development" - you mean desperately trying to work around legacy issues in a increasingly standardised environment?
Re:If Java Is Dying, It Sure Looks Awfully Healthy by EpicEng on Friday October 11, 2013 @06:26PM (#6536246)
JS is, in general, a relatively poorly designed language which is forced upon us (thankfully, not me). Given the choice people would jump ship in a heartbeat.
Re:If Java Is Dying, It Sure Looks Awfully Healthy by Flenser on Friday October 11, 2013 @08:40AM (#6532677)
Indeed, when compare Java with Python, Ruby, Javascript using the tool that the OP used for showing that monthly commits to Java were stable for the last 7 years it shows how quickly they are catching up:

http://www.ohloh.net/languages/compare?l0=java&l1=javascript...

Although it looks like Ruby isn't growing as quickly as JavaScript and Python.

It will be interesting to see if perceptions change after JavaScript and Python overtake Java.

Re:If Java Is Dying, It Sure Looks Awfully Healthy by jaggederest on Thursday October 10, 2013 @04:56AM (#6526426)
Ah, knew I'd forgotten one - Go, pretty interesting language with lots of action around it.
Re:If Java Is Dying, It Sure Looks Awfully Healthy by gizzlon on Thursday October 10, 2013 @07:00AM (#6526748)
Rust, Erlang?
Re:If Java Is Dying, It Sure Looks Awfully Healthy by LaGrange on Thursday October 10, 2013 @08:41AM (#6527190)
Mostly English. In ridiculous quantities.

I miss thought leaders using French, or Latin :-(

Re:If Java Is Dying, It Sure Looks Awfully Healthy by perlgeek on Thursday October 10, 2013 @04:58AM (#6526432)
Haskell?
Re:If Java Is Dying, It Sure Looks Awfully Healthy by quchen on Thursday October 10, 2013 @07:32AM (#6526838)
Haskell has multiple concepts that are so compelling that I do not understand why most of the new languages make no use of them. Very handwavy, here are a couple of them.

- Type inference: strong typing at the convenience of weak typing. (Some languages are moving towards this. C++ stapled on `auto` keywords, Rust is designed using it)

- Type classes: unifying things that "can do X", allowing the programmer to write functions that do similar things but work on many different types. A "sort" function can then be written for all things that "are containers of elements that can be compared". (Again, Rust adopts this.)

- Allowing separation of pure and impure functions. Imagine having a "pure" keyword that guarantees that a function doesn't have side effects. The benefit of this cannot be overstated in a multithreaded environment.

Re:If Java Is Dying, It Sure Looks Awfully Healthy by cmircea on Thursday October 10, 2013 @07:49AM (#6526892)
C# has had type inference for a long while. It's a pain using Java, which doesn't.

C# also sort of implements type classes. For your example, there's IComparable in C#; implement it and a List<SomeObject> can be directly sorted.

For pure functions, there's the [Pure] attribute, but it isn't enforced by the compiler, it's just a contract, a promise.

Re:If Java Is Dying, It Sure Looks Awfully Healthy by quchen on Thursday October 10, 2013 @08:14AM (#6526993)
Yes, there are languages that also have these features, the puzzling part is why not all of them do (except those that may have good design reasons not to).
Re:If Java Is Dying, It Sure Looks Awfully Healthy by ufo on Thursday October 10, 2013 @08:51AM (#6527240)
Its hard to implement type inference and type classes unless you carefully design the language to accommodate it from day 1. For example, return-type polymorphism (functions like `read` or `return`) is particularly tricky, specially in the more dynamic languages.
Re:If Java Is Dying, It Sure Looks Awfully Healthy by frankzinger on Thursday October 10, 2013 @10:39AM (#6527982)
"- Type classes: unifying things that "can do X", allowing the programmer to write functions that do similar things but work on many different types. A "sort" function can then be written for all things that "are containers of elements that can be compared". (Again, Rust adopts this.)"

This is what templates do in C++.

Re:If Java Is Dying, It Sure Looks Awfully Healthy by dkuntz2 on Wednesday October 09, 2013 @07:30PM (#6524659)
I'm fairly certain Java and C++ have comparable speeds, and I think in someways Java's faster.
Re:If Java Is Dying, It Sure Looks Awfully Healthy by jordanthoms on Wednesday October 09, 2013 @07:50PM (#6524726)
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.
Re:If Java Is Dying, It Sure Looks Awfully Healthy by pjmlp on Thursday October 10, 2013 @02:37AM (#6526034)
> C++ does give you the ability to more easily use processor extensions (SSE, AVX, etc), which you can't use from Java AFAIK

C++ does not support any processor extensions, they are not defined anywhere in ANSI/ISO C++ language standard.

They are a language extension not guaranteed to be available in all C++ compilers in the same form, thus not portable.

Java can make use of processor extensions by writing a small Assembly snippet callable via JNI.

Which is actually similar to what is required in C and C++ code, when writing "portable" code that should compile in various compilers.

Re:If Java Is Dying, It Sure Looks Awfully Healthy by exDM69 on Thursday October 10, 2013 @05:34AM (#6526538)
> C++ does not support any processor extensions, they are not defined anywhere in ANSI/ISO C++ language standard. > They are a language extension not guaranteed to be available in all C++ compilers in the same form, thus not portable.

This is true only if you're a language lawyer, but there's very little point to sticking pedantically to a language standard and not take advantage of the ubiqtuitous language extensions available. All the popular compilers out there support all the latest CPU instruction sets with the same syntax, etc. E.g. xmmintrin.h for SSE, avxintrin.h for AVX.

> Java can make use of processor extensions by writing a small Assembly snippet callable via JNI.

While this is true, you destroy any performance gain with the complexity of the JNI calling convention. It only pays off if you're doing a quite long stints of SSE/AVX/NEON code at once. Wrapping a small vector dot product or matrix multiplication in JNI will not yield any performance gain in practice. So while you can call native code via JNI, it's nowhere near as practical as writing it with intrinsics in C code. In addition, you get compiler optimizations to your native code if you use intrinsics from C, if you do it via JNI you lose all interprocedural optimization.

Re:If Java Is Dying, It Sure Looks Awfully Healthy by acomjean on Thursday October 10, 2013 @12:29AM (#6525642)
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.
Re:If Java Is Dying, It Sure Looks Awfully Healthy by cageface on Thursday October 10, 2013 @12:45AM (#6525686)
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.
Re:If Java Is Dying, It Sure Looks Awfully Healthy by danieldk on Thursday October 10, 2013 @02:16AM (#6525965)
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 by n3rd on Thursday October 10, 2013 @09:26PM (#6531012)
IBM's Java 7 and 8 beta's already have this. It's called Packed Objects and it lets you have have high density data with no pointer chasing along with a much cleaner interface to off-heap languages like C/C++/C# and even languages like Fortran/COBOL etc.

http://www.slideshare.net/mmitran/ibm-java-packed-objects-mm... and http://www.slideshare.net/ZeroTurnaround/ryan-sciampaconerun...

Re:If Java Is Dying, It Sure Looks Awfully Healthy by cageface on Thursday October 10, 2013 @03:01AM (#6526109)
For sure. Mixed value/reference semantics add a lot of complexity to C++.
Re:If Java Is Dying, It Sure Looks Awfully Healthy by pjmlp on Thursday October 10, 2013 @01:48AM (#6525862)
Being discussed for Java 9 and already available on IBM J9 JVM.

http://www.slideshare.net/mmitran/ibm-java-packed-objects-mm...

Re:If Java Is Dying, It Sure Looks Awfully Healthy by swah on Thursday October 10, 2013 @08:57AM (#6527286)
I do miss those in Go.
Re:If Java Is Dying, It Sure Looks Awfully Healthy by judk on Thursday October 10, 2013 @11:07PM (#6531227)
Why can't Java new() use a plank to allocate objects in an array, just like C++ new() can?
Re:If Java Is Dying, It Sure Looks Awfully Healthy by bradleyjg on Thursday October 10, 2013 @02:18AM (#6525974)
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 by frozenport on Thursday October 10, 2013 @02:39AM (#6526038)
And nobody else has too.

You use jni to call libraries somebody else made (opengl?), you don't plan your project around using jni.

Re:If Java Is Dying, It Sure Looks Awfully Healthy by 10098 on Wednesday October 09, 2013 @08:14PM (#6524842)
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.
Re:If Java Is Dying, It Sure Looks Awfully Healthy by threeseed on Wednesday October 09, 2013 @09:33PM (#6525156)
Your ignorance of the difference between server and client side Java leads me to believe that you're probably wrong.
Re:If Java Is Dying, It Sure Looks Awfully Healthy by sliverstorm on Thursday October 10, 2013 @01:16AM (#6525771)
This usually seems to be due to bad code, or bad GUI libraries (which Java seems to be the king of)
Re:If Java Is Dying, It Sure Looks Awfully Healthy by pjmlp on Thursday October 10, 2013 @01:48AM (#6525871)
And bad developers using those libraries.
Re:If Java Is Dying, It Sure Looks Awfully Healthy by artsrc on Thursday October 10, 2013 @02:18AM (#6525972)
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 by danieldk on Thursday October 10, 2013 @02:17AM (#6525968)
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 by axaxs on Wednesday October 09, 2013 @07:59PM (#6524773)
Java is not as fast or faster than C(++). The assertion always makes me cringe. I won't say Java is slow(though the startup time is annoying for some tasks), as it does perform better than many languages. But how does it make sense to you that a platform written in C can produce results faster than C is capable of?
Re:If Java Is Dying, It Sure Looks Awfully Healthy by artsrc on Wednesday October 09, 2013 @09:13PM (#6525099)
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 the performance of C code.

The performance of the code you write depends significantly on the quality of the machine code produced by the JIT compiler. This quality of this code is not theoretically dependent on the implementation language of the JIT.

Re:If Java Is Dying, It Sure Looks Awfully Healthy by waps on Thursday October 10, 2013 @01:36AM (#6525828)
> 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 also one that has different complexity.

So you're in the situation now that a few compilers (VERY few, though this is very very hard to do) will actually beat stupid programmers in optimization, but there is nothing any compiler can do to beat the optimizations a good programmer will implement.

As for startup time, the sad part of that is that is one area where you could really improve C/C++ : startup time. Right now a C program has 4 distinct things that need to run before main() starts, and involve quite a bit of calculation, C++ has a lot more (the various kinds of initializers which can cause arbitrarily complex calculation).

A lot of these initializers result in constant (and small) memory layouts, and could in fact be run at compile time. What you generally do in initialization phase is to calculate registered classes (e.g. for serialization, or protocols) and make indexes of them. Maybe even compile regexes. All of that could be optimized to occur at compile time (as long as memory usage of the code is reasonable).

Re:If Java Is Dying, It Sure Looks Awfully Healthy by artsrc on Thursday October 10, 2013 @02:16AM (#6525964)
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 by pron on Thursday October 10, 2013 @07:55AM (#6526913)
> But how does it make sense to you that a platform written in C can produce results faster than C is capable of?

It's actually quite easy.

Now, of course for every Java program there exists a C++ program that performs at least as well – proof: the JVM – but that doesn't mean that that program could be written by humans at acceptable cost. The JVM does a lot of optimistic inlining that's simply not possible in C/C++ (in those languages you'll need to write the same code lots of times).

Re:If Java Is Dying, It Sure Looks Awfully Healthy by frozenport on Thursday October 10, 2013 @02:42AM (#6526047)
Slow C compiler was used to write fast C compiler?
Re:If Java Is Dying, It Sure Looks Awfully Healthy by 0x0 on Wednesday October 09, 2013 @08:06PM (#6524802)
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?

Re:If Java Is Dying, It Sure Looks Awfully Healthy by axaxs on Wednesday October 09, 2013 @08:30PM (#6524903)
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 results. Is that sane? No, not really.

Comparing languages is typically silly, as it mostly boils down to implementation. If you -really- intend to compare speeds of languages, it would necessitate writing the best possible code in both languages, which may or may not even resemble each other. Under those circumstances, Java is not capable of beating C. Ever.

I don't understand why this is an argument anymore, it doesn't really even make much sense...unless my definition of 'language speed' is unusual.

Re:If Java Is Dying, It Sure Looks Awfully Healthy by bcoates on Wednesday October 09, 2013 @11:26PM (#6525487)
Both the JVM and a C compiler produce native machine code that is executed by the processor directly. Neither is an interpreter in the classic sense[1]. It doesn't matter what language they're written in -- you could write C compiler or a JVM in PHP (assuming it can make the syscalls to load object code at runtime). No matter how awful the performance of the PHP runtime is, it would not prevent the C or Java program executed from being fast (in the long run).

Because the eventual target is native code, the only limit on performance[2] is what program transformations the compiler is willing to perform. This is limited by how much information the compiler has, and what sort of transformations are valid in the language.

For the first, it's about a wash. Java has a mix of 'safety' features that may obligate inserting checks at runtime that C would assume away, but it also forbids a lot of things that a C compiler would have to accept that limit the ability to optimize programs. In particular, a C compiler has to make a lot of pessimistic assumptions about what all those pointers are doing and what happens to memory across an external function call.

JVMs have a solid advantage in the second -- it performs the equivalent of profile guided optimization at runtime against real usage patterns, something that AFAIK no C compiler even attempts... and the runtime tooling needed to turn C into something you could JIT-optimize would result in something I don't think most C programmers would recognize.

A third issue is GC, which is on by default in Java-land and off by default in C: if your program is under very little memory stress and has very complex memory access patterns, the overhead of malloc()/free() is going to be huge compared to the cost of running the occasional GC. But, if your program is under strong memory stress and the logic to determine when to malloc() and when to free() is trivial, GC overhead will be a serious issue.

None of this means a given Java environment is faster than a given C environment but there's not really anything you could assume from first principles that makes one faster than the other. Neither reaches the ultimate "speed of light" of computation that is self-modifying hand-tuned machine code favored by all Real Programmers[3].

But the real bottom line for performance is which language has faster library implementations, and which has idioms that programmers actually use that produce faster or slower code. Those considerations are probably going to be way more important than the hypothetical top speed of a perfect program made by cycle-counting weenies. It's also the sort of thing you'd have to run actual experiments at large scale to answer.

[1] the JVM might interpret Java bytecode that isn't frequently run based on some optimization heuristic, but it doesn't have to. A 100% JIT emitting JVM could exist, and might even be a JVM flag for all I know.

[2] if you ignore the time JVM spends optimizing at load/JIT time, which you can in most cases aside from startup time.

[3] http://www.catb.org/jargon/html/story-of-mel.html

[4] Despite this extensive apology for Java, I despise it and if I never have to touch it or the JVM ecosystem again it will be too soon.

Re:If Java Is Dying, It Sure Looks Awfully Healthy by danieldk on Thursday October 10, 2013 @02:24AM (#6525995)
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 by pjmlp on Thursday October 10, 2013 @01:55AM (#6525894)
> The JVM compiler compiles for the JVM, which is written in C

This is absurd.

First of all, there isn't one JVM. There are dozens to chose from, many of them certified. Each implemented in whatever language their designers have chosen.

Some JVMs are meta-circular, meaning they are also written in Java. For example, Squawk, Maxime, Jikes RVM.

Second, even if you mean Oracle's JVM, the embedded version is not the same as the desktop/server one, one uses C the other C++.

Not to mention that after Java 8's release, Hotspot might be replaced by Graal, the new JIT compiler written in Java as well.

Currently being developed and already in use by AMD for their Java/GPGPU work.

Re:If Java Is Dying, It Sure Looks Awfully Healthy by rdtsc on Thursday October 10, 2013 @12:27AM (#6525631)
> So, how again can something written in C perform faster than...something written in C?

Easy. JVM has runtime information it can use that C compiler simply doesn't have. There are some synthetic benchmarks that show how "java is faster than C".

Re:If Java Is Dying, It Sure Looks Awfully Healthy by alpatters on Thursday October 10, 2013 @06:44AM (#6526708)
You're wrong. http://en.wikipedia.org/wiki/Profile-guided_optimization The method for C/C++ is just different to JIT. Compile program, collect profile information, optimize program guided by profile information.
Re:If Java Is Dying, It Sure Looks Awfully Healthy by astral303 on Thursday October 10, 2013 @09:32AM (#6527513)
There's far more than branch prediction optimization, which AFAIK, is bread and butter of profile-guided optimization.

Even that assumes that your program does not significantly shift its behavior mid-execution--in fact, you're optimizing for the average, not the current case.

One of the coolest JIT things is ability to inline virtual calls. Think about that, I could have my code calling a 3rd party library calling another 3rd party library thru 10 levels of stack and if all that call ever returns is "false", then JIT will optimize right through all that.

I don't believe PGO does virtual call inlining. That's a C++ nonstarter. In C, the equivalent would be inlining for function pointer calls.

Re:If Java Is Dying, It Sure Looks Awfully Healthy by camus on Thursday October 10, 2013 @01:03AM (#6525739)
doesnt matter,the jvm takes a lot of resources which is problematic is some situations.raw speed is nothing without the memory footprint or AAA games would be written in java.they are not for a good reason:lack of direct memoy management.
Re:If Java Is Dying, It Sure Looks Awfully Healthy by rdtsc on Thursday October 10, 2013 @02:06AM (#6525935)
I am not saying one should use it or not, or how it is strictly better than something else, just saying I can easily see _in theory_ how a jit compiler written in C can be faster than plain C.
Re:If Java Is Dying, It Sure Looks Awfully Healthy by icebraining on Wednesday October 09, 2013 @08:14PM (#6524843)
dkuntz2 said C++, not C.

But in any case, it's perfectly possible that a platform written in C could produce results faster, because it's not an interpreter but a compiler that translates the application directly to machine code, and which could benefit from optimizations not available ahead-of-time.

Re:If Java Is Dying, It Sure Looks Awfully Healthy by axaxs on Wednesday October 09, 2013 @08:38PM (#6524940)
It is perfectly possible to write JIT optimizations in C/C++. In fact, HotSpot does just that.
Re:If Java Is Dying, It Sure Looks Awfully Healthy by Aldo_MX on Wednesday October 09, 2013 @07:57PM (#6524759)
Can you please provide real benchmarks?
Re:If Java Is Dying, It Sure Looks Awfully Healthy by Guvante on Wednesday October 09, 2013 @07:52PM (#6524740)
The lack of non-heap objects makes you bend backwards more than you should though.
Re:If Java Is Dying, It Sure Looks Awfully Healthy by n3rd on Thursday October 10, 2013 @09:41PM (#6531059)
If by "lack of", you mean "4 choices": DirectByteBuffers (Azul/IBM/OpenJDK/Oracle etc) Packed Objects (IBM) Real-time Java (Azul/IBM) Unsafe (Azul/Oracle/IBM/OpenJDK etc)