4/29/2007

Sieve of Eratosthenes - After thoughts

The most interesting part of this exercise was that each attempt performed better and better until I the DSL version. Even the objectisizing and then groovyizing resulted in better response times. Now perhaps I doing something silly in the DSL version because the extra method dispatch for the DSL keywords shouldn't slow it down 5 times.

It is clear that the need to use a DSL for this problem is irrational.

Here are the tests for the Sieve of Eratosthenes problems and the results

.Time: 488.8ms: Algorithm: Sieve1 Primes: [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
.Time: 248.4ms: Algorithm: Sieve2 Primes: [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
.Time: 270.4ms: Algorithm: Sieve3 Primes: [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
.Time: 1145.6ms: Algorithm: Sieve5 Primes: [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]

Sieve of Eratosthenes - Try 4 - DSL

Now to re-describe the basic parts of the algorithm into domain terms. Not saying its better just cooler.

Sieve of Eratosthenes - Try 3 - Groovyize

How about those groovy categories, the really allow you to put the code in the place you want it. Note I didn't say the right place?

Sieve of Eratosthenes - Try 2 - Objectize

Add in some OO, not much, just a sprinkling.

Sieve of Eratosthenes - Try 1

The groovy quiz this week was a prime number problem and I evolved through 4 different solutions.

The first was the basic script style approach, the second used OO, the third was groovyized with categories and the last converts the whole thing into a DSL. DSLs are cool right?

I am going to let each unfold in different posts so that you can compare and contrast if you are interested.

Here is the first, the basic "Sieve of Eratosthenes"

4/12/2007

A groovy finite state machine

Well this is my first DSL. The people on the groovy users list are talking about trying to model something like this from the ruby example posted.

Sing: "Anything they can do, we can do better, or at least as well."

4/10/2007

"Language Meshing" - April 10, 2007

I have created a new term, "Language Meshing" that refers to the ability to mix difference languages within the same source file.

Not a new concept I know, but I like the term so am blogging it now. Yes I might have created something completely new and completely useless.

I was review what Charles Nutter was posting about for JRuby and found their use of the Java 6 scripting extensions.

http://headius.blogspot.com/2007/03/can-your-ruby-do-this.html

I now dub it "Language Meshing". It might catch on.

4/09/2007

WheresTheWater


WheresTheWater
Originally uploaded by esumerfd.