<ihb>
ok, vincenz, why should i invest time in learning ocaml? :-)
<vincenz>
it's a great functional language that has execution speeds similar to c and supports multiple paragigms
<ihb>
riiiight. but really. why? :-)
<vincenz>
seriously
<ihb>
does it have any specific problem domain?
<vincenz>
it's a functional language
<ihb>
(more or less)
<vincenz>
just like haskell, except it's not lazy nor pure so it allows side-effects
<vincenz>
it's module system scales better than haskells
<vincenz>
it compiles to super efficient executables
<Smerdyakov>
ihb, what languages do you usually use now?
<ihb>
Smerdyakov: Perl when I want things done.
<Smerdyakov>
ihb, you can probably use OCaml to do the same things more reliably.
<vincenz>
I just dragged him over from #haskell
<ihb>
Smerdyakov: can you elaborate?
<Smerdyakov>
ihb, static checking helps you find errors
<ihb>
Smerdyakov: ok. what other benefits do you think there is with ocaml over perl?
<Smerdyakov>
ihb, more structure to programs makes them easier to read, understand, and maintain.
<ihb>
Smerdyakov: what makes ocaml structured?
<Smerdyakov>
Types
<mflux>
ocaml also has an extension mechanism that allows for example an integrated kind of regular expression support to be implemented (and it has been) as an extension
<ihb>
Smerdyakov: continue... :-)
<Smerdyakov>
ihb, that's the only answer necessary. Look at the language tutorial for more specific information.
<mflux>
ihb, btw, which editor do you use?
<ihb>
mflux: howcome?
<ihb>
Smerdyakov: i don't follow why types makes code more structured.
<mflux>
if it were emacs, there'd be some handy scripts for writing ocaml, so that one can ask the type of a variable under cursor
<mflux>
ihb, maybe you should study ocaml a bit to get a better perspective ;)
<neale>
someone should write up a standard response to "Why should I learn OCaml?"
<neale>
seems like we get that question in here a lot.
<ihb>
mflux: i have a couple of language i'd want to study if i had the time. i can't study them all so good arguments for choosing ocaml wouldn't hurt :-)
<mflux>
ihb, which are? chances are ocaml is different in a way that expands your way of thinking programs ;)
<neale>
chances of that are very good, in fact.
<ihb>
more than Prolog? :-)
<mflux>
oh yeah, and if you like perl, the possibility of defining custom operators (consisting of operator characters) must please you ;)
<mflux>
well, prolog is suitable only for certain kinds of programs
<mflux>
but it's nice too to learn
<mflux>
it might not really bring much back to programming in other languages
<mflux>
unless you want to build a similar logic solver
<ihb>
mflux: regexes, are you mentioned before, would be one case.
<ihb>
anyway, Ruby is a strong candidate as next language.
<neale>
ihb: there are four basic families of languages: procedural, functional, object-oriented, and whatever the crap Prolog is.
<mflux>
:)
<ihb>
neale: logical and declarative.
<neale>
Perl is a procedural language with a klunky object-oriented paradigm tacked on
<mflux>
and then there are eager and lazy, and dynamically and statically typed (although there are some shades of gray in that)
<neale>
Ruby would be more in the OO category
<mflux>
well, perl has also some functional aspects..
<Smerdyakov>
ihb, many OCaml libraries don't need to be documented. Their types alone explain exactly how to use them. You won't get that in Perl.
<neale>
mflux: maybe one or two, but it's not scheme
<pango>
mflux: I think only Perl 6 gets real closures
<ihb>
"real closures"?
<mflux>
pango, hm, so how much more real do they get?
<neale>
so when we say OCaml is going to broaden your horizons, we're talking about the fact that it's going to introduce you to the functional domain.
<neale>
or at least, that's what I'm talking about.
<ihb>
neale: what if i already know basic haskell? :-)
<ihb>
(or used to know anyway)
<pango>
mflux: more real than function references :)
<ihb>
pango: i thought a closure was a data structure that deeply binds variables in its lexical environment, typically functions.
<neale>
ah, well, if you're already comfortable with a pure functional language like haskell, your mind won't be blown so much by OCaml.
<mflux>
pango, but isn't function references almost enough, as you can define functions in-place and they can refer to local variables?
<Smerdyakov>
My understanding is that the latest Perls have "real closures," but that functional programming is still far from being idiomatic Perl.
<pango>
Smerdyakov: yes
<neale>
ihb: but if you've ever found yourself saying "wow, I really like programming in Haskell, I just wish I could use it in the real world", then OCaml is for you :)
<pango>
not to mention sluggish function calls
<vincenz>
either way, latest pythons also have closure, and python is much cleaner than perl
<vincenz>
so drop perl
<ihb>
neale: hehe, that must be the best argument i've heard to far :-)
<ihb>
vincenz: i think that cleanness is quite subjective :-)
<Smerdyakov>
I would say that "Standard ML is for you" is another, better, conclusion. ;)
<vincenz>
Smerdyakov: I would change that claim from better to equally good
<neale>
Smerdyakov: In my experience, OCaml is beating SML in the popularity contest
<Smerdyakov>
vincenz, OCaml is maintained by one group of people with a very non-open view of how to go about things.
<Smerdyakov>
vincenz, SML is much more in the traditional open source community kind of model -- which I much prefer.
<neale>
Of course, my view may be influenced by the IRC channels I frequent :)
<vincenz>
Smerdyakov: I honestly find your constant bantering of sml over ocaml in here annoying to say the least
<vincenz>
especially when talking to newbies
<Smerdyakov>
neale, it is _now_, but I'm talking about what's a smarter choice, technically.
<Smerdyakov>
vincenz, newbies are the best people to remind that there is another choice of a very similar language.
<vincenz>
or to convince because they don't have any knowlege
* neale
exits stage left
<Smerdyakov>
vincenz, I don't understand. Are you saying that I'm making false statements, and taking advantage of newbie lack of knowledge to get them to believe them?
<vincenz>
no
<vincenz>
you're placing words in my mouth
<Smerdyakov>
vincenz, I'm trying to understand what you're saying..
<vincenz>
I'm saying that sml vs ocaml is more a subjective than objectiv thing
<Smerdyakov>
I don't think so, and I think I just told you the main reason.
<vincenz>
...
<Smerdyakov>
SML tools are maintained using a better development model.
<vincenz>
subjecitve
<vincenz>
anyways
<Smerdyakov>
No, I can demonstrate objectively that it leads to higher-quality software in the long run -- with enough time to accumulate and analyze data.
<vincenz>
newbies, not having knowledge, will be easily convinced by reasons that to a knowledgeable person might seem like subjective
<vincenz>
anyways
<vincenz>
I'm not going to spend any more words on this
<vincenz>
I voiced my opinion, that I find it annoying
<neale>
so anyway, ihb, you should learn SML or OCaml, just for the fun of it, if nothing else. :)
<neale>
and then you can hang out in #ocaml or #sml and troll newbies ;)
<ihb>
neale: you missed when i said time wasn't my greatest resource? :-/
<ihb>
neale: hehe.
<neale>
ihb: so what else is a contender?
<Smerdyakov>
Hm, and MLton is beating OCaml for executable speed in the latest PL Shootout! :D
<ihb>
neale: now that i've looked a bit at Prolog only Ruby as a concrete candidate is left (but a really strong one).
<neale>
Coming from Perl, I think Ruby is going to be a snap, and probably not too exciting.
<neale>
(not sure what you're after, easy or exciting)
<ihb>
neale: the reason i'm interested in Ruby is that so many Perl programmers like it, and I like Perl so I might just like Ruby, and I hear Ruby solves certain issues that Perl 5 has while keeping many of the good parts.
<neale>
Some fun ones to consider: PostScript, Joy, Intercal
<vincenz>
ihb: ruby is really nice, but it's almost the same as python ('cept for inline regexes and first class values) except that ruby has smaller lib support than python
<vincenz>
neale: squeak
<neale>
ihb: I went from Perl to Python back before Perl 5 came out; when I saw Ruby, all I could think was "why rewrite Python?"
<ihb>
neale: befunge. there you have a clean language. :-)
<vincenz>
neale: yeah
<mflux>
postscript is the one that may actually be useful
<ihb>
vincenz: quite a different syntax though isn't it?
<mflux>
and fun. integrated drawing operations ;)
<vincenz>
ihb: not really
<vincenz>
ihb: not that python
<vincenz>
s/that/than
<neale>
nothing like programming your printer to do your calculus homework :)
<vincenz>
"my printer ate my homework"
<ihb>
vincenz: howcome Perl and Python people generally really dislike the other language (or so i've heard), yet Perl people like Ruby is Ruby is Pythonesque?
<vincenz>
ruby and python are quire similar
<vincenz>
perl people like it better cause they threw in a few perl features
<vincenz>
like regexes in conditions
<vincenz>
(aka regex-syntax)
<neale>
I think it's because a lot of Python people are like me; they learned Python because they were getting really sick of Perl 4.
* vincenz
never got into perl
<ihb>
i can imagine people getting sick at Perl 4.
<neale>
But when you get into the high-up Perl and Python hackers, the ones who really know what time it is, they both have a lot of respect for the other language.
<vincenz>
neale: to be honest...
<vincenz>
neale: what are things to be jealous of in Perl?
<neale>
It's just one of those stupid battles that started a long time ago for no good reason, and the Slashdot crowd decided to run with it.
<vincenz>
the regexes?
<ihb>
neale: you mean those that look beyond whitespace dependent syntax?
<vincenz>
hehe
<neale>
ihb: it's a funny thing about the whitespace, I hated it at first, but later I found myself wishing that C had it too. Nowadays I pretty much don't care.
<ihb>
neale: i like it in haskell. would prolly hate it in Perl. it's all about context, i figure.
<neale>
but I honestly can't recall *why* I hated it.
<mflux>
but even in haskell it's optional?
<neale>
well python has optional curly braces
<neale>
check it out
<vincenz>
in the end, if you're a seasoned programmer you'll end up placing the spaces
<vincenz>
the only issues is with tabs vs spaces
<neale>
if some_condition: #{
<neale>
do_something()
<neale>
#}
<neale>
else: #{
<neale>
do_something_else()
<neale>
#}
<vincenz>
what do the braces do?
<vincenz>
wait, that's comment
<neale>
they're optional, for people who like braces.
<vincenz>
they're not optional
* neale
gives vincenz a gold star
<vincenz>
you're adding comments
* vincenz
tsks
<neale>
one man's comments are another man's optional curly braces :)
<vincenz>
it'd be nice if python would check on them
<vincenz>
in case you accidentally mistabbed code
<vincenz>
(or copy pasted and did something wrong)
<neale>
I dunno, having tought both C and Python, I have to say I like the whitespace syntax
<ihb>
vincenz: wouldn't it just be easier to have them mandatory then? :-)
<vincenz>
ihb: no
<mflux>
I use emacs' indentation features constantly
<vincenz>
for those who wish for it..
<neale>
new students have a hell of a time with C's braces, if statements, whatever
<mflux>
it's nice that the part that really matters is visible
<vincenz>
neale: heh, we learned scheme in our intro to programming
<neale>
vincenz: lucky dog
<Smerdyakov>
This issue isn't so important in functional programming, since there's not so much sequencing.
<vincenz>
it's a lisp language (lots of irritating silly parentheses)
<neale>
I think we all know what scheme is :)
<vincenz>
especially when writing code on the exam
<ihb>
vincenz: ok, so you mean that it really would support optional braces?
<vincenz>
ihb: yesssss
<vincenz>
but a checker like that should be easy
<vincenz>
very easy in fact
<vincenz>
a simple one-pass line-reader should be able to do it
* ihb
pizza &
wam has quit [Read error: 110 (Connection timed out)]
wam has joined #ocaml
smimou has quit ["?"]
pango has quit ["Leaving"]
<ihb>
the tutorial in the topic can't be found.
<Smerdyakov>
The tutorial in the manual is fine.
<ihb>
the manual as in the book at inria.fr?
<Smerdyakov>
No. It will say "OCaml manual" quite clearly
<ihb>
quick question: can you do "int_var + float_var" in ocaml?
<vincenz>
ihb: no
<ihb>
vincenz: good or bad?
<Smerdyakov>
Good
<Smerdyakov>
You should know exactly what kinds of conversions must be performed to execute your code.
<Smerdyakov>
...because rounding errors can be nasty!
<Smerdyakov>
So writing the conversions yourself helps you be sure that you know what they are.
<vincenz>
typeclasses would be nice
<stef>
pango: the match is only attempted from the root of the tree, that is the problem?
<stef>
pango: I need to thread it explicitely
<stef>
??
<ihb>
vincenz: what does that mean?
<vincenz>
ihb: nm
<stef>
pango: I have played a long time ago with Mathematica, may be I have wong expectations
<Smerdyakov>
stef, the semantics of a 'match' expression do _not_ mean "keep applying this match until it has no further effect."
<ihb>
vincenz: typeclasses like "Num" in haskell?
<vincenz>
yes
<stef>
Smerdyakov: so how would you write it so that the problemantic expression can be reduced without going imperative? See http://nopaste.snit.ch:8001/1407
<Smerdyakov>
stef, can you describe in English how you reduce such expressions yourself?
<wolfman8k>
i have a question about the ocaml compiler optimizer...
<Smerdyakov>
wolfman8k, there is none! Haha!
<wolfman8k>
well, here's the question anyway :)
<wolfman8k>
f1 x = complex x + 2
<wolfman8k>
f2 x = complex x * 5
<stef>
Smerdyakov: I whould try to apply the match at each node of the tree...
<wolfman8k>
g x y = f1 x + f2 x + y
<Smerdyakov>
wolfman8k, do you mean those to be function definitions?
<wolfman8k>
Smerdyakov: yeah
<Smerdyakov>
wolfman8k, OK. You forgot 'let'. :P
<wolfman8k>
Smerdyakov: whatever... anyway, the question is about the g function
<Smerdyakov>
stef, what does that mean, more precisely?
<wolfman8k>
Smerdyakov: will "complex x" be evaluated once or twice?
<stef>
Smerdyakov: ...walking the tree
<Smerdyakov>
wolfman8k, twice
<wolfman8k>
Smerdyakov: even if it's a really fat and slow function?
<Smerdyakov>
stef, you're not being precise enough. How would you explain this to a high school student who knew nothing about programming?
<Smerdyakov>
wolfman8k, correct.
<Smerdyakov>
wolfman8k, if that bothers you, try MLton: http://mlton.org/
<wolfman8k>
Smerdyakov: that sucks.... do you know any languages/compilers that will optimize it into only one evaluation?
<pango>
wolfman8k: use lazy values
<wolfman8k>
haskell should be able to do this optimization in theory since it's pure
<Smerdyakov>
wolfman8k, I can't promise anything about exactly how MLton would handle that code, but it would probably use any obvious optimizations, like you're hoping for.
<wolfman8k>
thing is, this isn't really an obvious optimization
<wolfman8k>
and in a non pure functional language it can't be safely done i don't think
<Smerdyakov>
It is if you use inlining and common subexpression elimination, I bet.
<stef>
Smerdyakov:: I can write it in imperative style but that what I thought I could avoid
<Smerdyakov>
stef, well, that would at least be a start.
<stef>
Smerdyakov:: I probably lack some insight about the appropirate way to do it in ocaml
<Smerdyakov>
stef, it may be that what you think of as "imperative style" really isn't, if you change the words "change to" to "return a new value."
<mflux>
stef, it's not really a big change to that code to do it
<Smerdyakov>
mflux, but just giving away the answer would be less helpful....
<Smerdyakov>
stef, could you write some pseudo code ("imperative style," if necessary) that shows how to do it, and post it on the web for us?
<mflux>
smerdyakov, can I pleeease atleast say the name of the key concept?-)
<Smerdyakov>
mflux, OK!
<mflux>
yeah! it's called recursion ;)
<mflux>
atleast if I'm following what he's trying to accomplish
menace has quit []
<stef>
thx
<stef>
I got it
<stef>
I have to meditate the difference between the Mathematica algorithm and the mecanism of type unification
<Smerdyakov>
It's been a while since I've used Mathematica. Does it apply rules for you in a non-bottom-up fashion?
<stef>
Smerdyakov: Mathematica is exactly what you described: keep applying this match until it has no further effect." I forgot the specifics.
<Smerdyakov>
OK. What is the relation here with type unification?
<stef>
probably none. probably totally different approaches. That's why I was clueless.
<Smerdyakov>
Type unification is part of ML type checking. Why did you even consider it relevant in the first place?
vezenchio has quit ["haibane · renmei"]
<stef>
hum, unification, is that orthogonal with pattern matching?
<Smerdyakov>
_Type_ unification is.
<Smerdyakov>
There is also unification of expressions.
<stef>
Have you some tutorial about unification. I think I mix concepts and have imprecise vocabulary.
<Smerdyakov>
I don't know of one off-hand.
<Smerdyakov>
If you want to have a word for how 'match' expressions execute, that would be "pattern matching."
<vincenz>
stef: I do think you mean "explanation of" and not '
<vincenz>
"tutorial"
<stef>
I probably need to read the Pierce booK.
<vincenz>
tapl?
<stef>
"Type and Programming Language"
<vincenz>
so yes
<stef>
but may be it treat only of type unification...
<stef>
I learn on my own and I need to get some general mental map :)
<pango>
once you have type variables, the mecanism is the same
<vincenz>
it is/
<stef>
ok, anyway I solved my blocking problem. thx.
<pango>
stef: does it canonize Plus( Const 1, Plus (Var "x", Const 2)) ?
<stef>
I have no vars yet. :)
senko has joined #ocaml
<stef>
I am trying to get familiar with tuareg
<mflux>
C-c C-t is nice ;)
<mflux>
and C-c C-h
<stef>
I have tried to compile cameleon but it barked. Somone did me a nice demo at LinuxExpo Paris in September
<stef>
you should do some entrism to get all you ocaml stuff as package in linux distros :)
<Smerdyakov>
It's in Debian, the only distro that matters.
<stef>
I know that pixel in Mandrake is interested in camel.
<Smerdyakov>
Too bad. Caml isn't interested in Mandrake! :D
<stef>
s/came/ocaml/
<Smerdyakov>
Nothing else comes anywhere close to Debian for number of packages./
<stef>
pixel has written a nice perl style enforcer in ocaml
<Smerdyakov>
Anyone here going to POPL 2005?
<stef>
POPL?
<Smerdyakov>
Principles of Programming Languages
ihb has left #ocaml []
dobrek_ has joined #ocaml
smkl has quit [Read error: 238 (Connection timed out)]
dobrek has quit [Read error: 101 (Network is unreachable)]
Herrchen has quit ["bye"]
mlh has joined #ocaml
dan2 has quit []
CosmicRay has quit ["Client exiting"]
smkl has joined #ocaml
HOm4r has joined #ocaml
HOm4r has quit [Remote closed the connection]
<neale>
so like
<neale>
I actually have a question about a program I'm writing.
<neale>
A rarity for this channel, in my experience.