Closures in C# 2.0 (Did you hear that Sun?) Finding too many bugs in a close area
Sep 20

RE: It’s not about one-liners

Groovy, JavaScript, Perl, Ruby, Tech Add comments

I agree with Cedric.

The “best” programming language, doesn’t mean the one that creates the lowest wc -l.

I actually always found myself writing quite “verbose” Perl code, for example.

However, I do feel that languages such as Ruby, Groovy, and yes… even Perl allow me to get closer to the zen of “expressing everything I want, and need to get across… but not more”. Every operator/method tells me a lot.

For example. Compare the code for taking out some text from a string:

Groovy:

name = “Dion ‘Sick Boy’ Almaer”
name -= “‘Sick Boy’”

and in Java? ergh.

3 Responses to “RE: It’s not about one-liners”

  1. Morten Wilken Says:

    String name=”Dion ‘Sick Boy’ Almaer”;
    name=name.replaceAll(”Sick Boy”,”");

    ?

  2. Glen Stampoultzis Says:

    Dion, not a very good example in this case but overall most of these ’scripting’ languages are a lot less verbose.

    Marc, the main point isn’t that the IDE can let you write lots of code quickly it’s how quickly you can interpret it later when reading it back. Less code does not always mean easier to read (ie Perl) but it can. If Java would let me write something like:

    property read write int totalCost;

    indead of

    private int totalCost;

    public int getTotalCost()
    {
    return totalCost;
    }

    public void setTotalCost(int value)
    {
    this.setTotalCost = value;
    }

    it would be reduce the effort in understanding a new class. Obviously one bit of code on it’s own doesn’t create a big problem but when you multiply this by 10 or more properties it starts to make a bigger difference and really this is just one potential way you make things easier.

  3. Cedric Says:

    Totally agree, Glen. Actually, I was thinking of showing an example of properties in Ruby/Groovy to make my point initially. I write so many getters/setters/fields every day in Java that it should be part of the language.

    These are one-liners in Groovy, Ruby and C# (and I think I prefer the C# version of all three).


    Cedric

Leave a Reply

Spam is a pain, I am sorry to have to do this to you, but can you answer the question below?

Q: Type in the word 'cricket'

Loading...