Live data from Hacker News

Why OCaml, Why Now?

spyder.wordpress.com

11–20 of 106 posts

Re: Why OCaml, Why Now?

#11
post #7

Earlier quoted context omitted.

I write all my javascript in haskell, and haven't had any problems. What do you need/want "DOM bindings" for?

As someone who would like to write his javascript in Haskell, how do you put text on the page without interfacing with the browser's DOM?

Is that a trick question? I don't know how or why you would try to do that.

Re: Why OCaml, Why Now?

#12

I'm glad that the author is picking up a new functional programming language, but choosing OCaml over Haskell because of support for the Javascript implementations strikes me as choosing a BMW over a Mercedes[0] because of the number of cupholders it has. If you don't have a particular goal in mind (ie, "I work at Jane Street and need to be compatible with our existing code"), there are a number of other factors in t…

It sounds like you have a very language-centric view of the world. In practice, deployment is everything. (Why do people write code in Objective C? Because iPhone.)

Having a solid implementation for your target platform is very good reason to pick a language.

Re: Why OCaml, Why Now?

#13

I'm glad that the author is picking up a new functional programming language, but choosing OCaml over Haskell because of support for the Javascript implementations strikes me as choosing a BMW over a Mercedes[0] because of the number of cupholders it has. If you don't have a particular goal in mind (ie, "I work at Jane Street and need to be compatible with our existing code"), there are a number of other factors in t…

Car metaphors don't always match well with the situations they try to illustrate. Obviously if you had the chance to be offered either one of these two cars, you'd probably try them out and pick the one you feel the most comfortable with, but also which would best fit your needs. If all other factors have been weighted, and it boils down to the number of cup holders, would you stop there short of making a choice, because of the apparent superficiality of the argument? The author expressed his interest in both languages, and brought other arguments than just the js one.

Re: Why OCaml, Why Now?

#14
post #8
post #5

For me Scala has been the not-quite-as-good-as-haskell-but-more-industrially-acceptable language. I'd be very interested to see a more neutral comparison of functional languages for compile-to-JS, because if anything Haskell seems more popular for that - I hadn't heard anything about compiling OCaml to JS before this.

I just started at a Microsoft shop a few months ago (first time for everything), and I actually quite like F#, now that I've had a little while to play with it. It's a good contender for the NQAGAHBMIAL throne. Having used CMUCL/SBCL for a while, I always found ocaml's "well, you can compile your code, but then you can't run it in the REPL" to be off-putting. (For my purposes the CLR JIT compiler for F# is good enoug…

Posted 20 minutes ago, and this post already shows up when you google "NQAGAHBMIAL". Impressive...

Re: Why OCaml, Why Now?

#15
post #9

How do those "to js" code generator behave when used together with frameworks like backbone or angular ? I know things like typescript or dart have special versions of the framworks, but i'm curious to know how the ocaml to js tools behave ( since i've searched for a decent strongly typed server side technology for years, that would be an argument for me to try that language).

I don't know about OCaml, but generally speaking, there is a foreign function calling interface. You'd typically use it for integrating with large standalone codebases you don't want to rewrite (say, CodeMirror) but typically not for frameworky things. If you're going to use the same UI framework there's not much point in switching languages.

Re: Why OCaml, Why Now?

#16
post #7

Earlier quoted context omitted.

I write all my javascript in haskell, and haven't had any problems. What do you need/want "DOM bindings" for?

As someone who would like to write his javascript in Haskell, how do you put text on the page without interfacing with the browser's DOM?

http://elm-lang.org/ for example. To display text in the browser you would use -

main = plainText "Hello, World!"

From the page: "Elm is a functional language that compiles to HTML, CSS, and JavaScript".

So yes, technically this is working with the DOM. But you are not writing code that interacts with a "DOM binding" directly per se.

Re: Why OCaml, Why Now?

#17
Felix is to C++ what F# is to C# http://felix-lang.org/share/src/web/tut/tutorial.fdoc (I am not the author, just excited about this language) OCaML programmers will feel immediately at home.

It is a mature yet actively developed whole program optimized, strongly typed, polymorphic, ML like language that can interact effortlessly with C and C++ and has coroutines and threads baked in, although use of threads is somewhat discouraged. It has type-classes as well as modules. Functions written in it may be exported as a CPython module. This might be useful if one wants to gradually transition from a Python based src tree.

It uses a mix of lazy and eager evaluation for performance and compiles down to C++. Execution speed is comparable to hand written C++, mostly better. Its grammar is programmable in the sense that it is loaded as a library. So in the same way that languages may acquire libraries, Felix may acquire domain specific syntax.

It is also mostly a one man effort but with a feverish pace of development so it comes with its associated advantages and disadvantages.

Tooling info is here http://felix-lang.org/share/src/web/ref/tools.fdoc

The author likes to call it a scripting language but it really is a full-fledged statically compiled language with a single push button build-and-execute command. http://felix-lang.org/ The "fastest" claim is a bit playful and tongue in cheek, but it is indeed remarkably fast.

Re: Why OCaml, Why Now?

#18
post #6
post #2

This might be entirely superficial of me, but I always preferred Haskell over OCaml simply because OCaml required me to type ";;" after every line. The only real reason that I can see to choose OCaml over Haskell is that if you learn OCaml, you might be able to work at Jane Street. Is there a strong argument for abandoning my Haskell-ing for OCaml?

;; is a special token used only in the REPL to force evaluation, it is not something you ever use in real code.

Well, that explains a lot! I'm embarrassed I never got past that.

Re: Why OCaml, Why Now?

#19

Earlier quoted context omitted.

As someone who would like to write his javascript in Haskell, how do you put text on the page without interfacing with the browser's DOM?

http://elm-lang.org/ for example. To display text in the browser you would use - main = plainText "Hello, World!" From the page: "Elm is a functional language that compiles to HTML, CSS, and JavaScript". So yes, technically this is working with the DOM. But you are not writing code that interacts with a "DOM binding" directly per se.

I'm excited for PureScript for the property that it compiles to sane javascript.

http://purescript.readthedocs.org/en/latest/intro.html#hello...

Re: Why OCaml, Why Now?

#20
I've found it interesting that OCaml hasn't had more interest given the amount of recent momentum in Haskell.

Haskell is an Ivory Tower. The features that generally draw one to the language also tend to be the things that eventually push one away. Haskell has grown a lot over the years however as the language evolves to allow general programming within a pure framework.

OCaml on the other hand tends to make a compromise, acknowledging that the programmer occasionally needs a different tool for the job. OCaml allows the programmer to opt into things like mutability and objected oriented code when the need arises. These compromises can also be seen as the languages downside however.

I find it interesting that the driver for the author into OCaml is JavsScript... but it's nice to see OCaml come up a bit more often. :)

Post reply on HN