Java and Ruby: how language principles influence users’ mindsets

I’ve been doing some Java development lately and Java’s verboseness sent me looking for a way to shorten some of the monstrous generic type declarations. I know there is no typedef or similar concept in Java, but hoped that maybe some Java or Design Patterns gurus invented some clever trick or pattern to do something similar. It’s better to use a ThreeLevelHashMapOfStrings type instead of HashMap<String, HashMap<String, HashMap<String, String>>>, right?

Wrong. Google for ‘Java typedef’ and you will find out that many people encountered the same problem, but there is no approved solution for this problem. In fact, Java people tend to think that the problem is not the lack of keyword, but the people asking for it (as most of them admit that they have other languages background). Ask for ‘Java typedef’ on a Java forum and you will bashed by “true Java” advocates with ridiculous arguments.

My favorites are that “Java’s beauty was in its simplicity” (and apparently it loses some part of it with every new language feature, generics being the main offender), “if you don’t like it go back to your C++” (no comments) and that “typedef would require the other programmers to look up the definition to find out what it really is“.

The last one is repeated so often that I suppose some people really believe in it. If I understand it correctly those people also oppose defining new classes and new methods (because you would have to look them up to see what they do). This is ridiculous because, in a way, programming is all about defining new names for things (classes) and actions (methods) and then using them to define even more new names. I might be wrong but most of the modern languages (at least those I can think of right now) allow programmers to create some sort of type aliases (typedef in C/C++, type in Haskell, just assigning a constant in Ruby).

But “all others are doing this” is not the only argument for typedef in Java. The three main arguments are:

  • shortening the monstrous generic type definitions,
  • improving readability of variable declarations etc.,
  • preserving DRY and adding flexibility (typedef would allow you to change the underlying type in one place instead of every place).

This is when the fun starts because trolls join the discussion and start convincing you that the desire to shorten the code is evil (Java people are used to having 30+ character class names), that giving a name to a complicated type definition will not increase readability (because someone somewhere might come up with a bad name, apparently) and that for flexibility you should use a design pattern and define some interface or something like that. And why would you need to change a type, anyway?? Blub programmers in the wild.

I especially like the fragment when some of the typedef proposers uses Iterator<Container<Entity, Comparator<Entity>>> in his examples and a typedef opposer uses List<String> in his response. Internet trolling at its best.

This got me thinking about how the language design and principles influence the users and the communities. Java was created so “you can’t shoot yourself in the foot” and that’s the main reason why some C++ features (operator overloading, multiple inheritance, etc) were deliberately not included in Java. On the other hand, Ruby was created so programmers can enjoy programming. That’s why it has plenty of features that make programming easier and more enjoyable.

Somehow, this influences the mindsets of people using the languages. Or maybe it’s the mindset that makes person prefer Java or Ruby?

My impression from interacting with Java people (both at work and in the Internet) is that they generally don’t trust the other programmer, they tend to think that most other programmers are mediocre at best and the language should mainly be a tool that doesn’t allow those inferior beings to do much harm.

Ruby people are generally much friendlier to each other, they praise each other’s work (to the point of hype sometimes) and they treat the language as a tool to create fun things. If the tool is lacking, they look for the ways to improve it (hence DSLs, meta-programming and monkey patching). I also noticed that flames and trolling are much less frequent on Ruby forums than on Java forums.

And before you start flaming me, Java trolls, please note the use of “my impression”, “generally”, and “mostly” :)


5 responses to “Java and Ruby: how language principles influence users’ mindsets

  • andrei

    yeah u re rite javas biggest problem is its “verboseness”. i mean why NOT let anyone defime whatever they want wherever they feel like and then let everybody that comes afterward bash their heads trying to fogure it out. maybe we should get rid of that pesky String class too and have a different MyString class in every single project right. for u “go back tp cpp” would really be a compliment but im sure ure a big fan of php.

  • LucaB

    There was a debate, once upon a time: “does human beings have the famous opposable thumb because they are much more intelligent?” or on the contrary, they became intelligent, because the opposable thumb (which was meant primarily to peel bananas and so on) gave them a unexpected new world of possibilities in manipulating objects?
    Did I say “objects”?

  • PLJ

    I like it very much how you run wild with the story, and at the end point out that it’s just your opinions (btw you didn’t used mostly at all :D, and the other two just in the last paragraphs).
    No wonder that this sort of talking starts of flame wars. Saying:
    “In general fat people are incredibly stupid.” – the “In general” part doesn’t make the statement any less outrageous – I know it’s not easy to be politically correct (if you even want to be in the first place :P ). But I did got the impression that flame was not your intent :).

    On the subject itself just briefly:
    Java IS an “entry level” language – very powerful but it doesn’t have all the shiny toys :). Some of those due to it’s wide corporate use (if it’s not just Sun’s cover story :P). Anyways – it’s popularity tells me at least it DOES do something right :). That is – teach people how to program in OO language. Most of them stay there (because of fear, laziness or stupidity – I’m not sure). But GREAT lot of them doesn’t even get the OO concepts and use java as a procedural language :|. So provided people are generally dumb, and java is starter language – that it shouldn’t be surprising about the level of the discussion. HOWEVER – java ain’t all bad, and language X (whether Ruby or C++ or C#) isn’t all good (I’m sure even if I don’t know them very well. It’s simply because “There is NO right or wrong – there are just better approximations of the truth” – oh man XD. In other word – every language SUCKS (in some way) :).

    BTW what was the underlying subject ? XD – maybe I’ll just end here before I’ll go further off topic :P

  • szeryf

    @PLJ: well, this post started as an argument for including typedef-like concept in Java, but then I digressed into broader areas :)

    And I’m not trying to prove that Java is bad or anything like that. What I’m trying to focus on is how “Java people” react to proposals of introducing some of “higher level” concepts into Java, and why can this be.

    Anyways, thanks for insightful comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: