Sunday, May 11, 2008

Green IT - save the characters

Around JavaOne there was a lot of buzz around Java becoming a bit bloated. Now I've argued for a long time (including in the dreadful JavaSE 6 group) that Java should have a basic core and then architects should be able to decide on the extensions they want for their project. So the issue with Java isn't the bloat, its the process by which the JCP and (from experience) the Sun JavaSE team want to add more "features" into the language.

But the thing I really don't get is the obsession with the "new" languages on using the character saving, comprehension limiting syntax of C. Back in the wild and crazy 80s the focus on language design was as much on the syntax of the language as it was on the semantics and function of the language. In the 21st century we seem to have abandoned that strategy in favour of a "lets just use similar syntax" approach.

Take Scala

/* Defines a new method 'sort' for array objects */
object implicits extends Application {
implicit def arrayWrapper[A](x: Array[A]) =
new {
def sort(p: (A, A) => Boolean) = {
util.Sorting.stableSort(x, p); x
val x = Array(2, 3, 1, 4)
println("x = "+ x.sort((x: Int, y: Int) => x < y))

(stolen from the scala site)

What is this some sort of Green IT campaign based around the idea that characters are in short supply and should be rationed? This is the homepage example of the language.

# The Greeter class

class Greeter

  def initialize(name)

    @name = name.capitalize



  def salute

    puts "Hello #{@name}!"




# Create a new object

g ="world")


# Output "Hello World!"


From the Ruby homepage.

Seriously do these really represent the sort of syntax that will help more people adopt the language and make support of the programmes developed in that language easier? My money is on no.

Here in lies the problem as pointed out by Jim Waldo (via DanC).

there is still the worry that engineers who aren’t producing code are not doing anything useful.

And this is where I think the focus on a limited syntax comes from. Its the certifiably insane idea that the time taken typing in characters is the sort of time that needs to be reduced. The reality is that it is the time taken to read someone else's code that is the primary problem especially in larger systems. The focus on limited syntax and on saving a couple of characters is nonsensical in a world where the number of developers is increasing and the complexity of systems is increasing at pace. It also isn't the sort of approach that helps in making sure that the code from the majority of developers is of a reasonable quality and can be easily maintained by other majority developers.

Scala won't be Java 3, Ruby won't be the next Java. Java might have problems but solving them by having an even more obfuscated syntax is not the way to make the languages an operational rather than a blogsphere success.

Unfortunately part of the problem is the lack of professionalism and engineering in IT which means that there is a huge body of opinion that rates the quality of a language based on how few characters it takes them to write the code, not on how many minutes or hours it takes someone else to understand them.

Technorati Tags: , ,

1 comment:

Anonymous said...

Many years ago I foolishly asked why all the basic UNIX commands were so terse "cp" rather than "copy" "mv" rather than "move".

I was shown an old teletype machine and asked to type something. It the keys were hard to push and the respose was clunky and slow -- this was the techniligy C and UNIX was developed on! No wonder they wanted to save cahracters.

I like using long names like "shovel" and "digger" but its seems to me the current obsession with tersness is sparked by the java crowds use of "earth.mover.factory("handheld").implementation[0].instance" type names.

Lets call a spade a spade.