Sep 20
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.
September 20th, 2004 at 3:55 am
String name=”Dion ‘Sick Boy’ Almaer”;
name=name.replaceAll(”Sick Boy”,”");
?
September 20th, 2004 at 9:10 am
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.
September 20th, 2004 at 9:25 am
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