Sometimes I encounter things on the web that make me think what’s wrong with people. Some just seem to have to much time to insist on some mostly irrelevant point they dislike and use it to judge a whole technology by it.

Take this little example:

Someone, let’s call him Sebastian Sastre ;-), blogs about the top ten reasons why he chose Smalltalk to implement one of his projects and why he’s absolutely happy about his decision. Shortly after that, somebody links to the story on reddit and there people start to discuss in great lengths about why Smalltalk is completely, totally dangerous and just about to sink the world because it doesn’t implement mathematically correct operator precedence.

I agree that the fact that Smalltalk will incorrectly calculate 2+3*5 as 25 instead of 17 is irritating and strange. No doubt about that.

People I introduce to Smalltalk in my courses shake their heads about that, because they are busy soaking up all that’s new about Smalltalk and its environment and not ready to swallow that pill also.

But once they see how clear and concise the “everything is an object” princible and the message precedence rules in Smalltalk are, they simply take a note to rather add a pair of brackets too much than too little and accept it as a Smalltalk weirdness. Later I ask them to explain how #ifTrue: works, and those who get it start being fascinated by Smalltalk and objects, you can literally see it in their eyes. At the end of the course, nobody says “all good and well, but I cannot accept that Smalltalk can’t calculate”.

In the end, most Software bugs have other reasons than the fact that Smalltalk has no operator precedence, and even if so, this kind of error is so easy to find that it’s not worth talking about.

The funny thing about this whole reddit thread (or at least of most of it) is that it concentrates on some fact about Smalltalk that is such a minor drawback of conciseness and can be overcome so easily by placing brackets around mathematical expressions (which in my opinion improves readybility anyways). It’s somewhat frightening to imagine important management decisions being made on the basis of Statements like “But if it can’t even calculate a simple term, how could it possibly run our business? And don’t forget it’s not typed!” 😉

10 responses to “How to completely miss the point in discussions about a programming language (like Smalltalk)”

  1. Sebastian Avatar
    Sebastian

    Good point, Joachim!

    Maybe you should not just ask your students how True works, but also how they could implement a “Maybe” and how the corresponding coding might look like in other languages.
    Would be interesting to see what kind of discussion we might have once you post this story ;-).

    In fact, the mathematically correct operator precedence of Smalltalk helped me quite often when it came to implementations with a high abstraction, automatization, or generation of functionality.

    Too bad, that human race always tries to find something bad, instead of the positive. Judgement might sometimes be much easier if one collects all positive aspects. But this will soon end with SOPA and PIPA. Maybe we will then just have access to “negative” stuff,…. who knows…

    Mathematically correct operator precedence is not that bad, but I would really like to do it in true parallel execution 😉

    Sebastian H.

    Like

    1. Joachim Avatar

      Hi Sebastian,

      the sad thing here is that the question of operator precedence is quite an isolated problem and is a trade-off for very powerful concepts. I really prefer being able to implement and override methods like + and * on objects and am prepared to pay a price for that. The argument goes on for pages and pages and almost no comment relates to one of the ten reasons Sebastian enumerated in his posting.

      I’d be interested in how we could execute a term like (5+3-4/8)*0.5 in parallel threads. Maybe we’de be less interested in operator precedence once we get into that discussion ;-). Maybe we’ll find out that addition of two operands in two separate threads doesn’t even lead to any mathematically provable result at all. But that may, of course, be an answer to the question that DeepThought 2 (aka Earth 2) is currently working on… 😉

      Any ideas?

      Re: the ifTrue: exercise in my Smalltalk course:
      It’s always fun to see how the “Gates of Object Land” are opening to people (who’ve been using other oo languages for years) when they read and slowly understand what’s going on there. Before we do that exercise, the old “everything is an object” song has no real meaning for them. “Of course everything is an object, just like in Java and whatever else, why the heck do those damn Smalltalkers always make such a big deal of it? Just because numbers are objects? Pffh!”
      Some students start to really get excited about Smalltalk in that very moment…
      I doubt many people could handle more than that in a basics course. It’s hard enough to understand why this leads to an unusual form of if-statements for many students, even after this experience.

      Like

      1. Sebastian Avatar
        Sebastian

        Okay 😀 This was maybe a little to short, as I`m also not a “script kiddy”, I assumed a input population and some variables in a formula like “(a+3-c8)*d”.

        Where did anybody find an implementation like “(5+3-4/8)*0.5” anyhow? 😉

        Like

  2. Todd Edwin King Avatar
    Todd Edwin King

    Anyone that would be obsessed with something as trivial as operator precedence is either a script kiddy, someone taking high school “programming” classes, someone taking 100 or 200 level CS classes, or a moron.

    Like

    1. Joachim Avatar

      … or maybe just having too much time. But the whole thread is a good example of what the shiny new internet can do for us 😉

      Like

  3. Norbert Hartl Avatar

    I don’t know what smalltalk dialect you are using. But in my dialect 2+3*5 resolves to 25 not 10 🙂

    Like

    1. Joachim Avatar

      Norbert,

      you’re right. I didn’t follow the TDB “test driven blogging principle”. I posted before testing (or even worse, before thinking). This is what I get from it. 😉
      I’ll update my post in the hopes nobody continues reading up to your comment anyways… 😉

      Joachim

      Like

  4. Marten Avatar
    Marten

    Reading this interesting discussion reminds me to the endless discussions during those (good old :-)) days having Ti-calculators and HP-calculators and what calculation method is better: AOS (TI: was it that name) or RPN (HP) (reversed polish notation).

    In the end (and it shows that history is repeating): it did not matter and both calculators were able to do wonderful stuff in the hands of wonderful programmers 🙂

    Like

    1. Joachim Avatar

      Marten,

      I must admit I stopped reading some threads at the point where I had the feeling that there’s a guy or two who would never leave their standpoint that the fact that the lack of operator precedence means Smalltalk is useless. The rest of these subthreads promised to be useless to me 😉

      Like

      1. Norbert Hartl Avatar

        If your world tends to be either white (100%) or black (0%) and you keep this on the logical level by setting negation equal to inversion then it is easy. You just need to find anything that prevents something from being 100%. So it turns to a 0% thingie automatically and that could mean it’s crap! 🙂

        Like