Sign in to follow this  
dawidjoubert

OCamel, Oh what?

Recommended Posts

Hey does any1 know anything about OCamel programming language.. Some idiot tells my brother it is the most elitest language around, so far the language is so super I have been able to find no 3rd party information about it. Thanks in advance

Share this post


Link to post
Share on other sites
You will probably have better results searching for "O'Caml". And while a language cannot in and of itself be elitist (Sapir-Whorf hypothesis notwithstanding) O'Caml users are definitely among the most elitist of programmers out there. They make Lisp programmers sound like Visual Basic programmers.

Share this post


Link to post
Share on other sites
That's because it's "Ocaml". It is primarily a functional language, unlike C++ or C#; but also has good support for OOP and imperative programming, unlike pure functional languages.

Share this post


Link to post
Share on other sites
Okay fair one, would you think it a smart move to learn OCaml at all considering that my C++ is fairly good.

And what is in it for me, ie what can OCaml be used for that I can't use c++?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by dawidjoubert
And what is in it for me, ie what can OCaml be used for that I can't use c++?

Nothing. But OCaml is an elegant language.
http://en.wikipedia.org/wiki/Ocaml
Home Page

C++ vs OCaml: Ray tracer comparison



Share this post


Link to post
Share on other sites
Quote:
Original post by dawidjoubert
Okay fair one, would you think it a smart move to learn OCaml at all considering that my C++ is fairly good.

And what is in it for me, ie what can OCaml be used for that I can't use c++?

It would definitely be a good idea to learn a functional language if you've only had experience with C++. OCaml has a lot more high level power that C++ and produces fast executables and elegant code. Check that ray tracer comparison: Ocaml makes some things a lot easier than C++ does.

Ocaml is part of the ML family of languages. You could also consider learning Standard ML instead (or as well).

Share this post


Link to post
Share on other sites
Quote:
Original post by dawidjoubert
Okay fair one, would you think it a smart move to learn OCaml at all considering that my C++ is fairly good.

It's always a smart move to learn another programming language. It will make you better at both OCaml and C++.

Share this post


Link to post
Share on other sites
I Saw the raytrace comparison and I see OCaml is quite impressive however my concern is that the code they made using C++ does not need to be OO, c++ supports functional coding as well.

Well then I guess OCaml learning I will be

Share this post


Link to post
Share on other sites
Quote:
Original post by dawidjoubert
I Saw the raytrace comparison and I see OCaml is quite impressive however my concern is that the code they made using C++ does not need to be OO, c++ supports functional coding as well.


C++'s support for functional programming is horrible compared to a language like OCaml.

Share this post


Link to post
Share on other sites
Quote:
Original post by dawidjoubert
c++ supports functional coding

I think you will be pleasantly surprised by OCaml. [smile]

Share this post


Link to post
Share on other sites
Quote:
Original post by dawidjoubert
I Saw the raytrace comparison and I see OCaml is quite impressive however my concern is that the code they made using C++ does not need to be OO, c++ supports functional coding as well.

Not really. In ML you can use algebraic data types to define structures like trees in single lines of code. This leads to very understandable, concise and fairly error proof code.

In C++ you can't do this. Instead you have to use structs, pointers and inheritance to hack together a solution.

Share this post


Link to post
Share on other sites
Quote:
Original post by dawidjoubert
I Saw the raytrace comparison and I see OCaml is quite impressive however my concern is that the code they made using C++ does not need to be OO, c++ supports functional coding as well.

Well then I guess OCaml learning I will be


Umm... methinks you're a wee bit confused. Functional programming isn't the same thing as procedural programming. Procedural programming is like C, where the point is that things get executed one line after the next and your program operates much like a finite state machine. Functional programming is a little more abstract than that and while my understanding of it is weak (to say the least), you can read about it at Wikipedia. OCaml does this stuff way better than C++, and so that's why you might want to learn it.

-Auron

Share this post


