News for hackers. Stuff that matters.
Re:BuckleScript: write JavaScript faster, safer and smaller by bootload on Saturday January 21, 2017 @12:29AM (#13448974)
"BuckleScript is one of the very few compilers which compiles an existing typed language to readable JavaScript."

Elm (type inference) is sort of. While there is a lot of OS type projects used, having bloomberg use it is a plus. Interesting that FB have build system ^Reason^ (build system) doing something similar (OCaml backend->JS) ~ http://facebook.github.io/reason/

Re:BuckleScript: write JavaScript faster, safer and smaller by yawaramin on Saturday January 21, 2017 @01:42AM (#13449168)
Reason is an alternative, JavaScript-like, syntax for the OCaml language. Same language, different syntax! It's crazy cool. BuckleScript is an OCaml -> ES5 compiler, so it actually compiles Reason to ES5 just fine.

Bloomberg and Facebook are two big users of BuckleScript. FB have a couple of folks writing significant stuff in Reason, compiling with BuckleScript, and deploying to user-facing web properties.

Re:BuckleScript: write JavaScript faster, safer and smaller by k__ on Saturday January 21, 2017 @08:19AM (#13449926)
What is the difference between reason and bucklescript?
Re:BuckleScript: write JavaScript faster, safer and smaller by phpnode on Saturday January 21, 2017 @08:30AM (#13449954)
Reason is a language, bucklescript is an alternative backend for ocaml which generates JavaScript. You write reason, you don't write bucklescript
Re:BuckleScript: write JavaScript faster, safer and smaller by k__ on Saturday January 21, 2017 @08:31AM (#13449961)
okay, then what's the difference between ocaml and reason? :)
Re:BuckleScript: write JavaScript faster, safer and smaller by sgrove on Saturday January 21, 2017 @12:20PM (#13451004)
I spoke quite a bit about ReasonML during 2016, hopefully this should cover a lot of what Reason is, how it relates to OCaml, and how it's different: https://www.youtube.com/watch?v=8LCmLQ1-YqQ

Happy to answer any questions I didn't get to in the talk as well!

Re:BuckleScript: write JavaScript faster, safer and smaller by phpnode on Saturday January 21, 2017 @08:36AM (#13449975)
Reason is a js like syntax for ocaml, semantically they're identical. Similar to coffeescript and JavaScript, except ocaml has really good support for this kind of stuff
Re:BuckleScript: write JavaScript faster, safer and smaller by nerdponx on Saturday January 21, 2017 @09:00AM (#13450044)
So what you're saying is I could write a JavaScript-esque program and compile it to OCaml using Reason, and then compile it to true JavaScript using Bucklescript?
Re:BuckleScript: write JavaScript faster, safer and smaller by phpnode on Saturday January 21, 2017 @09:09AM (#13450072)
Yes exactly, although you can avoid the middle step and go straight from reason to js because of the way bucklescript plugs into the ocaml compiler
Re:BuckleScript: write JavaScript faster, safer and smaller by e12e on Saturday January 21, 2017 @09:27AM (#13450136)
Why would one prefer reason to ocaml? (Honest question)
Re:BuckleScript: write JavaScript faster, safer and smaller by tomku on Saturday January 21, 2017 @10:53AM (#13450557)
You might find this page from the Reason website useful: https://facebook.github.io/reason/mlCompared.html

It replaces a lot of the idiosyncratic bits of OCaml's syntax with things that feel more appropriate if you're comfortable with other modern languages.

A quick example is tuple types. OCaml declares tuple types as int * int, which makes total sense if you know that tuples are a product type. However, you actually create tuples using commas. Reason throws away the connection to theory and uses the same syntax for types (int, int) and creating values of that type (3, 7).

Re:BuckleScript: write JavaScript faster, safer and smaller by purity_resigns on Saturday January 21, 2017 @09:51AM (#13450232)
Reason's syntax is a little cleaner and it's easier to get up and running with.
Re:BuckleScript: write JavaScript faster, safer and smaller by phpnode on Saturday January 21, 2017 @09:51AM (#13450234)
It is much more like JavaScript than ocaml and so you get a familiar language but one which benefits from all the cool things that ocaml can do.
Re:BuckleScript: write JavaScript faster, safer and smaller by k__ on Saturday January 21, 2017 @11:15AM (#13450671)
Another n00b question: What are "all the cool things that ocaml can do"?

I only saw rather simple typing examples, which didn't seem much different from what TypeScript can do.

On the other hand I read often that ocaml doesn't have runtime errors, which I certainly get with TypeScript.

Re:BuckleScript: write JavaScript faster, safer and smaller by yawaramin on Saturday January 21, 2017 @12:57PM (#13451187)
This is a good overview I think, although it doesn't get into specifics: https://realworldocaml.org/v1/en/html/prologue.html#why-ocam...

Of course the rest of the book is a great read too if you're so inclined.

Re:BuckleScript: write JavaScript faster, safer and smaller by eru on Monday January 23, 2017 @12:10PM (#13463681)
OCaml does have exceptions at runtime (eg if you try to take the maximum of an empty list), but generally your programmes won't have type errors at runtime.
Re:BuckleScript: write JavaScript faster, safer and smaller by SureshG on Saturday January 21, 2017 @04:24AM (#13449477)
Re:BuckleScript: write JavaScript faster, safer and smaller by wstrange on Saturday January 21, 2017 @12:35PM (#13451090)
DDC is an alternative to the dart2js compiler. It supports "strong mode" which provides better compile time checking, and produces more idiomatic Javascript.

Dart has a large team behind it, an awesome package management infrastructure, a "Dart native" angular 2 library.

Re:BuckleScript: write JavaScript faster, safer and smaller by willtim on Saturday January 21, 2017 @06:05PM (#13452598)
Dart is just another junk food programming language in the same vein as Java (with some of the same people involved). If you really want to learn what a "strong mode" is, learn OCaml. Good job Bloomberg for Bucklescript.
Re:BuckleScript: write JavaScript faster, safer and smaller by cel1ne on Saturday January 21, 2017 @03:45AM (#13449401)
Kotlin can do that too: https://kotlinlang.org/
Re:BuckleScript: write JavaScript faster, safer and smaller by agumonkey on Saturday January 21, 2017 @04:51AM (#13449531)
Kotlin is slow though. To compile that is.
Re:BuckleScript: write JavaScript faster, safer and smaller by akhilcacharya on Saturday January 21, 2017 @02:18AM (#13449242)
I'm still waiting on full JSX and React for BuckleScript.
Re:BuckleScript: write JavaScript faster, safer and smaller by quicksnap on Saturday January 21, 2017 @04:12AM (#13449457)
JSX is available in Reason out of the box: https://facebook.github.io/reason/#diving-deeper-jsx
Re:BuckleScript: write JavaScript faster, safer and smaller by akhilcacharya on Saturday January 21, 2017 @02:39PM (#13451671)
Oh snap, didn't know this was supported yet.

I think the tooling isn't available for transforming Reason => JSX in a consistent development environment from what I gather, but I haven't paid attention for a few months.

Re:BuckleScript: write JavaScript faster, safer and smaller by bootload on Saturday January 21, 2017 @11:02PM (#13453526)
"Interesting that FB have build system ^Reason^ (build system)"

One reason to define a tool and use language clearly, I interpreted, 'Build Systems Rapidly' as a ^build system^ where in reality Reason is a ^systems language^ to build things quickly.

Some of the tools are fantastic. I would love to have REFMT "dynamically as the window resizes in order to make optimal use of screen real estate while still abiding perfectly by the formatting rules" built into language editors to aid development.

Re:BuckleScript: write JavaScript faster, safer and smaller by teen on Saturday January 21, 2017 @06:04AM (#13449648)
didn't gwt do this 5 years ago
Re:BuckleScript: write JavaScript faster, safer and smaller by grayrest on Saturday January 21, 2017 @07:09AM (#13449751)
If we're just talking about compiling a typed language to javascript, gwt did it 12 years ago.