Ayende @ Rahien

My name is Oren Eini
Founder of Hibernating Rhinos LTD and RavenDB.
You can reach me by phone or email:


+972 52-548-6969

, @ Q c

Posts: 6,124 | Comments: 45,470

filter by tags archive

My Java Experience

time to read 6 min | 1142 words

As I mentioned before, I am actively trying to find what I don’t know, and plug it. As part of that endeavor, I spent the last week learning Java EE. I decided that in the interest of saving time I am going to invest some money and I took a week long course in it. That allowed me to kill several birds in a single stone, I got to experience Java in an environment that had an instructor that I could call on for help, it allowed me to learn Java EE and it allowed to me experience how people using Hibernate Profiler feel like.

Now that it is over, I can say that the course has met my expectations to a T. But that isn’t the point of this post. I wanted to talk about what I learned and my experience.

Nitpicker corner: please note that I am talking only about Java EE and EJB 3.0. I am well aware of the existence of frameworks that build on top of that (and earlier versions), but right now I intend to discuss Naked Java EE.

From language perspective, working with Java was incredibly frustrating. I had not really realized how much I come to rely on such things as object initializers, the var keyword or null coalescing operators.

As a platform, I have a much better understanding for how the Java EE eco system developed. Basically, it works like this (the concepts does not translate exactly, mind you):

Java EE .NET
Servlet Http Handler – but with singleton semantics & with threading issues.
JSP ASPX – but without any code behind.
Listener Http Module

One of the things that really drove me crazy is the notion of making everything a singleton. I wonder if there was a time where object creation in Java was very expensive, that might result in this design. The problem in making everything a singleton is that it become shared state, which means that you need to handle concurrency yourself. This is a bad thing. In fact, I would go further and say that any framework that requires users to handle concurrency for standard scenarios is flawed.

When I learned that you had to wire each independent servlet in the web.xml, I was quite shocked. The sheer friction that this is going to add to a project is mind numbing. Imagine the camera unzooming, and the full picture showing up. There are usually very few servlets in an application, often only one. They handle the request by sending the data to an EJB to handle the business end and a JSP to handle the HTML generation end. If it sounds a lot like MVC, it should. The interesting bit is that I don’t think that all the Java MVC frameworks came out because of anything unique in the Java sphere. They came out of sheer self defense out of the amount of toil & trouble that you have to go through using what the bare bones Java EE gave you.

Moving on to what I would call the controller side of things, we have EJBs, Enterprise Java Beans. There are Session Beans and Message Driven Beans. The MDB reminded me quite strongly of a very basic service bus. Considering something like Rhino ServiceBus or NServiceBus, it looks very similar in concept and execution, but without a lot of the things that the those two do for you. Session Beans are supposed to handle requests, they are divided into stateful and stateless beans. In general, I seems that you would generally use the stateless beans.

A stateless bean is a class implementing a specific interface, and that is where a lot of the interesting things are happening, dependency injection, automatic transaction management, session management, etc. It is interesting to note that with .NET we have gotten to the same result, but without having the overreaching presence of the container everywhere. I really like the fact that there is no attempt to disguise how they are doing things, the Java’s language decision to make everything virtual by default has really paid off in here.

Still, I can’t say that I like the default architecture, it seems very inflexible. I do like the ideas of full blown servers that you can just deploy a file into. It is a very nice concept, but it has some sever downsides, the time that it takes to do a modify-deploy-test cycle is significantly larger than what I noticed on the .NET side of things. And keep in mind that I am talking about projects that had about 5 classes in them all told.

During the course, the instructor said something that I found very insightful, “the tooling help you deal with… [wiring the xml, inheriting from the appropriate interfaces, etc]”. I found this very telling, because up until then I was quite puzzled by the behavior of all the standard wizards in Eclipse. They seem to violate the KISS principle, especially after getting used to the Yes, Dear experience when using R# on VS. It was only after I realized just how much work those poor wizards had to do for me that I understood what was going on.

