I know this might as so often turn into a "language X is better" or "I've been using Delphi before you were even born I like it as it is" argument but I will risk it anyway (but since I got the mighty power of comment deletion for this post I will use it to remove all the unconstructive flaming - deal with it ;p).

I know this might as so often turn into a "language X is better" or "I've been using Delphi before you were even born I like it as it is" argument but I will risk it anyway (but since I got the mighty power of comment deletion for this post I will use it to remove all the unconstructive flaming - deal with it ;p).

Let's talk about something that is called "ceremony vs essence" (see http://bryanpendleton.blogspot.de/2010/02/ceremony-vs-essence.html).

Don't get me wrong: I like the Delphi language (why else would I waste a lot of my precious time writing open source in it...) but I feel it's way too much ceremony.

When I have to exactly explain how something should be done instead of just writing what I want to achieve when I don't need to and typing long expressions and boilerplate code I feel the language forces way too much ceremony. And no, it's not just about the typing but also about reading more code than would be necessary.
And no: cryptic short syntax with x, y, z and some fancy operators is not essence. Code that is not littered with stuff the compiler can figure out on its own is.
If you have some time, watch this video which shows some point of view I share (and ignore the fact that scala is for the JVM ^^): https://www.youtube.com/watch?v=grvvKURwGNg (imo it's quite entertaining and interesting to follow him)

After some of his comments how Java is way too much ceremony I was thinking: "dude you haven't seen the Delphi code that would be required to do the same"

