10 ms·
A major cleanup of the Java libraries is scheduled for Java 9. The JVM actually does not surprise anyone who's been working with it for a while: it is downright
by pron 13y ago
A major cleanup of the Java libraries is scheduled for Java 9. The JVM actually does not surprise anyone who's been working with it for a while: it is downright the most performant, flexible and awesome runtime environment ever developed. I've been playing around with lots of languages and environments in my pretty long career and, in the past decade, have always come back to Java (or the JVM). It feels like driving a Ferrari where everything else is at best a Toyota - might be easier to handle at first, but it's not your dream car.
This pattern, by the way, has been going on in lots of tech companies. They always end up going back to the JVM.
Aside from terrific performance, the JVM gives you the best concurrency platform out there (though not the easiest to use), cool and extremely useful capabilities like dynamic linking and bytecode instrumentation, and unparalleled monitoring and profiling tools. It's the most professional platform you can choose (unless you're limited to Windows, in which case .Net is also an option). It's so far ahead than anything else out there, that the competition can only beat it in very specific use cases (e.g. Go is much better at startup time as well as standalone packaging, and C has better performance, though mostly in single-threaded programs). But nothing else gives you the whole package of performance, flexibility, maturity and monitoring.
- chaostheory 13y ago> Aside from terrific performance, the JVM gives you the best concurrency platform out there (though not the easiest to use) It's getting easier http://akka.io/ http://akka.io/ http://gpars.codehaus.org/ http://gpars.codehaus.org/ I think clojure is also actor based.
- rooted 13y agoClojure is not actor based but has some terrific primitives for concurrency
- FreezerburnV 13y agoDon't forget Quasar: https://github.com/puniverse/quasar https://github.com/puniverse/quasar
- benjamincburns 13y agoOn the off chance that readers aren't aware, pron, the GP, is the author of Quasar.
- neverminder 13y agoIn my opinion http://www.typesafe.com http://www.typesafe.com stack is the most powerful and consistent one running on JVM. Scala/Play/Akka/Slick/SBT speaks for itself and I enjoy every day of working with it.
- flurdy 13y agoNot sure if I enjoy SBT but Scala/Play/Akka is definitely great
- lclarkmichalek 13y agoDoes anyone enjoy SBT? My love for Scala is profound, but fuck SBT
- yukinon 13y agoSBT, also known as Slow Build Tool in my office.
- saryant 13y agoOnce I got my head around it, I began liking it. If you're using Akka's clustering, SBT's multi-JVM testing is killer.
- bad_user 13y agoYes, I enjoy SBT. I miss it every time I end up working with similar tools for other platforms. I'm not crazy about the syntax and I avoid build.sbt files, but as a tool it's very pragmatic and takes care of my needs perfectly. It has incremental compilation and continous testing built in. For testing within SBT with something like say ScalaCheck simply works out of the box with no configuration necessary, by simply slapping a ScalaCheck test in the test directory. SBT has cross compilation support, something that is needed for Scala. Some of the best Maven plugins have been ported to it (I enjoy sbt-release for example). I tried my hand at writing a simple SBT plugin and it really isn't bad. Dependency management is based on Maven repositories, again something that I miss a lot on other platforms. Publishing stuff on Sonatype has been painless. SBT's support for sub-projects in the same repository worked flawlessly for me and it is easy to setup. The console support is great too, allowing one to easily open a Scala console with the right classpath loaded (compile/runtime versus test). And in general I like how it just works out of the box. Every time I end up interacting with Python for example, I get headaches from the clusterfuck that is setuptools, easy_install, pip, wheels, virtualenv, virtualenvwrapper or whatever the fuck they are using these days. Every time I interact with Ruby, I get headaches from rake, gem and gemspecs, bundler, rbenv, rvm or whatever else they are doing these days. I don't even want to remember Javascript and the clusterfuck that is npm, bowler, brunch.io, grunt.js, closure, amd, commonjs, browserify or whatever else they are doing these days. Or about .NET that's still in the Ant/Delphi age with MSBuild. For Scala, the only fair competition that SBT has is Maven. And the only (other) pragmatic build/packaging/dependency management tool that I used has been Clojure's Lein, but lein lacks for example the capability of keeping a JVM process loaded, so you suffer the startup time every time you invoke a command, plus it seemed weird that lein doesn't offer things like continous testing out of the box. And speaking of configuration formats, lein's profiles are simply confusing. You don't have to use SBT if you don't like it. Maven works fine and SBT's secret sauce, which was the incremental compilation, has been extracted in project Zinc and so it now works with Maven. But I still prefer SBT over Maven and when switching to other platforms it now feels like going back to 1999.
- mongol 13y agoDo you have more info on the cleanup in Java 9? Will they remove some deprecated methods then?
- isuraed 13y agoHow do deprecated methods affect you? Just curious. Maybe I'm missing something.
- mirkules 13y agoIn my opinion, they don't. If you use an IDE like Eclipse where deprecated methods are clearly marked by a strikethrough and marked with a compiler warning, I don't see the big deal. And the bonus is that old code still compiles with new versions (and there is something to be said for backwards compatibility, a la "This presentation is not compatible with Keynote" discussion from a few days ago)
- fosk 13y agoMethods are marked as deprecated when they're planned to be removed in the next version.
- pohl 13y agoThat's the story that gets told, but how often have they actually removed something after deprecating it? Does anybody have a single concrete example of a method that actually went away? http://stackoverflow.com/questions/18063599/has-ever-anything-been-removed-from-the-standard-java-api?lq=1 http://stackoverflow.com/questions/18063599/has-ever-anythin...
- meddlepal 13y agoI don't believe they have ever removed a Class or method from the JDK... Thread still has all of those super-unsafe or non-implemented methods in it (see: stop(), destroy() etc.) I think part of the reason for this ultra-conservative approach might be that alternate JVM implementations could in theory have well-implemented versions of deprecated methods such as the above-mentioned Thread ones.
- hugofirth 13y agoIs there any chance you could briefly enumerate some of the things that make the JVM's approach to concurrency so strong? I'd be interested.
- pron 13y agoIt's not the approach, but the capabilities: 1. State-of-the-art garbage collectors, which enable good implementations of lock-free data structures. 2. Excellent implementations of lock-free data structures (like ConcurrentLinkedQueue and ConcurrentSkipListMap) and other concurrent data structures (like ConcurrentHashMap). 3. A state-of-the-art work-stealing scheduler (ForkJoinPool), excellent for both parallelism (as used by Java 8's streams) and concurrency. 4. A cross-platform memory model specifying memory visibility across threads. 5. Access to CPU concurrency primitives like CAS and memory fences. These building blocks are a great foundation for any concurrent application.
- smikhanov 13y agoCould you please elaborate on #5? What you mean there is the fact that AtomicInteger implementation is actually using this primitives on your target platform, correct?
- pron 13y agoIt's more than that. AtomicInteger's implementation uses JVM intrinsics which are calls to methods in the sun.misc.Unsafe class, that, when JITted, are replaced by a platform specific machine instruction (where available), such as CAS or a memory fence.
- hugofirth 13y agoThanks - I use Java all the time - but sometimes I find knowing which data structures to turn to in a given situation tough.
- azinman2 13y agoThat's true for any language, and any platform. The language can't save you from having to, at some point, understand how to properly engineer software.
- hkphooey 13y agoWhat is best practice when it comes to Java GUIs? Would you recommend Java for building cross-platform desktop apps with near native UI performance? The IntelliJ IDE looks great but most Java desktop apps I've come across just look and feel weird. Not sure why there is such a big difference.
- neverminder 13y agoJavaFX is now a default platform (supported by Oracle) for developing desktop apps. It replaced the clumsy Swing and is showing a lot of promise. http://www.oracle.com/technetwork/java/javase/overview/javafx-overview-2158620.html http://www.oracle.com/technetwork/java/javase/overview/javaf...
- Yhippa 13y agoWhat is the case for desktop apps these days vs web apps? I would love to mess around with JavaFX but really can't come up with a compelling reason to use it.
- rcoder 13y agoIf you want to interact with local hardware/storage media, native apps are still easier. "Offline" mode can also be the default, at least for systems that have a local data store. Finally, multicore CPUs may be theoretically exploited with web workers, but it's a lot easier to just spin up a native thread in your Java code. Downsides are all the usual ones, of course: updates don't happen automatically, you may need some sort of licensing/DRM if you want people to pay for your application, and your testing story is a lot more complex. (Plus: look-and-feel on various platforms, reverse engineering is that much easier, etc., etc.)
- girvo 13y agoOffline + sync, and higher performance requirements are my two use-cases for desktop apps.
- tsotha 13y agoHow widely is this adopted? FX is one of those tools I'm a little leery of because of the possibility it may be abandoned by Oracle if not enough people use it.
- radiantsand 13y agoI've been using Java since the 90s. The JVM is a pretty solid piece of engineering, but your post is pretty heavily loaded with hyperbole. There are plenty of other excellent concurrency platforms for example Erlang, Go, even the. NET CLR.
- kriro 13y agoI agree that the JVM is pretty awesome and will only improve (lots of money is bet on it after all) but I think BEAM may fulfil some of the items on your "awesome runtime" list :)
- SkyMarshal 13y agoAgreed, in fact what's surprising is that anyone thinks it's surprising that the JVM with its billions of man hours and primary usage in mission critical finance/banking/etc is anything but one of the most performant, scalable, robust, well-tooled platforms around. >Aside from terrific performance, the JVM gives you the best concurrency platform out there (though not the easiest to use) Though I'd probably still reserve that accolade for Erlang OTP/BEAM.
- yummyfajitas 13y agoThough I'd probably still reserve that accolade for Erlang OTP/BEAM. I would absolutely not. Erlang/OTP/BEAM might be the best distributed computing platform (though Akka is making huge inroads), but Erlang is actually a pretty terrible at single-box concurrency. Erlang has one concurrency primitive - message passing. Which is great, but it's not always the right one. Consider a a producer process which solves a PDE or does a big Bayesian computation (output is an Array[Float] or Array[Double]). You have consumer processes which read from the array and compute sums over subsets of the elements. In Erlang you are just passing around copies of arrays. In the JVM, you'll probably have a single mutable array. You'll either wrap the appropriate calls in arr.synchronize {...}. Or you can use memory barriers and let the consumers freely read from the array, and invalidate their computation if the producer wrote to the array between the start and end of their read.
- hibikir 13y agoThe JVM has a couple of pretty significant problems when trying to work with functional-style languages. The biggest one is the way it deals with the stack: It's not in the heap, and it's pretty limited, so with something like scala, and more specifically with scalaz, you have to do some contortions to avoid overflows. 90% of usages of scalaz trampolines are nothing but ways to work around JVM limitations. I'd argue that today, you are better off with the .NET VM, as far as features are concerned. But being stuck in windowsland is really a non-starter for all kinds of applications. I can send a major task that will take 400 computers for a week to Amazon if my code relies on the JVM. If I write it in .NET, not so much
- manojlds 13y agoAzure?
- richdougherty 13y agoThe stack doesn't have to be in the heap to make things better for recursion* , the JVM just needs to support tail-call optimisation. See my blog post: http://blog.richdougherty.com/2009/04/tail-calls-tailrec-and-trampolines.html http://blog.richdougherty.com/2009/04/tail-calls-tailrec-and... I'm excited to see tail-call optimisation ("proper tail calls") coming to JavaScript. Hopefully a bit of competition will encourage the JVM to clean up its act too. http://bbenvie.com/articles/2013-01-06/JavaScript-ES6-Has-Tail-Call-Optimization http://bbenvie.com/articles/2013-01-06/JavaScript-ES6-Has-Ta... (* Heap-allocated frames can help with other things though, e.g continuations.)
- bad_user 13y agoIn Scala I work with self tail recursive functions all the time. Scala optimizes self tail recursive functions just fine, rewriting them as simple loops. Yes you do have to use trampolines for mutual tail recursive function, because the JVM currently lacks support for it, however if you take a look at the Da Vinci sub-projects in OpenJDK, a prototype has been in the works for quite some time, led by none other than John Rose and given the attention that invokeDynamic is getting, I have no doubt that this will also happen on the JVM: http://openjdk.java.net/projects/mlvm/subprojects.html http://openjdk.java.net/projects/mlvm/subprojects.html Also, Scalaz great as it may be, it simply sucks in terms of the actual implementation, as it has loads of functionality that breaks when that shouldn't have been a possibility in the first place. Every time I happened to investigate issues related to Scalaz, I always ended up with a "WTF were they thinking" moment. > I'd argue that today, you are better off with the .NET VM, as far as features are concerned. That's bullshit. Speaking of tail calls optimizations, the bytecode available in .NET didn't even work at all on 64 bits .NET, prior to version 4.5 - that's right, before 4.5 the tailcall bytecode was considered more of a guideline. And Because C# doesn't use it, they never bothered to optimize it, so it has a pretty dramatic performance hit in comparison with normal function calls. And Mono probably doesn't do tailcalls properly even today, with F# being unusable on top of Mono for several years. In terms of features - for example the CLR doesn't optimize virtual method calls. This is killing dynamic languages, or static languages that diverge from the C# OOP flavor in terms of polymorphism. IronRuby was never even close to what JRuby could do even when Microsoft was funding its development, simply by virtue of JRuby running on top of the JVM. And now ever since JDK 7 with invokeDynamic, the performance boost is so amazing at times compared to Ruby MRI, that people are running apps on top of JRuby for performance reasons ;-) The JVM for example can inline virtual method calls at runtime and can de-optimize those call sites in case invariants change or in case it notices that there are no performance benefits. This is something that really few other VMs can do. invokeDynamic is amazing. It provides a way to override the default method resolution that the JVM does, while still benefiting from the same optimizations that the JVM does for normal method calls. It even has benefits for static languages such as Scala, for dealing with closures and Java 8 introduces a facility for initializing a value that can afterwards be treated as a constant, so there are big wins ahead for Scala in terms of performance for things like "lazy val", or structural/dynamic types and others. Functional languages use a lot of persistent data-structures and persistent data-structures are by their nature wasteful in terms of short-term junk. You need a really good garbage collector to not suffer from this and the JVM really has the best garbage collectors available. You should see what it can do in a server-side environment with server instances being hit with thousands of reqs/sec per JVM process of real traffic. I have and it's freaking sweet. Also, it's actually good that Java's generics aren't reified. Reification is only needed for languages like Java in which the type system sucks and stays in the way for more expressive/advanced type systems. Language implementers have to pull off a lot of tricks in order to work around CLR's reified generics. F# has 2 generics type systems in the same language, as Hindley-Milner can't be piggybacked on top of CLR's reified generics. .NET still has some niceties, like stack-allocated value types, which is sweet if you want numbers that diverge from the standard primitives offered and to avoid boxing (and JRuby suffers a little because of this). But btw, here's another thing that the JVM can do - it can do escape analysis and for example it can decide to allocate certain short-lived objects straight on the stack if it sees that those objects don't escape their context.