28
Jan 08

Introduction to Algorithms

Maybe this is old news to some, but I recently discovered that there’s a complete recording (audio at iTunes, audio and video on the web) of an MIT lecture by Prof. Charles E. Leiserson using “The Big Book” Introduction to Algorithms (which he co-wrote) as textbook. I just listened to the first of 25 lectures and liked it as a refresher course on the stuff I learned at university years ago. Lecture notes are available online as well.


25
Jan 08

ActiveRecord and Hibernate – Friends or Foes?

Currently, I am in the nice situation to decide for myself with which framework I will build a demonstration portal. So, as I want to profit from the fast-paced development processes (at least the Ruby aficionados say so) and the lightweightiness of Rails, I decided to go the Rail(s)Way.

Problem is, that I have to use a legacy database in PostgreSQL where I am not allowed to tinker with the structure, but I am forced to insert data into the tables. The database was created using Hibernate, which means an overall database sequence is used to generate the unique IDs. Unfortunately my new pal ActiveRecord does not know anything about global Postgres sequences, so I had to figure out a way to use the hibernate sequence in a hack to get my unique IDs.

What I did was to use the hook before_validation_on_create in the ActiveRecord table model to create an ID. This looks like this:

[ruby]
class Term < ActiveRecord::Base
before_validation_on_create :generate_id

private
# use the hibernate sequence to generate the next id
def generate_id
self.id = Term.connection,execute(“select nextval(‘hibernate_sequence’)”).result[0][0]
end
end
[/ruby]


11
Jan 08

Developer Coffee Mug

I need a coffee mug with all the nifty regular expression constructs on it. Especially the java character classes would be nice to have.


02
Nov 07

My Favourite Programming Font

When it comes to editing source code, Bitstream Vera Sans Mono is the one true ghod. Consolas is too fat, Courier has disturbingly many serifs. Monaco is for brainwashed Apple disciples who think using a Comic-Sans-like monospaced font is sort of hip.

More detailed reviews of programming fonts over at Coding Horror.


24
Oct 07

Scripting Happiness With Ruby’s ActiveRecord

I am currently enjoying the discovery of Ruby as a language for blazingly fast scripting database tasks. Like e.g. converting database records on the fly. The ActiveRecord module is a great help in that.


13
Sep 07

Pandora’s Box

Even a simple HTML parser library today comes with hundreds of dependent archives, adding up to a nice 4 MB download. Which should be no problem, but at home I am blessed with an ISDN connection. Is there anything as a library package management system like in Python, Perl or Ruby for Java? If anyone has seen this, let me know. If there is none, this would be the time to stand up and implement!


30
Jul 07

Eclipse And The Dreaded PermGen Space

Just a quick note for Eclipse developers: The dreaded PermGen space error might be avoided by starting the IDE with the option -vmargs -XX:PermSize=64M -XX:MaxPermSize=128M – under Linux. For Windows, the eclipse.ini settings apply. See the Eclipse Wiki for more information.


07
Jul 07

Quite Groovy

In the recent weeks, both of my co-bloggers told me independently of each other about Groovy, the new hipster language which brings the scripting goodness of dynamic languages like Ruby and Smalltalk to the JVM Sweet JVM, so I finally couldn’t resist but take a look at it. To be honest, I didn’t like its Java-like syntax from the beginning, with all the parentheses, lowerCamelCaseIdentifiers and such, but that was just because I prefer Ruby’s very lean syntax. Its concepts are very close to Ruby (modification of objects and classes at runtime, blocks/closures, etc.) and of course it integrates well with the Java platform and its rich libraries, since this is the purpose for which it was created, to add a scripting facility to the Java platform. Groovy scripts are compiled into bytecode before execution and thus run on a normal JVM.

A crucial part for dynamic languages today (at least in my eyes) is the creation of domain-specific language, which Groovy also supports. Gant, for example, is a Groovy DSL for Ant scripts. Another example (take from the Tutorial Domain-Specific Languages in Groovy, PDF) I find very practical is a DSL for creating query criteria for Hibernate in the Grails framework (formerly known as Groovy on Rails, so its purpose should be clear):

def c = Account.createCriteria()
def results = c {
  like("holderFirstName", "Fred%")
  and {
    between("balance", 500, 1000)
    eq("branch", "London")
  }
  maxResults(10)
  order("holderLastName", "desc")
}

A good thing, but looks too java-y for my taste, I miss the feeling I get when using a Ruby DSL, such as SQL-DSL, for example:

statement = Select[:column1, 'book', 10].from[:table1, :table2].where do
  equal :column1, 99
  not_equal :column1, 100
  less_than :column2, 'foo'
  less_than_or_equal :column3, :column4
  greater_than :column1, 0
  greater_than_or_equal :column2, 'bar'
  like :column1, 'any'
  is_not_null :column1
  is_in :column1, [1,2]
  is_not_in :column2, [3, 4]
  exists 0
  not_exists 0
end

But maybe that’s just personal preference.

From a few first glance I get the impression, that Groovy is quite successful as a scripting sidekick to Java and I’m curious to learn more about it.


27
Jun 07

Survey on Web Development Platforms

The software engineering folks at our institute, who hosted the Plat_Forms contest, are conducting a survey on platforms for web development. So if you are familiar with developing web applications in at least two programming languages and would like to contribute to research in this area please take the survey, it will take about 10-15 minutes.


20
Jun 07

Comparing Web Development Platforms

I would like to point you to a study a professor of my university (i.e. my workplace) did with his team. One goal, nine teams, thirty hours, three platforms – J2EE, Perl and PHP. Why they did not evaluate Ruby or Python is far out of my knowledge (and why anyone would do actually web devopment in Perl), but the setting is interesting enough. A rather lengthy report can be found here.

Update: I did not read the document thoroughly enough. The answers to my questions:

“We had some contact with potential teams from the Python arena, but there were not sufficiently many who were qualified enough. In the end, only one formal request for participation was submitted, so we did not admit Python into the contest.”
“It was impossible to find Ruby-on-Rails teams (“we are too busyâ€?). “


Better Tag Cloud