systems changed the topic of #ocaml to: Archive of Caml Weekly News http://pauillac.inria.fr/~aschmitt/cwn/ | ICFP Programming Contest 2003 http://www.dtek.chalmers.se/groups/icfpcontest/ | Good free book http://cristal.inria.fr/~remy/cours/appsem/
docelic has quit ["later folks"]
eno has joined #ocaml
eno has quit ["Read error: 2.99792458 x 10^8 meters/second (Excessive speed of light)"]
brwill is now known as brwill|tube
polin8 has quit [Read error: 110 (Connection timed out)]
<bk_> oh #trace is useful
<bk_> neat
<Maddas> heh
<Maddas> What kind of stuff do you guys code in O'Caml?
<Maddas> Looks like it's a rather good general-purpose programming language
<bk_> currently i don't really 'do' anything with it
<bk_> i'm merely trying to understand it
<Maddas> :-)
<Maddas> I'm thinking to learn it to replace C/C++ in what I'm doing
<Maddas> as it seems to be fast
<bk_> i think of its speed more as an added benefit
<bk_> i guess its real power lies in the functional programming paradigm
<Maddas> Yes, that, too
<Maddas> Speed is just a handy thing :)
<bk_> of course
<Maddas> as I already know Perl/a little Scheme for the "normal" scripting
<Maddas> having something which can be compiled to native machine code is good :-)
<bk_> haskell does offer a machine code compiler, too if i'm not mistaken
<bk_> and so does lisp imho, only lisp compiles to c, then to machine code afaik
<Maddas> I see
<Maddas> Yes, the Scheme to C compilers still create very large code
<bk_> right
<Maddas> mostly :)
<Maddas> Stalin seems to be fairly good
<Maddas> I'm learning Scheme while reading about other things, but I think I'd like to learn O'Caml too
<bk_> i'm mainly interested to figure out how and if functional programming gives me the elegance non-functional languages don't
<Maddas> well, Scheme definitely is very elegant.
<Maddas> even for me, and I only know Scheme since two days :-)
<bk_> i see
<Maddas> I don't know much either, but Scheme almost forces you to program elegantly
<Maddas> and I find that even complex things can often easily be implemented in Scheme
<Maddas> algorithms or so
<Maddas> (ok, not REALLY complex, just complex compared to how little code it uses)
<bk_> hm heh
<bk_> if scheme works for you why would you want to even consider ocaml
<Maddas> I don't really know
<Maddas> Why not?
<Maddas> Don't fall for the Blob Paradox
<bk_> what would that be ?
<Maddas> I also want to learn many other languages once I know Scheme/O'Caml
<bk_> ah ok
<Maddas> eventually a bit Erlang, Common LISP, maybe Haskell
<Maddas> knowing more languages broadens your horizont and often increases your programming style
<bk_> hm
<Maddas> sorry, Blub Paradox
<bk_> i don't care much about knowing many languages, i rather care about knowing useful paradigms
<Maddas> Yes, that's what I want to learn
<Maddas> Scheme has already taught me interesting concepts
<bk_> yes, i believe so
<Maddas> SICP is a very good book.
<Maddas> (It's the reason I know a little Scheme)
<bk_> i have heared about the SICP book, but never read it
<Maddas> it's free, online :)
* bk_ bookmarks
<Maddas> HDTP too
<Maddas> I should read that afterwards
<Maddas> err, HTDP
<Maddas> I hope to learn a lot in these two bokos
<Maddas> books
<Maddas> anyway, later :)
<bk_> l8r
brwill|tube is now known as brwill|zzz
<bk_> The type of this expression, '_a list ref,
<bk_> contains type variables that cannot be generalized
<bk_> wtf is this
brwill|zzz has quit [orwell.freenode.net irc.freenode.net]
teratorn has quit [orwell.freenode.net irc.freenode.net]
brwill|zzz has joined #ocaml
teratorn has joined #ocaml
<bk_> why is this so
<bk_> # let s = ref [] ;;
<bk_> val s : '_a list ref = {contents = []}
<bk_> # s := ["abc" ; "def" ] ;;
<bk_> - : unit = ()
<bk_> # s ;;
<bk_> - : string list ref = {contents = ["abc"; "def"]}
<whee> bk_: when you see the _ in front of a type that means it's polymorphic at the moment but will eventually be bound to a specific type
<whee> there's probably a nice technical term for it, but I don't know what it is :)
<bk_> thing is i needed this :
<bk_> let s = ( ref [] : string list ref )
<bk_> instead of
<bk_> let s = ref []
<bk_> in my compiled program
<whee> you want a reference to a list of references to stings?
<bk_> yes
<bk_> well actually no, i didn't use the s anywhere else
<whee> er, I'm not sure what you want
<bk_> i just made s into a list of strings because w/o that the compiler would complain
<bk_> ie.
<bk_> 07:42 < bk_> The type of this expression, '_a list ref,
<bk_> 07:42 < bk_> contains type variables that cannot be generalized
<whee> oh, right
<whee> sometimes the compiler can't figure the types out because it's too general, so you have to specify them
<bk_> hm ok
<bk_> but using the toplevel interactively it did not complain
<bk_> # let s = ref [] ;;
<bk_> val s : '_a list ref = {contents = []}
<bk_> i was only surprised the compiler wouldn't take it
<whee> it depends on usage
<whee> if you have a binding to a ref [], and then a function that uses that empty list (but has a more specific type), it could complain
<whee> or wait, maybe not
<whee> there's an explanation of this somewhere
<bk_> meanwhile i have found an explanation
<Maddas> heh
<Maddas> silly ocaml elisp mode
<Maddas> oh, never mind
<bk_> the explanation makes sense in context of compiled code
<bk_> question answered
srv has joined #ocaml
<Maddas> wow, OCaml has a lot of syntax
<Maddas> can you recommend any good OCaml tutorial?
<srv> http://www.ocaml.org/ <- take a look at the `Documentation' section on the right of this page
<Maddas> heh, ok
<Maddas> I think I found something even better throguh google though :)
<srv> cool :)
<Maddas> oh never mind,iit's based on version 2.something
<srv> erf
<srv> FYI, this is my bible when I write some OCaml code: http://caml.inria.fr/oreilly-book/html/index.html
<Maddas> ok :)
<srv> I think the answer to 98% of the problems I've had with OCaml was in this book
<srv> and for the 2% left, I ask on this channel ^_^
<Maddas> a free book, cool!
<Maddas> much better than the other thingy :)
<srv> yep!
<Maddas> thanks a lot!
<srv> U're welcome
<Maddas> hah
<Maddas> is OCaml good to do Maths stuff in?
<srv> well YES, but what kind of math stuffs?...
<Maddas> I don't know yet
<Maddas> Just wondering!
<Maddas> any kind of number crunching really :)
<srv> anyway, for me ocaml is the Language, so I'll answer yes :)
<Maddas> I don't believe that there is one language that is superior to all others for everything
<srv> I've dropped C and C++ :)
<Maddas> that is exactly WHY I'm learning O'Caml :)
<Maddas> I'll *have to* learn C++, Java and C (know a bit of all of them already) later on in the University
<Maddas> sucks :-(
<srv> C++ is too badly conceived, so it's a mess
<Maddas> How long did you code in C++
<Maddas> s/$/?/
<Maddas> (I don't disagree, just wondering)
<srv> 1 (damn intensive) year
<Maddas> What I find worst is that they don't seem to see that Java and C++ aren't good languages to teach to students.
<srv> actually I've written a compiler in C++
<Maddas> nice
<Maddas> I myself know Perl pretty well and learning I'm Scheme and O'Caml now
<srv> and it made me understand that C++ is a mess...
<Maddas> I hope I'll still have time to use O'Caml despite school
<Maddas> although those courses aren't very intensive from what it looks
<Maddas> I just hope that I can keep three languages in my head without mixing all the syntax and concepts up :/
<srv> well C++ and Java are used in the industry, so it's necessary to teach these lgg
<Maddas> especially when they have similarities
<Maddas> no, srv
<Maddas> We learn them only to understand the concepts
<Maddas> I'm not studying CS
<srv> CS ??
<Maddas> and C will be the only thing we'll seriously use later on
<Maddas> Computer Science
<srv> k
<Maddas> especially C++ is a bad choice of a language to teach concepts
<Maddas> and Java is the first programming language being taught, I don't know if that'll work out well.
<srv> in my school, we first do an intensive C learning, and a few months later we learn OO languages (C++, java). I think it's a good scheduling
<Maddas> C++ is not a good language to teach
<Maddas> even you yourself admit that it's badly conceived
<srv> well it's a fact...
<Maddas> Yes
<Maddas> Scheme is a good language to teach, you can learn the concepts with knowing only very little syntax
<Maddas> not all concepts, but many.
<Maddas> And many universities agree :)
<srv> I don't know scheme
<srv> ;)
<Maddas> it's not a book about Scheme, but it teaches you a little
<Maddas> it's a book about Programming in general
<Maddas> (That book was written as an introduction to programming, every CS/EE student must take it in the beginning)
<Maddas> and it's very good, even I learned a lot
<Maddas> (about programming)
<srv> it looks like what I call a "bracket language" :)))
<Maddas> The brackets are a part of the language design
<Maddas> they are important, once you get better, you'll see why
<Maddas> they let you do very powerful things in LISP for example, which in that way no other language can (which is why LISP is still used)
<srv> I already see why
<Maddas> why?
<Maddas> And, additionally, there is very little syntax to learn to do basic things, so the students don't get distracted by the syntax, but can focus on the ideas and concepts
<srv> because I've written a compiler for a recursive lgg, and I know bracket make the grammar nicer
<Maddas> Scheme is very easy to parse
<Maddas> I see
<Maddas> TinyScheme is < 80kb :)
<srv> and it makes the lgge more intuitive
systems has joined #ocaml
<Maddas> Well, the brackets in LISP are necessary for certain features :)
<Maddas> not just visual decoration
<srv> lisp without brackets would be charmless :))
<Maddas> and pretty useless compared to LISP now
<srv> well right now I gotta work....
<Maddas> I wouldn't know how to implement it otherwise :)
<Maddas> sure ;)
<Maddas> anyway, I'll continue reading that book, talk to you later
<srv> k
<srv> (I'm coding in Ocaml right now :) )
<systems> what book maddas
<srv> FYI: http://libnn.org
<Maddas> oh, that book is for 2.04 too, srv :(
<Maddas> cool, srv :)
<systems> what book
<systems> ahhh
<srv> maybe the english translation is not up to date?
<srv> (I use the french version...)
<Maddas> damn :(
<systems> hehe
<systems> why would the french version be more up2date
<srv> Maddas: I can find the page where they talk about the ocaml version. Could you give me the link so that I compare
<Maddas> ok
<srv> systems: ocaml is made by the INRIA, which is a french research institute
<systems> well i downloaded both
<systems> i had this wicked idea , to improve my french and learn ocaml at the same time
<Maddas> haha, nice :)
<srv> systems: lol :)))
<systems> up until the compiler part, they were both identical
<systems> i know french
<srv> systems: moi aussi :)
<systems> i used the english version as a translator dictinary, since my english is better, and most CS i learned in english
<Maddas> moi seulement un peu :)
<srv> :))
<systems> je pense que mon niveau en francais n'est pas mauvais du toup
<srv> Maddas: I think you can use this book anyway...
<Maddas> ok
<srv> systems: agreed :)
<systems> mon language maternel est larabe, parfois que je pense en arabe et dis/traduit en francais
<systems> je dis des betises
<systems> :P
<srv> normal...
<srv> well I really gotta work. Yesterday I almost didn't work because I had drunk too much the night before :)
<systems> bad srv bad
<srv> don't tell my mother ^_^
<Maddas> haha
<systems> :> okay
<srv> sex, drugs, alcool,... and OCaml :)))
<systems> but drinking will make you do more serious "betises"
<systems> :P
<srv> (I forgot rock and roll :) )
<systems> sex, drugs and politicians is more dangerous
<srv> agreed :)))
<bk_> err
<bk_> is there something to "unload" the code i've loaded w/ #use into the toplevel ?
<Maddas> hm
systems has quit [Connection timed out]
docelic has joined #ocaml
<Maddas> actually, OCaml isn't all that hard :-)
<srv> Maddas: true :)
<Maddas> It seemed very confusing at first, so much Syntax (compared to Perl/Scheme)
* bk_ finds it hard
<Maddas> What are you trying to do?
<Maddas> I'm just playing around with function declarations now
<Maddas> it seems very restrictive, but not so hard :)
<whee> ocaml was my first real functional language; I just worked with a lot of existing code to figure things out
<Maddas> Heh. Seems like a hard way to figure things out in ocaml
<Maddas> are the List.xxx functions made in Ocaml?
<Maddas> I'd like to take a look at them if yes, how would I do that?
<whee> Maddas: they're in ocaml/stdlib/
<Maddas> thanks
<bk_> i am working w/ existing code to figure out things for my own code
<Maddas> thanks
<Maddas> hey srv, still there?
docelic has quit ["late rall"]
<srv> Maddas: I'm cooking...
<Maddas> srv: just wondering, what is the largest app you've ever implemented in O'Caml?
<srv> actually, my neural network library is the biggest project I've ever made
<srv> and it's being developed
<Maddas> hm, the biggest thing you've completed?
<Maddas> Or do you know any large popular applications coded in O'Caml apart from MLDonkey? :)
<srv> I've not really done big stuffs before
<Maddas> I see
<srv> I always cameleon watch the `cameleon' project's CVS when I'm looking for examples
<srv> there's also `unison', but I've never seen the sources
<srv> I always watch the `cameleon' project's CVS when I'm looking for examples
<Maddas> ok :)
<srv> http://savannah.nongnu.org/cgi-bin/viewcvs/marvin/marvin/src/libnn/ <- LibNN is getting more and more fat :)
<Maddas> :)
<Maddas> is coding in O'Caml more rewarding than in C/C++?
<srv> what do you mean when you say "rewarding"?...
<Maddas> less frustrating :)
<Maddas> you get things done more easily, or at least it's more fun to get things done
<srv> well, compared to C++, I have the impression I spend more time on "what do I want to make" than on "how can I make it" and "how can I get this shit to compile" :)
<Maddas> I see :)
<Maddas> So you get things done more quickly?
<Maddas> with less debugging and all :)
<srv> I'm really fed up with the 2 pages long g++ errors about the C++ STL, which are impossible to read
<Maddas> heh :/
<bk_> no pointers, no memleaks, no dangling crap anywhere - that is a BIG benefit of ocaml vs c++
<bk_> no templates :>
<whee> you get the functionality of templates with the parametric polymorphism and functors
<whee> and there's camlp4 if you're into defining new constructs in your source
<srv> ocamlc warnings are understandable because OCaml is a well conceived lgg (read "it doesn't have a grammar which has been tortured for years in order to add features, which has lead to complete nonsenses")
<Maddas> That's what I expected, thanks :)
<srv> the main asset of C++ compared to OCaml is the amount of libraries which are available, but if you learn how to use OCaml/C interoperability, there's always a way to use existing libs
<Maddas> Yea, I see.
<Maddas> I'm quite surprised that O'Caml isn't more popular, considering that it has important features for achieving mainstream recognition (can be compiled to machine-code, cross-platform compilers exist, it's fast)
<srv> it takes a lot of time to change the companies habits...
<Maddas> I'm thinking more of private people
<Maddas> small projects and all
<srv> I've seen some customers saying "no way, I want my stuff done in C++. No Ocaml". That's frustrating
<Maddas> doesn't seem to make much sense, but then, what do I know :-)
<Maddas> Yeah, I agree, that sucks.
<Maddas> But then, people are stubborn, and mostly caught in the Blub Paradox
<Maddas> which is very widespread and contagious
<srv> what's more, there is no big lobying and advertising for OCaml like Sun has been pushing Java
<Maddas> That's true
<Maddas> A pity, really, that marketing has so much influence on things like this
<srv> yep
<srv> my vision of the thing is : "INRIA provides us the language, the compiler and the standard lib. We (communauty) now have to make some groovy libs to make the lgg more popular, that's exactly what I'm trying to do :)"
<Maddas> :-)
<Maddas> Maybe, if I find anything I could do and want to do, I should do it, just to show that O'Caml exists
<Maddas> that's what I'm thinking
<Maddas> :)
<Maddas> I think MLDonkey is a success in that way, it shows that good software (I don't like P2P, mind you, but I've heard that it's one of the best clients) needn't be done with mainstream programming languages
<srv> exactly
<srv> that's what makes GNU/Linux's success. Share the code! :)
<bk_> M$ is 'advertising' ocaml with F# in a way
<mattam> Maddas: Blue Paradox ?
<srv> bk_: LOL :)
<bk_> if it helps giving ocaml more recognition when ppl. want to know where F# has its origins, it is a kind of advertisement imho
<Maddas> Blub Paradox
<Maddas> F#?
<srv> bk_: I thought you meant "C#". What is F#
<Maddas> what is F#?
<Maddas> oh
<Maddas> another language by microsoft.
<mattam> Blub Paradox... by a lisp programmer
<bk_> F# is M$' implementation of ocaml on .net
* srv fills sick :(
<srv> Yet Another Ms Shit
<Maddas> cool
<Maddas> yes, mattam
<Maddas> Why?
<Maddas> I think that's good to have F#, gives OCaml some attention.
<Maddas> And I'm VERY happy that they didn't just invent a OCaml# or something.
<mattam> It's like OCaml-- I think
<Maddas> It's an implementation of OCaml, it seems.
<Maddas> oh crap, it's not.
<Maddas> no wait it is
<Maddas> it's just another target or something :)
<Maddas> Not a new language
<bk_> its on top of .net
<mattam> I was told some things can't be done
<Maddas> F# is an implementation of the core of the Caml programming language for the .NET Framework, along with cross-language extensions.
<whee> F# is lacking a few features of OCaml
<Maddas> Oh, ok
<Maddas> At least it's still OCaml
<srv> Well I fear that they want to give developers the habit of using THEIR compiler (with all the licensing restrictions it means) instead of the INRIA compiler...
<Maddas> Oh, ok, th at sucks.
<Maddas> that, even.
<mattam> he... it's a company
<whee> srv: I don't see it that way at all
<Maddas> But don't forget, it might also just make developers aware of O'Caml, and they'll use the normal compiler if they want cross-platform compability.
<whee> if you want to use a caml workalike and windows, you'd probably be better off using F#
<mattam> just don't do what you don't want to
<whee> especially because of the .NET support (which is actually pretty useful)
<srv> whee: well, look at what happened with Java...
<whee> Java flopped on its own merits
<Maddas> Java was never supposed to get popular :)
<srv> 1) ms has made a java vm 2) they've tried to crush Sun (i.e. to make everybody use Ms's compiler and not sun'sone)
<whee> srv: the thing is, F# isn't O'Caml
<whee> they aren't passing it off as such, either
<Maddas> I've just seen, whee is right.
<Maddas> In particular it is the first ML language where all the types and values in an ML program can be accessed from some significant languages (e.g. C#) in a predictable and friendly way.
<Maddas> It's not OCaml.
<Maddas> It's an own language, similar to OCaml, it seems
<srv> well, the future will tell us if I'm wrong
<srv> I'd be curious to know what the INRIA folks think of all this
polin8 has joined #ocaml
<Maddas> looks light you might just be right :/
<whee> Xavier approves of it, at least
<srv> k
<Maddas> oh, good.
<Maddas> here are no current plans to commercialize F#, and the source code for the F# compiler is due to be published in June 2003.
<whee> a lot of the .NET languages aren't done directly by microsoft in order to take over the world
<Maddas> But the rest sounds like crap. They're implementing a Windows-only Caml-like thing for universities to be used to teach.
<Maddas> How stupid :)
<whee> Maddas: eeh, .NET is useful :P
<Maddas> well, VB is useful too.
<whee> think the java libraries, available in many many languages, with complete interoperability
<srv> Maddas: it's not stupidity. It's strategy
<Maddas> srv: I know, but the explanation is stupid :)
<Maddas> Well, stupid not from a business point of view, but from a students point of view.
<Maddas> Why would you (as a teacher, for example) actively encourage to code in a language which can only be used on Windows?
<srv> Maddas: agreed
<Maddas> or why would a student want to learn that in CS? Not like you can't do that by yourself if you are interested in that
<Maddas> I'm worried that some universities might fall for it.
<Maddas> but then, my university sticks to C++ and Java, *sigh*
<srv> Maddas: well I think that a teacher who uses MS will find this interesting because it enables him to benefit from the whole framework
<whee> Maddas: the curriculum shouldn't be language specific, anyway
<whee> if a CS course is teaching a student how to use a specific language, it's wrong
<Maddas> Yes, that's what I agree.
<Maddas> s/what/where/
<Maddas> But our courses seem to do that, I couldn't see why you would use C++ for concepts :)
<whee> you teach concepts, not languages. The actual language used should make no difference when the student completes the course
<Maddas> I completely agree
<Maddas> Which is why I don't understand why Java and C++ are used in the first courses, as opposed to languages which were made to be taught.
<whee> I think you'll find that many of today's students are lazy and would rather be spoon-fed industry languages :)
<Maddas> I will, but I don't know why the teachers give in
<Maddas> If you teach something much less popular like Scheme or Smalltalk, you also have the advantage that almost all your students will know nothing about it, so they start from the same level.
<srv> when you get out of the school, companies want you to speak the language theyuse...
<Maddas> srv: yes, but university isn't a language school
<Maddas> it's called Computer SCIENCE, not "Learning Industry Languages"
<whee> srv: well, I think the easy solution is to not specialize on any language
<Maddas> Indeed
<Maddas> And the radical differences between those language (Scheme, Smalltalk, ...) and popular languages will stop the students from thinking that they already know how everything works, and they'll pay more attention
<whee> perhaps every week, switch to a new language; the concepts are mostly the same, the syntax changes
<Maddas> Every week is a bit too frequent, you don't have that many good languages :)
<srv> I agree, but the final aim is to get a job...
<Maddas> no, srv
<whee> Maddas: it'd work here :)
<Maddas> The final aim isn't to get a job, it's to make you a good programmer
<whee> there's only 9-10 weeks in a quarter here, I can think of that many languagse worth using
<Maddas> whee: well, you can't really dive into the core concepts of many languages in one week
<Maddas> Don't forget, I'm thinking about students who program the first time in their lives, too
<whee> Maddas: you're learning the concepts as you go; it's just a matter of getting people familiar with syntax
<Maddas> Yes, I think the frequently changing syntax would just confuse many people.
<whee> you don't have to introduce the entire language, just enough to introduce the concept
<Maddas> Unnecessarily
<Maddas> whee: in many cases you need a lot of syntax for that
<whee> well, it'd get people to not associate the problem with the language
<srv> I'm not saying I like this situation. I'm saying that's the situation
<Maddas> Yes, but would it get people to be able to solve any real problem in any language?
<Maddas> C++ for example needs a lot of syntax to understand many concepts
<whee> I don't see it that way
<Maddas> whee: And people like me will only have a few hours of similar classes every week :)
<Maddas> I think that you need to have one language for problem solving and larger projects, but that ought not to be the language used to teach the concepts
<whee> Maddas: things like template template parameters in C++ are really just fancy delegation and the like
<whee> sure there's lots of syntax to learn in C++, but the concept is much simplier
<Maddas> Yes
<Maddas> But they'd rather learn a language good enough to continue on their own IMO
<Maddas> The MIT course for example works very well, and the students seem to agree
<Maddas> The introductory one
<whee> I suppose
<Maddas> pretty much every other course uses a language most fit to its tasks
<whee> I like to tortute people, though :)
<Maddas> which is what I think should be done
<whee> torture, even :\
<Maddas> The introductory course is based on one language, Scheme, to teach concepts. That's a language where you need almost no syntax to teach most concepts :)
<whee> yes, scheme's a great learning language
<Maddas> You'll probably not use Scheme later on, but I don't know anybody who says he didn't profit (massively) from learning to code in Scheme.
<Maddas> Their book is great.
<whee> I had the joy of learning to program with perl and C++, that was rather painful :)
<Maddas> It focuses on common problems, and only uses Scheme to highlight possible (multiple) ways to solve it, and discusses the benefits/disadvantages.
<Maddas> whee: Perl was the first language I really started using, I got around fine
<Maddas> although I agree that it's a terrible language to teach
<whee> I found it started a lot of bad habits
<Maddas> Heh.
<Maddas> I knew basic C/C++/Java before I started, I just never coded anything in those languages.
<Maddas> And I never coded without strict/warnings :)
<Maddas> But already now I see that Scheme has affected my way of thinking, showing me new ways of solving problems
<Maddas> even though I only read the online-version of the book for two days
<Maddas> a few hours every day
<Maddas> most important of all, it showed me that there is no 'best' programming language, which then motivated me to look for more alternatives to C/C++/Java, which then got me here :)
<Maddas> You could say that it freed me of the Blub Paradox
<whee> heh
<Maddas> Although a few of my friends are exactly like described there
<whee> I started learning as many languages as I could a couple years ago
<Maddas> That's what I started a couple of days ago :-)
<Maddas> Going for Scheme and O'Caml now, I hope I can code decent things in O'Caml before University starts
<whee> I find I can approach problems a bit more effectively now, having dealt with them in many different paradigms
<Maddas> once it starts I won't have much time left to study
<Maddas> whee: I find the biggest difference is that it made me enjoy programming more :)
<Maddas> My friends though, they don't take anything or anybody seriously unless it/they use C++ or C#.
<Maddas> For them, everything else are just toys
<Maddas> They are CS students :)
<whee> right now I'm working on learning haskell more extensively
<Maddas> I see
<whee> one of the few languages I can't pick up by reading the reference manual and running :)
<Maddas> I'd like to pick up haskell, maybe Common Lisp (that's supposed to be really powerful) and Smalltalk later on
<Maddas> haha whee :-)
<whee> lisp is a lot of fun too
<Maddas> Scheme is, I don't know LISP yet :)
<Maddas> For me as more of a Perl coder, and after having started a bit of Scheme, Haskell has terribly lot of syntax though :-)
<Maddas> Reminds me of Perl 6
<Maddas> err, not Haskell, O'Caml
<Maddas> Lot of syntax isn't bad, I'm just worried that I'll forget it quickly if I don't have much time to keep my O'Caml skills up to date later on.
* srv going back to LibNN
<whee> I didn't find retaining the syntax to be much of a problem
<srv> whee: same for me
<whee> I don't do a lot of O'Caml code these days, but I can still pull off most of it
<Maddas> I see, cool
<Maddas> I'm just worried, I don't know yet
<Maddas> Because I won't be able to use O'Caml in Uni, at least definitely not in the beginning :-*
<Maddas> Actually, it's annoying that you have to use ONE language, they should let you choose between 4 or 5 well spread languages for the assignments
<Maddas> I should annoy the teacher who teachse in C by doing all in Perl and converting that to C code, what a mess :->
<Maddas> teaches, even
docelic has joined #ocaml
docelic has quit ["Client Exiting"]
polin8 has quit ["Lost terminal"]
polin8 has joined #ocaml
<Maddas> haha
<Maddas> C++ allows you to have fun! Look at this function declaration:
<Maddas> template<class KT, class DT, class cmp> template<class W> typename BTreeNode<KT, DT, cmp>::ptr BTreeNode<KT, DT, cmp>::Edit(KT key, W& obj, bool (W::*proc)(typename BTreeNode<KT, DT, cmp>::ptr&))
<Maddas> pop quiz! What is the name of this function, and what parameters does it take? :)
<srv> LOL!!!!
<Maddas> A guy I know did these kind of things for homework assignments :-)
<Maddas> (btw, that above is the "universal multi-purpose generic recursive subtree editing function")
<srv> name: Edit ?
<Maddas> Yes!
<Maddas> Pretty good! :)
<srv> parameters: key, obj. The third paramater is too obscur.
<Maddas> Ok, three parameters, good!
<Maddas> Bonus question: What's the return type? :)
* srv computing :)
<Maddas> :)
<srv> ptr ?
* srv can't stand all this suspense ;)
<Maddas> ok :)
<Maddas> you're right :)
<Maddas> BTreeNode<KT, DT, cmp>::ptr
<srv> I have a good one:
<srv> template <orientation_e orientation, class NodeLabel, class EdgeLabel>
<srv> const typename Graph<orientation, NodeLabel, EdgeLabel>::neighbors_of_node_t&
<srv> Graph<orientation, NodeLabel, EdgeLabel>::preds_of (hnode_t n) const
<srv> {
<srv> ...
<srv> }
<srv> nice prototype :))
<Maddas> hah, nice indeed :)
* srv going back to work
<Maddas> enjoy :)
mellum has quit ["ircII EPIC4-1.1.11 -- Are we there yet?"]
<bk_> erm, is there a shorthand for looking at / printing out the contents of a set ?
<Maddas> O'Caml isn't even that ugly once you get used to it :)
<bk_> my code is a mess
<Maddas> haha
<Maddas> I like colours
<Maddas> :-)
<Maddas> well, at least you have code!
<bk_> but its a mess, i suck
<bk_> damn
<Maddas> why?
<Maddas> what did you code?
<bk_> i'm just playing with lists, sets and file I/O
<bk_> ie. read a textfile and construct something out of it
<Maddas> cool
<Maddas> I'm never even that far :-)
<bk_> i still seem to have not understand something very fundamental about functional programming
<bk_> erm understood
<Maddas> Why?
<Maddas> well, I can't judge it yet
<Maddas> but the SICP is good reading
<bk_> simply because me code is probably the worst ocaml code ever written
<Maddas> heh ;)
<bk_> currently i feel my code is mainly such a mess due to my limited knowledge of the language elements of ocaml
<bk_> OR i have completely missed something
<Maddas> probably first :)
<whee> hhe
<whee> bk: put some of your code online, we can critique
docelic has joined #ocaml
<bk_> yes, i will do that
<whee> I need to locate some food first, though :)
<bk_> ah, not as of right now, i'll put it up tomorrow when it does all i want it to do
<bk_> i'd actually love to have someone w/ experience review it and tell me all my wrongdoings
<whee> if you're writing code that's dealing with i/o, the part doing that will look pretty imperative
<bk_> i've tried to evade imperative features whereever possible, but i do use ONE ref [], yes
<Maddas> hm
<Maddas> I need to have a primer of functional vs imperative
<Maddas> with typical examples :-)
<srv> personnally, I use OCaml, but I code the imperative way
<Maddas> I'm not aware of the clear differences quite yet
<srv> Maddas: You'll find that kind of stuffs on google...
<Maddas> yeah, I'm looking :)
<bk_> thing is, i don't want to use it the imperative way
<bk_> for now at least
<bk_> i figure once i'm comfortable w/ functional "thinking", i'll use imperative features sparsely, only where they can't be avoided
<bk_> alas i keep running into "Warning this blabla should have type unit" all over
buggs has quit [Read error: 54 (Connection reset by peer)]
buggs has joined #ocaml
<bk_> ok i'm done for today
<bk_> l8r
<Maddas> omg
<Maddas> functional programming kicks ass :-)
<Maddas> Although I think it's easiest to use a bit of imperative programming mixed in in most cases
<srv> Maddas: looks like you've just seen the light :)
<Smerdyakov> Maddas, like?
<Maddas> Thinking about it, especially one application I have should be majorly rewritten
<Maddas> It makes heavy use of things which should be done in a functional way :)
<Maddas> Smerdyakov: a bit imperative stuff can often be helpful for the program flow
<Maddas> I guess :)
<Maddas> although O'Caml so far still seems more imperative to me ;-)
<Maddas> Not much in common with Scheme :]
<Maddas> Hm
<Maddas> srv: I think the book doesn't describe "in" :/
docelic has quit ["Client Exiting"]
<Maddas> And I can't figure it out
<srv> Maddas: you mean the "in" keyword?
<Maddas> Yes
<bk_> http://www.cs.caltech.edu/courses/cs134/cs134b/book.pdf <- short but concise introduction to ocaml
<Maddas> Thanks
<bk_> you might want to look at it, Maddas
<Smerdyakov> Maddas, are you telling me that you don't know how to bind variables??
<Smerdyakov> Maddas, that would explain why you erroneously think OCaml is "more imperative"!
<Maddas> with "let"?
<Smerdyakov> Yes
<Maddas> Yes, that is functional
<Maddas> Smerdyakov: be patient, I'm still learning! Only started today morning :-)
<Smerdyakov> But you said you don't know something about "in"
<Smerdyakov> How can you know about "let" without "in"? :)
<Maddas> I don't know
<Maddas> I know "let" from Scheme :)
<Maddas> Thanks too, srv
<Maddas> oh
<Maddas> Missed that part :]
<srv> Maddas: no pb :)
<Maddas> hm, but still..
<Maddas> let rec sigma_rec x = if x = 0 then 0 else x + sigma_rec (x-1) in
<Maddas> if (x<0) then "error: negative argument"
<Maddas> I'm not sure about precedence here.
<Maddas> err, wait, I'll put the thing somewhere else on the web :)
<srv> Maddas: I always use the "index of concepts" and "index of language elements" pages (see the bottom of the book index)
<Maddas> I see
<Maddas> Should come handy :)
<Maddas> I'm not sure about this code fragment: http://nopaste.snit.ch:8000/487
<Maddas> Which "let" does the "in" refer to?
<srv> the 2nd one
<srv> the first "let" begins a function declaration, so there is no "in" associated to it
<Maddas> I see.
<srv> you can see the "=" as an "in" keyword for function declarations
<Maddas> Would that change if there weren't a newline after the first "let"?
<srv> nop
<Maddas> I see.
<Maddas> I'm sorry, in this case, I still don't understand the "in". I'll try harder
<srv> if (x<0) then "error: negative argument"
<srv> else "sigma = " ^ (string_of_int (sigma_rec x)) ;;
<srv> the code above is an expression
<Maddas> Yes.
<Maddas> But what part is "let" in that expression?
<srv> you have to define what "sigma_rec" is in that stuff
d-bug has joined #ocaml
<srv> uh I',m saying bullshits
<srv> let xl = 3 in xl * xl ;;
<srv> this is more simple
<Maddas> Sure, I've got no problem with that :)
<srv> " xl * xl" is an expression
<Maddas> that's similar to { int xl = 3; xl * xl }
<Maddas> the "in" determines the scope
<srv> here, let ... in enables you to define what is "xl" in that expression
<srv> exactly
<Maddas> Yes
<Maddas> but in the example, I don't get it
<Maddas> oh, wait.
<Maddas> I think I'm on the track :)
<srv> in your example, the stuff you have to define is a function
<srv> you define a function INSIDE another function
<d-bug> hi
<srv> d-bug: hi
CybeRDukE has joined #ocaml
<Maddas> yes.
<Maddas> I think I had problems with the precedence :)
<Maddas> I thought the "in" still belongs to the "else" clause
<srv> Maddas: your example shows one of the important stuffs: functions are variables, just like an int or a string
<srv> BRB
docelic has joined #ocaml
<d-bug> no, functions are values, not variables
two-face has joined #ocaml
<d-bug> that was a bad typo, srv
<d-bug> :)
<two-face> hi
<Maddas> :)
<Maddas> I understand that, I just got scope wrong :)
<Maddas> or however you call that
<Maddas> rhm
<Maddas> Does O'Caml have the Tail-Recursion optimisation thingy?
<d-bug> maddas: write something the compiler could tail-rec. opt and disassemble to see what it does.
<Maddas> Heh.
<Maddas> I'll stick to learning O'Caml then.
<d-bug> you can disasm with objdump
<srv> d-bug: sorry... ;)
<whee> Maddas: it does do tail recursion optimization
<Maddas> Ok
two-face has left #ocaml []
<Maddas> Heh.
<Maddas> Is it just me or is that example I pasted very abstract and complicated? :)
<Maddas> I understand it now, but I still find it very unobvious.
<Maddas> oh, wait, it's ok.
<Maddas> I think I REALLY understand it now :)
docelic has quit ["later"]
srv has quit [Remote closed the connection]
d-bug has quit ["brb"]
d-bug has joined #ocaml
systems has joined #ocaml
z|away has joined #ocaml
mattam_ has joined #ocaml
systems has quit ["Client Exiting"]
mattam has quit [Read error: 60 (Operation timed out)]
Vincenz has joined #ocaml
buggs|afk has joined #ocaml
bk_ has quit ["Terminated with extreme prejudice - dircproxy 1.0.5"]
buggs has quit [Connection timed out]
bk_ has joined #ocaml
Xcalibor has joined #ocaml
d-bug has left #ocaml []
<Maddas> anybody around?
<Vincenz> yes
<Vincenz> hehe, I meet you everywhere
<whee> Iheh
<Maddas> heh
<Maddas> I don't understand something again :)
<Maddas> What does List.tl list do?
<whee> tail of a list?
<Vincenz> tail
<Vincenz> afaik
<Maddas> oh.
<Maddas> This book sucks a bit ;)
<Maddas> Yes, I see
<Maddas> Thanks!
Vincenz has quit ["Watching a movie"]
<Maddas> sorry, I can't find info on this
<Maddas> compose?
<Maddas> :)
<Maddas> used in the book, not mentioned either with the example or in teh index.
<Maddas> the, even
srv has joined #ocaml
<Maddas> Hi there :)
<Maddas> Mind a quick question? It's not mentioned in the index :)
<whee> err, what compose function
<Maddas> well, this example uses it!
<Maddas> and it isn't defined befoer :)
<Maddas> before, even
<whee> got a link?
<Maddas> sure
<Maddas> it might be quicker to paste the code fragment :)
<Maddas> oh sorry
<Maddas> it was defined two chapters before! HOW COULD I HAVE MISSED THAT
<whee> heh
<Maddas> .)
<Maddas> It's not a useful function anyway, just use for confusing me
<Maddas> # let compose f g x = f (g x) ;;
<Maddas> :)
<whee> that's what I thought it might be :)
<Maddas> heh
<Maddas> it's bad to use functions defined long ago in a different subchapter :)
<Maddas> especially if they are small things you easily forget about
<Maddas> whee: mind looking at thissmall thing? I'm still confused :)
<bk_> you seem to enjoy chatting more than studying your books ;)
<whee> Maddas: sure
<Maddas> bk_: it's easier :)
<bk_> :>
<bk_> nm, i was only making fun of you
<Maddas> :)
<bk_> i'm new to ocaml myself, and i know what it does only i couldn't come up with a clear a concise explanation
<Maddas> well
<Maddas> I know what it does, but not why :)
<Maddas> compose is defined as:
<Maddas> # let compose f g x = f (g x) ;;
<whee> Maddas: okay, so what's the question
<Maddas> in the example though it says else compose f (iterate (n-1) f) ;;
<Maddas> Wouldn't compose only get 2 parameters that way?
<whee> it's being partially applied; look at the first branch of the if statement
<whee> the iterate function itself is returning a function
<Maddas> that returns function x -> x
<Maddas> the first branch
<whee> and the function it returns accepts one more argument for a complete evaluation
<whee> I think if you look at the type it'll make more sense
<whee> val iterate : int -> ('a -> 'a) -> 'a -> 'a = <fun>
<Maddas> Hm
<Maddas> so iterate returns 'a
<whee> n is the integer, f is a function from 'a to 'a, and then you have one more argument before the final result
<Maddas> Yes, I understand that
<Maddas> I don't understand where compose gets it's third argument from :)
<Maddas> I see two: f and whatever iterate returns
<Maddas> iterate only seems to return one value as you showed
<whee> okay; not all arguments to a function have to be in the first part before the =
<Maddas> Ah.
<whee> when you write let compose f g x = f (g x) it's really let compose = function f -> function g -> function x -> f (g x)
<whee> (I think, if I didn't screw that up :)
<Maddas> Yes, I understand that
<whee> so what ends up happening when you do "compose f (iterate (n-1) f)", you end up with everything being bound except that "function x" part
<Xcalibor> shouldn't it be function f -> function g -> 'a x ?
<Maddas> Oh, I see.
<Maddas> whee: so it doesn't matter?
<whee> so that evaluation returns that last function for further evaluation
<Maddas> Ah, ok.
<Maddas> Silly me :)
<Maddas> I assumed that compose must have three parameters
<Maddas> otherwise there would be a compiler error
<Maddas> I forgot that functions are first-class thingies :)
<whee> you can partially apply any function; there's some restrictions when you have labeled arguments, though
<whee> Xcalibor: I think that's right, the types match up and the interpreter accepts it :)
<Maddas> I see. Thanks :)
<Xcalibor> whee: :-)
<Maddas> Needs getting used to, I guess :)
<whee> Maddas: oftentimes people will structure function calls so the last argument is the one you're most likely to use in pattern matching
<whee> that way you can use function and jump right into the matching, instead of having a match block
<Maddas> I see
<whee> if you look at list.ml in ocaml/stdlib you'll see some examples of that, as well as in the other files
<Maddas> I should have payed more attention to the val iterate : int -> ('a -> 'a) -> 'a -> 'a = <fun>
<whee> length_aux is one example, right at the top
<whee> same with hd and tl
<Maddas> I didn't notice that the return value is a <fun> :){
<Maddas> I see :)
<Maddas> I'll need to get used to ocaml. It's very different than what I used so far :)
<Maddas> In a good way, though
<Xcalibor> :)
<Maddas> Ah, this makes much more sense seeing it in the context it's used in later on
<Xcalibor> mm... so length_aux takes 2 args but we only specify one before the = and the other one with the function?
<whee> yes
<Xcalibor> mmm... interesting... function is the same as fun, right?
<whee> yes and no
<whee> I don't know the details, but I think fun is more fun :)
<Xcalibor> lol
<Xcalibor> :)
<Maddas> HAH
buggs|afk is now known as buggs
<Maddas> pencil and paper helped me trace this :)
<bk_> hm
<bk_> # let rec b len ll =
<bk_> match ll with
<bk_> [] -> len
<bk_> | h::t -> b (len + 1) t;;
<bk_> this should do the same thing as length_aux, right
<bk_> only it introduces a 'match ... with'
<bk_> is one form preferable for any reason over the other ?
<Maddas> I WON'T EVEN TRY TO UNDERSTAND
<Maddas> :)
<Maddas> OCaml makes me feel stupid, everybody seems to understand it intuitively :)
<bk_> believe me, i'm not much further into the language than you are
<Maddas> Heh.
<Xcalibor> Maddas: yes, it's functionally the same code
<Xcalibor> dunno, either the length_aux way is faster or it was just the way Xavier or any other wrote it and it stuck around...
<Xcalibor> i mean, bk_ :-)
<Xcalibor> ok. it's easy, it just says that the length of a list is the number of elements it has :-)
<Xcalibor> [] -> len (initial len)
<Xcalibor> and then for each list, sum 1 for the head and take the tail and sum it's length... easy, right?
<z|away> [] -> len = initial len? It is the stop condition on the recursive.
<Maddas> heh, heh, heh, I'm not the only one who doesn't get it.
<Maddas> hello z|away by the way. :)
<z|away> hello.
<Xcalibor> hiyas there, z|away :)
<Smerdyakov> Hi all person!
<Xcalibor> z|away: it is, of course, but you alwawys have a x_0, or initial position from a mathematical point of view...
<Xcalibor> Smerdyakov: hiyas there :)
systems has joined #ocaml
<z|away> fun & function : http://caml.inria.fr/oreilly-book/html/book-ora015.html#@fonctions70
<Xcalibor> interesting
<bk_> i hardly ever use fun or function, mostly i use let ... =
<bk_> perhaps fun & function make more 'sense' when used to define anonymous funs
<Xcalibor> bk_: nod, but fun works like lambda in scheme or haskell, letting you gather several args in an anonymous function
<Xcalibor> bk_: there ... :)
<bk_> right
<Xcalibor> from stdlib/list.ml: let append = (@)
<Xcalibor> does this mean that the operator @ is the 'good one'?
<Xcalibor> i mean: [1;2] @ [3;4] -> [1;2;3;4] ...? curious...
<bk_> @ is mentioned in the docs about lists
<bk_> OR use List.append
<Xcalibor> indeed, List.append = (@)
<bk_> val append : 'a list -> 'a list -> 'a list
<Xcalibor> the weird thing is that the operator is defined first, instead of the function...
<bk_> Catenate two lists. Same function as the infix operator @. Not tail-recursive (length of the first argument). The @ operator is not tail-recursive either.
<Xcalibor> yup
systems has quit [Read error: 110 (Connection timed out)]
<Xcalibor> let rec for_all p = function
<Xcalibor> [] -> true
<Xcalibor> | a::l -> p a && for_all p l
<Xcalibor> this one looks like List.map ?
<Xcalibor> but it doesn't return the list...?
<bk_> nope for_all and map are different funcs on lists
<Xcalibor> yes but... for_all checks that p applied to all elements of list is true?
<bk_> yes
<Xcalibor> ah, cool :-)
<Xcalibor> another question: why many function definitions don't end with ;; while others do? i thought it was mandatory...
<bk_> ;; is not mandatory in compiled code afaik
<bk_> it is in the toplevel tho
<Xcalibor> ah
<Xcalibor> mm.. by compiled code you mean code in a module?
<Xcalibor> thanks :-)
<bk_> np
<Xcalibor> I gotta organize my bookmarks and index them or something :-)
<bk_> my explanation wasn't entirely corrent tho, doh
<Xcalibor> i cannot reach that site (?)
<bk_> ?
<bk_> it loaded kinda slow, but i can see it
<bk_> perhaps i should quick wget it before the server goes away or something
<z|away> Plug the URL into google, and read the cache of it.
bk_ has quit ["I'll be back"]
srv has quit [Remote closed the connection]
CybeRDukE has quit ["Documentation is like sex: when it is good, it is very, very good. And when it is bad, it is better than nothing."]
<Maddas> O'Caml is nice. Very nice.
buggs is now known as buggs|afk
cm has quit [Remote closed the connection]
cm has joined #ocaml
cm has quit [Remote closed the connection]
cm has joined #ocaml
Smerdyakov has quit [Read error: 104 (Connection reset by peer)]
cm has quit [Remote closed the connection]
Smerdyakov has joined #ocaml
cm has joined #ocaml
systems has joined #ocaml
eno has joined #ocaml
systems has quit [Read error: 60 (Operation timed out)]
z|away has left #ocaml []
<Xcalibor> Maddas: right you said :-)
<Xcalibor> well, gang, time for bed
<Xcalibor> laters
Xcalibor has quit ["Terminando cliente"]