mcclurmc has quit [Remote host closed the connection]
<boom583>
but ocaml looks like chinese to me
<boom583>
is it worth the learning curve?
<Drup>
yes, it is.
<boom583>
Drup: can you elaborate?
<Drup>
can you elaborate your question ? It's far too general for a precise answer
<boom583>
Drup: in what field do you use ocaml?
<Drup>
there is tons of article on why ocaml (and functionnal programming in general is good/interesting/better, so I'm not going to repeat those (because I would do it very badly ;))
snyp has joined #ocaml
<boom583>
ok
<Drup>
but if you have specific question, I can try to answer
<boom583>
Ok, for one, I have a hard time wrapping my head around functional programming. seems to use a diff part of the brain
<boom583>
is it hard to get used to?
<Drup>
you have to accept the fact that your previous programming knowledge will not be super useful for some time =)
<boom583>
Drup: what does ocaml allow you to do that other langs can't?
<companion_cube>
I'd say it's safe and expressive
<Drup>
ocaml has the advantage that you can do it in a progressive maner, since you can still use imperatif paradigme
<boom583>
Ok, but why would you say, in comparison, that C++ is *not* safe, expressive?
<boom583>
and why can't C++ do progressive manner?
<boom583>
(relative to Ocaml)
<boom583>
<-- don't know what "imperative" is yet
<Drup>
imperative is what you are used to already =)
<Drup>
sequence, for loops, all that stuff
<Drup>
boom583: a simple stupid example : there is no segfault in ocaml
<Drup>
the type system prevent them at compile time
<boom583>
hmok
<Drup>
there is far more than that, obviously, but that's a simple example of the "safety" part
<smondet>
boom583: You can also see it that way: C++ let's you do anything without checking whereas the OCaml compiler will make sure to catch as much mistakes as (automatically) possible. Since the human brain is essentially a mistake making machine, with OCaml you will be more productive by catching and fixing your errors earlier.
<boom583>
smondet: but c++ is also a statically typed lang, so what do you mean?
<boom583>
what other mistakes does ocaml catch? (other than segfaults)
<smondet>
Or, you can look at the experience: most software is written in c++/python or that kind shit, and software does not work, it's a disaster
<smondet>
OCaml lets you express much more safety properties in the types, and the type inference algorithm is basically trying to prove theorems on those types.
pminten has quit [Remote host closed the connection]
<smondet>
C++ "static" typing is a joke, too easy/tempting to work around
<boom583>
hm ok
<smondet>
and it is not even consistent with itself
mika1 has quit [Quit: Leaving.]
<Drup>
boom583: it's a bit complicated to explain it if you never actually touched those stuff, so I would advice to try it
<Drup>
boom583: you will learn stuff on the way on programming as a whole anyway
<boom583>
yeah
<Kakadu>
boom583: For example, you can have C++ enums in OCaml with optional variables attached to some enum members, and compiler can check if you have tested all possible cases in you `switch` statement (in OCaml it is`match` statement)
<Drup>
so it will be fruitful
<boom583>
Kakadu: cool
<boom583>
But the programming in OCaml stays Object-Oriented right? You make objects for your various things, as in C++?
<Drup>
boom583: no.
<Kakadu>
boom583: Type system has features what do not exactly exist in C++ type system, that's why we don't need objects in most cases
<smondet>
"objects": you can, and many beginners try it that way, it's not wrong by itself, OCaml's object system is 20 years ahead of Java/Scala, but in practice most Ocamlers drop objects
<boom583>
interesting. So if you want to represent a "Person", with "name" and "address", what do you do in OCaml?
<Drup>
boom583: a record
thomasga has joined #ocaml
<Drup>
boom583: which is a sort of struct
<Kakadu>
boom583: or a pair
<boom583>
but what replaces methods? just regular functions?
<boom583>
person1.eat()
<smondet>
the core ML typing + GADTS + polymorphic variants + modules is more 'functional' and fit better most problems
Arzaga has quit [Quit: Computer has gone to sleep.]
<Drup>
boom583: there is an object system in ocaml, but it's completly different from usual object systems and it's not the core part of ocaml
<boom583>
strange
<Drup>
boom583: and, tbh, as a beginner, you should ignore it
<smondet>
Person.eat person1 (actually in C++, person1.eat(args) is "compiled" to eat(person1, args) :) )
<Drup>
it's an advance feature use for specific purposes
<boom583>
hmm, ok. in other langs, beginners start with OO
Neros has joined #ocaml
<companion_cube>
smondet: not necessarily, you can't if it's dynamically dispatched
<Drup>
boom583: not all other langs, some of them =)
<companion_cube>
(ie virtual)
Kakadu has quit [Quit: Page closed]
<smondet>
companion_cube: yes if you need a for dynamic dispatch, then you can put the function in the record, or use objects, or define 'person' with a variant, etc.
snyp_ has joined #ocaml
<companion_cube>
yes
zpe has quit [Remote host closed the connection]
<boom583>
So, when did you guys break into Ocaml?
<boom583>
OCaml
<companion_cube>
a few years ago, in a lab :)
snyp is now known as Guest15622
snyp_ has quit [Client Quit]
Guest15622 has quit [Ping timeout: 248 seconds]
mcclurmc has joined #ocaml
snyp_ has joined #ocaml
snyp_ has quit [Client Quit]
snyp_ has joined #ocaml
snyp_ has quit [Client Quit]
<Drup>
during my studies :p
<smondet>
my 'introduction to (functional) programming class' was using caml-light (hiuh! more than 10 damn years ago :-/) then I used mostly only ocaml since 2006 (starting my phd)
<boom583>
cool
<Drup>
smondet: don't worry, 4 years ago, it was still this damn caml-light
snyp_ has joined #ocaml
<strobegen1>
boom583: I guess at first you would like to learn what it is the functional programming paradigm in general - and after will choose language for your needs - it's many languages here that has FP in some ways (not always with type system like Ocaml has & some of it's doesn't has OO complitly) - Ocaml, F#, Scala, Scheme, Clojure, Erlang, Haskell etc. but all of those has many advantage and disadvantages
<boom583>
which is the most popular now?
<Drup>
difficult to answer
<companion_cube>
depends on the application domain, I think
<boom583>
ok
<companion_cube>
(e.g. erlang is mostly used in telecoms)
<smondet>
F# & Scala are used in industries that have big legacy stuff running on .Net or the JVM
peterbb has quit [Ping timeout: 248 seconds]
<Drup>
And Clojure is from the Scheme family but runs on the JVM
<strobegen1>
Clojure - is close to better alternative for python&ruby domains - and according to count of #clojure users it's surprising popular
<boom583>
heh
<boom583>
so why did jane street pick ocaml instead of the others
<boom583>
haskell say
<smondet>
I've also noticed that microsoft-biased C++/C# programmers tend to associate language and IDE tightly so F# will sound easier to them because of visual studio.
<companion_cube>
boom583: maybe to retain more control on the execution of their programs
<jpdeplaix>
boom583: for performances
<boom583>
companion_cube: how so?
<companion_cube>
well, haskell is lazy and has lazy IO, which can be quite tricky
<boom583>
yes i've heard ocaml can get c++ speeds
<companion_cube>
in ocaml, how and when the code is executed, is relatively easy to predict given the source code
<smondet>
and also janestreet values code readability *a lot*, and haskellers tend to like unreadable code (they use type-classes to indroduce tons crazy operators)
<Drup>
smondet: crazy operators and type-classes are only colloquially related :p
<smondet>
'OCaml from the very beginning' got well reviewed by people around here, but I did not read it
ontologiae has joined #ocaml
<boom583>
ok
<boom583>
thanks
<smondet>
I went through a beta-version of 'Real World OCaml', like Drup say, a lot for choices are taken there, but some explanations are very good
<smondet>
(especially about ocaml internals, c bindings, etc)
ttamttam has joined #ocaml
<avsm>
That's the thing about the real world. You gotta make choices :)
<companion_cube>
it's a bit too JaneStreet flavored imho, but that's fine
<Drup>
avsm: it doesn't justify the fact that you don't specify explicitely when you are using syntax extensions
<boom583>
Do these books explain well not just the HOW but also the WHYs? That is, why functional programming instead of OO programming? Why OCaml?!
<companion_cube>
boom583: functional programming is at least as old as OO
Kakadu has joined #ocaml
<adrien>
avsm: don't take it badly however; it's mostly that it turns out that some people get confused when they don't have these syntax extensions or auto-opens
<companion_cube>
and besides, many arguments why exist
<Drup>
avsm: that's not "real world" at all, on the contrary. Those syntax extensions just confuse beginners when they are not available anymore.
<adrien>
I don't think I would have foreseen that
<companion_cube>
for instance, safer, more modular...
<avsm>
hang on, we do point out when we use syntax extensions in most cases
<avsm>
some may have been lost in the editing shuffle, but I'm happy to fix those in a future rev
osa1 has quit [Read error: Operation timed out]
<avsm>
And the extensions we use are really essential for beginners, Drup. OCaml is close to unusable without type_conv, for instance
<Drup>
is it ? I never used it and I don't mind :|
sepp2k has quit [Quit: Konversation terminated!]
* avsm
shrugs
<avsm>
every single large ocaml codebase I've worked on has used type_conv quite a bit
<adrien>
I agree that for some tasks it can be quite annoying to not have something like it
manizzle has quit [Ping timeout: 272 seconds]
<avsm>
as I said, we made a choice to just write about what we use day-to-day, not to explain every last possibility
zpe has joined #ocaml
<companion_cube>
I'm not sure Coq uses type_conv
<avsm>
i yanked an entire chapter on Lwt as it was too confusing to explain how it fits along Core
<companion_cube>
(nor ocamlc, of course)
<Drup>
avsm: we have seen lot's of beginners here completely confused because they are trying to use some core example and they can't make it work in their repl, too, but that's not really your fault :/
<Kakadu>
Does xcp-xapi uses type-conv?
<avsm>
indeed, many people fail to read the utop instructions
yastero has joined #ocaml
<avsm>
it does, along with several other extensions like module_conv for RPC support
<avsm>
no worries, I've almost got js_of_ocaml + Core working. problem solved shortly via online REPLs
<companion_cube>
most of the OCaml code I read/write does not use type_conv, but well, I don't have much serialization to do ^^
<avsm>
i did a hunt through opam+docker to get a rough idea how popular each p4 extension was
hnrgrgr_ is now known as hnrgrgr
<boom583>
companion_cube: interesting. wasn't really aware of that...
ontologiae has quit [Ping timeout: 260 seconds]
<boom583>
for some reasons, i've only ever come across OO
<boom583>
imperative and OO. that's the only thing i got to know
<Drup>
boom583: don't worry, you are not the only one.
<boom583>
strange
ollehar has joined #ocaml
ocp has quit [Ping timeout: 260 seconds]
<jpdeplaix>
« OCaml is close to unusable without type_conv, for instance »
* jpdeplaix
suffocate
shinnya has quit [Ping timeout: 260 seconds]
<Drup>
jpdeplaix: yeah, I didn't want to unleash a troll fest, but ... :/
<jpdeplaix>
Drup: the metal band ? :D
<avsm>
you don't think that generic printers are useful?
<Drup>
avsm: oh, it is
<avsm>
or deriving-ocsigen, take your pick
<jpdeplaix>
but we can live pretty well without it
<Drup>
avsm: I just think that this sentence is a incredibly huge overstatement.
<companion_cube>
jpdeplaix: :D
<avsm>
Not really. Standards for serialization are important on large codebases.
<companion_cube>
not all code bases need to serialize many things
<companion_cube>
(even big ones, see Coq)
<avsm>
Noone really wants to depend on camlp4, but it has provided us with a decade of experimenting with syntax extensions, and type_conv hit a sweet spot of performance vs complexity that has survived pretty well
<avsm>
sure, but even a compiler really benefits.
<avsm>
i.e. for debugging something
<companion_cube>
oh, for printing
<companion_cube>
I find that combining printing functions by hand is quite doable
<companion_cube>
serialization is harder
<avsm>
Pretty much every syntax extension in Core and Xapi were added after careful thought about all the alternatives being worse
<avsm>
some (e.g. pa_pipebang) have now been fixed upstream and aren't needed any more
<Drup>
avsm: You can accuse me not to work on large codebase, it would be true. But no, I don't really huge polymorphic printer.
<Drup>
use*
peterbb has joined #ocaml
<avsm>
then don't add 'with sexp' to your code. Quite easy
<rks`>
avsm: i'm curious about your "stats" regarding the use of syntax extension in opam packages
<Drup>
avsm: that's not the issue I pointed on the beginning of this conversation.
<rks`>
thank you!
<companion_cube>
wow, a script on github
boogie has quit [Read error: Connection reset by peer]
<companion_cube>
I'm envious of how meticulous you are :D
<avsm>
it's just a swap service for my limited brain ;-)
<jpdeplaix>
I agree its useful for serialization (deriving-ocsigen is used almost exclusively for this purpose) and maybe for debugging (but I never used it), but otherwise I don't see (for now) any use-cases for this
<companion_cube>
the code is nice
<avsm>
jpdeplaix: fieldlib and variantslib to manipulate them as firstclass values
<avsm>
orm for sql generators (opam install orm)
<avsm>
dyntype for web forms
<avsm>
it's generally just a handy extension to have around
<strobegen>
- may be it will help learn FP in some ways
<Drup>
looking at it, I think it would confuse him more than anything else x)
<companion_cube>
is there patterm matching inside named arguments ?
ontologiae has joined #ocaml
dant3 has quit [Remote host closed the connection]
<boom583>
Drup: yeah i think so too lol
<boom583>
i'll just look into ocaml
<strobegen>
Drup: yes it can confusing, but when I heard about FP languages at first time I don't understand that FP is not related to specific languages/compilers, and I guess this scary examples in already know language can help to select that is pure concepts is
<ggole>
companion_cube: yep
<ggole>
let test ~foo:(a, b) = a
<companion_cube>
yes, I found, thanks
<companion_cube>
weird that I never used that before
<ggole>
It's pretty marginal, really...
<companion_cube>
I just used it for deconstructing tuples, the same way
<ggole>
Bit strange that ~foo:int and ~(foo:int) mean different things though
<companion_cube>
right
<companion_cube>
one is a type annotation and the other, a pattern match...
<ggole>
And you can do let test ~foo:int:int = int O_o
<ggole>
Bit of a corner case there, I suppose
thomasga1 has quit [Quit: Leaving.]
<companion_cube>
:D
<companion_cube>
well, it's nice being able to name variables "int" sometimes
ontologiae has quit [Ping timeout: 246 seconds]
<ggole>
That's fine, it's more the two colons
boom583 has quit [Quit: boom583]
Xenasis has joined #ocaml
Xenasis has quit [Remote host closed the connection]
jao has joined #ocaml
jao has quit [Changing host]
jao has joined #ocaml
Neros_ has quit [Ping timeout: 248 seconds]
osa1 has joined #ocaml
dant3 has joined #ocaml
thomasga has joined #ocaml
zpe has quit [Remote host closed the connection]
nikki93 has joined #ocaml
avsm has quit [Quit: Leaving.]
avsm has joined #ocaml
AltGr has left #ocaml []
manizzle has joined #ocaml
thomasga has quit [Ping timeout: 246 seconds]
avsm has quit [Ping timeout: 245 seconds]
rand000 has joined #ocaml
rand000 has quit [Client Quit]
rand000 has joined #ocaml
Neros has joined #ocaml
dsheets has quit [Read error: Operation timed out]
ollehar1 has joined #ocaml
mcclurmc has quit [Remote host closed the connection]
thomasga has joined #ocaml
mcclurmc has joined #ocaml
thomasga has quit [Client Quit]
manizzle has quit [Remote host closed the connection]
manizzle has joined #ocaml
peterbb has quit [Ping timeout: 252 seconds]
ontologiae has joined #ocaml
ttamttam has quit [Quit: ttamttam]
ggole has quit []
mcclurmc has quit [Remote host closed the connection]
ulfdoz has joined #ocaml
dsheets has joined #ocaml
zpe has joined #ocaml
skchrko has quit [Quit: Leaving]
mcclurmc has joined #ocaml
nikki93 has quit [Remote host closed the connection]
tane has quit [Quit: Verlassend]
nikki93 has joined #ocaml
avsm has joined #ocaml
pkrnj has joined #ocaml
nikki93 has quit []
Kakadu has quit []
malvarez has joined #ocaml
peterbb has joined #ocaml
hellome has quit [Read error: Connection reset by peer]
Rc43_ has quit [*.net *.split]
hellome has joined #ocaml
dant3 has quit [Remote host closed the connection]
ttamttam has joined #ocaml
ttamttam has quit [Client Quit]
ulfdoz has quit [Ping timeout: 245 seconds]
manud_ has joined #ocaml
manud has quit [Read error: Connection reset by peer]
manud_ is now known as manud
ollehar has quit [Ping timeout: 272 seconds]
hellome has quit [Remote host closed the connection]
hellome has joined #ocaml
pango has quit [Ping timeout: 272 seconds]
avsm has quit [Quit: Leaving.]
avsm has joined #ocaml
ulfdoz has joined #ocaml
pango has joined #ocaml
nikki93 has joined #ocaml
hellome has quit [Remote host closed the connection]
hellome has joined #ocaml
ollehar has joined #ocaml
<malvarez>
Is there any OCaml language extension that would allow me to write lisp-style macros?
<malvarez>
If not, would it be possible to write such a beast?
<companion_cube>
camlp4 allows to write syntax extensions
<companion_cube>
but it probably isn't as powerful as lisp macros
<companion_cube>
(nor as convenient)
<patojo>
malvarez: Look into camlp4 or metaocaml
<malvarez>
patojo: never touched metaocaml, but I always found camlp4 to be too cumbersome for some things