Archive for May, 2009

Forgiving those Scandinavians

After learning 15 or so programming languages, in different levels of proficiency, I don’t tend to get excited about a new programming language. Moshe occasionally sends me links to the project websites of new languages. I usually reply that “If you know you’re OOP, you don’t need 5 extra levels of fluff just to get things done”. One of his links, however, hit the bullseye: Erlang.

Erlang stands out in the landscape of new programming languages: It’s a pure functional language. Yes, you’ve read it right: Pure. No pointers, no shared memory, no side-effects. If you want something stateful in Erlang, you have to use special libraries.

Erlang, however, is not an academic language. That radical design derives from very practical reasons. Erlang was designed for a single purpose: To support concurrent, distributed, fault-tolerant systems. Anything else in Erlang derives from this goal. Since that many bugs in distributed systems are caused by shared resources and other mainstream-languages imperative features, the designers of Erlang simply threw them out. You can’t code a casting error in ML, and you can’t code a race condition in Erlang.

Continue Reading »

3 Comments »

Guy Wiener on May 29th 2009 in Programming

SMTP through SSH Tunnelling in Linux

I don’t know how many of you have encountered this annoyance: You’re using an SMTP server to send your e-mail, but the server is accessible only from within its local network, so you can’t use it if you wander around with your laptop. It was a real problem for me, since I use the CS dept. SMTP sever, which is accessible only from the campus network. When I go home and take my laptop, I can’t use this server to send mail. My previous solution was to send mail through the ISP’s SMTP server, but it requires selecting the outgoing server according my location - and that’s annoying.

It’s probably not a very common problem any more, when more and more people use gmail. I personally don’t like using webmail account - I don’t find them convenient.

But this is not a ranting post: Here’s how to do this.

Continue Reading »

1 Comment »

Guy Wiener on May 22nd 2009 in Linux

SOAB IDEA

I was preparing a sketch-of a solution for the assignment I’m going to give to the students in OOP. It’s a Java program, so I used IntelliJ IDEA. The following piece of code had a warning sign on it:

System.out.printf("0, %s, %s, %s, %d\n",
  reg.getUsername(), reg.getFirstName(), reg.getSurname(), reg.getSalary());

The warning was: “format string does not match the types of its arguments.”

The reason: “getSalary()” returns float, not an integer, so the last arg should be “%f” and not “%d”.

Son Of A Bitch! That cocky IDE watches over my format strings!

The next logical step, I suppose, is to do SQL syntax check to query strings, and then warn against SQL injection attacks (a.k.a “Little Bobby Tables“), and then write code instead of us, retarded humans.

The question is: If an IDE can do that - Why it cannot be a language feature? Why doesn’t the compiler steps in?

9 Comments »

Guy Wiener on May 12th 2009 in Programming