Comments

  1. /offtopic/ whenever possible, I like to play some chess, here's an entire web chess game that works fantastically well and it's written in scala
    https://github.com/ornicar/lila

    ReplyDelete
  2. More often than not, I find Java way more verbose than Delphi. 

    I would kill for having interface delegation Delphi style in Java :)

    ReplyDelete
  3. Dalija Prasnikar Then take a look at traits in Scala ;)

    ReplyDelete
  4. Some time ago I tried and was impressed by coding in Wolfram Mathematica. No ceremonies, 10 Mathematica lines are worth  200 lines of imperative language like Delphi.

    ReplyDelete
  5. Yep, because of this, there are some programs you CAN'T write in Delphi... :)

    ReplyDelete
  6. I'm absolutely with you. I'm a Delphi developer and I'm happy with it. But I'm also a C# developer and everytime I switch back to Delphi I think to myself "Why do I need to read and write so much code?" I spend much time in scrolling through boilerplate code and producing even more boilerplate code.

    Let's take a simple example: I want to extend an existing Interface called `IPosting`  with a readable and writeable string property called `Title`.
    This explains the essence of what I want to do. It could be a one-liner in the interface declaration and another one-liner in the `TPosting` class.

    But how many lines do I need to write in Delphi?

    Since I want to add the property to an interface I need to declare a getter and setter method for it. So I need at least +3 lines of code for this. When I go now to the `TPostingClass` I need to add the field `FTitle` (+1 Line), add the getter and setter methods to the type declaration (+2 Lines) and implement them in order to setup the mapping between the interface's property `Title` and the class' field `FTitle`. This is +4 lines per method. So I result in 14 more lines in total. These 14 lines are spread over two different files in 3 different sections (interface parts of both units and the implementation part of the class).

    Is it easy to read? Is it easy to write? Is it easy to maintain in the future? How easy is it to get the essence of a piece of Delphi code that has been written by someone else?

    I think there are some possible improvements for Delphi in the future. But maybe there should be someone in power saying "OK, let's simplify the language - Even though the next compiler can't work with 20 year old source code anymore".

    ReplyDelete
  7. I have seen, like many others of us, more than one language.
    And from the first second I switched from C++ and C# to Delphi in production, I disliked many aspects of that language.

    But for what I like Delphi is its speaking, fluent syntax.

    A natural language is, if spoken right and understandable for the intended audience, a mix from essence and ceremony.
    If it is done wrong, one will distract its listeners.

    Same goes IMHO for programming languages.
    Regardless which one one uses.

    An example from my POV, I personally like speaking and writing English more than German, regardless of the fact that the latter is my mother tongue.
    The former has more essence in terms of less chars/words/sentences to communicate.
    But my ceremony in that case is, I have to think more about what and how I write it.
    The pro is, more people can understand me, if I have done every thing right.
    If I speak German, I can express me better with less thinking (essence/ceremony) but I will force the non native audience to take over a part of the ceremony of translation. This can be frustrating and distracting.

    My point is, there is no "ceremony vs essence".
    In and with every language - scientific or natural - the "versus" is more or less an "and".

    ReplyDelete
  8. Udo Sommer You cannot compare a human language with a programming language. A programming language is about telling the computer what you want, nothing more. There is no need to express feelings or wrap your expressions into appealing forms to make them more attractive or be careful about political correctness. So it's all about essence in a programming language.

    ReplyDelete
  9. Stefan Glienke​
    This is true if you work for your own (sometimes not even then).
    If you work in a team you have to take care of speaking and efficient code, or you will document yourself to death for making clear what your intention was to write that piece of code.

    The ceremony is the how (to say) before the essence.

    So, IMHO, you can compare it.

    ReplyDelete
  10. Udo Sommer You seem to have a misunderstanding of what ceremony vs essence means.

    ReplyDelete
  11. Christopher Wosinski I'm in the same situation as you and want to add another word to the discussion : consistency. I know there's a lot history, but the same holds for java and to a lesser extent C#. Danny Thorpe​'s book was all about consistency and idiom. Keeping up at that level has shown to be impossible.

    ReplyDelete
  12. Jeroen Wiert Pluimers Good point. Just look at arrays in Delphi:

    static array: x: array[0..2] of Integer = (1, 2, 3);

    dynamic array: x := TArray.Create(1, 2, 3);
    or (since XE7): x := [1, 2, 3];
    or as typed const since XE7: x: TArray = [1, 2, 3];

    open arrays (or dynamic arrays since XE7):
    Foo([1, 2, 3]);
    or was that a set of Byte? d'oh!

    So what's the rule about arrays? They have square brackets... unless it's a set. Or a const array ... but not a dynamic const array... argh! No rule without exception... or a dozen of them, right?

    ReplyDelete
  13. Cannot agree more with you. I need to force myself to use Delphi nowadays...You shouldn't need to write so much boilerplate in 2015, IMO. Usually more code = more bugs. I love expressiveness of Scala, you can even skip the dots and then code reads like a problem statement.

    ReplyDelete
  14. Stefan Glienke​​
    Enlighten me! ;)

    I think not. There are different ways to solve a problem in different coding languages and even in the same language.

    I know what is meant by ceremony here.
    Delphi has a longer ceremony by a, in my view, comparable essence.
    But I think this is a pro, because it forces a (good) coder to think at least twice about what and how to do (in Delphi).

    ReplyDelete
  15. Udo Sommer I think you missed the point on the ceremony. If I tell my girlfriend to go make me a ham sandwich, she will understand immediately what I mean. I don't have to spell out "go to the kitchen, find the bread, cut two slices, go to the fridge, find the mayo, find the lettuce, find the cheese, find the ham, go to the drawer, find a knife, spread the mayo on the bread, put a slice of cheese and a slice of ham on one of the slices of bread, put some lettuce on top, then cover with the other slice of bread".

    That would be the ceremony, which isn't useful. Instead I just say the essence, and she will understand immediately, give me a slap and tell me to go do it myself.

    In his Scala example, he simply says "numbers.map(element => element * 2);". You haven't lost any important details there, and it's very clear what you're saying: "take these numbers and for each element, double the value". How exactly "map" does the "for each element" part isn't interesting, and writing it manually would be a ceremony that just clutters up the essence: "for each element, double the value".

    Now, you can do similar things in Delphi, for example you can go:

    commaSeparatedList :=
      Functional.Reduce(
      function(const res: string; const element: string)
      begin
        result := res + IfThen(res <> '', ', ', '') + element;
      end,
      Functional.Map(QuotedStr, list)
      );

    This would take a list: TArray, apply QuotedStr on each value, and "reduce" the array of quoted strings by concatenateing all the elements with a comma between each element.

    However there's still a lot of ceremony here! For example, I need to specify , even though the compiler could deduce this from list being of type TArray. And then there's the entire reduction anonmyous function. I have to be very explicit that this is a function, again I have to specify the types of the parameters, and I have to assign the result variable. This whole thing could have been a one-liner ala the Scala example.

    ReplyDelete
  16. Udo Sommer I think I provided enough links in my original posts that can do that.
    Essence is not about keywords vs curly braces or splitting types into 2 parts (interface/implementation) or pre-defining variables on the top of the method and telling yourself "this is helping me writing good code, yes yes". It's about language design that makes these things unnecessary (just watch a few minutes from 58:00 in the video I posted)

    Asbjørn Heid Great comment and good example :)
    Let me to add that it's not even only ceremony in the source code but also in the resulting executed code in this example.

    ReplyDelete
  17. I know this might as so often turn into a "language X is better"

    Yup, you were right!!

    ReplyDelete
  18. David Heffernan Well actually I originally posted a video about Scala so its obvious we are also talking about that. But I want it to be kept constructive. Learning from other languages and looking at what they do well or not is a good thing. In fact most of the newer languages are not complete reinventions but are taking inspiration from a bunch of other languages. And personally I think (from the little I have seen so far without trying it myself due to lack of time) Scala does a good job on reducing ceremony while staying readable. If you look at F# for example I find that syntax horrible.

    ReplyDelete
  19. I'm a massive proponent of using lots of languages. This week I've been porting a bunch of code from Delphi to Python. Very interesting trying to find the right idiom.

    ReplyDelete
  20. Boilerplate code is not an issue -- I can either copy and paste it in, or let the IDE write much of it. Templates can solve a lot if I take the time to train myself to use them which I never do! Anyway what ceremony in Delphi do you find to be the most egregious?

    ReplyDelete
  21. Agree that interfaces in Delphi is generally too much work. Especially since there is no enforcement of the property get/set vs. the methods once you make a descendant interface. I do find it curious that I can't just declare a property for an interface but that I have to declare the get/set methods with it. That isn't just a ceremony, that's a sacrifice ritual.

    ReplyDelete
  22. Brandon Staggs Yes, boilerplate code IS an issue. When you need tools to generate such code then something is wrong - and we are talking about syntax elements here that you have to write to help the compiler because it cannot do it's job properly (and because you had to 30 years ago because the technology and the processing power was not that advanced).
    It's like in Asbjorns example telling some adult and sane person how to cut a bread in slices or how to get the cheese and ham out of the fridge - you just don't. Venkat Subramaniam calls this "IDE vomit".

    Number one ceremony for me are anonymous methods because their sheer verboseness is making people cringe whenever they see code that makes heavy usage of them. A simple check if a number is even or not adds like several hundred percent of overhead to such code.

    ReplyDelete
  23. I don't mind the ceremony, as long as it is easy to understand and maintain, but yeah - some times it gets in the way.

    ReplyDelete
  24. Lars Fosdal It's always getting in the way :D
    Don't let me read things that aren't necessary or even worse don't let me write them.

    I wish we would closer to the last programming language
    https://patricecarbo.wordpress.com/2011/09/29/uncle-bob-robert-c-martin-the-last-programming-language/

    Wouldn't it be nice to have one development environment - it should not even be one language - that does it all. And that you could combine all those languages so you could pick the best tool for the job.

    ReplyDelete
  25. Stefan Glienke I completely agree with your opinion about verbosity in anonymous methods.  I would very much like "true" lambdas in Delphi -- there is no reason I should have to write a procedure begin-end block in a variable assignment.

    ReplyDelete
  26. By coincidence, I've recently viewed mostly the same stuff (I suspect) by the same guy, but different venue/setting/video here: https://goo.gl/chdMlv

    Posting it as it's well worth watching (well, I don't know, maybe not if the link posted by Stefan covers the exact same stuff and you've watched that then maybe not.)   

    So yeah, been thinking similar thoughts recently. Also agree David, as a professional programmer you really should use lots of languages and lots of paradigms.  It will make you a better programmer.  FWIW, probably my other "go to" language today is Python, you would therefore be unsurprised that I would say it's well worth learning, and other interesting languages I've recently looked at (aside from Scala) includes Rust (which puts some novel ideas on the table to my mind) and also Haskell...  I also seem to be using JS more and more, though I still want to have fits over some of its automatic type conversions (Wat!!?!?!? https://goo.gl/TV8eiv )

    Anyway...

    ReplyDelete

Post a Comment