I noticed that in the Ruby community “Java” is a synonym of pure evilness. It’s often used as an argument against some techniques.
“It’s Java all the way”
“If you drop static methods, then welcome to Java and its billions of useless factories.”
“Your mention of ‘factories’ gives me nightmares about Java-style over/premature abstraction where you need to interact with (and therefore understand) WAY too many different classes to get anything done.”
Those are some quotes that come from only one discussion triggered by Nick, me and Michal only because our ideas sounded a bit Java-like.
History
Part of the Java-hate comes from the historical reasons. When Rails appeared lots of Java people switched to it as it solved some of the problems with Java. I was one of them.
Rails was simpler than the existing Java frameworks. It let us solve most of the problems much faster than with Java. Ruby as a language was and still is a big advantage. Its syntax is more concise. Even though I still prefer Rails than Java based frameworks I don’t get why so many Rails people simply hate Java.
Java and XML
I always disliked the XML impact on the Java frameworks. It didn’t come from nowhere, though, let’s be fair. Java as a languages is not as readable as Ruby, so it wasn’t perfect for configuration. Yaml wasn’t popular and JSON was still not really mature back in 2000. Something had to be chosen and that was XML. What would you do better back then?
It doesn’t mean that whenever some Java-like idea is presented then somehow you have to be scared that you’d have to use XML again. Let’s try not to be biased and look at Java ideas without the XML bias.
Java and over-abstraction
Yes, often Java frameworks were very abstract and overgeneralized. Again, it was a result of Java lack of dynamic features. Whenever you needed a pluggable system in your code you had to abstract away some concepts in order to make it work. Ruby lets us do it much easier and that’s cool.
Java and good things
There is lots of good things that came from Java to the Rails world. Most of the TDD/BDD stuff comes from Java. Refactoring came to us from Java [UPDATE: What I mean is that those techniques came to the Rails world *through* the Java world, they're not originally from Java]. They became popular in the Rails world. That’s cool. There are other techniques that are great, but somehow didn’t get so popular:
Dependency Injection and Inversion of Control
These two techniques are great for many reasons. They suggest that you should expose your dependencies in the constructor or through setters. It reduces the usage of globals and static methods and simplifies testing. In my opinion they result in much better object oriented design.
POJO - Plain Old Java Objects
This is one of the places where I felt I made a step back when entered Rails from Java. In Java there was a clear trend that your business classes should be clear from any framework dirtiness. Persistence was configured and injected from outside (or through annotations). When your business classes are not polluted with framework stuff it’s much easier to test them in isolation. In Rails there are many tries but no good solution on how to test models without a database.
Aspect Oriented Programming
I was involved in the AOP movement in my Java life. AOP was the tool that let you intercept method calls and run some crosscutting code from one place. If you needed logging of method calls and params, it was just 3 lines of code in an aspect and all of your method calls were traced. Similarly, it was possible to handle persistence with AOP. Another part of AOP was composing classes from smaller pieces. Fortunately, this part now appears in the Ruby world in form of the DCI architecture. The dynamic part (interception of methods) didn’t get very popular. We have some limited AOP with filters in Rails controllers and callbacks in Rails models, but we could go further and use it for persistence or for logging.
Let’s stop the hate
It’s cool that we, as a community, strongly identify with some techniques. What I’d love to see is more tolerance for other technologies.
There are smart things in the Java world but we have to be open to reuse what’s most cool and replace the bad parts with Ruby awesomeness. When someone starts his talk with “In Java this problem is solved by …” don’t laugh and interrupt with quotes like “OMG, XML and factories again”. It didn’t happen only to me. I have seen this behavior at Ruby conferences very often. It's childish.
Many good things came from the Java world - we should love them for that.
There are more large Java systems than Ruby ones. They abstract for reasons. They use IoC and DI for good reasons. AOP is awesome when used in a good way. Let's learn more from Java - it will help us once we work more with larger systems and codebases. They already learnt their lessons.
[Discussion on Hacker News: http://news.ycombinator.com/item?id=2793227 ]
If you read this far you should and subscribe to my RSS. You can also buy me a beer at the wroc_love.rb conference. I'm one of the organizers.
49 comments:
What I’d love to see is more tolerance for other technologies.
Peace & Love? No way! ;) Holy wars will never end.
TDD and Refactoring, AFAIK, started on Smalltalk world...
And I disagree about POJOs. In most of my Rails programs, there is a directory (app/) that have only "POROs" (Plain Old Ruby Objects, if you like), and it's really simple to test then.
True, refactoring originally is more from Smalltalk. I meant that they come to Ruby/Rails through the JAva world.
+1 for you for using POROs!
disliking is different from hating. I dislike java.
It all depends how quick a technology/language linguistic can adapt, embrace the latest trends. C# is a best example in this. Constant innovation is happening w.r.t .NET. Though I am a recent Ruby guy who worked in JEE for 4 years.
I don't think TDD and BDD are taken from Java world. Hardly Java guys aware about TDD, BDD, linux, open source world. They are just dumb ass except quite few
Moreover Java guys are fit only to use Windows XP, IE6, and heavy weight eclipse hanging machines, and other unproductive disjointed tools.
java is a load of crap.
Not sure where does all the hate come from and I agree that Java brought a lot of good philosophy to Ruby and RoR. I think part of the problem, is that RoR developers feel sorry to see the waste of time and energy to solve simple things. I don't think Java, or any web language in fact, should be hated. They should be treated with respect. Like you respect old people. You admire their contribution to present reality, but at the same time you simply ignore them.
Nice, next target, stop Java/Ruby developers hating PHP... or is that never gonna happen? :\
Judging from the comments, this is hopeless... Good luck anyway.
Awesome post bro. I have been getting more and more frustrated with the communities pitting these hopeless wars against each other. Yeah Ruby can do some powerful things, but so can Java and PHP. As a ColdFusion developer, I see people trashing CF all the time and it really is stupid what I hear.
This is a great write-up. Thank you for calling out some of the nonsense that I see in the ruby community. I don't know Java well but it is still an alternative to Ruby. And anywhere there is an alternative, there is competition which can only be good for Rails.
If Ruby is so great, why are companies like Twitter moving away from it and towards Java/Scala?
The reason is because Java is better, the problem with RoR is it removes the need to understand what is going on. A dependency is created and the developer gets reliant and dumber, taking too many things for granted and creating too many bugs.
RoR was even created by a self confessed Java hater, it really seems to be that RoR is simply used as a way of hating Java, not because it is really better, and every argument I have seen to the contrary is either pathetic or tenuous.
Something had to be chosen and that was XML. What would you do better back then?
Beanshell?
to be honest, I think the Java world did go a bit overboard when it came to XML, using it an areas where it made no sense whatsover (like Apache Jelly - XML as a scripting language????)
Good point, hate makes you blind. The Anti-Java attitude is very common among Ruby developers sadly.
I don't think any (modern) programming language should be considered superior or inferior to another, they all have their own merits and their share of problems.
There are always things you can learn by looking at another language, since they provide another methodology for solving things and whole different mindsets.
Factories and XML configuration is not necessarily evil, it's just not the right thing for every use case. Furthermore only if you for instance combine baseline XML configuration with convention over configuration and declarative programming (for example via annotations) you get the best of all worlds: fine-tuneability and as little as possible boilerplate code.
Java learned a lot from Ruby, Python and even C#. Ruby does not have to be agnostic of the world around for ideological reasons.
Alternatives to XML? What about S-Expressions? They've been here since the sixties (or was it te fifties?). TDD has been part of the Smalltalk culture since forever.
The problem with Java is that it's such a dumbed down subset of everything that came before that it makes Java programmers think it was the beginning of it all. It wasn't. Java is the modern Cobol.
Most of the "modern" edgy things you see in Ruby have been there for 30, 40, 50 years. LISP and Smalltalk both predate Java. Even Haskell and Erlang are older than Java.
Java isn't an alternative to Ruby. Java still sucks. The JVM is an alternative. Scala is. Those two don't suck.
Twitter isn't using Java. It's using the JVM, people should make this distinction.
And it's nice to see how some people here is stuck in 2006. Rails? Ruby has much more than Rails, ffs.
Regarding your point about Plain Old Java Objects and mixing business logic with persistence layer (which is AR in Rails) - this is exactly what DataMapper 2.0 will try to solve by completely decoupling business logic from the persistence. I hope it will change the way people develop Rails apps by embracing new patterns and best practices *and yes* many of those do come from Java!
Overall - great post, I couldn't agree more with you.
Mostly because people who don't like java are forced to use it or hear from it, by bosses, by customers, or by mainstream ideas etc ...
Once they have the right to choose, they stop hating.
You can't hate a person you don't know, right ?
Andrzej, I totally agree.
I am working with both, Java and Ruby. It is stupid not to learn from each other. Prejudices don't help either.
I also agree with this: "Java overused XML". Thing is, when I started using Rails, I started doing things for 10 mins, which in Java (no matter the web technology!) takes me 2+ hours. Okay, hate is not nice, but seriously -- 10 vs. 120 mins?
I would theorize this is the main reason for the hate. Without being ashamed, I also trash-talk Java now, even though I have been using it for solid 7+ years.
Also, I am yet to see a Java Web framework devised BEFORE Rails which uses at least SOME it's concepts -- like Convention Over Configuration, DRY etc. Java is still a great language, but it's developers are poisoned by years of sloppy technologies and cannot be creative anymore.
Disclaimer: a personal opinion backed by my professional experience.
I agree with the author to a large extent.
And do believe there should always be exchange of idea or discussions atleast how to make any technology, framework or language better.
Stop telling people what to do. And fuck you.
last time I checked JVM stood for Java Virtual Machine, because that is the bytecode level that Java and others are compiled down to to run... so Java = JVM... go figure.
as a PHP dev I have to take crap from all programming communities because a lot of people got stuck with an older version of PHP and base everything they say on that...whatever,...languages are tools, no more (I'm feeling shakesperean this morning)
people who hate java is because they are not a good programmer. language is not important.
java = slower than everything else, therefore not worth using
A language that you don't use = CRAP
Used to think like that at 8
"people who hate java is because they are not a good programmer. language is not important."
Not true.
In fact, it is often quite the opposite. People hate Java because Java has limitations which annoy them and cause them to type reams of unnecessary code. Many hate Java because it wastes our time, and there are many much better, more efficient languages available. It is precisely because they *are* good programmers, many with a great deal of experience, that they hate Java -- because they have used much better languages.
There are many programming languages that are roughly equivalent in expressive power. I think that is why it is so common to hear programmers say that your choice of language doesn't matter. However, not all languages are created equal. I could go on about why, but I believe Paul Graham has written much more eloquently than I have about this: http://www.paulgraham.com/avg.html.
Before you dismiss Paul's writings on the subject (as some have), may I ask you this? -- have you really read the article and given it a fair hearing? Or are you willing to accept other's assessment of it without making up your own mind? I would challenge you to be sure you have not been swayed by the opinions of others, without making an honest assessment for yourself.
My first introduction to Java, oddly, was using it to interact with Apple (nee NeXT) WebObjects, sometime around like 1994. Now the odd thing about that is, that at least around then, you didn't really use ANY of the java standard libraries when doing this, WebObjects even provided it's own collection classes (the descendents of which are probably the collection objects and stdlib in cocoa and such, but I don't do OSX programming).
And from that experience, I've got no dislike for Java _as a language_, it was just fine (and surely better than any alternatative where you had to do your own memory management). I'm not really fundamentally opposed to static typing, it's fine. And if you can handle static typing, there's not much in the Java _language definition_ to dislike.
The problem is the Java stdlib, the JDK, and the design sensibility of the Java community. I've heard it's gotten a lot better since then, and seen it somewhat better in my encounters with Java. But things are still just Too Complicated -- ruby from the start has had a development community (starting from Matz's example) that optimizes for ease of use by developers. attempting to create library APIs at the right level of abstraction for common uses, so developers have to understand no more than they need to understand, and can write both concisely and clearly.
Part of this is a commitment to making things workable without complicated tools, using only a text editor and the command line. Whereas the Java community's approach seems to be adding ever more complicated tooling to try to get around things becoming over-complex in the text editor/command line -- instead of trying to fix things at the root.
Now you could say that ruby (and rails esp) are having ever more troubles with 'keeping things simple AND powerful' as they get older and more complex. It's true that starting simple is easy, but as you add more power, staying simple is hard, and ruby/rails are having some trouble there. Also as the community grows, you run the risk of giving the developer Too Many Options (_what_ the heck should I be using for XML again? for HTTP? I don't want to think about it, I want there to be a standard (de facto or not) that Just Works).
and ruby/rails are maybe having some troubles there as it becomes a larger community with more history -- but Java _started out_ there, and the community has seemed, from my perspective, to not have had much success making a priority out of making things that should be simple, simple for the developer.
Nonetheless I'm sure there are many useful things to learn out of the Java community -- but there are still some useful things to learn of what _not_ to do too. I'm sure there are similar from ruby community. In both cases, I think there's probably less to learn about from the actual language design, and more from the community norms and practices and standard (de facto or official) libraries/frameworks -- what people DO with the language.
One tension that's inevitable however is the backwards compatibility issue. PART of what leads to Java's difficulty of use is the pretty high commitment to backwards compat -- which means there's lots of cruft and bad ideas that have to be left in. Ruby (the language itself, and community norms in ruby libraries/frameworks) cares much less about backwards compat, which means bad ideas and cruft can be removed and things can continually be made easier to use -- IF you're using the most recent version. But as ruby has gotten older with more of a history, this lack of backwards compatibility (which is intimitately related to the dependency nightmares with rake/rails/gems/bundler/etc) has also become one of the biggest not fun/confusing/annoying things about dealing with ruby, esp if you've got old code to support.
Hmm, well. All Java-hate I've ever heard is around the language, it's syntax, and it's _bad_ ideas. No one is hating on the good ideas. I think the situation is fine. People will hate on what they don't like so matter what, and there's really nothing wrong with them hating on it... what's the big deal? For example: I hate Python. I think it's ugly, I hate it's class system and it's users are, in my opinion based on 6 years programming only Python, arrogant jackasses. So? Python lives on, so does Java, so does Ruby. Let's just get back to work, shall we?
The title should probably be "ruby people, stop being arrogant and ignorant"
jruby is faster than mri...grow up ruby guy...
"If Ruby is so great, why are companies like Twitter moving away from it and towards Java/Scala?"
Because Java has a good VM. That's because of its implementation, and does not reflect the language itself. It also reflects old ideas, like the idea that you need to have threads for everything. I'm working with EventMachine on 1.9 and writing software that can rival the performance of many Scala IO-oriented programs. There's also things like processes, such as what Unicorn uses. Not saying threads are useless, but they're not the only game in town, and often they're not the best solution.
I'll admit it. I don't dislike Java, I hate Java. I hated it when it was that thing in my browser that crashed everything and slowed my computer to a crawl to scroll "HI MY NAME IZ JON" on a Geocities page, I hated it when it became this half-assed GPL project, I hated the stuffy corporate culture that lived around it (it really is the 70s IBM of our times), I hate the memory bloat it's always had, I hate that it dominates so much of software because of forced college adoption, and now that Oracle owns it and is in the process of trashing open source with their horrible corporate culture (that fits Java like a glove), I really hate it. Java has been nothing but a problem throughout my entire history of interacting with it. I want Java to die. Or at least be like COBOL, and get written off as a joke language that some sorry coder has to maintain because the business is too screwed up to migrate off of it.
Like most of my other predictions in software, this scenario is likely to become true for no reason of mine. Largely as a result of how crappy most of the software is, largely because the corporate culture is turning off an entire generation of programmers to it, and largely because Oracle is going to wreck things.
Ruby is a better language for Java's intended purpose (high-level software development), under a better license. For high-level development, it's more productive on almost every front. Does that mean I won't use Scala or JRuby someday? No. I'm an engineer, and if I decide the Java VM is a better fit for a certain problem, I will use it. But that problem has never arrived. Whenever I have tested Java for better viability, I have never been impressed with the results. It's either too slow, or has too much memory bloat, or has some crazy bugs I don't have time to fix (it's not perfect software, it has its fair share of nastiness).
When Rubinius gets stable, Ruby will have a VM that does the same thing the Java VM does, and then the argument for using Java because of its VM goes away for me, along with the memory bloat.
But hey, if you want to sink with Java, don't let me plug the hole in your boat. I'm very happy living free in the ruby world.
The best thing to come out of Java is Clojure.
I'm surprised that no-one here has mentioned Groovy.
I'm a lisp/scheme kind of guy (the original ruby :), and using Groovy is a pleasure, and of course it's very happy to work w/ old school Java classes. And even old school Java programmers, since for the most part legal Java is legal Groovy, but you can also specify no type information if you'd like and you get code that is as expressive and concise as Ruby, Scheme, etc.
And your IT dept (if you're at some giant megacorp) is more likely to not fight you...
I have built many system in Java, have SCEA certification and I love the language and the JVM. But I switched to all my company's systems (credit card company) to Rails in 2006. Simply because we came to the conclusion that even though java is fast and reliable, the whole Java stack is not business friendly. It just takes too long to get something done in Java. I hate large teams and Java was forcing me to have a very large one.
I should be blaming Struts, Spring or JCP for bringing crap like JAXB to life. But no: I blame the community. The product is result of the community wishes, and the Java community wishes complexity for reasons I do not understand.
Java will always be around, it's great, but projects made in Java are very hard to pivot and can put startups in jeopardy.
We now have many cool languages and tools to choose from (thanks to the JVM). This is the end of times where only 3 or 4 languages were "mainstream" in business apps.
Long live java.
Personally, I'm glad to see Ruby slowly disappearing:
http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
say what you want about every language out there, at least they aren't coldfusion (or at least, most of them aren't)
What about this: Ruby is a piece of sloooow, shitty elephant - pythonista :D
According to the Debian language shootout, Java is one of the fastest languages around. It's beaten by C and C++, but the differences are small (~1.4x).
Now look at Ruby and Python. Those two are in a completely different performance league, with some benchmarks running 300! times slower, an average of being 60x slower and not a single benchmark where Ruby beats Java.
It's not just the JVM though, it's also the language. Java's syntax is simple and straightforward, which means the JIT has a lot of information to work with. With JRuby this is simply not possible (although the new opcode in the JDK 7 VM will make it faster).
Then look at the Tiobe language index. Java is at number 1 and languages with similar syntax are at the other top positions. Where is Ruby? It's at 1.4% or so.
It has been some 5 years after RoR was introduced, and despite all the hype of it completely dominating the industry in a couple of years, Ruby (which is of course bigger than RoR), is at 1.4%? Really?
In 2004/2005 the direction of Java did look bleak. But after its transformation from J2EE into Java EE, it's a world class platform now. JSF 2.0 (which was at many levels inspired by RoR) is one of the best web frameworks now, and I dare you to find any kind of tech that's as simple and ellegant as EJB 3.1.
Andrzej don't pay attention to ruby fanboys..
they can't understand a thing without http://bit.ly/nySdU4 :)
+1 for the article!
Guys check out what Google Engineer are saying..
http://obamapacman.com/2011/07/google-engineer-java-alternatives-all-suck-android-needs-to-negotiate-license/
That should shut all other's
Andrzej, good post, see my response at:
http://www.dzone.com/links/r/stop_hating_java_2.html
igor
There are languages that people hate and there are languages that noone uses. If you can't count 10 things you hate about the language/environment you are developing you really need to start learn your tools.
Greetings!
Good post.
What I can additionally say, not only some of Ruby- Python-devs dislike Java, many c#-devs dislike and even hate it. What's more, I've been hating it for ~3.5 years, while had been working as c#-dev. However, after working 0.5 years with Java and moving closer to it's community I realized that Java really rules, mostly thankfully to it's community. Yeah, there are some bad things in Java-lang(overusing of xml, 'throws Exception' keyword), but it's just not important details, generally Java rules, as I said.
p.s. still working as c#-dev, so c# rules as well :)
thanks.
An excellent write up from your side.Keep it up..
Java has given programming a new dimension, people are fool who hates Java, new generation of programming and application language has been led by Java.
Javin
comparator and comparable in java with example
I wanted to like Java. I really did. I saw that it was going to be the next big language when my career switched tracks in 2002. I tried installing it and running it. It took an awful long time to get anything done.
Then I had an opportunity to write a web app in 2003. I chose Perl/MySQL/HTML because they had documentation and a clear path from developing on a local machine right through to deployment. (At the time, both PHP and Java failed for me). The process was predictable with few moving parts. And I went from conception to deployment without having to muck about with configuration etc.
I tried Java again. Instructions were poor. I couldn't get components installed and running, libraries were confusing, and so on. I felt stupid. Eclipse ground my computer to a crawl.
I then started Rails. I got a web app (with scaffolds) running in minutes. The blogs, forums, and other pages showed how to build Rails apps. Around that time I discovered heroku.com, and deployment became easy too. I built quite a few web applications and learned a lot about web apps in general.
I tried Java again. Again...slow to install. Slow to configure...slow to compile, link, deploy & test. I couldn't solve my software problems quickly. And there were a lot of little things I had to remember to get anything useful done. And I never knew what I didn't know.
I tried C#.net too. Not as bad as Java, but very slow to get stuff done. And I felt stupid using it.
Ruby on Rails beats Java for me because independent of my intelligence (or lack thereof), working in Java makes me feel stupid and incompetent, while working with Ruby and Rails makes me feel smart. And when I feel smart, I push the edges of the technology and the edges of my cognitive abilities and learn more interesting things and build new software.
And you can't get better than "git push heroku master" and 30 seconds for deploying software to the internet. Rails also has github.com which is a great place to study, download, and deploy working Rails applications.
Ruby/Rails sucks for getting jobs. My city is mostly Java or .Net, and very few employers know Ruby/Rails or the benefits it can bring. But for quickly solving web application development problems Ruby/Rails beats the other technologies hands down for me. Perhaps that makes me stupid for not learning Java. But it has freed me to learn the art of quickly developing complex web applications.
Ruby guys hate Java, Java guys hate C++, ... It seems to me that hating is what we as developers do.
I've been a Java developer for a number of years now. I remember how frustrated I was with it's syntax initially. I can recount hundreds of hours trying to figure out wtf all of the abstractions and frameworks were actually trying to accomplish. I just needed to get a job done and there was an incredible number of profoundly nonsensical configurations and packages to wade through. I remember back in 06 when I started developing AJAX heavy web apps where most of the work was handled by the client and DWR made my life a breeze. I've only recently come to see the whole spring framework as a benefit (i've been doing a lot of grails work and I no longer have to think about it). At the end of the day I'd say 90% of the frameworks ARE completely bloated and a f*&king pain in the a%$. That said I've always been one enthusiastic about the bleeding edge, the majority of people I speak to in the mobile/start-up world swear by rails and I've spent a lot of time trying to understand their enthusiasm. It was tough for me moving to Java from c and asm (my original works were all in embedded systems). However, I realized that with native interface I could really get Java to do whatever I wanted whenever I wanted it. Back then I worked on windows/nix/osx and still have to. Java has never let me down here and as much as I've tried to understand and love rails for me it has never made sense. I have developed a base package with jars and javascript that I can port anywhere that implements AJAX and cometd on whatever machine I choose.A lot of the work I do now is in ios and I've developed libraries that convert my pojos to json to NSDictionaries or Core Data objects without a thought. All of this said, I'm REALLY trying to understand this debate. I have a system (Java based I admit) that does the job I want and does it better than any jar or gem out there but that's because it was developed by me for years and I know EXACTLY what everything does. No surprises. So my point? I really think we are all insecure/antagonistic because we want to be on the right side of things. However, coding in Ruby is honestly the exact same experience as in Java. The only difference for me is that with Java I know how to make it do exactly what I want because I've spent so many painful hours slogging through the nuts and bolts. At the end of the day what matters is whether you can get what you/the client want running. If I see a jsp at the end of a website I like that's great, but truth be told that's not what matters. What matters is getting the blasted machine to do what you want. There are countless performance tests out there arguing this or that but they are honestly useless, if you have control of every aspect of your system and you are a competent engineer you will MAKE IT WORK. I don't think anyone will come to a point where they say "hey, we need to rewrite the whole thing in X b/c Y won't cut it." Maybe I'm wrong? Love to know why though. Thanks for listening.
Post a Comment