Link to post
Share on other sites
Quote:
Original post by Auron
Umm... methinks you're a wee bit confused. Functional programming isn't the same thing as procedural programming. Procedural programming is like C, where the point is that things get executed one line after the next and your program operates much like a finite state machine. Functional programming is a little more abstract than that and while my understanding of it is weak (to say the least), you can read about it at Wikipedia. OCaml does this stuff way better than C++, and so that's why you might want to learn it.

-Auron

I think David understands the concept of functional programming.

Share this post


Link to post
Share on other sites
Quote:
Original post by Sneftel
Quote:
Original post by Auron
Umm... methinks you're a wee bit confused. Functional programming isn't the same thing as procedural programming. Procedural programming is like C, where the point is that things get executed one line after the next and your program operates much like a finite state machine. Functional programming is a little more abstract than that and while my understanding of it is weak (to say the least), you can read about it at Wikipedia. OCaml does this stuff way better than C++, and so that's why you might want to learn it.

-Auron

I think David understands the concept of functional programming.


OK, my bad. It came off as though he didn't, but then again, that's from the perspective of someone who doesn't know much about functional programming, so I probably should've kept my mouth shut in the first place...

Sorry David if I insulted you at all...

-Auron

Share this post


Link to post
Share on other sites
I've been 'self studying' ocaml for a couple of months now as my first functional language and it is very interesting. One thing really jumped out to me with regard to ocaml, even beyond the recursion and 'functions are first class objects' bit; pattern matching. If you've ever used lex and yacc to build any type of compiler like thing then you'll recognize pattern matching; it's like ocaml has built regexp and ebnf (well, the pattern matching aspect of caml is so straight forward it makes it easy to implement regexp and ebnf in your code). This was surprising to me; since ocaml makes these things so easy I started thinking about different ways to use pattern matching. I haven't come with anything yet but it seems like a really powerful capability to have at your finger tips.

I'm interested to hear how someone with more experience would compare ocaml to lisp? Ocaml has no preprocessor, which I understand to be on of lisp strengths?

Share this post


Link to post
Share on other sites
Quote:
Original post by Auron
Quote:
Original post by Sneftel
Quote:
Original post by Auron
Umm... methinks you're a wee bit confused. Functional programming isn't the same thing as procedural programming. Procedural programming is like C, where the point is that things get executed one line after the next and your program operates much like a finite state machine. Functional programming is a little more abstract than that and while my understanding of it is weak (to say the least), you can read about it at Wikipedia. OCaml does this stuff way better than C++, and so that's why you might want to learn it.

-Auron

I think David understands the concept of functional programming.


OK, my bad. It came off as though he didn't, but then again, that's from the perspective of someone who doesn't know much about functional programming, so I probably should've kept my mouth shut in the first place...

Sorry David if I insulted you at all...

-Auron



Procedural/imperative programming is, as you said, having a machine whose state you change with every line of code. Hence, "time" is of the essence here, since a variable's value depends on the time at which you inspect it.

Functional programming is the opposite: all variables are readonly, there's no state anymore and the time dimension disappears. You could say that Haskell, being a lazy, purely functional language, takes this to the extreme, since you mostly don't have a clue of *when* expressions are evaluated, and neither do you care.

As a simple example, consider a stack. The imperative style would have you have one stack-object to which you can add and remove elements. The functional style would have you implement push and pop as operations which return new stacks each time you invoke them. Another way of saying it is that imperative data structures are ephemeral, since operations destroy the old state, while functional data structures are persistent, because there's no way you can modify them.

(Do not think of functional style as being inherently less efficient, you simply need to approach the problem differently)

Share this post


Link to post
Share on other sites
Quote:
Original post by jsgcdude
I've been 'self studying' ocaml for a couple of months now as my first functional language and it is very interesting. One thing really jumped out to me with regard to ocaml, even beyond the recursion and 'functions are first class objects' bit; pattern matching. If you've ever used lex and yacc to build any type of compiler like thing then you'll recognize pattern matching; it's like ocaml has built regexp and ebnf (well, the pattern matching aspect of caml is so straight forward it makes it easy to implement regexp and ebnf in your code). This was surprising to me; since ocaml makes these things so easy I started thinking about different ways to use pattern matching. I haven't come with anything yet but it seems like a really powerful capability to have at your finger tips.

