mbishop changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | Grab Ocaml 3.10.0 from http://caml.inria.fr/ocaml/release.html (featuring new camlp4 and more!)
hkBst has quit ["Konversation terminated!"]
hsuh has joined #ocaml
Mr_Awesome has quit ["aunt jemima is the devil!"]
hsuh has quit [Remote closed the connection]
kreaturr has joined #ocaml
<kreaturr> evening people.
<kreaturr> I'm admittedly a newb. what is the difference between the List and Array?
hsuh has joined #ocaml
Associat0r has joined #ocaml
ita has joined #ocaml
<Smerdyakov> Arrays are a primitive type and lists are (modulo the syntax of ::) defined using OCaml's regular datatype definition facility, for one thing.
pants4 has quit ["Leaving."]
<JohnnyL> Smerdyakov, i don't think he asked that.
<JohnnyL> kreaturr, you want to know what the hold correct?
<JohnnyL> s/the/they
<JohnnyL> sorry
<Smerdyakov> He asked for "the difference," and I gave a difference.
cloupsy has quit [Remote closed the connection]
<JohnnyL> thats a difference, not 'THE' difference.
<JohnnyL> there is a difference.
<JohnnyL> but it's not THE difference.
<JohnnyL> Smerdyakov, is it your aim to confuse users or just make their heads explode?
<kreaturr> see, you made my head explode. took me this long to recover. ;)
<kreaturr> well, I'm interested in any significant differences.
<kreaturr> I understand that neither are tuples. are array's contiguous in memory like C-ish arrays? (at least for numeric types)?
<JohnnyL> kreaturr, depends on the JIT, the interpreter, etc. ocaml is managed memory.
<kreaturr> ok.
<kreaturr> as a user, is there any specific reason I should use one over the other?
<kreaturr> I guess, due to my ignorance, they seem like much the same structure to me. So I'm curious why both exist.
<Smerdyakov> kreaturr, do you know what a linked list is?
<kreaturr> yes.
<kreaturr> list is a linked list?
<Smerdyakov> Yes.
<kreaturr> perfect. gotcha.
<Smerdyakov> That's the unsatisfying answer that makes an impression on C-family people the quickest. :-)
<Smerdyakov> Lists are defined as: [type 'a list = nil | cons of 'a * 'a list] (modulo some special syntax to replace [cons] with [::] and [nil] with [[]]).
<kreaturr> Smerdyakov: and your more satifying answer is your previous one?
<Smerdyakov> Thus, just understanding type definitions in OCaml makes everything about lists clear.
<Smerdyakov> Arrays are built-in.
<Smerdyakov> You can't deconstruct arrays with pattern matching in the same way that the above definitions shows you that you can with lists.
<kreaturr> ahhh, that makes sense.
<JohnnyL> kreaturr, welcome to math! :)
<kreaturr> still coming to grips with the type system.
<kreaturr> still not sold on the super strong explicit typing. need more proficiency in the lang and then to try it some in my use.
<Smerdyakov> Welcome to "JohnnyL is best ignored." :-P
<kreaturr> I must admit though, "Arrays are built-in" isn't very illuminating.
<JohnnyL> kreaturr, maybe you should learn a bit of lisp. there are many similiatires between lisp and ocaml (types not being one of them)..
<kreaturr> unless it is to say that Array's couldn't be implemented in ocaml syntax.
<Smerdyakov> kreaturr, they're fixed-length mutable sequences with constant time access to elements. Is that enough?
<Smerdyakov> kreaturr, but, really, does that tutorial in the manual not make all of this clear?
<kreaturr> Smerdyakov: that is much better.
<kreaturr> well, apparently it didn't to me.
<kreaturr> or, I'm a dolt.
<kreaturr> JohnnyL: I know the basic concept of lisp, and not much else.
<Smerdyakov> The tutorial at least says explicitly that lists are immutable and arrays are mutable.
<Smerdyakov> A quick scan through leads me to guess that it relies on intuitions from other programming languages so far as the time complexity of array operations.
<kreaturr> I'll look again. Apparently I did miss it.
<Smerdyakov> What other languages are you comfortable with? I would think that "array" and "list" would be pretty suggestive from the standpoint of most popular languages.
<kreaturr> in any case, the answers I got here resolved my confusion. so I'm pretty happy.
<kreaturr> C, ruby, perl.
smimou has quit ["bli"]
<Smerdyakov> Yeah, if you're familiar with C, "array" and "list" should have explained it all, with the possible caveat of needing to insert "linked" before "list".
<kreaturr> yup. makes sense now.
<kreaturr> I needed the "linked" bit.
ikaros has joined #ocaml
<kreaturr> perhaps I shouldn't, but I take a lot of names with a grain of salt until I understand wtf is meant by them.
<kreaturr> for example, in ruby - an Array is really a tuple.
<kreaturr> which means it's not anything close to an array in the C sense.
<ita> kreaturr: list o(log(n)) access and o(1) append; array is o(1) access but has no append - got it ?
ikaros has quit [Remote closed the connection]
piggybox has joined #ocaml
<kreaturr> ita: :) thanks. yeah, got it.
<JohnnyL> Smerdyakov, Can i quote you on your quotations of your understanding of my understanding?
<Smerdyakov> JohnnyL, you can quote my accurately whenever you want.
<JohnnyL> oh goodies!
<Smerdyakov> ita, don't confuse O(1) with o(1). It's a big difference.
<ita>
<Smerdyakov> An operation running in o(1) time needs to get faster as input size increases.
<JohnnyL> log(100)=10
<JohnnyL> oh ok, so it's about division.
<Smerdyakov> Log base 10? What a maroon.
buluca has quit [Read error: 110 (Connection timed out)]
<Smerdyakov> Or log base something not equal to 2, actually.
buluca has joined #ocaml
<kreaturr> little-o notation is most often used to compare significance, right? stupid example: log(n) = o(n^3)
<Smerdyakov> I don't know what "compare significance" means.
<kreaturr> sorry, bad terminology. compare computational complexity.
<Smerdyakov> O() and o() are both used to compare computational complexity.
<kreaturr> *sigh* fine, you're right. but I meant o() is defined by a ratio. using my example, log(n) / n^3 -> 0 as n->large.
<kreaturr> so while O() makes sense alone, o() doesn't as much.
<Smerdyakov> That's one way of defining it. There's another definition that is more symmetrical with the usual O() definition.
<Smerdyakov> Something like "no matter how much higher you want one function to get than the other, you can push the input high enough to achieve that."
<JohnnyL> fractals are very sexual in nature.
<JohnnyL> what revision control systems do you guys use?
<kreaturr> git mostly
<ita> tla
hsuh has quit ["y"]
Jeff_123 has joined #ocaml
buluca has quit [Read error: 113 (No route to host)]
Jeff_123 has quit [Read error: 104 (Connection reset by peer)]
ita has quit [Remote closed the connection]
JeffSmac has joined #ocaml
JeffSmac is now known as Jeff_123
Jeff_123 has quit [Client Quit]
Jeff_123 has joined #ocaml
JohnnyL has quit ["Leaving"]
Jeff_123 has quit []
kamiphlauge has joined #ocaml
Jeff_123 has joined #ocaml
Jeff_123 has quit ["Quit"]
seafood_ has joined #ocaml
Snark has joined #ocaml
kelaouchi has quit [Remote closed the connection]
asmanur has joined #ocaml
ttamttam has joined #ocaml
kreaturr has quit [Read error: 110 (Connection timed out)]
kreaturr has joined #ocaml
Snark has quit [Read error: 113 (No route to host)]
kreaturr has quit [Read error: 110 (Connection timed out)]
Torment has joined #ocaml
Tetsuo has joined #ocaml
bringert has joined #ocaml
Jedai has quit [Read error: 110 (Connection timed out)]
kreaturr has joined #ocaml
filp has joined #ocaml
hkBst has joined #ocaml
kamiphlauge has quit [Connection timed out]
jave has quit [Remote closed the connection]
Amorphous has joined #ocaml
jave has joined #ocaml
Snark has joined #ocaml
bluestorm_ has joined #ocaml
<flux> what's the best way to create unique ids in a thread-safe way?
<flux> hm, s/best/fastest/
<flux> I'm thinking even a C-wrapper: it wouldn't need to use mutexes for locking
<flux> a function such as val new_id_gen : unit -> unit -> int, used like let _ = let id_gen = new_id_gen () in foo (id_gen ()); foo (id_gen ()) ..
<flux> of course, I should benchmark it before saying that's going to be the fastest way..
<flux> but atleast C-functions get automatic serialization with little overhead, right?
<pango> not afaik
<flux> not afaik what?
<pango> they don't get any kind of automatic serialization
<flux> I think they do, in the form of grabbing GC lock
<pango> oh, you're talking in OCaml runtime context only? Well yes, the runtime grabs a mutex for you
<flux> runtime context? what kind of contexts are there?
<flux> that doesn't happen with native code?
<pango> I mean (OCaml runtime) context, not OCaml (runtime context) :)
<pango> vs. plain C programs
<flux> right
<pango> you could use the Mutex module
<pango> to create a critical section around your counter(s)
<flux> of course, but at a cost
<flux> infact the cost appears to be 50x less performance
<flux> the lock is quite a big operation considering the work to be done: increment a counter, return a copy of the value
<pango> you mean 50x slower than (ab)using the gc lock, or than just incrementing the counter?
<flux> 50x slower when using Mutex.lock/unlock than incrementing a plain counter
<flux> let new_id_gen () = let m = Mutex.create () in let i = ref 0 in fun () -> Mutex.lock m; incr i; let v = !i in Mutex.unlock m; v
<flux> remove mutex, gain 50x speed
<flux> (as benchmarked by a for let new_id = new_id_gen () in a = ... do value := new_id () done)
<asmanur> does dynamic array (I mean, array whose size can be modified) already exist in caml ?
<pango> the less expensive solution is to use CPU atomic primitives, when available; Even then, there's a cost
<flux> asmanur, google found this: http://ocaml-lib.sourceforge.net/doc/DynArray.html
<flux> asmanur, not in standard distribution
<asmanur> ok thanks
<bluestorm_> asmanur: Hashtbl :-'
<pango> flux: http://people.redhat.com/drepper/cpumemory.pdf (interesting reading)
<asmanur> bluestorm_: hashtl is pretty overkill when keys are integer :-'
<pango> asmanur: DynArray probably uses reallocation, which is not for free either... The choice of the datastructure depends on what operations you're gonna use the most often
<asmanur> hum
smimou has joined #ocaml
<asmanur> i'll use mostly access functions so reallocation should be used often
<asmanur> shouldn't*
bongy has joined #ocaml
<flux> an atomic increment-return-previous-value written in C takes 5.4 long to run as a ocamlopt-compiled version
<flux> "as long to run"
<flux> hm, "times as long to run" :)
<pango> doesn't look too bad, if you get atomicity that way
<Associat0r> can I discuss F# here?
<cygnus_> isn't it just ocaml anyway ? :p
<Associat0r> I am not sure, I just started exploring it today
Yoric[DT] has joined #ocaml
jave has quit [Remote closed the connection]
<Smerdyakov> Associat0r, yes, you can.
<Smerdyakov> And F# is definitely not OCaml.
<bongy> hi Yoric[DT]
<Smerdyakov> But ##f# and #f# are so empty that it would be silly to send anyone there yet.
bongy has quit ["Leaving"]
seafood_ has quit []
<Yoric[DT]> hi
<Associat0r> can you do a data as code like in lisp?
<Associat0r> also is it possible to disable gc temporarily for certain tasks?
<Associat0r> in ocaml that is
<Associat0r> also what about inline asm?
<flux> ocaml has a preprocessor with hygienic macros, but in general, no.
<flux> gc parameters can be adjusted, but again, it cannot be completely disabled
<flux> and no inline assembler. it can be interfaced with C, though, with average levels of pain
<flux> inline assembler wouldn't be very cross-platform anyway
<flux> I suppose it would be possible to write a language extension facilitating that. however, inline C would in my opinion be more useful.
<Associat0r> is the GC dealloc deterministic, I read about allocation but couldn't find about dealloc
<flux> it is not
<flux> finalizers are provided; I'm not sure if calling of them is guaranteed (before the program exits)
<pango> it may depend on .NET environment implementation ;)
<flux> in general resource-like values can be scoped with an auxiliary function; if you're familiar with lisp, then you should know about those too
<pango> (if those questions are about F#, that is)
<flux> yes, I'm definitely answering in the context of Ocaml
<pango> (mmh just noticed "in ocaml", so you were right to answer in ocaml context)
hkBst has quit ["Konversation terminated!"]
<Associat0r> ocaml I asked yes
Amorphous has quit ["shutdown"]
Amorphous has joined #ocaml
asmanur has quit [Read error: 110 (Connection timed out)]
buluca has joined #ocaml
ttamttam has left #ocaml []
Jedai has joined #ocaml
seafood_ has joined #ocaml
seafood_ has quit [Client Quit]
seafood_ has joined #ocaml
Torment has quit [Read error: 110 (Connection timed out)]
seafood_ has quit []
bringert has quit []
hsuh has joined #ocaml
asmanur has joined #ocaml
Jeff_123 has joined #ocaml
Jeff_123 has quit [Client Quit]
hsuh has quit [Remote closed the connection]
hsuh has joined #ocaml
pango has quit [Remote closed the connection]
pango has joined #ocaml
ita has joined #ocaml
hsuh has quit [Remote closed the connection]
Yoric_ has joined #ocaml
Yoric[DT] has quit [Read error: 104 (Connection reset by peer)]
marmottine has joined #ocaml
hsuh has joined #ocaml
bongy has joined #ocaml
mordaunt has joined #ocaml
buluca has quit [Read error: 113 (No route to host)]
bongy has quit ["Leaving"]
buluca has joined #ocaml
jlouis has joined #ocaml
beschmi has joined #ocaml
ttamttam has joined #ocaml
buluca has quit [Read error: 113 (No route to host)]
ikaros has joined #ocaml
svenl_ is now known as svenl
buluca has joined #ocaml
kelaouchi has joined #ocaml
Yoric_ has quit ["Ex-Chat"]
bringert has joined #ocaml
bringert has quit []
ozzloy has quit [SendQ exceeded]
jlouis_ has joined #ocaml
buluca has quit [Read error: 113 (No route to host)]
ozzloy has joined #ocaml
ita has quit [Remote closed the connection]
jlouis has quit [Read error: 110 (Connection timed out)]
gaja has joined #ocaml
gaja_ has joined #ocaml
gaja__ has joined #ocaml
dbueno has joined #ocaml
gaja has quit [Read error: 110 (Connection timed out)]
JohnnyL has joined #ocaml
gaja_ has quit [Read error: 110 (Connection timed out)]
gaja has joined #ocaml
<JohnnyL> hey guys how are you doing?
* JohnnyL waves to Smerdyakov
<bluestorm_> :D
gaja_ has joined #ocaml
gaja__ has quit [Read error: 110 (Connection timed out)]
sadmac_ has joined #ocaml
Jeff_123 has joined #ocaml
ttamttam has left #ocaml []
gaja has quit [Read error: 110 (Connection timed out)]
gaja has joined #ocaml
sadmac has quit [Read error: 110 (Connection timed out)]
asmanur has quit [Remote closed the connection]
gaja_ has quit [Read error: 110 (Connection timed out)]
<JohnnyL> hey bluestorm_ !
sadmac has joined #ocaml
gaja_ has joined #ocaml
Jeff_123 has quit []
gaja__ has joined #ocaml
gaja has quit [Read error: 110 (Connection timed out)]
sadmac_ has quit [Read error: 110 (Connection timed out)]
Snark has quit ["Quitte"]
gaja_ has quit [Read error: 110 (Connection timed out)]
gaja has joined #ocaml
gaja__ has quit [Read error: 110 (Connection timed out)]
gaja_ has joined #ocaml
gaja has quit [Read error: 110 (Connection timed out)]
bringert has joined #ocaml
<Associat0r> is there some visual studio add-in for native ocaml?
gaja has joined #ocaml
bringert has quit []
gaja_ has quit [Read error: 110 (Connection timed out)]
gaja_ has joined #ocaml
gaja has quit [Read error: 110 (Connection timed out)]
ita has joined #ocaml
seafood_ has joined #ocaml
marmottine has quit ["Quitte"]
suppaman has joined #ocaml
<suppaman> hello
gaja has joined #ocaml
gaja_ has quit [Read error: 110 (Connection timed out)]
gaja_ has joined #ocaml
filp has quit ["Bye"]
bluestorm_ has quit ["Konversation terminated!"]
gaja has quit [Read error: 110 (Connection timed out)]
suppaman has quit ["all your bye are belong to us"]
Tetsuo has quit ["Leaving"]
ser_ has joined #ocaml
gaja has joined #ocaml
ser_ has quit [Remote closed the connection]
ser_ has joined #ocaml
ser_ has quit [Remote closed the connection]
gaja_ has quit [Read error: 110 (Connection timed out)]
beschmi has quit ["Leaving"]