<tactics_>
random curiosity. What kind of compiler optimizations does Ocaml employ to acheive its legendary speed?
diego_diego has joined #ocaml
diego_diego has quit [Client Quit]
<thelema>
tactics_: the main source of ocaml's speed is a good match between the operations it performs and the low level implementation
<tactics_>
hm
<thelema>
tactics_: i.e. the performance isn't a matter of optimizing the code that's given to the compiler, but by having very good implementations of the primitives given to the user
<thelema>
The ocaml compiler does very little rewriting of the code.
<tactics_>
That sounds very much the opposite of Haskell
Guest76193 is now known as dnm
ski has joined #ocaml
<thelema>
tactics_: very possibly.
Progster has quit [Ping timeout: 246 seconds]
<tactics_>
Is it possible to define inline operators in Ocaml?
<tactics_>
I remember reading somewhere it was possible, but that the rules are much tighter than Haskell
<_habnabit>
what's an inline operator
<tactics_>
x <*> y
<tactics_>
x ** y
<tactics_>
Those kinds of things
<_habnabit>
let (<*>) x y = x + y in x <*> y
<tactics_>
Yes, those
<tactics_>
What are the syntax rules in Ocaml for those things :)
sepp2k1 has quit [Remote host closed the connection]
tactics_ has quit [Read error: Connection reset by peer]
tactics_ has joined #ocaml
ankit9 has joined #ocaml
Hussaind has joined #ocaml
Hussaind has left #ocaml []
Hussaind has joined #ocaml
Hussaind has left #ocaml []
mjonsson has quit [Remote host closed the connection]
<flux>
basically: 1) an operator is composed of operator characters 2) the precedency is determined by the first character
<flux>
for more details there's a section on the language definition in the manual :)
Framedragger has quit [Ping timeout: 244 seconds]
tactics_ has quit [Read error: Connection reset by peer]
munga has joined #ocaml
yezariaely has quit [Ping timeout: 260 seconds]
Xizor has joined #ocaml
ankit9 has quit [Quit: Leaving]
Framedragger has joined #ocaml
Hussaind has joined #ocaml
Hussaind has left #ocaml []
ftrvxmtrx has quit [Quit: Leaving]
pango is now known as pangoafk
ankit9 has joined #ocaml
djcoin has joined #ocaml
eni has joined #ocaml
Xizor has quit [Ping timeout: 260 seconds]
edwin has joined #ocaml
silver has joined #ocaml
eni has quit [Ping timeout: 248 seconds]
cago has joined #ocaml
mika1 has joined #ocaml
eni has joined #ocaml
eni has quit [Ping timeout: 244 seconds]
ftrvxmtrx has joined #ocaml
Sablier has joined #ocaml
avsm has joined #ocaml
Kakadu has joined #ocaml
Submarine has quit [Quit: Leaving]
yezariaely has joined #ocaml
Kakadu has quit [Ping timeout: 245 seconds]
eni has joined #ocaml
avsm has quit [Quit: Leaving.]
thomasga has joined #ocaml
osa1 has quit [Ping timeout: 244 seconds]
Yoric has joined #ocaml
Progster has joined #ocaml
caligula has quit [Remote host closed the connection]
Kakadu has joined #ocaml
caligula has joined #ocaml
<Kakadu>
hi all!
<Kakadu>
where can I read which cmi format use different version of OCaml?
<rixed>
Kakadu: are you looking for ocamlobjinfo?
<Kakadu>
rixed: I think not
<Kakadu>
I want to OCaml for android
<Kakadu>
4.00+dev17 generates CMI version 013
<Kakadu>
3.12.1 ---- 012
<Kakadu>
4.0b2 --- 0.14
<rixed>
Kakadu: isn't it the last number in the magic identifier string?
<gnuvince>
ocamlfind: When using -syntax, the META variable 'preprocessor' must be set
<adrien>
is there a package "js_of_ocaml.syntax"?
<AndreaGot>
i need help for a ocaml function
<AndreaGot>
in today's exam of functional programming
<AndreaGot>
the teacher asked us to write an ocaml function
<AndreaGot>
that make a list of all the paths in a tree
<AndreaGot>
i wrote this
<AndreaGot>
let path t = match t with Empty -> [[]] | Tr(x,Empty,Empty) -> [x] | Tr(x,l,r) -> (x::path l) :: (x::path r) :: [[]];;
<AndreaGot>
but it says that x is an 'a list
<mrvn>
error 1: missing "rec"
<AndreaGot>
ok sorry i wrote rec
<pippijn>
I prefer spaces around ::
<pippijn>
because x::path looks like it belongs together while it doesn't
<AndreaGot>
and the last [[]] is simply []
<AndreaGot>
ok
<mrvn>
the first too
<pippijn>
and you could write this as [x :: path l; x :: path r]
<mrvn>
don't you mean (x::path l) @ (x::path r)?
<AndreaGot>
i wanted to make an int list list
<pippijn>
he's building lists of lists
<AndreaGot>
from a tree
<AndreaGot>
to an int list list, every path has a list
<AndreaGot>
but the problem is x
<mrvn>
then x :: path l does not make sense
<AndreaGot>
why not?
<pippijn>
right.. it doesn't make sense
<mrvn>
because path returns an int list list. You prepent x, which therfore mut be an int list. And then you return an int list list list
<AndreaGot>
wait
<mrvn>
so every level of your tree increases the number of lists you stack inside each other
<AndreaGot>
the [[]] are wrong
<AndreaGot>
i wrote a []
<gnuvince>
adrien: I just copied the command from js_of_ocaml's website.
silver has quit [Remote host closed the connection]
<pippijn>
adrien: I updated the ircd
<mrvn>
AndreaGot: You can't use x :: path ..., path returns a list of all paths in the subtree. you need to prepend x to each of those paths.
<pippijn>
finally, you should be using an accumulator
<mrvn>
let rec path = function Empty -> [] | Tr(x,l,r) -> List.map (fun y -> x::y) ((path l) @ (path r))
Sablier has quit [Read error: Connection reset by peer]
<AndreaGot>
ok
<AndreaGot>
thanks
<mrvn>
or let path t = let rec loop acc path = function Empty -> (List.rev path)::acc | Tr(x,l,r) -> let path = x::path in let acc = loop acc path l in loop acc path r in loop [] [] t
<AndreaGot>
at university we didn't study loop :D
<AndreaGot>
and the exam was without a compiler
<mrvn>
actually switch the l and r around in the last one to get inorder traversal instead of reverse inorder
<mrvn>
AndreaGot: loop is just a name
<AndreaGot>
oh sorry
<AndreaGot>
btw we used only a sheet and a pen
<AndreaGot>
it was hard for us to tkink about such kind of function :D
<mrvn>
AndreaGot: unless asked to make it tail recursive you would want to write the first one.
<AndreaGot>
i didn't think about List.map
<AndreaGot>
the answer was right how you wrote it
<pippijn>
mrvn: I generally try to make things tail recursive
<AndreaGot>
on a computer is easier :D
<mrvn>
pippijn: in an exam where you can't test th code?
<pippijn>
maybe not in an exam :)
<AndreaGot>
we had 5 exercises to do in only one hour
<AndreaGot>
type of functions
<AndreaGot>
say what functions do
<tac-tics>
AndreaGot: Are you doing CS in school?
<mrvn>
how many where finished in half the time?
<AndreaGot>
exactly
<AndreaGot>
no one finished all the test
<mrvn>
where have all the natural programmers gone?
<AndreaGot>
only 4 or 5 of us (on 160) mad the last function (the one i was asking about)
<tac-tics>
mrvn: They're hitting up Ruby on Rails and making money
<mrvn>
AndreaGot: Well, you saw me writing 2 answeres there in a minute.
<AndreaGot>
ok, but do u use ocaml at work?
<mrvn>
AndreaGot: I've used ocaml for a while. But sometimes you have people in class that have done that too.
<AndreaGot>
on February we didn't even know what OCaml was
<AndreaGot>
we had 3 months to learn all functions
<AndreaGot>
and that was not so easy to write, cause it was the last exercise and we had only 5 or 6 minutes to write it
<lin>
I hope I had OCaml courses in school
<lin>
it
<mrvn>
you hope? Can't you remember?
<mrvn>
or do you wish?
<lin>
I just took C/C++ classes in my freshman year
<AndreaGot>
it's my freshman year too
emmanuelux has joined #ocaml
<AndreaGot>
and i took C++, Java and OCaml
<pippijn>
I wish my uni had ocaml courses
<AndreaGot>
but italian courses are a little differend
<pippijn>
java and C++ :(
<lin>
I majored in electronic engineering , btw
<pippijn>
but it's ok, I write ocaml in java now
tmaedaZ has quit [Ping timeout: 252 seconds]
<pippijn>
with only public finals :)
<AndreaGot>
studying ocaml and java almost at the same time is difficult
<AndreaGot>
cause you write blocks of code even in ocaml "then" branch :D
<Hodapp>
ew, C++
<Hodapp>
ew, Java
<AndreaGot>
i made Java exam on Tuesday, and Ocaml today
<AndreaGot>
Honestly i don't get the utility of Ocaml
<AndreaGot>
When can ocaml be useful?
<mrvn>
when can't it?
<AndreaGot>
Java, or even C++, it's easier than ocaml
<AndreaGot>
are*
<mrvn>
AndreaGot: that is just your lack of experience
<Kakadu_>
after OCaml tutorial I promised never write Java code which doesn't fits a screen
<AndreaGot>
probably
tac-tics has quit [Ping timeout: 245 seconds]
<lin>
the question of AndreaGot are often asked by people
Progster has quit [Ping timeout: 245 seconds]
tmaedaZ has joined #ocaml
<AndreaGot>
maybe in next exams i'll see that ocaml was useful
<mrvn>
hardly. you need real world experience
<Kakadu_>
mrvn: +1
<lin>
IMHO, it's a lack of popularity of OCaml, but not a lack of capability of the language itself
<AndreaGot>
i am not saying that the language itself lacks of something
<djcoin>
Tools (eg: package manager) and optimization ?
<AndreaGot>
but i find it more difficult to think in ocaml way than OOP way
<Kakadu_>
vice versa
<mrvn>
then programm oop in ocaml
<AndreaGot>
(even because in high school i made only VB.net programs
<AndreaGot>
is ocaml even OOP?
<Kakadu_>
yep
<Kakadu_>
duck-typing OOP
<lin>
that's where the 'O' came from
<lin>
i guess
<mrvn>
oop is a state of mind. But ocaml also has classes
<AndreaGot>
we studied less than 10% of ocaml i think
<AndreaGot>
and the exam itself is worth less than c++ and java
<AndreaGot>
cfu speaking
<lin>
In cornell's ocaml course, they say "In fact, OCaml does support objects, but we will focus more on other aspects of the language"
<thelema>
Kakadu_: static duck typing, to be more specific.
<Kakadu_>
thelema: sure
<Hodapp>
classes and OOP are kind of orthogonal.
<AndreaGot>
our course wanted to introduce ourselves to functional programming
<mrvn>
Hodapp: not really. OOP is a state of mind. you can do it in assembler if you like or scheme.
<Kakadu_>
Hodapp: If you're talking about type classes than yes :D
<AndreaGot>
it isn't a complete sourse on ocaml
<AndreaGot>
it didn't want to be
<mrvn>
AndreaGot: I don't think there are any courses that go into the classes in ocaml. Ocaml is normaly picked for its functional parts.
<AndreaGot>
even if there are easier languages to use for talking about classes
<AndreaGot>
like Java, since we made c++ 6 months ago
<mrvn>
Type inference with classes is kind of screwy and you get really hard to understand type errors if you've never seen them before. So C++ or Java is certainly the better choice to introduce OOP.
<mrvn>
AndreaGot: did you get into templates, generics or functors?
<Hodapp>
mrvn: I don't see how this is "not really".
<AndreaGot>
no
<AndreaGot>
we didn't even made hashtables
<Hodapp>
Kakadu_: At no point in Alan Kay's definition of OOP was 'class' central to it.
<mrvn>
Hodapp: you don't need classes to write OOP and you can write non OOP code with classes.
<Hodapp>
mrvn: yes, that's basically what I said.
<mrvn>
If OOP would require classes it would be just OP.
<Hodapp>
mrvn: Did you not see where I wrote 'orthogonal'?
<pippijn>
the inventor of OOP actually meant message oriented programming
<mrvn>
Hodapp: yes. :(
<Hodapp>
mrvn: hah, I see :P
<Hodapp>
pippijn: well, he did regret later that he called it OBJECT-oriented because he felt like people totally ignored the messaging when that was of equal importance.
<pippijn>
Hodapp: yep
<pippijn>
that's what I mean
<Hodapp>
I feel like OOP in C++ and Java ends up as kind of a bastardization though.
<mrvn>
yeah, no message passing there
<Hodapp>
"OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. It can be done in Smalltalk and in LISP. There are possibly other systems in which this is possible, but I'm not aware of them."
phao has quit [Read error: Connection reset by peer]
<Hodapp>
that's Kay from 2003
<AndreaGot>
messaging = delegation?
<Kakadu_>
AndreaGot: messaging like smalltalk and ObjectiveC
<Hodapp>
now, OCaml doesn't do dynamic dispatch (as Scala does), does it?
sgnb has quit [Read error: Connection reset by peer]
sgnb has joined #ocaml
<companion_cube>
if OOP is messaging, the only OO language I know about is erlang...
<mrvn>
Hodapp: easy enough to do yourself
beckerb has quit [Quit: Konversation terminated!]
Progster has joined #ocaml
AndreaGot has quit [Quit: Page closed]
lin has quit [Remote host closed the connection]
Yoric has quit [Ping timeout: 244 seconds]
phao has joined #ocaml
rawtatoor has joined #ocaml
rawtatoor has left #ocaml []
sgnb has quit [Read error: Connection reset by peer]
sgnb has joined #ocaml
<Hodapp>
companion_cube: well, a lot of things can qualify as messaging, I think
<Hodapp>
companion_cube: and there's also Smalltalk, of course.
<companion_cube>
well, I mean, it feels like a call is not really a message to me
<companion_cube>
whereas in erlang, you really have entities that communicate through messages
<Hodapp>
what's a good working definition of a message though?
<companion_cube>
it's a matter of feeling, here, but for me message-passing is an asynchronous concept
<companion_cube>
of course, smalltalk guys will disagree
<mrvn>
so send closures
djcoin has quit [Quit: WeeChat 0.3.2]
<Hodapp>
companion_cube: I would just like to get a real idea what Alan Kay meant so that a more descriptive term can be put there
<Hodapp>
Wikipedia: "Message passing model based programming languages typically define messaging as the (usually asynchronous) sending (usually by copy) of a data item to a communication endpoint (Actor, process, thread, socket, etc.)."
<Hodapp>
so not automatically async
Sablier has joined #ocaml
<wmeyer>
ssbr: I am considering inclusion of Datalog
phao has left #ocaml []
Kakadu has quit [Ping timeout: 245 seconds]
Xizor has joined #ocaml
Progster has quit [Ping timeout: 240 seconds]
Xizor has quit []
Progster has joined #ocaml
<orbitz>
I'm reading the Garbage Colleciton Handbook, so far quite good. I haven't hit any of the really technical stuff yet
<bitbckt>
it's the only book I keep next to my monitor...
<bitbckt>
but it's also what I do. hah.
<orbitz>
Professionally or school?
<bitbckt>
professionally.
<orbitz>
Cool. One of the big platforms or something else?
<bitbckt>
Hotspot.
<orbitz>
Awesome
<orbitz>
Do you work with/under Jesper Wilhelmsson?
<bitbckt>
No. I don't.
<orbitz>
I saw a talk he did, I think he said he is Team Lead on the HotSpot JVM, are there a bunch of teams owrking on JVM?
<bitbckt>
yes. and several companies.
<orbitz>
Cool. What do you work on in GC?
tmaedaZ has quit [Ping timeout: 265 seconds]
<bitbckt>
I work on Twitter's Hotspot fork.
<bitbckt>
mostly performance-related work in the GC.
<orbitz>
Cool
<bitbckt>
some of which filter back out to Oracle.
<orbitz>
I want to builda really simpel language with a cheesey GC for kicks
<bitbckt>
a simple mark/sweep with freelist allocation is a good start.
tmaedaZ has joined #ocaml
<orbitz>
Yeah, sounds like fun
<orbitz>
Does HotSpot do any sort of region/escape analysis?
<bitbckt>
yes, in it's "server" compiler.
<bitbckt>
its*
<orbitz>
Any idea how useful it is?
<bitbckt>
very. it can elide write barriers based on that analysis.
<orbitz>
interestign
<bitbckt>
at least, that's how it affects me :)
<orbitz>
Does HotSpot do any stack allocations if it can prove it safe?
<bitbckt>
yes.
<bitbckt>
significant amounts.
<orbitz>
Any knowledge on how it compares to .NET?
<bitbckt>
in fact, it's entire locking infrastructure defaults to stack allocated, and inflates to heap monitors only when necessary.
<bitbckt>
I'm only marginally familiary with the CLR. My coworkers from MSFT know better.
<orbitz>
Does HotSpot have ot do a check every dereference to test if a pointer has been moved during compaction?
<bitbckt>
that depends upon the specific collector, but in general, no.
<orbitz>
Is tehre a one sentence description as to why that is the case? An compaction can happen at any time, no?
<bitbckt>
because compaction happens with all mutators stopped; it's atomic from their perspective.
<orbitz>
So teh GC keeps references back to every user of a reference and changes it during the compaction?
<bitbckt>
right.
<orbitz>
Godo to know
<bitbckt>
it becomes slightly more complex with weak/soft/phantom references, but you'll get to that in the book ;-)
<orbitz>
Have you ead teh VCGC paper (Very Concurrent Garbage Collector)? jdh always talks about it on twitter, how easy it is toi mplement and how HLVM has it
<bitbckt>
heh. no, I haven't read that paper.
<bitbckt>
I don't subscribe to any of Harrop's journals.
<orbitz>
Paper is quite short, no idea if the authors of full of themselves or if harrop is bs'ing the paper
<bitbckt>
I'll give it a read.
<orbitz>
Thanks
<orbitz>
Thanks for the answers, much appreciated!
<bitbckt>
no problem.
<bitbckt>
I enjoy this stuff, or I wouldn't do it.
<orbitz>
Yeah, it's pretty fascinating. Do you know of any good research going on in putting more resources under automatic collection?
Submarine has joined #ocaml
<bitbckt>
more resources?
<orbitz>
Like files
<orbitz>
sockets
<orbitz>
One argument from C++ peeps is that every resources fits under RAII, which is, in some ways, kind of nice
<bitbckt>
ah.
<bitbckt>
well, the "GC guy's" answer to that is finalizers.
<bitbckt>
that isn't really a complete answer, though.
<orbitz>
It seems like kind of an impedience mismatch though, usually you want soem guarantee of files closing
<bitbckt>
most non-regional management strategies have "eventually" in their semantics, somewhere.
<bitbckt>
I don't know of any ongoing research in generalized resource management, though.
<bitbckt>
the finalization strategy, for instance, says that "eventually" the finalizer will be invoked.
<bitbckt>
but it will be tied to another resource - memory utilization.
<orbitz>
Yeah
<bitbckt>
I can't think of any options that _don't_ work either "eventually" or are regional, like RAII.
<bitbckt>
and they are also each tied to an independent resource - execution context or memory utilization.
<bitbckt>
I guess I'm no help, here.
* bitbckt
shrugs
<orbitz>
no biggie, didn't seem like a top priority in the GC world
<orbitz>
Off to shower, tahnks bitbckt
<bitbckt>
np
BiDOrD_ has quit [Ping timeout: 265 seconds]
BiDOrD has joined #ocaml
Yoric has joined #ocaml
<bitbckt>
orbitz: good paper. it's interesting how similar it is to Detlefs and Printezis "mostly-concurrent" collector, yet neither reference the other.
ftrvxmtrx has joined #ocaml
lusory has quit [Ping timeout: 252 seconds]
Anarchos has joined #ocaml
Tobu has quit [Remote host closed the connection]
Tobu has joined #ocaml
Tobu_ has joined #ocaml
Tobu has quit [Ping timeout: 272 seconds]
BiDOrD has quit [Ping timeout: 246 seconds]
<mrvn>
There is no reason you can't close a file with a command and also have the GC close it on free if you forget (and warn about it).
<Anarchos>
mrvn hmmm the gc only task is to get memory back to you, not to reclaim resources to the OS....
<mrvn>
Anarchos: says who?
<mrvn>
The GC decides which values are reachable.
<thelema>
mrvn: but only when it wants to.
<mrvn>
If an open file descriptor becomes unreachable then you have obviously done something wrong. So it should detect that, close the FD and warn about the program error.
<Anarchos>
mrvn if you don't close a file descriptor, it must stay available for future uses, so the GC won't close it for you
<mrvn>
Anarchos: how are you supposed to use it if it isn't reachable? You can never ever use it again.
Tobu_ has quit [Read error: Connection reset by peer]
<Anarchos>
mrvn no idea, i had not done system programming in ocaml for months
Tobu has joined #ocaml
<thelema>
file descriptors are just ints, the idea of one becoming unreachable...
<mrvn>
thelema: That the kernels FDs are ints is an implementation detail. The ocaml FD doesn't have to be a plain int. And input / output channels certainly aren't.
<Anarchos>
mrvn maybe they could be finalized blocks inside ocaml, with closure of FD inside teh finalization fucntion ?
<mrvn>
Anarchos: except they are now called custom blocks.
<thelema>
mrvn: sure, the issue is that some data structures are actual data structures and others are handles to parts of data structures managed elsewhere, and by default, destroying a handle shouldn't call the destroy function (close) on the target of that handle.
tmaedaZ has quit [Ping timeout: 246 seconds]
<thelema>
You can add a finalizer to your ocaml FDs to do what you want. If you're saying that should be the default... maybe not.
<mrvn>
thelema: It should if it is the last handle for the resource.
<mrvn>
And having to manually add a finalizer to every FD is error prone.
<thelema>
mrvn: which requires knowing things that the GC doesn't know.
<thelema>
let my_open = ...
<mrvn>
thelema: The GC already knows about reachability, which is eaxtly this.
<thelema>
not for data structures that are outside its domain.
<thelema>
which includes FDs
<thelema>
and other kernel-managed resources
<mrvn>
thelema: yes it does. You already do this with memory that isn't allocated in the GC heap like Bigarrays or any memory you share with C code.
<mrvn>
The wrapper code wrapps the resources in a custom block
<thelema>
just memory.
<mrvn>
which makes zero difference. Instead of malloc on creat you call open, instead of free you call close. The GC has no knowledge of what you do for the resource within a custom block.
<mrvn>
Or Bigarray uses mmap() and munmap().
tmaedaZ has joined #ocaml
gnuvince has quit [Ping timeout: 252 seconds]
<ssbr>
wmeyer: Sorry, I was AFK
gmcabrita has left #ocaml []
<ssbr>
wmeyer: What's up?
BiDOrD has joined #ocaml
emmanuelux has quit [Read error: Connection reset by peer]
emmanuelux has joined #ocaml
BiDOrD has quit [Ping timeout: 245 seconds]
_andre has quit [Quit: leaving]
sepp2k has joined #ocaml
BiDOrD has joined #ocaml
Submarine has quit [Quit: Leaving]
gnuvince has joined #ocaml
yezariaely has quit [Ping timeout: 245 seconds]
yezariaely has joined #ocaml
milosn has quit [Ping timeout: 265 seconds]
yezariaely has quit [Ping timeout: 245 seconds]
Progster has quit []
eni has joined #ocaml
gnuvince has quit [Ping timeout: 245 seconds]
Progster has joined #ocaml
milosn has joined #ocaml
gnuvince has joined #ocaml
Yoric has quit [Remote host closed the connection]
milosn_ has joined #ocaml
eni has quit [Ping timeout: 240 seconds]
Kakadu_ has quit [Quit: Konversation terminated!]
milosn has quit [Ping timeout: 248 seconds]
diego_diego has quit [Quit: diego_diego]
diego_diego has joined #ocaml
Sablier_ has joined #ocaml
Snark has quit [Quit: Quitte]
Sablier has quit [Ping timeout: 265 seconds]
gnuvince has quit [Ping timeout: 265 seconds]
yezariaely has joined #ocaml
Anarchos has quit [Quit: Vision[0.9.7-H-090423]: i've been blurred!]
diego_diego has quit [Quit: diego_diego]
diego_diego has joined #ocaml
BiDOrD_ has joined #ocaml
yezariaely has quit [Ping timeout: 272 seconds]
BiDOrD has quit [Ping timeout: 245 seconds]
yezariaely has joined #ocaml
yezariaely has quit [Remote host closed the connection]
yezariaely has joined #ocaml
diego_diego has quit [Quit: diego_diego]
Sablier_ has quit [Read error: Connection reset by peer]