raganwald
(This is a snapshot of my old weblog. New posts and selected republished essays can be found at raganwald.com.)

Friday, February 09, 2007
  Program in Java? You must be joking!



The Y combinator design pattern in Java is easily understood and can be used and maintained by unskilled, entry-level programmers.

Cuius rei demonstrationem mirabilem sane detexi. Hanc marginis exiguitas non caperet.

You know, this kind of joke seems to rile Java apologists to no end. They come out of the woodwork with their web browsers set to flame. Absolutely no criticism of the language that powers everything from the web to space exploration (although there is never any talk of toasters) is allowed.

And do not criticize the culture in any way whatsoever. Although it’s perfectly ok to boast that Java is designed to appeal to the widest possible diversity of skill levels, you may not suggest that Java programmers are stupid. Or else.


silly daddy!, originally uploaded by thomas.braithwaite.


I am trying not to tell anyone what to do, but I have an observation. Have you ever heard a politically incorrect but extremely funny joke about a member of a particular culture? You know you have. And furthermore, the joke was probably told by a member of the group victimized in the joke.

The unwritten rule is, if you’re a member, jokes are fair game. I was once with some, ahh, members of a religion that directly predated and evolved into Christianity. They were telling some jokes about their culture and religion. I had heard a few such jokes, but I wisely refrained from telling any. It’s not allowed. That’s the rule: outsiders may not joke.

So back to Java. Guess what? I’m an insider. I write Java code every working day. If you care about hollow appeals to authority, I once wrote a Scheme implementation in Java. I was also the team lead for JProbe Threadalyzer, a tool that analyses multi-threaded Java behaviour. And the development manager for JProbe Server-Side Suite (the aforementioned thread analyser, plus profiling, code coverage, and memory debugging tools). And various J2EE implementations with various degrees of Enterprisy-ness.

None of that makes me an expert. Nor does it make me right when I criticize or joke. But it does give me a certain smug right to joke. And don’t we all need a laugh from time to time, even if we’re laughing at ourselves? Perhaps especially if we're laughing at ourselves?

I think it’s a sign of good health to be able to laugh at ourselves and criticize our foibles. For all of the talk of Java as a “mature platform,” don’t you agree that “not taking criticism well” is a little, well, immature?

So since it’s Friday:


A Muslim, a Vegetarian, and a Java Programmer are traveling by foot, and they stop at a farm house to sleep for the night. The farmer is impressed at the obvious sophistication of the Java Programmer’s tales of Enterprise wonder, and he invites her into the house. The Muslim he sends to the hayloft, and the Vegetarian can sleep in the barn.

Well, the farmer is just pouring a night-cap and listening to the Java Programmer describe the time she knocked together a farm workflow application in less than a million lines of XML configuration code when there’s a knocking on the door.

He opens the door and the Vegetarian is standing there. “I’m sorry,” the Vegetarian apologizes, “But you slaughter animals in the barn, and eating meat is offensive to my beliefs. I cannot sleep in the barn.” The farmer thinks this is bunkum, but he was raised to be courteous to his guests, so he asks the Vegetarian to swap places with the Muslim.

The farmer knocks back his drink and turns down the lights. He can hear the Java Programmer setting up a sleeping bag factory to generate down-filled singleton sleeping containers in the living room. His wife is reading in bed, and he’s looking forward to catching up on the Wall Street Journal.

Well, he is just about to climb into bed when there’s a banging on the door. He opens the door, and the Muslim is standing there. “I’m sorry,” the Muslim apologizes, “But you keep pigs in the barn, and pigs are profane according to my beliefs. I cannot sleep in the barn.”

Muttering, the farmer rouses the Java Programmer off the couch and asks her to switch with the Muslim. He climbs into bed and has just started to read an interesting article on hedging commodity futures with convex derivatives when there’s a thunderous hammering at the door. His wife tells him to stay put and she goes to answer it. The farmer hears some excited talking, and a moment later his wife is at the bedroom door.

“Honey,” she says, “it’s the pigs.”

Labels: ,

 

Comments on “Program in Java? You must be joking!:
Man, you hurt me. You really hurt me.
 
The unwritten rule is, if you’re a member, jokes are fair game. I was once with some, ahh, members of a religion that directly predated and evolved into Christianity. They were telling some jokes about their culture and religion. I had heard a few such jokes, but I wisely refrained from telling any. It’s not allowed. That’s the rule: outsiders may not joke.

Ah, yes. And, if experience is any guide, it is wise not to find any of the jokes said insiders are telling too funny. You may laugh discreetly. Perhaps an ironic chuckle or a restrained smirk. Outright belly laughter, however, will be immediately met with an outraged "Hey! What the %$^& are you laughing at?"
 
you hurt me

I apologize. This was not meant to offend Muslims, Vegetarians, or Farmers.
 
