I really did not have an holiday, but I stopped posting for a while.

But I want to talk about another “holiday”: Scala.

I have spent a couple of months with Scala: A functional-OO programming language done from the scratch with the JVM in mind, with a nice, smart community.

I actually decided to stop my efforts on Scala and decided to go back to explore the Ruby way… The reasons:

  1. No metaprogramming facilities. This comes from ML, I suppose. But Ruby has it and many “old school” elegant languages have it (Lisp, Prolog). It is possible to be elegant (in fact I would contend that in many settings it is a requirement) with metaprogramming.
  2. There seems to be some difference in the semantics between compiled and interpreted. I only compiled, but the interpreter could add new variables to its local scope (as it really needs it) but the compiler couldn’t. While one might argue that that is excessive flexibility coming from the scripting languages camp, but I actually had to, on a compiled program, to create new classes which would include traits that would be dependent of need of the user, and this cannot be done. If one has many traits, it has to compile a priori all the trait mixins desired, they cannot be defined at run-time in a compiled environment (contrast this to JRuby or even JPython). This is actually metaprogramming lacking part 2.
  3. Type inference: Scala type inference might seem clever, but, compared to CAML it is not. Sometimes the compiler is not able to infer the types and the user has to explicitly declare them. CAML was always capable (at least in my cases) of complete type inference.
  4. Information sources are scarce. The mailing list is reasonable, but sometimes questions get unanswered and there is no other source (other than inspecting the source code). This will sort out if there are more people using it – and more books like the Artima ebook.

Decent metaprogramming in a runtime setting would be my main requirement, but in the current Scala status, one can only have it though the typical Java way: execute the compiler, link a jar, not elegant…

Regarding Ruby, I would like to have some form of strong and explicit (or inferred) typing. I would imagine that the requirements of metaprogramming flexibility and typing are contradictory, but, at least, some kind of optional (but standard) annotation for input/return parameters would allow avoiding some debugging nightmares of not having the compiling helping with types and would also allow for smart code editors to do all that fancy completion that is possible with explicit typing.

[This was initially posted - with modifications and additions - on Artima as a comment]

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • connotea
  • DZone
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati

5 Comments to "A holiday, Ruby and Scala"

  • Erik Engbrecht said:

    Why have you chosen Ruby over Python or Lisp?

    In Common Lisp you can add type information and the compiler will perform both safety checks and optimizations using them.

    I don’t think metaprogramming conflicts with static typing. C++ is statically typed, and has fairly powerful compile-time metaprogramming capabilities (although they are almost impossible to comprehend).

  • Raphaël Valyi said:

    Hi,

    well, I should say I woudn’t go for a pure dynamic language either. Type sefety is just too good sometimes.

    Actually I found JRuby was a good mix. Yes Ruby doesn’t have types, but then you can externalize code parts you find risky without types to typed Java code. Granted Java isn’t very expressive, neither very good at meta-programming. But I find that associated to JRuby it’s just good enough. Other are even talking about using JRuby+Scala combine sharing the same bytecode. Well if Java really doesn’t fit, may be.

    Also, a JRuby to Java language (not just bytecode) compiler is being actively developed. That means that you’ll soon be able to meta program in JRuby and get complex generated object injected into your inexpressive but type safe Java language. I personally think that’s better that anything else available.

    Regards,

    Raphaël Valyi.

  • tiago said:

    Erik: I need a language that works under JVM. You might say that Python is an, option… I use Python a lot: I am the author of the Biopython Population Genetics module, and my most recent work (I am a PhD student) is Python on Java. But Python on Java still lags a bit. I am actually a Prolog/Caml (probably LISP) fan, but there are no options, JVMwise, other than Scala. Don’t get me started on C++ ;)

    Raphaël: I think I agree 100% with your points…

  • tiago said:

    Just a final comment: Being a DSL fanboy, makes Python a bit out too… Actually that is probably the biggest reason

  • Bioinformatics Zen » February 2008 edition of Bio::Blogs said:

    [...] So that’s the open science part done, but there were plenty of other things going on in the bioinformatics blog community. Neil Saunders mentioned the Gene Wiki project, the aim to give every human gene a page on Wikipedia, some kind of online encyclopedia. He also gave an interesting perspective on the history of nodalpoint.org, the original bioinformatics blog. Researcherid.com, a site to give every researcher a unique id, received attention from Pierre, Neil, and Deepak. A recent paper on the uncertainty in aligning sequences took the interest of Blind.Scientist, Thirst for Science, and Computational Biology News. SNPs are hot at Open Helix and the Spittoon. Gopubmed.org is even hotter at Medical 2.0, Konrad’s Konsiderations, Peanut Butter, What You’re Doing, and BBGM. Pawel Szczesny became a Freelance Scientist, and posted a novel method for visualising repeats in sequences. Stew showed how to increase MySQL speed, and Biocurious had a biohumorous article about the anatomy of a seminar. Last, but not least Perfect Storm compared Ruby with the new programming language Scala. [...]