You people should learn CAML and functionnal programming. That rocks, really. CAML syntax really is beautiful and pleasant. Compiled OCaml is *just* as fast as compiled C++.
http://caml.inria.fr (yes, this is french. Frenchmen just rules. They aren't patriotic. They don't make war, they make great compilers =))

Posted on 2003-04-30 12:14:57 by roy

Frenchmen just rules. They aren't patriotic.

Coming from a frenchman, I find that rather funny.

Posted on 2003-04-30 16:16:00 by Fake51
Good on you Roy, "socket 2 em". :tongue:



PS: What is CAML ? I am from Australia where there is almost no French spoken at all so I have little chance of reading the site.
Posted on 2003-04-30 20:51:56 by hutch--
Hutch, even though the host is .fr, the site seems to be in english :)

Roy, nice to see you again :). I'll have a look-see at the language. just as fast as C++? Did they beat the intel engineers with regards to x86 code optimization?
Posted on 2003-05-01 02:45:24 by f0dder
Code looks like pascal to me.
Posted on 2003-05-01 03:38:57 by roticv
Whoa, :eek: , I just had a look at http://caml.inria.fr/FAQ/exemples-eng.html ... boy does it seem alien! Of course every language takes some time learning, but...
considering the base langauge features, none of the fancy features like OOP, pascal seemd intuitive and C was the same - I could read source code before having read any programming books on pascal or C. Asm was simple as well.

But this... is alien :). But if it gets the job done, performs, and you like it... I guess that's all well.
Posted on 2003-05-01 04:00:26 by f0dder

Hello hutch, f0dder, long time since i hadn't met you =)

Well, actually, the page is in english, and the language, tough i must admit looks a bit strange at first, really is easy and natural to code when you just take about 30mins to learn it. Try and grab some examples on the site =)

Actually, this language is meant for computer science, that is fundamental computer science (computer science seen as a branch of mathematics, that is, the most beautiful and interesting way to see computer science).

This language permit to implement natural primitives and function in a very natural way, because it is functionnal programming, so it is recursively-oriented. So you can implement and test *REALLY* quickly all the algorithms you want. That is much faster than doing all the code and tests in asm =) (though i still like asm hehehhe)

For instance, you can define integer binary trees just in a single line :

type b_tree = Void | Node of b_tree * int * b_tree;;

that means : b_tree is a type that is either Void or a 3-uplet (A,e,B) where A and B are binary trees, e is an integer.

So you can build a tree just like this :

let my_tree = Node( Node(Void, 2, Void), 1, Void)

wich represents :

/ \

We could also define general binary trees just as easily :

type 'a b_tree = Void | Node of ('a b_tree) * 'a * ('a b_tree);;

'a means a polymorphic type, that is 'a could be anything (int, string, ...) so for instance :

let my_tree = Node( Node(Void, "here", Void), "hey", Void)

Well now, look how easily you can code functions on trees :

size(a) : returns the size (that is the number of nodes) of the b_tree a :
we have :
size(Void) = 0
size(Node(a, e, b) = 1 + size(a) + size(b)

so we code it like this :

let rec size = function

| Void -> 0
| Node(a, e, b) -> 1 + size(a) + size(b);;

CAML will automatically recognize that it applies to a b_tree, and if we defined b_tree as polymorphic (the second definition) this proc will work for all binary trees (int, string, ...)

So what does this code mean :
let : okay
rec : it means this proc is recursive
| Void : if the argument is Void
-> 0 : we return 0
| Node(a, e, b) -> 1 + ...
if the argument is a Node, we can match it directly, that is associate (a,e,b) with the content of the node, and treat it like this.

The syntax is beautiful, check these examples :

So for instance, if you want to code a factorial :
traditional way (c, c++, asm, ...)
let rec fact n =

if n = 0 then 1
else n * ( fact (n-1) )

with caml style :

let rec fact = function

| 0 -> 1
| n -> n * (fact (n-1));;

and so on...

Just take 30 mins to learn it and you'll use it very efficiently and it'll help you alot, i'm sure =)
Posted on 2003-05-01 04:43:07 by roy
Humm, it probably has uses. I don't really like the syntax though... it's a subjective matter of course, but a couple of things that strike me:

why do you need "let" and "rec"? Let seems like an unnecessary fluff-word, and rec seems unnecessary?

Also, your code example

let rec fact = function
| 0 -> 1
| n -> n * (fact (n-1));;

It's easy enough to decipher this... but, where does 'n' come from? What happens if you have more than one argument to the function (and can you even do that?). I think the "->" syntax is somewhat strange, but it might be okay... the other things I'm not so happy about.

Oh well - I can see from the binary tree definition that it could be a useful language for one branch of computer science - I think I prefer my current languages for the work I currently do, though.
Posted on 2003-05-01 04:53:44 by f0dder

type 'a b_tree = ...
let my_tree = ...

seems "let" is needed to differentiate from "type"

.. ?
Posted on 2003-05-01 05:00:54 by abc123
Then why not keep only one of them? Or change the way a type declaration is done? :)
Posted on 2003-05-01 05:03:06 by f0dder
Originally posted by f0dder
It's easy enough to decipher this... but, where does 'n' come from? (and can you even do that?).

maybe he forgot the "n" in that example, i.e:

let rec fact n =
.. other stuff

What happens if you have more than one argument to the function

maybe two or more arguments could be implemented like:

let rec fact n, y, s, h, e =
.. stuff

Posted on 2003-05-01 05:04:40 by abc123

Then why not keep only one of them? Or change the way a type declaration is done? :)

maybe he wants a language that is easier to speak out loud:

"let x equal 10"

preferable to:

"X EQUALS 10!"

^ c / c++

or asm style:
"put 10 into x"
Posted on 2003-05-01 05:07:30 by abc123
lots of maybe there :)

The "let" part might be good if you want to read it up loud, perhaps also while teaching. To me, it seems a bit like a "teaching" language actually - you can probably implement + teach algorithms pretty fast with it.

Just not my kind of language, 's all.
Posted on 2003-05-01 05:15:14 by f0dder
I'd say you can't really compare it to C++. It's a functional language (based on lambda calculus), while C++ is procedural. It's a completely different programming paradigm. If you're comparing speed, usually functional languages execute slower (sometimes a lot) but it's easy to write algorithms in them.

Posted on 2003-05-05 04:14:05 by Thomas
Haskell looks to be a little simpler, but maybe it's only my sight of view.
Functional languages are very helpful, when testing some alghoritms, but I wouldn't use them to write big projects.
Posted on 2003-05-07 09:59:01 by Dryobates
funny lang
Posted on 2003-05-07 12:20:30 by wizzra
What's the lenght of a simple executable (such as the famous hello world app.)
produced by CAML?
Posted on 2003-05-08 06:09:23 by Vortex
Imo, looking at "hello world" size isn't very useful if you want to say something about the quality of a language. There's a whole lot of things to take into consideration.
Posted on 2003-05-08 06:19:25 by f0dder
Yes f0dder,but it can give an idea about bloatware.Why not?
Posted on 2003-05-08 06:27:48 by Vortex
true, as long as you don't judge the language just because of some initial "bloat". Real applications tend to use a lot of the runtime. Like, you might have an app with an initial size of 128kb and think "wtf!", but as you add more and more and more and _MORE_ functionality, the exe only grows slightly, because you just use the stuff that was initially pulled in. I've seen that tendency in some of my own apps.
Posted on 2003-05-08 06:32:22 by f0dder