After the course, I took a look at some of the MVC frameworks in the Java market. Just reading the tutorials is fascinating, from a code archaeology perspective. You can clearly see that Struts came early on, since while I am sure it is an improvement over Naked Jave EE, the amount of XML you have to deal with is not funny.

All in all, I find myself unimpressed by the amount of work that was shuffled to the tools, it doesn’t seem right. And it seems like a justification of a bad practice. When I consider my own design principles (Zero Friction!) in light of this, I am much happier that I am mainly working in the .NET world. But I think that having this understanding is going to be very helpful moving forward.



I can imagine you were quite a problematic student and drove your instructor crazy, all the time talking about how bad Java is ;)

I've gone through the same acceptance problems when switching from Java to .Net in 2002 - ASP.Net was a bloody mess, .Net API sucked, but luckily there were no EJBs (I'm astonished they re still alive)

Bert Willems

I recently transitioned from .NET to Java for a specific project. My experience is the same as yours: a lot of glue is needed to achieve even the simplest thing.

The typical response from the Java community is that tooling will fix this for you. I have seen wizards and extensions to build tools solving this problem but I still can't shake off the feeling that working with EJBs is cumbersome.

Although I learned a lot from developing with Java, my personal opinion is that developing on .NET is generally faster.

Dmitriy Nagirnyak

I think you would better try a REALLY new thing. Java is not that new for a .NET devs. It is very similar (IMO). There are major differences, but the basics and the language are pretty much the same.

What you could try is something like Ruby, Python. Especially Ruby.

It is totally different mentality, platform.

The main difference is probably the frustration and fun you have using a platform. For frustration, I would order it like this: Java, .NET, Ruby.

And for fun the order would be: Ruby, .NET, Java. And Ruby IS just a pleasure.

Though, you need to break the way you think NOW as a .NET/Java user.


Russell Garner

Working with Android, as I am (which is a nicely designed compact framework) I can only speak about the friction that the actual language induces. Even the absence of things we take for granted in the .NET world - things like properties and multicast delegates - contribute enormously to the increased cognitive load necessary to mentally parse a piece of code (even your own!)

Java has one or two things going for it - as you state, virtual-by-default is a much more sensible route. I quite like the "anonymous class implementation of this interface" approach as well, though the absence of events and delegates has much to do with this shorthand.

So if Ruby's expressiveness has a baseline of 1.0, C# 3.0 is about a 0.8, Java is a 0.4 :) (I'm not going to argue with LISP coders)

Arnis L.

"the amount of XML you have to deal with is not funny"

It's not funny, it's hillarious! :D

Bogdan Marian


After reading this post, I can only jump for joy since I know Java Enterprise Edition has evolved a lot since version 1.4 (the one I have started to use for my first JEE application) - currently, Sun has just released its 1.6 version and I do want to mention they are VERY different.

I know Java from 2002, the year I start learning and using it, and in those days, man, they really loved XML files ... Right now, I can say that an JEE 6 application can be run with almost no XML file (annotation has killed the XML star :)).

I really like that I can work both .NET and Java and I can look at one side and apply the things I like into the other. I am way past the .NET vs Java war. There are plenty differences between these 2 languages, but there are also lots of similarities...

I have come to think that any developer should use the best tool for the task at hand, even if this tool is very awkward to use in any other situation.

PS: Why don't you try NetBeans 6.8 for a most pleasant JEE 6 experience ? I guarantee it will almost convert you to Java :)

Shimi Bandiel

Thoughts from the Java side:

"...any framework that requires users to handle concurrency for standard scenarios is flawed..."

I totally agree. However, Servlets in JavaEE do not usually require the developer to use synchronization because in most use-cases there are no shared objects between concurrent threads running on the same Servlet (business logic usually depends on request parameters and session data and not upon members).

Note that the wiring of the Servlets to the XML deployment descriptor has been solved by the new Servlets 3.0 standard (part of JavaEE6).

MDBs allow you to respond to messages (e.g., JMS, Emails, Legacy EIS messages). The purpose here is not to serve as an ESB. Java has specification for that also: JBI and several open implementations Apache ServiceMix, OpenESB, Mule, etc...

