<tsuyoshi>
I did a japanese-english dictionary in ocaml
<jkeith>
how does the execution speed compare to that of other languages?
<tsuyoshi>
working on a fundraising database right now
<tsuyoshi>
jkeith: it's about half the speed of c
<jkeith>
FWIW, I'm in no way bashing on ocaml, I'm just curious
<tsuyoshi>
faster than anything else afaik
<Smerdyakov>
jkeith, yes. Almost everyone who has used a language in the ML family agrees that they're the best general purpose programming languages today.
<Smerdyakov>
tsuyoshi, SML has a considerable runtime performance advantage over OCaml ATM, thanks to MLton.
<jkeith>
so it's slower than java, but faster than say perl?
<jkeith>
(assuming good program design)
<mbishop>
I doubt it's slower than java
<tsuyoshi>
slower than java? I don't think so...
<Smerdyakov>
jkeith, no, the native code OCaml compiler produces binaries considerably faster than any Java compiler I know of.
<tsuyoshi>
definitely faster than perl
<jkeith>
tsuyoshi: if it's half the speed of C, it's slower than java ;)
<mbishop>
It's faster than any "scripting" language
<tsuyoshi>
hah.. which java compiler gives that kind of speed?
<jkeith>
tsuyoshi: sun's jvm's from 1.5 and later
<tsuyoshi>
well, I am skeptical of that.. but ocaml is pretty fast
<Smerdyakov>
Still, if you care about performance, you should probably choose SML over OCaml.
<mbishop>
I've seen ocaml code that was faster than it's C++ counter part, but I hear they are about even in speed, typically
<jkeith>
Smerdyakov: I was more concerned about something as slow as say python or ruby
<Smerdyakov>
jkeith, languages don't have speeds. It happens that those languages have single popular implementations, but that's not always the case.
<mbishop>
Indeed, Smerdyakov's statement is true, as shown by Scheme, and the "Stalin" compiler
<jkeith>
hmmmm, well, it looks like it's worth learning
<jkeith>
thank you for putting up with my questions :)
<jkeith>
is caml light a scripting language, or just a subset of ocaml?
<tsuyoshi>
it's a subset
<tsuyoshi>
I think it's just missing the class system.. and maybe labels?
<Smerdyakov>
No. It's a completely impractical predecessor frozen in time and used in French university classes only. It is missing a wide variety of important aspects of a "real" language.
<jkeith>
Smerdyakov: so you would recommend I just plonk down into ocaml?
<benny99>
a function must always return the same type huh ?
<benny99>
makes sense :p
bluestorm_ has joined #ocaml
<benny99>
I really wonder if ocaml is worth learning :
<benny99>
everything works like expected now :)
<benny99>
thank you
<Sparkles>
a function must always return the same type huh ? ====> a function can be polymorphic ! ...
<Sparkles>
like :
<Sparkles>
let id x =x ;;
<Sparkles>
let id x = x ;;
<bluestorm_>
some function may even return a different type from the one you give
<Sparkles>
it returns its argument, but the type of its argument doesn't matter, it can be whatever you want
<bluestorm_>
(but they're evil)
<benny99>
hm, mine required that :<, whatever
<benny99>
Sparkles: how long did it take for you to learn OCAML ?
<Sparkles>
well, if a function returns a type that is not contained anywhere in the arguments type, then it means that the function raises an exception or never returns
<Sparkles>
I learned ocaml in a few weeks... but now i've been practising this language for more than 3 years...
<Sparkles>
actually, ocaml is very easy to learn if you want to do simple things
<benny99>
Sparkles: ah, you 'learned' it in a few weeks ?
<Sparkles>
if you want to know ocaml very well, it takes a lot of time... really a lot, because it's a very rich language
<benny99>
Sparkles: I want to do a simple lexical tree :(
<benny99>
Sparkles: whatever; hope I'll do it then try the next exercise...
<Sparkles>
in a few weeks, you can learn everything about "simple functional programming"
<benny99>
Sparkles: Do you think OCAML is the right language for AI ?
<benny99>
Sparkles: (sorry for asking it that sudden :Z)
<Sparkles>
it depends... now many AI is in java :-(
<benny99>
AI in Java o_O! ?
<Sparkles>
yes...
<Sparkles>
and python
<benny99>
Like a brain in a dish-washer :p ?
<benny99>
hm.. just thought that those "Higher order functions" are maybe extremely useful
<Sparkles>
ocaml allows you to do anything you want, sometimes it's really great because it's very simple and very expressive, but sometimes it is not at all... Like if you want to make an awesome UI, it's not easy in OCaml...
<benny99>
Puh... I guess I never did an UI
<benny99>
*a real UI
<Sparkles>
well, for example, some people programming with objects need to handle closures, and so they reproduce complex scheme of classes to simulate what ocaml can do with a few lines when you handle functors...
<benny99>
Sparkles: so it's worth learning it -- just needed some motivation
<benny99>
Sparkles: I feel like a total idiot using ocaml :|
<benny99>
Sparkles: maybe because I am :<
<Sparkles>
" OCaml is really great and OCaml is really bad ", to me, is a true
<Sparkles>
For my part, it's my favourite programming language.
<Sparkles>
Well, OCaml is not very easy to learn when you discover it...
<mrvn>
benny99: you do the first time you learn functional programming
postalchris has quit [zelazny.freenode.net irc.freenode.net]
G has quit [zelazny.freenode.net irc.freenode.net]
twobitsprite has quit [zelazny.freenode.net irc.freenode.net]
vorago has quit [zelazny.freenode.net irc.freenode.net]
zmdkrbou has quit [zelazny.freenode.net irc.freenode.net]
bebui has quit [zelazny.freenode.net irc.freenode.net]
levi_home has quit [zelazny.freenode.net irc.freenode.net]
zmdkrbou has joined #ocaml
bebui_ has joined #ocaml
twobitsprite has joined #ocaml
vorago has joined #ocaml
G has joined #ocaml
postalchris has joined #ocaml
<Sparkles>
still, it depends on your motivation....
levi_home has joined #ocaml
<mrvn>
But ocaml is very easy to learn and very powerfull even with the basics. At university we wrote a compiler for a subset of ocaml in ocaml and some pupils learned ocaml along the way without problems.
<benny99>
Sparkles: Oh, 3 points -- I guess I should stop bothering you, thanks so far :)
<mrvn>
For ASTs the variant types and recursive capabilities are truely great.
<benny99>
mrvn: "easy to learn" means "easy to get started with" ?
<mrvn>
benny99: easy to get started with, easy to use for complex things and easy to write a compiler for.
<mrvn>
We didn't do matches or optimizing though. just a basic compiler.
<benny99>
x_x if it's that easy I guess I'm an idiot
<benny99>
doesn't matter, have to learn it anyway --- maybe I get a bit less idiotic by learning :p
<mrvn>
You have to get used to the concepts of functional languages. that is all.
<benny99>
OK, didn't want to bother that much (again and it's certainly not the last time) -- I'll try my lexical tree then :)
<Sparkles>
benny99 : You can't know ocaml is easy before you have actually understood why. So it's the hardest part of it : understand why it's easy ;-)
<benny99>
Sparkles: ok, I'll punch it till it tells me why :p -- ok, I hope I can get rid of that
<benny99>
Sparkles: yeah, but I rather like that book
<benny99>
mrvn: look at the exercise above ;)
<Sparkles>
member:benny99 : ok no problem. :-)
<benny99>
mrvn: but insertion sort + ocaml is nonsense...
<mrvn>
Aeh, that exercise comes with answeres
<benny99>
mrvn: where !?
<mrvn>
as mouse_over popups.
<benny99>
mrvn: -.-' stupid me
<Sparkles>
why insertion sort + ocaml is nonsense ? If your structure is not bad for insertion, then it's not nonsense. Of course, if you make a insertion sort with 'a list data, it's nonsense because its cost is way prohibitive...
<benny99>
Sparkles: ok, I guess I took enough shame on me today :|
<benny99>
Sparkles: mrvn: thanks once again -- I'll try to "solve" that second exercise now
<Sparkles>
it's no shame to start learning a good language ;-)
<mrvn>
no, solve the first one before reading the solution
<benny99>
mrvn: I'm not capable of doing that
<benny99>
mrvn: but if you say so :|
<mrvn>
Whoever wrote those answeres needs to learn about tail recursion and List.fold_left
<Sparkles>
mrvn : well, no, first you learn to program without List.fold_left (nor List.fold_right), and then you learn how to use them.
jkeith_ has joined #ocaml
twobitsprite has quit ["Lost terminal"]
<mrvn>
Sparkles: you can safely ignore fold_right
<Sparkles>
fold_right can be faster than fold_left in some cases...
<mrvn>
but only works on small lists
<Sparkles>
in deed.
<mrvn>
Writing a tail recursive insert for a tree is fun.
<mrvn>
In case you want to store very long words in the tree.
<mrvn>
When I learned ocaml at university I nearly drove my tutor insane by handing in solutions with stacked List.fold_left constructs being like half to quarter the size of the rest of the group. It was realy fun optimizing the code flow into the most higher level form and minimal length.
<benny99>
that exercise #6 is really bad explained huh? my one was "let insert e l = l.mList::e ;;" before :Z
<benny99>
mrvn: the fastest if it wouldn't copy the whole list huh ? (Yeah, I read something about search-algorithms once ago :Z)
<mrvn>
insertion sort makes tons of copies all over the place.
<benny99>
mrvn: yeah :(
<benny99>
mrvn: dunno, the book says I should program that, so I (try) to do
<benny99>
I give up for today
benny99 has left #ocaml []
Sparkles has quit []
bluestorm_ has quit ["Konversation terminated!"]
Smerdyakov has joined #ocaml
dark_light has quit [Read error: 110 (Connection timed out)]
benny91 has joined #ocaml
<benny91>
does anybody know how List.fold_right is working ?
<postalchris>
Looks all right to me.
<postalchris>
let rec fold_right f l accu =
<postalchris>
match l with
<postalchris>
[] -> accu
<postalchris>
| a::l -> f a (fold_right f l accu)
<postalchris>
That's straight from the sources
<benny91>
thanks
pango_ has quit [Remote closed the connection]
pango_ has joined #ocaml
<benny91>
I guess it's not my day today
<benny91>
At least IRC is not (yet) against me -- Have a nice evening anyway -- bye :)
benny91 has left #ocaml []
jlouis has joined #ocaml
pango_ has quit [Remote closed the connection]
pango_ has joined #ocaml
bluestorm_ has joined #ocaml
david_koontz has joined #ocaml
Madonna has joined #ocaml
cheese` has quit [Read error: 104 (Connection reset by peer)]
postalchris has quit ["Leaving."]
a-priori has quit [Remote closed the connection]
a-priori has joined #ocaml
jajs has joined #ocaml
bluestorm_ has quit ["Konversation terminated!"]
benny99 has joined #ocaml
<benny99>
it's not my day ... damn, I feel so stupid :|
benny99 has left #ocaml []
jajs has quit ["Quitte"]
joelr1 has joined #ocaml
<joelr1>
good evening
<joelr1>
how can i create permutations of [ 1; 2; 3; 4 ] and a another list? i would like to pair each member of the 2nd list with each member of the first
<joelr1>
pango_: but what i really want is what i describe
<joelr1>
any elegant way to achieve that? easily done with list comprehensions but i don't think ocaml has any
<pango_>
List.combine ?
<joelr1>
checking
<joelr1>
pango_: Raise Invalid_argument if the two lists have different lengths.
<joelr1>
my 1st list has just 4 items whereas the 2nd has more
<pango_>
oh, I misunderstood what you want then
<joelr1>
in other words, i have a list of pairs where each pair represents a function return type and a list of arguments
<joelr1>
i need to produce functions called "plot1", "plot2", "plot3" and "plot4" where each of these can have the type and arguments in the previously mentioned list
romanoffi has joined #ocaml
<joelr1>
pango_: so i do need to combine but the lists are of different length
<joelr1>
in haskell:
<joelr1>
plotFuns = [ plot n ty args | n <- [ 1 .. 4 ], (ty, args) <- defs ]
<joelr1>
where plot n ty args =
<pango_>
If the number of combinaisons can be large, you should better not mimic the Haskell solution
<joelr1>
pango_: it's not large, just 4 x 5
<pango_>
so, all pairs made of an element from a first list and an element from a second ?