News for hackers. Stuff that matters.
Re:Type-safe GraphQL with OCaml by lilactown on Thursday November 30, 2017 @02:41PM (#15818846)
I'm hoping the movement around ReasonML[0] could lead to both the web community being able to reap the benefits of OCaml's fundamentals, while also giving people a point of introduction to the OCaml community through web dev.

It has been my experience that the ReasonML community is incredibly welcoming to new comers, and is moving at a break-neck pace to find the right target of being approachable for people who are familiar with JS, but also empowering users to use all of OCaml's power to create web apps that are more simple and correct than they would otherwise be.

[0]: https://reasonml.github.io/

Re:Type-safe GraphQL with OCaml by noncoml on Thursday November 30, 2017 @03:01PM (#15818976)
I really don't understand why they had to invent a brand new syntax.
Re:Type-safe GraphQL with OCaml by quicksnap on Thursday November 30, 2017 @03:08PM (#15819041)
The short answer is that Reason's syntax is simpler and more enjoyable to use. I simultaneously learned both OCaml and ReasonML syntaxes and find Reason to be much easier to work with.

Perhaps people in Reason core will chime in with a more detailed answer. Here's some official information: https://reasonml.github.io/guide/ocaml/

Re:Type-safe GraphQL with OCaml by bad_user on Thursday November 30, 2017 @04:57PM (#15819954)
OCaml's syntax on the other hand is stable, whereas it is my impression that ReasonML changes with the same frequency that JS libraries are changed.

And the differences are very superficial. What trips people is not the actual syntax, but the concepts learned, the rules of the type system, scoping rules, etc, which don't change.

I'm glad that ReasonML exists, but personally I would use OCaml instead of risking that my codebase gets stuck with an old release after only six months because the current version now has different opinions about how to express anonymous functions.

Re:Type-safe GraphQL with OCaml by lilactown on Thursday November 30, 2017 @05:09PM (#15820042)
You're right in that ReasonML syntax is a bit of a moving target, but I think it's part of the initial pains of their effort to provide an approachable port into the ML world. The syntax should stabilize eventually. The maintainers are aware of the churn they are creating, and have deemed it worth it.

That being said, I have a bunch of old projects written in Reason 2 (which still work; the tooling has preserved perfect backwards compatibility[0]), and recently started a new project using the new Reason 3 syntax. It was easy enough to pick up the new syntax in about a day. I haven't done it yet, but my understanding is that it's completely automated[1].

[0]: https://reasonml.github.io/community/blog/#reason-3

[1]: https://github.com/reasonml/upgradeSyntaxFrom2To3

Re:Type-safe GraphQL with OCaml by jordwalke on Friday December 01, 2017 @12:32AM (#15822142)
We provide tools to automate the upgrade between any two reason versions. It’s actually pretty trivial to keep up with changes due to refmt.
Re:Type-safe GraphQL with OCaml by noncoml on Thursday November 30, 2017 @03:30PM (#15819223)
Yeah, I guess the complaint comes from a guy that was already familiar with OCaml's syntax.

I guess if you don't know OCaml, maybe the Reason syntax is more appealing.

Re:Type-safe GraphQL with OCaml by jordwest on Thursday November 30, 2017 @03:59PM (#15819481)
I learnt Reason syntax first, then OCaml second. I prefer the OCaml syntax, it seems simpler, cleaner, and doesn’t hide the nice things about the language behind JavaScript semantics.

The biggest example I can think of is that OCaml uses let..in, which reminds you that every function is a statement. By contrast, the `;` in Reason hides that fact.

That said, it was the Reason syntax that first brought me to the ecosystem, and I think it’s going to be the catalyst that makes OCaml a big player in front end.

Re:Type-safe GraphQL with OCaml by jordwalke on Thursday November 30, 2017 @11:23PM (#15821878)
> “The biggest example I can think of is that OCaml uses let..in, which reminds you that every function is a statement. By contrast, the `;` in Reason hides that fact.”

... Except in OCaml modules/files where you don’t use “in”. OCaml still has “semicolons” for let bindings - but they are just spelled as “in” or “let () =“ depending on the the context. All but one of these “semicolon” forms have nothing to do with language semantics and are only used to help the parser figure out how to group bindings and values. It doesn’t make OCaml’s core semantics worse or better- though it might make it harder to learn initially or copy/paste code between different contexts.

The point of ; in Reason is merely for consistency - to have exactly one way to form bindings whether you are in a module or expression, allowing you to copy paste lines between the two contexts. Compare that to OCaml which requires different syntax depending on the context and copying values from module bodies to expressions requires a lot of editing. There may be other ways to achieve the same kind of consistency without semicolons and we are open to them - just so long as they are consistent across all contexts and easy to learn. (And as long as they don’t have major foot guns like JS’s ASI).

(Often people object to ; as a parsing separator because they think it means “side effect”. It doesn’t. Not in Reason. Not in OCaml. OCaml features ubiquitous use of semicolons for everything from arrays, lists, to records field separators, all things that have nothing to do with side effects. And if you still haven’t had your fill, there’s the ;; double semicolon - which actually does typically imply side effects).

Re:Type-safe GraphQL with OCaml by lilactown on Thursday November 30, 2017 @03:58PM (#15819466)
I do miss a lot of the parentheses-less-ness of OCaml (and the old Reason syntax), but I'm honestly a lot more comfortable at least broaching the topic of using it on some work projects now that it's more JavaScript-y.
Re:Type-safe GraphQL with OCaml by ch4s3 on Thursday November 30, 2017 @03:07PM (#15819029)
Probably because they were first trying to sell an ML internally and it sounded like OCaml/Bucklescript didn't catch on. I think the new syntax is the raison d'etre to some extent.
Re:Type-safe GraphQL with OCaml by k__ on Thursday November 30, 2017 @03:12PM (#15819082)
Yes, many devs know stuff with C/Java/JavaScript like syntax.
Re:Type-safe GraphQL with OCaml by ch4s3 on Thursday November 30, 2017 @03:34PM (#15819259)
Yeah, for better or worse that's ort of the default. I think ML syntax is fine, and in some cases great. However very few CS programs seem to teach MLs and AFAICT no bootcamps do so these languages tend to get picked up by dedicated autodidacts and academics. ReasonML might be a nice bridge,
Re:Type-safe GraphQL with OCaml by k__ on Thursday November 30, 2017 @04:13PM (#15819591)
I used LiveScript until ES2015 was a thing and found ML syntax rather nice.
Re:Type-safe GraphQL with OCaml by abiox on Thursday November 30, 2017 @03:13PM (#15819095)
to varying degree, syntax matters. (for better or worse.) the nice thing is that the semantics of ocaml haven't been changed by reasonml.