Or the comment *could* have been from a pig . . .
 
I think you hit the nail on the head, Reg.

extremely funny jokes are fine.

The problem is, I don't often see that happening. Usually java is being used as a generic language to piss on. Being the most popular language around and hence also being the unfortunate first choice of idiots who clearly can't program (anyone who uses the word 'enterprise' has a statistically speaking excellent chance of falling in this group) has its disadvantages, but without occasionally stepping up to correct some obvious FUD, you get a bad situation.

It reminds me of a lesson in political history when I was a freshman in the USA (I'm a european, but lived in america for 2 years).

Without any further explanation, the teacher asked of each student: Which country has the best political system in the world.

Virtually all americans answered: America!

Though none of them could explain why; in fact, asking why engendered curious stares. Of course america has the best system; duh!

Basically, it was as an axiom to them.

Before the class could really start in earnest, first that belief that this was an axiomatic truth had to be knocked out of their heads.

I sometimes see the same thing happening in people who have drank a little too much of the Steve Yegge and Paul Graham coolaid.


Worse, perhaps, are programming language discussions where even those who should know better are so often confronted with the notion that java is inherently uninteresting that they dismiss an interesting tangent only because java (and related languages like C#) are the only ones that work that way.


So, there's that, and, of course, the usual problem that the 'default' choice also means the idiots flock to that language... and they don't usually know better. This does do bad things to the community (let's face it, java's community in general sucks), but with such general disdain there's not much chance of a better community arising.

However, in my opinion, the ones who can't take a joke are overwhelmingly NOT on the java side of the fence. LISP, PHP, Python, and more recently, Rails (let's not call them ruby programmers for obvious reasons) programmers have a significant number of arrogant idiots amongst their evangelisers.
 
The ones who can't take a joke are overwhelmingly NOT on the java side of the fence. LISP, PHP, Python, and more recently, Rails (let's not call them ruby programmers for obvious reasons) programmers have a significant number of arrogant idiots amongst their evangelisers.

What do all these things have in common? Could it be people flocking to something to be "in" with a particular crowd, and having very little experience with diverse points of view?

I think you've identified something extremely important. And just so you know, I've deliberately written a joke about Rails creator DHH on reddit.com.

Not really to offend him, but because I'm using Ruby as well as Java these days, and I ought to give it equal time.

I sincerely hope he sees it for what it is: a friendly elbow from someone who admires his work.
 
This post is horrendously inaccurate and makes a good number of unsubstantiated claims. Java is an articulate and expressive language that correctly conveys business logic encapsulated in a powerful object-oriented paradigm and, and invented the "if-then-else" idiom and...stuff...
 
Did you just vilipend me?
 
Update The reddit post with my joke was deleted. Probably due to lack of interest in the subject.

Don't jump to any conclusions about a Rails conspiracy: when I last say the post, the joke had four upmods.
 
You have seen this I presume?
http://lukewelling.com/2006/08/03/java-programmers-are-the-erotic-furries-of-programming/
 
Reinier,

Allow me to suggest a method for comparing the relative merits of national political systems. Compare the flows of people moving into and out of the country. I assume as axiomatic that countries which do not allow emigration are prisons.

I think by that standard the US does quite well.
 
I don't get it. Is the joke that the farmer can read?
 
> http://programming.reddit.com/info/13piw/comments

this article has been deleted

Perhaps the joke struck a chord? Now I *really* want to hear it!
 
http://programming.reddit.com/info/135rx/comments

its still there, there are two threads covering that. The link is the one with the joke. BTW it also includes my "solution" in jdk 1.5.

I'd love to know two things though:

1) is the code actually understandable (all joking aside, I don't really care if a mediocre programmer, java or not, can understand it)?
2) what, in general, would I want to use a y combinator for?

I've read all of the links, I understand the mechanics, but I've no idea what a y-combinator is practically used for.

fangs
 
Fangs:

About your y combinator in Java:

At first glance, it appears that you are defining "y" in terms of itself. To be a fixed-point combinator, you have to define it without recursion.

In other words, you have to create named recursion (like factorial calling factorial) without using named recursion (y calling y).

Y would U want to do that?
 
Allow me to suggest a method for comparing the relative merits of national political systems. Compare the flows of people moving into and out of the country.

I'll accept that comparison if you normalize for economic parity.

If you don't, you are conflating economic opportunity with political merit.

Some people do assume that the USA's former economic prowess is a direct result of its political system.

I'm not sure of that. History has shown us example after example of economic powers with a variety of political systems.

Likewise, there are plenty of poor countries with nearly identical democracies (right down to disenfranchising a large socio-cultural group).

This suggests to me that economics and politics are not closely correlated. That doesn't mean that there's anything wrong with American politics, of course, all I'm saying is that we shouldn't draw too many conclusions about politics from phenomena that can be explained by economics.
 
