News for hackers. Stuff that matters.
Re:OCaml 4.03 will, “if all goes well”, support multicore by almosthaskeller on Thursday May 21, 2015 @12:14PM (#9583659)
Looked into a static FP language recently. Was torn between OCaml and Haskell. Leaned more toward Haskell than OCaml. Mainly because OCaml feels like it was hacked together, with a lot of very strange and inconsistent syntax and poorly thought out semantics. That said, I haven't chosen either yet, because Haskell has its own share of oddities that I'm still not comfortable with. But at least it feels more pure and consistent and well thought out in its syntax and semantics.
Re:OCaml 4.03 will, “if all goes well”, support multicore by elihu on Thursday May 21, 2015 @01:10PM (#9584007)
Ocaml and Haskell are both good languages. Haskell probably has a bigger community and more momentum at this point. I switched from Ocaml to Haskell long ago because I wanted parallelism.

The implementation philosophy of the two languages is pretty different, despite being superficially similar in terms of syntax. Ocaml is pretty predictable -- you can look at code and have a pretty good idea of what kind of code the compiler is going to generate.

Haskell is a lot more opaque. Between laziness and a more rigid type system, ghc can do some pretty crazy code transformations. In general, this is a good thing, but it can make performance questions harder to figure out.

I think that Ocaml is easier to learn, but Haskell is more fun, and I've learned more from using it.

Re:OCaml 4.03 will, “if all goes well”, support multicore by ufo on Thursday May 21, 2015 @09:18PM (#9586219)
Haskell libraries also tend to have more levels of abstraction then Ocaml ones, in my experience. Ocaml libraries don't tend to use things like monad transformers or lenses.
Re:OCaml 4.03 will, “if all goes well”, support multicore by alextgordon on Thursday May 21, 2015 @12:31PM (#9583763)
After many years of struggling with Haskell, I've all but given up on it, because of the broken record semantics. They seem to be able to find time to implement monad comprehensions or whatever paper fodder is most in vogue, but you still can't have two datatypes with the same field name in the same module. It's not a serious language.
Re:OCaml 4.03 will, “if all goes well”, support multicore by elihu on Thursday May 21, 2015 @01:00PM (#9583941)
That is also true of Ocaml, and probably every other ML derived language that treats accessor functions as ordinary functions (rather than using the C-style dot operator). There is a type-directed name resolution proposal that would remove this limitation in Haskell, but it would probably make the typechecker a lot more complicated.

The can't-reuse-field-names thing is annoying, but claiming that it "isn't a serious language" because they made a design choice that doesn't meet your exact expectations seems kind of closed-minded to me.

Re:OCaml 4.03 will, “if all goes well”, support multicore by lpw25 on Thursday May 21, 2015 @03:21PM (#9584858)
OCaml has had type-directed record disambiguation for a few versions now. So you can quite easily reuse field names these days.
Re:OCaml 4.03 will, “if all goes well”, support multicore by elihu on Thursday May 21, 2015 @04:14PM (#9585135)
That's cool, I didn't realize they had done that. I haven't used Ocaml in quite awhile -- it's good to hear the language is still getting better.
Re:OCaml 4.03 will, “if all goes well”, support multicore by pcwalton on Thursday May 21, 2015 @02:38PM (#9584576)
> ML derived language that treats accessor functions as ordinary functions

OCaml is not in that tradition—field projection uses dot notation and has historically not been an ordinary function (although maybe that has changed in later versions).

Re:OCaml 4.03 will, “if all goes well”, support multicore by gmfawcett on Thursday May 21, 2015 @04:26PM (#9585179)
You're right, and that is still the case.
Re:OCaml 4.03 will, “if all goes well”, support multicore by kuschku on Thursday May 21, 2015 @01:07PM (#9583983)
Or one could use the lisp-way – and just call the functions <record-name>-<field-name>.

This avoids those problems.

Re:OCaml 4.03 will, “if all goes well”, support multicore by gmfawcett on Thursday May 21, 2015 @01:30PM (#9584126)
The Ocaml way would be to define the functions in separate modules (A.foo, B.foo, etc.). There are convenient syntaxes for declaring which modules are in scope in a given expression, as well as support for first-class modules (you can define functions that take modules as parameters). The module system is sophisticated, and is arguably the "power feature" of Ocaml.
Re:OCaml 4.03 will, “if all goes well”, support multicore by creichert on Thursday May 21, 2015 @01:46PM (#9584240)
This is what you generally see in larger haskell programs which might have a name clash (at least it's what I use):

    data F = F { fName :: String }
    data P = P { pName :: String }
Re:OCaml 4.03 will, “if all goes well”, support multicore by LeonidasXIV on Thursday May 21, 2015 @05:52PM (#9585608)
Yes, this is one of the cases where ML modules are elegant, since you can put the definition of the type into its own module, so it becomes F.t and P.t and you avoid field name clashes.
Re:OCaml 4.03 will, “if all goes well”, support multicore by djur on Thursday May 21, 2015 @01:10PM (#9584001)
Having two datatypes with the same field name in scope doesn't work well with type inference. OCaml permits it, but it requires type annotations, and in practice it seems like developers solve the problem the same way Haskell does -- separate modules.

That said, working with modules is a lot nicer in OCaml than in Haskell, so it's a less painful solution.

Re:OCaml 4.03 will, “if all goes well”, support multicore by issaria on Thursday May 21, 2015 @12:41PM (#9583815)
A record field accessor is just a normal function, are you also expecting define methods with the same name within the same module? If you want an elegant solution, write a typeclass. You have to write you java in the haskell way. https://wiki.haskell.org/Name_clashes_in_record_fields
Re:OCaml 4.03 will, “if all goes well”, support multicore by e_d_g_a_r on Thursday May 21, 2015 @12:17PM (#9583681)
What do you mean hacked together? It looks like most any other ML for the most part.

And what poorly thought out semantics?

Re:OCaml 4.03 will, “if all goes well”, support multicore by jallmann on Thursday May 21, 2015 @12:25PM (#9583725)
ML actually has a formally specified semantics. Haskell does not.
Re:OCaml 4.03 will, “if all goes well”, support multicore by brians on Thursday May 21, 2015 @12:32PM (#9583769)
OCaml doesn't either.
Re:OCaml 4.03 will, “if all goes well”, support multicore by jallmann on Thursday May 21, 2015 @12:46PM (#9583854)
Sure, for a subset of the language. But the point is, a hand-wavy complaint about PL semantics (which can be precisely defined) doesn't make sense when comparing languages in this context.
Re:OCaml 4.03 will, “if all goes well”, support multicore by codygman on Thursday May 21, 2015 @05:17PM (#9585438)
Re:OCaml 4.03 will, “if all goes well”, support multicore by jallmann on Thursday May 21, 2015 @06:03PM (#9585649)
That's the one for Standard ML, yes. There are others for SML, some using proof assistants [1]. Other (S)ML extensions have formal semantics as well, and OCaml itself is partially specified [2].

[1] https://github.com/CakeML/cakeml

[2] http://www.cl.cam.ac.uk/~so294/ocaml

Re:OCaml 4.03 will, “if all goes well”, support multicore by creichert on Thursday May 21, 2015 @01:40PM (#9584195)
Both are great languages and worth learning. All programming languages have quirks.