Wednesday, March 26, 2008

More Erlang

I'm finding erlang to be a fun language to learn. One of the differences between it and other functional languages is that there is no type system. Well no extensible type system. we are really down to Atoms, Numbers, bytes, Tuples and Lists. With bytes generally being used as lists of bytes.

Even Strings don't get their own type, which is a little bit of a liability but can be muddled through for, at least for latin1 characters. Some people have hailed this as an advantage saying hay look I can learn to program and don't have to learn some complex type system.

So far my toy programs havn't felt the lack of types. But even there it seems to me that this could easily be added as with a preprocessor just like records where, if we take the perl approach of saying classes are modules then you can easily rewrite Var.doSomthing(...) to module.doSomthing(Var, ...) providing you know what module should be. which we could have declared at the time the variable was assigned to by writing Var~module (I picked ~ as it dosn't have any meaning that I'm aware of as yet.

The Question is then, is such syntactic sugar worth while and does it gain anything in reasability over the syntax that it is being written into? At the moment I'm undecided. It certainly seems like it would be doable, after all Lisp Flavoured Erlang is doing somthing much more complex then this. The key question would be how hard is it to write an Erlang parser in Erlang?

No comments: