PDA

View Full Version : ML? You said ML?


Rasqual Twilight
2006-11-30, 16:12
While having a sneak peak at The Boss' Subversion repository (http://svn.haeleth.net), I noticed a few programs written in an ML language (http://en.wikipedia.org/wiki/ML_%28programming_language%29), not sure which.

Having had a bit of bitter taste of OCaml, I wondered how you ended up learning this programming language. Sure, it's concise and all, but barely makes more sense than hieroglyphs to me :)

zalas
2006-11-30, 23:08
I think you would really just have to rethink how you program things for ML to make sense, as it's a functional programming language as opposed to an imperative programming language. I believe Haeleth's using OCaML...

Roto
2006-12-01, 11:03
It takes some time to get used to functional programming, and you have to approach it differently than an imperative language.

One advantage to many functional languages is the ability to run the interpreter interactively, which can be really useful when you're trying to reverse engineer a file format since you can try things without having to figure everything out beforehand and compile before you can do anything useful.

Haeleth
2006-12-01, 11:26
Yup, it's OCaml. Why do I use it? Because I find it a nice compromise between fast-but-clunky languages like C++ and expressive-but-slow languages like Python and Ruby.

This (http://flint.cs.yale.edu/cs421/case-for-ml.html) explains why I chose OCaml for RLdev better than I ever could. ^^

And to answer the specific question of how I came to learn it... well, I was kind of bored one day... :P

zalas
2006-12-01, 20:42
I actually prefer Python for prototyping, as speed usually isn't an issue when you're poking around, and the resulting code is at least somewhat legible by most people who know programming languages ^_^;

But yeah, OCaml has a clear advantage in being able to be compiled and is clean about it. To speed up Python programs, you'd need either a just-in-time compiler like psyco, or you need to write your fast functions in another language and load it in as a DLL with ctypes. (Well, there's also writing a real Python module in C or something, for you masochists out there...)

Rasqual Twilight
2006-12-02, 06:33
What's been keeping me away from Python thus far is the clunky TAB enforcement actually, otherwise the immediate evaluation of statements is nice indeed. My preference in the gang of the P's language would rather be PHP, despite its shortcomings, then Perl due to its Huge collection of libraries (but that's also a hard-to-decipher language).

Otherwise Ruby seems to be a practical language, but lacks a bit of reference paper books...

PyTom
2006-12-02, 07:39
I should point out that there is quite a bit of work being done on compiling python. It's still experimental, but in a few years it will probably be something used more often. (See the PyPy project, which intends to rewrite the python runtime in python, and then convert it to native code.)

Indentation enforcement is one of those things that looks like it will be a big issue at the start, but really isn't one when a text editor supporting it is used. Also, people don't usually realize the exceptions for strings and parenthesized expressions.

Haeleth
2006-12-02, 10:18
My reason for avoiding Python is actually as much to do with the way it handles types as with speed.

This is very much a matter of personal taste, and one in which I seem to be in a minority, but I find untyped languages very hard to read - unless the programmer has been very rigorous with comments (which is unlikely if he was prototyping!), I find myself constantly having to hunt around through pages and pages of code just to try to work out what fields a given object is supposed to have, or trying to find out where a given variable was actually initialised, and so on.

Things that in OCaml, I can just ask the compiler to tell me... ;)

zalas
2006-12-02, 13:28
My reason for avoiding Python is actually as much to do with the way it handles types as with speed.

This is very much a matter of personal taste, and one in which I seem to be in a minority, but I find untyped languages very hard to read - unless the programmer has been very rigorous with comments (which is unlikely if he was prototyping!), I find myself constantly having to hunt around through pages and pages of code just to try to work out what fields a given object is supposed to have, or trying to find out where a given variable was actually initialised, and so on.

Things that in OCaml, I can just ask the compiler to tell me... ;)
I actually am very careful with comments, because if I don't comment something that's not obvious, I'll forget exactly wtf I was doing. ^^;