EJBs provide you with an infrastructure for writing Scalable & Highly Available applications which are portable across server vendors.

Keep in mind that most vendors offer extended services and functionality over the standard.

Not every application (even enterprise one) needs EJB. There are many alternatives and framework-stacks for providing Enterprise Services.

As for MVC frameworks, Java is flooded here. Ranging from Struts (old), JSF (standard based), Wicket (wonderful), Spring (MVC, WebFlows, Roo,(very flexible)), Grails (like RoR but on-top-of Groovy), and the remaining list is still long. Just have your pick.

I don't really want to go into comparison between Java/JavaEE & .NET. we are in the Polyglot age, use whichever language you think is right for your use-case and constraints.


What I'm most missing in the Java Language is LINQ and company. Closures etc. Generally I agree, that Java is quite verbose. But you can say the same thing about C# when you're a F# developer etc. There are enough alternatives like Groovy, Scala etc.

Yes, the JavaEE stuff is a painful, but it gets better with each release. As 'Shimi Bandiel' said, there a lots of alternative frameworks.

But there this goes also the other way around. I'm missing lots of stuff in the .NET world. For example the excellent IDE's in the Java-World. I'm still missing lots of features of IntelliJ IDEA and Eclipse in Visual Studio. (R# included).

Anyway, in the end you both technologies stacks are quite similar, powerful and you can achieve your goals. The right tool for the job.


I had to study JAVA in a month for the sake of 1 project (and actually produce production ready code in 3 month). After having many years of.net it was... painful. But after a month I felt myself pretty confident that I can release on time.

My IMHO suggestions:

  1. Use Spring + Hibernate and you will have everything you're used to, EJB are out of date as well as Struts and so on. If you want asp.net similar framework try JavaServerFaces but Spring MVC is ok for most scenarios. There is also Jboss Seam if you want to be tied to vendor.

  2. Use Maven, it will simplify development and deployment.

  3. Don't start with big and featured App Servers (like JBOSS), start with something smaller - you will have less problem with dependencies and configuration.

  4. Many people like Eclipse as it's free but IntellijIdea gives much better user experience and Resharper shortcuts as a bonus).

Java is of course two steps back in terms of language but it has evolved for many years and has many mature frameworks and technologies. Unfortunately, you cannot count on the single vendor anymore and should be flexible. Good luck. )



So the one thing about this post that blew me away was this, "Now that it is over, I can say that the course has met my expectations to a T". What is your secret? How did you find a one week course that even came close to meeting your expectations? I've been doing this for quite some time and I can honestly say that I haven't found or attended a one week course that even met half of my expectations. I ended up just abandoning the whole concept of training courses.

Please enlighten.

Omer Mor


can you please give some information about the course and the instructor?

Alex Simkin

This post is just a beautiful music to my ears.



The secret is how high you set your expectations. :-D

Ajai Shankar

Looks like Grails / Groovy took all the rails ideas and ran with it.

I dabbled with it briefly - am sure you'd find it to your liking.

And you'll be an expert in it in... half a day :-)



Java EE => .NET

Servlet => Http Handler


Listener => Http Module


But how about these?

JCP => ?

Servlet Containers => ?

Angel "Java" Lopez

EJB should be erased from human history. EJB 1.x, EJB 2.x, were convoluted (I'm trying to use light language). EJB 3.x was too late to fix the damage.

Hibernate and related open source projects flourished in Java eco systems, thanks to EJB and other Sun "ideas".

Spring Framework was born from Rod Johnson disgust with past technology as Struts 1.x.

JSR are a good thing, we miss in .NET.

There are more IDEs in Java world than in .NET. But such freedom has a cost: every project, generally, should be supported using the same tools/plugins/IDE that were used in its inception (or rely on endless ant/maven projects).

Swing (GUI) model has lot of methods, events, but, curiously, in .NET you need to manage a few methods to build something useful. But to use Swing effectively, you must manage more concepts and technicalities.

You skipped JavaServer Faces: two way binding in web pages, and more. But I guess it didn't gain enough momentum.

Angel "Java" Lopez



after years in .net land, i've spent the last six months working on a java desktop app project (using netbeans). i actually kinda dig it for the most part.

the hardest stuff to adjust to was:

  • no LINQ. damn, LINQ is good.

  • i really miss delegate support. anonymous inline classes are ugly.

  • the netbeans gui builder is WEIRD. when it works it's fine, but sometimes it just totally vomits on your forms. can be very painful.

  • events and callbacks are a bit nasty and the performance of that stuff isn't great either.

refactoring support and some other nice stuff in netbeans is extremely tasty though. overall, i'm quite enjoying it. certainly learning a lot, and the codebase is very clean.


I switched from Java to .NET in 2002.

What I miss in .NET is the much smaller open source ecosystem and community. Most of the guys I enjoy reading in the .NET world go outside of the walled garden and play with things like Linux, Clojure, NoSQL, etc.

What I dislike most about .NET is the preponderance of people who are basically uncritical Microsoft shills.

I work with one, and it is a royal pain discussing pros and cons with him, he is so far up Microsoft's backside, all he can do is "Bing" for comebacks whenever I point out deficiencies in Microsoft frameworks...


I'd like some one to explain why you would use anything other than Grails to develop a Web app on the JVM in 2010.

matt b

Sorry to hear you wasted your money on a class on J2EE.

Guess what, people don't use it! EJB, whats that?

Spring, Hibernate, etc. - these tools make life a lot simpler.

The great thing about Java is the set of tools and libraries that evolved from the community in response to ugliness that was the J2EE APIs.

That's all J2EE really is - not a "platform" but a set of APIs. You are free to not use them, and in 5 years of professional development, I've seen very few people that actually do use them, unless they're pushed on you by a vendor like IBM.

It makes me sad to read about your experiences because I'm afraid that this course gave you a poor view of "Java" itself.

Ayende Rahien


I knew what I wanted to learn, and I was aware that I would be hearing a lot of stuff that I already knew (since I am already familiar with web technology).

But what I wanted to get more than the course materials was a feeling of how you work with Java, and I got that.

Ayende Rahien


The closest thing to the JCP is the insiders group, but even those have very little effect compared to the JCP.

That is both good and bad, of course, but I would like to see something like the JCP in the .NET world.

As for Servlet Containers, the nearest thing would be the ASP.Net infrastructure. We don't really have something similar, but many of the techniques are still valid, just using a different approach.

Ayende Rahien


The point wasn't to learn Web dev on JVM.

The point was to learn the JVM env.

Ayende Rahien


It would be pretty hard to teach me about Hibernate, you realize that, don't you?

And I am pretty sure that I would waste my time learning Spring in a course vs. on my own.

The point wasn't to learn J2EE, the point was to learn the environment, I did just that, and I think it was successful.



The point wasn't to learn Web dev on JVM.

The point was to learn the JVM env."

Then why not learn Cassandra DB, Hadoop, Clojure or any other really cool and useful technology that uses the JVM? Your education on the JVM is far from complete.

Jimmy Barnes

What was the course that you took? Who gave it? I'd like to look into it myself.


Ayende Rahien


Why would I want to learn about any of those in a course? Those are projects, I can get to grips with them very quickly.

I am not saying that I now know everything about JVM, but what I wanted to get out of the course was the basics, and that is what I did.

Demis Bellot

Sounds like you're having a pretty common experience for devs that have had to use Java from C#/.NET

The JVM ecosystem is strong with a thriving open-source community unfortunately the Java language has stagnated for the last few years and is now lacking a number of language features which requires more effort and less readable then the equivalent code in C#.

Type Inference, Automatic Properties, Indexers, Events, Auto Boxing, Nullables, Delegates, Lambda's and LINQ are just some of the features which make C# far more joyable to work with than Java.

Unfortunately rather than trying to improve the Java language, Sun themselves have chosen to invent another language (JavaFX) to be competitive in the RIA space. The defficiency in the Java language is also the reason there are a large number of other languages targetting the JVM. Scala, JRuby, Grails and Jython seem to be the leading alternatives for the JVM at the moment. Unfortunately Java still retains the best IDE support which will keep it at the helm for a while.

Despite the deficiency in the language they have a superior community which is the reason why most of the break-through frameworks and technologies are still invented in the Java space (i.e. log4j, JUnit/JMock, Hibernate, Spring, Lucene, etc).

Even though there are a lot of good reasons to remain in the Java ecosystem I personally find that most of the frameworks are too academic and over architected requiring too much effort, configuration and third party components in order to get anything done. You're mileage may vary but I find myself more productive with C#/VS.NET+R# which is the reason for my switch.

I've also found IKVM to be invaluable to run 3rd party java components for which there is no equivalent port in .NET yet.


... interesting read.

Sterile straight jacket of the .Net vs. mock of Java world. Come to think of it as much as people gripe about the early EJBs, at the same time there was plenty of room for other things to evolve. Struts, then Spring just to name a few and now Grails just to mention one. Call me wrong, but leaving this much room for growth and evolution was the real genius behind creating the Java echo system. I doubt that any benevolent dictator can compete that long term ( and VERY LONG term especially ).

Chris Carter

I've been playing around with Java a little bit in the past few months, and I have to say there are a few things I think they really did right:

  1. virtual by default - all of the arguments I've heard against this seem like they could be solved with a compiler directive or a class level decorator to reverse it. The lack of this in .NEt is an inconvenience that doesn't need to exist.

  2. Inner classes on interfaces and inner class private data sharing

  3. The ability to recompile a single class and hot "update" an application, or just run that class to test it by itself (without the need for other tools)

  4. Application servers - as in the container, the ability to have a whole bunch of hard service dependencies supplied by the server as opposed to ported around by your application. This lets you do things like unified logging and monitoring without a lot of fuss

  5. Deployment as a single file - I wish we had WARs and EARs in .NET. ILMerge works in some cases, but doesn't manage the flexibility you have with the formentioned packaging options.

There are probably a few that I'm missing, but I'm not fully into Java development at this point, just dabbling. I prefer .NET, but like Ayende I'm feeling the itch to learn something new and expand my horizons.

Cay Horstmann

Oh boy--you haven't been learning Java EE but something resembling J2EE circa 2001. Servlets? JSPs? Why would you want to learn that in this day and age? That's like saying you don't like .NET because those CLR bytecodes are so cumbersone to program with.

I suggest you learn Java EE as it exists today, with JSF, CDI, easy session beans (without boilerplate or XML), and JPA. You'll recognize JPA--it's just like Hibernate :-)


