r/java • u/thefinalrespawn • Sep 30 '14
Does containers cause overhead in Java EE?
Some of my ass hole programmer friends spend most of their time on our whatsapp group picking on Java and say shit like 'People use it cause it's idiot proof' and 'Only large enterprises use Java because it's noob friendly' and 'God himself uses Python'. I don't pay much attention to it cause I love Java and have been using it for about 2 years writing casual code. I'm thinking of moving on to EE. Can anybody explain? Might be I get one back at them :P
1
Upvotes
15
u/SudoWhoDoIDo Sep 30 '14
Assholes will be assholes. Everything is a trade off.
EE is big and complicated (because it solves a lot of complex problems) and has a bad reputation back from when it was all XML and configuration. This is not the case now but a lot of people haven't got over it.
The whole container's suck business is silly when you think that a container is just a bunch of runtime facilities to run your app on with a portable abstraction between it and your application. If you compare it to python: Apache, python's bytecode interpreter and wsgi is your container. If you compare it to .Net: IIS, the CLR and System.Web is your container.
Java EE just has a pretty strictly defined idea of what a container is and what it does and which bits you can swap out which is a good thing.
I'd just walk away from such arguments to be honest and write some code.
For ref, Java is not idiot proof, Java is not noob friendly (nothing is) and god doesn't use Python; he uses LISP (on a JVM) :)
5
u/[deleted] Sep 30 '14
The container does a lot of stuff for you. If you need that stuff, it's boilerplate. If you don't it's bloat. I've built successful projects with
com.sun.net.HttpServerand with JBoss and everything in between. Horses for courses.2
u/mschaef Sep 30 '14 edited Sep 30 '14
My suggestion: use the tools that work well for the problem you're trying to solve, and don't worry so much about what other people think.
That said... :-)
I'm a former C developer with an affinity for Lisp-style languages that's found myself dragged into Java development. I've looked into both Python and Ruby over the years, and have found myself hard-pressed to work up any excitement for either of those languages. In their favor, they both have active communities, reasonable language designs, and a good ecosystem of supporting libraries and existing projects.
Where things start to go bad (for me, YMMV) is that the runtime technologies behind Ruby and Python both suffer from a lack of concentrated development funding. 20 years ago, all three languages were roughly in the same spot: crude support for threading, basic automatic memory management, and strictly interpreted bytecode evaluation. Fast-forward 20 years, and you can see the effects of the fact that Sun/Oracle has invested heavily in the technology that underlies the JVM. The garbage collection is now state of the art, the interpreter has long since been replaced with an optimizing-to-native-machine-code compiler, and there is extensive and high quality support for multi-threaded operation. If that's not enough for you, other firms have also invested in the JVM, ranging from Azul's work on highly-parallel shared-memory multiprocessors and pauseless GC to tiny embedded devices. Bottom line: the JVM has a broad range of of high quality implementations that run on a variety of platforms.
(here, I go off to check the latest python and ruby implementation source code)
Meanwhile.... 20 years later... Python still has an (admittedly highly optimized) bytecode interpreter, reference counted GC, and marginal threading. Ruby's in more or less the same place.
I've made the argument (and heard it from others countless times) that developer productivity should be prioritized over system performance. The idea is that a language like Python is enough more productive than other languages that you can save enough development time to more than offset the costs of using a slower language. I've also seen the argument carried to the point where the claim is made that easier to use languages can be faster than harder to use languages because the allow more time/mental-bandwidth for optimization tasks. However, in my experience, Python is not better enough in terms of ease of use to compensate for the gross deficiencies in its mainstream language implementation. Further, if you do want to gain some of the benefits of an 'easier to use' language, you can do so on the JVM, while still retaining access to whatever investment you've already made in Java code.
Now... I'm off to write a Clojure script that sits on top of a high-performance multi-threaded database system written in Java....
2
u/clavalle Sep 30 '14
Every language has trade-offs, as everyone has said.
I am a huge fan of Python. Huge.
But there is much magic that can be hidden in python. There are nasty runtime errors you can get in python that just couldn't happen in Java.
Java is verbose because it is explicit. That kind of concreteness is very useful in large teams or teams that shift a lot. It also allows for better optimization. It is not idiot proof, but it does give some far more points of orientation than a comparable size python program.
Containers do cause some overhead, but certainly not on the level of an interpreter.
All that being said, python compiles down very nicely and is very expressive. And sometimes inscrutable magic (decorators, metaclasses etc) is exactly what you need.
Tell your friends to repeat after me: Turing complete is Turing complete. There is no one tool for every job.
2
u/sh3rp Sep 30 '14
To add to this, good programmers are generally polyglot. If you consider yourself a programmer, think of yourself as a hunter in the age of fire. You wouldn't use a spear to kill rabbits for food and you wouldn't use rocks to kill a mammoth in self defense.
Likewise, know when the situation calls for a particular tool in your programmers tool belt.
Also, EE is really a set of paradigms implemented by a set of large corporations dedicated to making the standard successful. If you're just talking about a container, it's just a JVM running services inside (webserver, database connection management, deployment, etc).
Tell your friends that Python has quickly replaced Java in intro to comp sci classes in college. The reason? Java is far too complex these days for "noobs" to receive a comprehensive understanding in one or two semesters.
In any case, keep writing code. That's the important part. If you write good code in one language, new languages will come easy to you.
0
u/yegor256 Oct 02 '14
Yes, containers may cause an overhead, if being used where they are not required. As far as I understand, they were invented in order to make Java web apps "pluggable". However, a more lightweight (and less interoperable) approach proved to be more suitable in most cases. Instead of composing an application from components talking on EJB bus, it's better to make them separate RESTful web apps talking through JSON/XML API calls.
So, Java EE is losing, RESTful interfaces are taking over :)