Archive for the ‘languages’ Category

h1

What’s wrong with *J*Groovy?

February 23, 2008

Patch

Every new year comes up with its JRuby vs (J)Groovy battle. Obviously (J)Groovy users/community are good at promotion, you’ll hardly ever see posts about JRuby without (J)Groovy marketing propaganda posted in comments.

I am definitely in favor of JRuby but I can understand some of the (J)Groovy arguments. I have nothing against JGroovy, it surely integrates pretty well with Java World and I think the mix of Java with Groovy will be easily adopted by the fearful Managers (fearing Ruby).

So what’s wrong with *J*Groovy ?…

Groovy!

JRuby and Jython were developped on top of 2 popular languages (Ruby and Python) which have been existing for more than 15 years, with their own community. Today Ruby and Python are heavily used running their own vms on nearly all os possible. Ruby has no less than 4 vm implementations. JGroovy is based on Groovy language which is 5 years old and only cloned what it found cool from its neighboors to patch Java dinosaur. Would you invest in such language? At least Sun, Microsoft, IBM, Thoughtworks, Oracle made their choice…

Fact is Groovy language has no mean of existence on its own without Java.

h1

When visionaries are too much in advance.

May 15, 2007

There’s a company out there that always surprised me for always being in advance next to its competitors. This company is JetBrains (and no I do not work for JetBrains nor do I have stock options in it). But sometimes seeing in the future doesn’t always pay (in term of $!). Indeed maybe you remember back in 2004 Sergey Dmitriev, the cofounder and CEO of JetBrains Inc., published a paper about Language Oriented Programming: The Next Programming Paradigm.

Rather than solving problems in general-purpose programming languages, the programmer creates one or more domain-specific programming languages for the problem first, and solves the problem in those languages.

I remember reading that paper when it came out and finding it really promising and avantgardist, I thought it would be the future. Soon after I gave a try to MPS EAP version. Martin Fowler found it promising as well in 2005:

Although I’m not enough of a prognosticator to say whether they will succeed in their ambition, I do think that these tools are some of the most interesting things on the horizon of software development.

The old debates were already starting… Unfortunately, years passed and MPS became a commercial failure, and has been like discontinued since then. Nowadays everybody and his dog talk about DSL, maybe that’s the reason why it appears again on JetBrains website. Sergey had only 2 years in advance with his development software solution. People always complain about late delivery of their software, JetBrains is the only company delivering your software and features before you ever needed it!

h1

How to detect which language a text is written in? Or when science meets human!

May 13, 2007

As I mentioned earlier in my spam attack analysis, I wanted to know which language spams I receive are written in. My first bruteforce-like idea was to take each word one by one, and search in english/french/german/… dictionaries whether the words were in. But with this approach I would miss all the conjugated verbs (until I had a really nice dictionary like the one I have now in firefox plugin). Then I remember that languages could differ in the distribution of their alphabetical letters, but well I had no statistics about that…
That was it for my own brainstorming, I decided to have a look at what google thinks about this problem. I firstly landed on some online language detector… The easy solution would have been to abuse this service which must have some cool algorithms, but well I needed to know what kind of algorithms it could be, and I didn’t want to rely on any thirdparty web service. Finally I read about Evaluation of Language Identification Methods, of which the abstract seemed perfect:

Language identification plays a major role in several Natural Language Processing applications. It is mostly used as an important preprocessing step. Various approaches have been made to master the task. Recognition rates have tremendously increased. Today identification rates of up to 99 % can be reached even for small input. The following paper will give an overview about the approaches, explain how they work, and comment on their accuracy. In the remainder of the paper, three freely available language identification programs are tested and evaluated.

I found the N-gram approach on page 8 (chapter 4) rather interesting. The principle is to cut into defined pieces m long texts written in their respective language (english, french…), that we will call training texts, and count how much time each piece appeared; Do the same on the text you want to identify, and check the training text matching your text the best; This training text is most likely written in the same language as your text.
The pieces are the N-grams, ie for the word GARDEN the bi-grams (N=2) are: G, GA, AR, RD, DE, EN, N.
Now there are various way of finding the best matching text playing with the N-grams, distances, score…

N-gram comparison
I found an implementation from 1996 in C, here with sources. So I followed same algorithm and implemented it in Ruby. Those C sources reminded me of my C days where you had to implement your lists, hashes. Those sources are optimized for memory usage (10 years ago…)… At the end the Ruby code is a hundred line while the C was four times more, and the Ruby code is easier to read. Don’t take that as a demonstration, it is not!! I admit the C binary is maybe a bit faster (but not that much ;)). I’ll try to commit it on rubyforge when I have some time.

The results are excellent as shown in the paper:

N-gram results

Anyway actually in this story the most interesting was not the implementation but the method: It is funny that you can identify languages (so human population as well) by without requiring linguistic knowledge: ignoring grammar, senses of words (dictionary)… But by only analyzing letters and blocks of letters from Shakespeare or Baudelaire. N-grams can also be used in other areas, for example in music to predict which note is likely to follow.

h1

Why Ruby Matters ?

March 22, 2007

Last week Alexis was wondering about Haskell becoming the future of Rubyists. Reginald Braithwaite, one of the ex-JProbe suite leader, re-read Why Functional Programming matters ? from John Hugues. Although this paper is 23 years old, it is still up-to-date, and the functional paradigms it describes are still applicable. Reginald found out that there were insights that apply to programming language in general :

In a very real sense, the design of a programming language is a strong expression of the opinions of the designer about good programs. When I first read WhyFP, I thought the author was expressing an opinion about the design of good programming languages. Whereas on the second reading, I realized he was expressing an opinion about the design of good programs.

Then Reginald defines what makes a language better or more powerful.

Any feature (or removal of an [harmful] feature) which makes the programs written in the language better makes the language better.

Making an analogy with Mathematics, Reginald compares factoring with the the act of dividing a program into smaller part. The process of breaking a program into distinct features overlapping as little as possible in functionalities is called Separate of Concern (SoC). Programs that separate their concern are well factored. From this fact, Reginald defines the power of programming language :

One thing that makes a programming language “more powerful” in my opinion is the provision of more ways to factor programs. Or if you prefer, more axes of composition. The more different ways you can compose programs out of subprograms, the more powerful a language is.

Structured programming is a way to promote this.

Reginald illustrates his talk with Ruby examples where you can clearly distinguish the separation of concern between the how and the what.

In the end even if Ruby cannot be called a pure functional language, Reginald showed us notably Why… Ruby Matters.

Follow

Get every new post delivered to your Inbox.