I'm interested to hear how someone with more experience would compare ocaml to lisp? Ocaml has no preprocessor, which I understand to be on of lisp strengths?


It depends on what you mean by preprocessor. If you define at as being something that goes over your code before compilation, then you can't say that some languages have a preprocessor and others don't.

Anyway, OCaml has CamlP4 as a preprocessor, and Lisp, well, Lisp has Lisp. I would suggest you try out Lisp to be able to really understand where Lisp's power comes from.

Share this post


Link to post
Share on other sites
Quote:
Original post by jsgcdude
I'm interested to hear how someone with more experience would compare ocaml to lisp? Ocaml has no preprocessor, which I understand to be on of lisp strengths?

Lisp isn't really about functional programming, it's about a lot of things.

As for the preprocessor, Lisp/Scheme use macros which can manipulate code at compile time. It's much more advanced than C's preprocessor. OCaml has CamlP4 and an extension called MetaOCaml.

Share this post


Link to post
Share on other sites
Someone has to mention the even more leet Haskell since it has some serious imperative programming style (you can create you own flow-control-structures, it has a workable solution for the IO problem but is still pure).

Fortran on the other side doesn't even have 'while (condition)'-loops, this sucks.

Oh, and someone please get me some functional programming into C++ until 2009, thanks...

(I know the proposals but the syntax is a bit akward)

Share this post


Link to post
Share on other sites
Quote:
Original post by Rebooted
Quote:
Original post by jsgcdude
I'm interested to hear how someone with more experience would compare ocaml to lisp? Ocaml has no preprocessor, which I understand to be on of lisp strengths?

Lisp isn't really about functional programming, it's about a lot of things.

As for the preprocessor, Lisp/Scheme use macros which can manipulate code at compile time. It's much more advanced than C's preprocessor. OCaml has CamlP4 and an extension called MetaOCaml.


I'm not quite sure what your definition of compile time is for lisp, but I'd say that lisp macro's allow you to manipulate code at run time!. ie you can use macro's to dynamically generate your code the first time its executed or you could use the same macro to generate different code each time its executed depending on the parameters passed to the defmacro call.

Cheers
Chris

Share this post


Link to post
Share on other sites
Quote:
Original post by jsgcdude
I'm not quite sure what your definition of compile time is for lisp, but I'd say that lisp macro's allow you to manipulate code at run time!
Sorry, it's instinctive to say compile time when you are talking about metaprogramming. Obviously, Lisp often isn't even compiled [grin].

[rolleyes]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
We, the members of the secret programmer's society, like to tell aspiring young programmers to learn esoteric languages like O'Caml and Lisp and Haskell (if we feel really sadistic, we'll even recommend scheme), because it makes them waste time learning stuff that is useless in the industry. This means more jobs for us, the initiated!

Share this post


Link to post
Share on other sites
Quote:
Original post by TrueTom
Someone has to mention the even more leet Haskell since it has some serious imperative programming style (you can create you own flow-control-structures, it has a workable solution for the IO problem but is still pure).


Serious imperative programming style? You mean functional? Also, you can really create your own flow control structures in any OO language or language which has first class functions (basically, any language that has something which is isomorphic to a lexical closure).

Quote:

Oh, and someone please get me some functional programming into C++ until 2009, thanks...


You can already do functional programming in C++, but it isn't as easy. Look into Boost and FC++.

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
We, the members of the secret programmer's society, like to tell aspiring young programmers to learn esoteric languages like O'Caml and Lisp and Haskell (if we feel really sadistic, we'll even recommend scheme), because it makes them waste time learning stuff that is useless in the industry. This means more jobs for us, the initiated!


Why do you post anonymously?

Can't you stand up for your claims?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this