Update The reddit post with my joke was deleted.

i thought the deletion was the joke and it was very funny. (although I know reddit doesn't use Rails)
 
Update The reddit post with my joke was deleted.

i thought the deletion was the joke and it was very funny. (it would have been even funnier if Reddit used Rails)
 
Hi,

I guess it wasn't clear then and the quote is right :-).

re the code: y is the combinator not the end function, I think I chose unclear names for the variables which leads to bad reading on first looks. Using factorial then:

y calls fac calls y calls fac etc.

factorial doesn't call itself, and y doesn't call itself (y does keep a reference to factorial though).

for example lifting straight from your original post:

lambda { |f| lambda { |n| n.zero? && 1 or n * f.call(n-1) } }

in the example I posted is (extra stuff stripped):

Function f = (Function) arguments[0];
double v = ((Number) arguments[1]).doubleValue();

if (v==1.0) { return 1.0; }
return ((Number) f.apply(v - 1)).doubleValue() * v; }

ie. similar to your example (minus the check for zero).

Its still completely possible I've missed the plot on this one though (if I have I'd be extremely happy to be knudged in the right direction).

Re uses, I can see the use for detecting loops in parsers or memoizing, but for anything else I'll know what to use when the problem hits :-)

thanks for looking at the code and helping out re understanding,

cheers,
Fangs
 
Fangs:

y calls fac calls y calls fac etc.

I wonder if I didn't explain this correctly?

If y calls fac and fac calls y, it is still using named recursion, albeit in a mutually recursive way.

The goal is for y to produce a recursive version of fac without calling itself directly or indirectly.
 
No I think your explanation was fine, as was plenty of other links and docs on named vs anon recursion. If you look at the code example, the fac funtion just calls the parameter "f" just like the lamda does.

There are no names being used and no binding to names, otherwise it would not be usable for anything else, like the fib example I also posted.

I just think the explanations that I gave of

y->fac->y

are misleading, I meant it to explain that the anonymous function that y creates to call fac, calls fac passing itself. Then fac calls this y created anonymous function etc...

cheers,
Fangs
 
RedneckSmalltalker at C2Wiki is a classic of self-deprecating ethnic-programmer wit.

(Apologies if this is a double-post.)
 




<< Home
Reg Braithwaite


Recent Writing
Homoiconic Technical Writing / raganwald.posterous.com

Books
What I‘ve Learned From Failure / Kestrels, Quirky Birds, and Hopeless Egocentricity

Share
rewrite_rails / andand / unfold.rb / string_to_proc.rb / dsl_and_let.rb / comprehension.rb / lazy_lists.rb

Beauty
IS-STRICTLY-EQUIVALENT-TO-A / Spaghetti-Western Coding / Golf is a good program spoiled / Programming conventions as signals / Not all functions should be object methods

The Not So Big Software Design / Writing programs for people to read / Why Why Functional Programming Matters Matters / But Y would I want to do a thing like this?

Work
The single most important thing you must do to improve your programming career / The Naïve Approach to Hiring People / No Disrespect / Take control of your interview / Three tips for getting a job through a recruiter / My favourite interview question

Management
Exception Handling in Software Development / What if powerful languages and idioms only work for small teams? / Bricks / Which theory fits the evidence? / Still failing, still learning / What I’ve learned from failure

Notation
The unary ampersand in Ruby / (1..100).inject(&:+) / The challenge of teaching yourself a programming language / The significance of the meta-circular interpreter / Block-Structured Javascript / Haskell, Ruby and Infinity / Closures and Higher-Order Functions

Opinion
Why Apple is more expensive than Amazon / Why we are the biggest obstacles to our own growth / Is software the documentation of business process mistakes? / We have lost control of the apparatus / What I’ve Learned From Sales I, II, III

Whimsey
The Narcissism of Small Code Differences / Billy Martin’s Technique for Managing his Manager / Three stories about The Tao / Programming Language Stories / Why You Need a Degree to Work For BigCo

History
06/04 / 07/04 / 08/04 / 09/04 / 10/04 / 11/04 / 12/04 / 01/05 / 02/05 / 03/05 / 04/05 / 06/05 / 07/05 / 08/05 / 09/05 / 10/05 / 11/05 / 01/06 / 02/06 / 03/06 / 04/06 / 05/06 / 06/06 / 07/06 / 08/06 / 09/06 / 10/06 / 11/06 / 12/06 / 01/07 / 02/07 / 03/07 / 04/07 / 05/07 / 06/07 / 07/07 / 08/07 / 09/07 / 10/07 / 11/07 / 12/07 / 01/08 / 02/08 / 03/08 / 04/08 / 05/08 / 06/08 / 07/08 /