Something must be wrong with the date on this article!!!

hmm it does say 2010 but talks about stuff from the beginning of the century.

Struts, xml, jsp - When those tools were popular what did MS have? ASP+basic or jscript on the serverside (believe me I was there and You dont know "pain").. JSP does not equate ASPX. JSP was ASP+++++. JSF is comparable to ASPX but I would actually say ASPX+.

And why throw himself at EJB? Did he need declarative distributed transactions, or did he want to scale his business layer independantly of his client and did he ever try to do the same with MTS?

Take it from someone whos been doing Java for 11 years and C# for 3 years: They are actually very similar even if you can find one or two frameworks that differ significantly.

And his comment on singletons.. hmm thats funny. Once this guys get to build really big applications where scalability is a requirement then he will learn to appriciate the singleton. What does he think his C# garbage collector is going to do once his application is put under pressure and start spitting out millions of objects per second?? Yea its gonna break its neck.

Anyway learning JavaEE in a week - I dont recommend it. Any language I have learning in the past year have cause me at least a few months of frustration. Entertaining read though :)


"...but I would like to see something like the JCP in the .NET world."

Me too! But how to start that, who should we poke at Microsoft? Scott Gu? Somasegar? Miguel? Is it a job for Codeplex Foundation? Is Microsoft even interested?

Chris Wright


Modern generational garbage collectors are good with dealing with lots of small allocations. Regardless, I'd rather deal with memory issues than threading issues.

