Better HN
topnewbestaskshowjobs
Log inSign up

mjambon

7 karma · joined Sep 3, 2010 (16y ago) · 5 submissions

http://mjambon.com https://github.com/mjambon https://twitter.com/mjambontech
Submissions

comment 12y ago · link · parent

For our web app we've been sticking with JavaScript so far. It's a conservative choice with a lot of problems due primarily to the absence of typing. The absence of typechecking is a problem for our moderately complex app (> 10K lines).

Alternatives that we've been considering include js_of_ocaml and TypeScript.

comment 12y ago · link · parent

For the kind of Android app we're developing we wanted a native look-and-feel. That means using the Android SDK, and I don't know how going through OCaml would make that any easier.

comment 12y ago · link · parent

Pure Haskell is slow, that is why.

comment 12y ago · link · parent

We use it in our backend to tie everything together. It serves an http/json api to our client apps (Web/JavaScript, Android/Java; iOS/Objective-C coming soon). We're handling the same data types in JavaScript, Java and OCaml.

What is clear is that we spend a lot of time fixing type errors in JavaScript due to the lack of basic type checking. Java does not have this problem and for Android programming it is a breeze since really the mobile app is just a GUI which doesn't have to do anything clever with the data.

Now the backend is in charge of serving correct data to the client apps. I could explain that OCaml is fast and lets us implement any CPU-intensive algorithm without having to switch to C, but the truth is most of our code is not much about algorithms but very much about data modeling and data management. Anything we store needs to be stored correctly if we don't want to accumulate broken data resulting in bugs that are costly to fix. Untyped languages such as JavaScript let you store anything without checking their conformance to a type definition, this is awful. Java for example would be perfectly acceptable if it wasn't so verbose. We want to write JSON-like records and arrays like in JSON or JavaScript. OCaml provides this, Java doesn't.

Now, we don't want half of our code to consist in annotating each variable with a type. The compiler should infer that 123 is an int. How hard is that? You tell me. JavaScript doesn't check anything. Java or C++ force you to declare that 123 is an int. How clever is that? I don't know. OCaml, Haskell just figure out that 123 is an int. That's called type inference. That makes code readable like JavaScript or Python, with the safety of Java and the performance of C++.