Sven Helmberger

First of all, you're expecting the wrong thing. There seem to be quite some differences in the general approach to things in .NET and java. Sun/JSP always try to define a general way of doing thing everyone can live with. Some results are good, some are just silly, but the nice thing is, you can absolutely ignore the parts you don't like, that don't really work for you, and in my book it's exactly what makes you a good Java developer. With Sun/JCP there's usually an open API that can and is implemented by different companies/orgs with different goals. The focus is not so much ease of development but basic enabling.

Servlets are no Singletons. You can create web applications with lots of instances of the same servlet, if you want to. Servlets are just stateless, because defining the way state is handled would have been too much of a limit.

There are hundreds of webframeworks out there (all usually compatible with every servlet container there is) that all have different approaches about how a web application should be done.

Just to pick some examples: GWT is very different from Spring Web MVC, which is different from Spring Webflow which is different from Grails.

Some frameworks pride themselves in using no or only very, very little XML, some just can live with XML because they can live with it and focus on other aspects. We're about to release our own model based web development framework in which you can create applications that are like 95% XML with some groovy scripts mixed in.

EJB is just silly to me and I always avoided it. EJB3 might be an improvement, but it's not like I've been waiting all this years for EJB to come around. Personally, I find the spring framework very useful (more XML!), but still, I will only use the parts that I find useful and ignore the parts of spring where I don't see that.


Ayende, I warned you about JEE development!!!! :-) It really is a dinosaur!!! I've heard a lot of talk about how everything will be ok if you just add one more framework but it's clear to me that the EXCESSIVE amount of frameworks that are needed to be reasonably productive in the Java ecosystem reflects a fundamental deficiency in the language. Unfortunately, Sun stopped working to improve this long before their company collapsed.

Sven Helmberger

Java isn't meant to be a kitchen sink language.. Do you take the many library bindings in C as a proof that C sucks, too?

John Sonmez

You have hit the nail on the head with this post.

I had been doing .NET development for quite a while and have been doing Java for the last almost 2 years, and I had the same experience. It is very frustrating trying to do some simple things and searching through pile and piles of dead frameworks and tooling. The language needs to move forward. I do understand that J2EE has moved forward, but there is still a large amount of confusing old EJB stuff, because it changed so much.

It is pretty funny though, all the other Java developers always say to me. I know what you are going to say... "IF ONLY I HAD FUNCTION POINTERS!"

I do like Java Enums and the ability to do anonymous overrides on classes for unit testing.

Sven Helmberger

While it certainly would be nice to have first class functions in Java, the lack of it is mostly an inconvenience because it requires you to write a strategy interface what could be a function reference otherwise.

The interface also forces you to explicitly define your function and self-documents all places of use,which can be really helpful for ongoing development.

Many things that are really nice to have while writing the code in the first place are not really helping you maintain it.

Comment preview

Comments have been closed on this topic.


  1. RavenDB 3.5 whirl wind tour: You want all the data, you can’t handle all the data - 2 days from now
  2. The design of RavenDB 4.0: Making Lucene reliable - 3 days from now
  3. RavenDB 3.5 whirl wind tour: I’ll find who is taking my I/O bandwidth and they SHALL pay - 4 days from now
  4. The design of RavenDB 4.0: Physically segregating collections - 5 days from now
  5. RavenDB 3.5 Whirlwind tour: I need to be free to explore my data - 6 days from now

And 14 more posts are pending...

There are posts all the way to May 30, 2016


  1. RavenDB 3.5 whirl wind tour (14):
    29 Apr 2016 - A large cluster goes into a bar and order N^2 drinks
  2. The design of RavenDB 4.0 (13):
    28 Apr 2016 - The implications of the blittable format
  3. Tasks for the new comer (2):
    15 Apr 2016 - Quartz.NET with RavenDB
  4. Code through the looking glass (5):
    18 Mar 2016 - And a linear search to rule them
  5. Find the bug (8):
    29 Feb 2016 - When you can't rely on your own identity
View all series



Main feed Feed Stats
Comments feed   Comments Feed Stats