News for hackers. Stuff that matters.
Re:A set of efficient persistent immutable data structures f... by Drup on Tuesday March 28, 2017 @06:19PM (#13981299)
Oh, great, yet another library of data structures that introduce incompatible abstractions with both the standard library and the 3 other big libraries of data structures[1,2,3], that is exactly what the OCaml ecosystem needs! :D

More seriously, though, at least the naming convention is consistent. It looks a bit heavy on signature-indirection. I would really prefer if they used a standard iterator (gen[5] and sequence[6], for example, or the future one in the stdlib[7]) and settled for one serialization method (such as sexp) and get formatters everywhere.

Also, please use ocamldoc or odoc[4] for your documentation. The one generated here is really terrible, even for OCam^W Reason standards.

[1]: https://github.com/c-cube/ocaml-containers/ [2]: http://batteries.forge.ocamlcore.org/ [3]: https://github.com/janestreet/base [4]: https://github.com/ocaml-doc/odoc/ [5]: https://github.com/c-cube/gen/ [6]: https://github.com/c-cube/sequence/ [7]: https://github.com/ocaml/ocaml/pull/1002

Re:A set of efficient persistent immutable data structures f... by bordoley on Tuesday March 28, 2017 @08:06PM (#13982095)
Hi Drup,

The intent of Immutable-re is to provide a complete set of persistent immutable collections that complement the standard library and core. The initial release is limited to common Map, Set, and Vector types, but we have intent to add additional collections such as BiMaps, Multisets, and Multimaps. There is of course some overlap with the stdlib collections (SortedSet vs. OCaml Set, SortedMap vs. OCaml Map) but even in these cases, the Immutable-re implementations have slightly different characteristics from their stdlib counterparts, which provide added value.

The public API is designed to be very Reason like, and familiar to web developers with experience in JavaScript, Java and C#, hence the naming conventions and camlCase. I've also considered adding an OCaml compatibility layer, which provides a more familiar API for OCaml developers. While the public API itself is heavily dependent upon signature indirection, these signatures are purely for documentation and not heavily depended upon within the implementation, which means the OCaml compat API may not include them at all.

Regarding the choice of APIs for sequences, the current Sequence type is intentionally opaque and is internally designed to be compatible with the proposed standard OCaml Sequence (https://github.com/ocaml/ocaml/pull/1002). If/when, that PR lands, we will switch our internal implementation to be compatible with OCaml's while maintaining the same public API.

Finally you are completely correct regarding documentation generation. Unfortunately refmt does not currently support outputting OCaml mli files including comments. This left me with the choice of hand rolling docs as I did or shipping ocamldocs lacking any comments explaining the types and functions. I chose the former.

Thanks for your feedback.

Re:A set of efficient persistent immutable data structures f... by Drup on Wednesday March 29, 2017 @06:59AM (#13984927)
Well, multisets, multimaps and a lot of other things are also provided in containers and core. It's nice that you (already!) adopted that style of iterator.

I'm not sure what an "OCaml compatibility layer" would mean. It's already OCaml-y: it's referentially transparent and full of functors and signatures! The main weird thing is that the type of compare is not the same (I understand why, but I find compatibility more valuable). The naming convention matters little, as long as it's clear, readable and consistent (OCamlers are not going to boycott a library because it uses camlCase).

I don't think the signature indirection is a real problem, you just need a good tool for documentation generation that inlines signatures. You can ask the odoc people, I'm sure they would be happy to help you. I'm surprised there is no "reasondoc" tool just yet. :)

Re:A set of efficient persistent immutable data structures f... by a-nikolaev on Tuesday March 28, 2017 @08:08PM (#13982104)
Thank you for the link to c-cube/containers, didn't know about it, looks interesting!

The above comment is relevant from the OCaml language ecosystem perspective. Although I think that possible segmentation is not a huge problem if it means wider adoption of the language. Especially considering that Reason maintains full compatibility with OCaml.

Re:A set of efficient persistent immutable data structures f... by kornish on Tuesday March 28, 2017 @03:51PM (#13980043)
Question for jordwalke or any Facebookers around: how's Reason's adoption inside of Facebook relative to OCaml? The hypothesis around the syntax seems to be that it's more approachable for Javascript programmers – are you noting a significantly faster onboarding time?
Re:A set of efficient persistent immutable data structures f... by jordwalke on Tuesday March 28, 2017 @06:28PM (#13981399)
The feedback we've gotten from web developers is that it's easier to learn, and the integration that we've done for web makes it much easier to be instantly productive. Many say they would have not even taken a look at OCaml if there wasn't a group of developers caring about improving the overall ergonomics and front end experience.

"relative to OCaml".

Many people don't know, but a ton of Facebook's critical infrastructure has been developed on OCaml for a long time: projects such as Infer, Hack, Flow and many others. So there's a ton of existing projects that might be hard to catch up to in the short term and thats okay in my mind, because those projects are using the right tool for the job at hand. Even though the syntax they use might be a little more off-putting to new contributors, I think they're getting the big things right. One benefit to Reason is that it stands to make sure that more developers who are starting new projects, get the big things right - syntax is just one of many means to that end.

We want to fully interop with the OCaml ecosystem and we go through great lengths to ensure that Reason can be used with any OCaml project. I would love to focus even more on that once the ReactJS story is in a really good place.

Re:A set of efficient persistent immutable data structures f... by jordwalke on Tuesday March 28, 2017 @06:59PM (#13981664)
And another interesting thing to note about the approach taken here, is that I did several surveys and interviews that explored why developers choose the languages they do, and there were many cases where people could have (arguably should have) chosen either of OCaml/Haskell but didn't. I wanted to find out why, and the most common responses were that: they didn't like the syntax of OCaml, they didn't like the available build systems, the installation was too difficult or didn't integrate with their familiar workflow, it needed a better debugger, and the type errors needed improvement (approximately in that order for the groups I asked - which were heavily biased towards application developers). So, the approach we're taking is to solve the most common objections we can do something about, and other people in the OCaml community are making tons of progress towards solving these problems as well (build systems and gdb support for example) (as well as ones I think are even more important than all of the ones I heard about in my survey (multicore etc)).
Re:A set of efficient persistent immutable data structures f... by jordwalke on Tuesday March 28, 2017 @06:35PM (#13981453)
The most common (constructive) feedback we currently receive is that once people want to dive into some advanced stuff, they need more material than the brief tutorials, and the primary book is written in OCaml syntax / toolchain. I would love it if we could have custom Real World OCaml "renditions" that allow custom automated presentation of syntax in the online book, as well as some focus on web development workflows.
Re:A set of efficient persistent immutable data structures f... by tekknolagi on Tuesday March 28, 2017 @06:48PM (#13981552)
Isn't there a Chrome extension that automatically converts OCaml snippets to Reason syntax?
Re:A set of efficient persistent immutable data structures f... by jordwalke on Tuesday March 28, 2017 @06:52PM (#13981598)
I believe so, but IIRC, it's not possible to use it on Real World OCaml. Also, for something as core as a book, it's worth being able to custom tailor some things including the code generation, and some extensions to the book that focus on specific use cases like getting setup for web development etc.
Re:A set of efficient persistent immutable data structures f... by Flow on Wednesday March 29, 2017 @03:08AM (#13984054)
Maybe they'll consider forking the book into "Real World Reason"? It's quite a great name for a book.
Re:A set of efficient persistent immutable data structures f... by tekknolagi on Tuesday March 28, 2017 @11:44PM (#13983202)
Why is it not possible to use on RWO?
Re:A set of efficient persistent immutable data structures f... by jordwalke on Tuesday March 28, 2017 @06:40PM (#13981497)
Also, if you're looking to help out, the biggest area of impact is to help us unify the install/development process for both native ocaml development and web frontends. That means building a single workflow that allows you to create/build/develop local sandboxed projects - one workflow to develop web applications, as well as native projects that consume/compile opam packages.
Re:A set of efficient persistent immutable data structures f... by ubercow on Tuesday March 28, 2017 @03:39PM (#13979934)
Is anyone here using Reason in any meaningful way? Even just a side project.

If so, what are you using it for and how do you like it.

Re:A set of efficient persistent immutable data structures f... by kornish on Tuesday March 28, 2017 @03:49PM (#13980026)
Not using it, but jumping in to share an anecdote –

I saw the Reason announcement months and months ago and decided to use it as a jumping-off point into the OCaml ecosystem. It took about a week of writing Reason before I realized I was spending so much time reading OCaml (all the libraries were written in it) before I just switched to OCaml proper. Haven't looked back - the syntax takes a few days to pick up, but is hardly the most difficult part of writing a program.

Hopefully they can capitalize on the "Build" and "Share" part of their value prop [0] because "Syntax" appears (to most) to be the least valuable improvement. As a disclaimer, I could be totally wrong, never having worked at a FB-size organization – that onboarding time probably adds up quickly.

Come to think of it: can anyone think of a successful transpiled language that doesn't actually provide new semantics? Coffeescript is the closest thing that comes to mind, but it's dying out as ECMAScript absorbs its most appealing features.

[0]: http://facebook.github.io/reason/#reason

Edit: forgot about Elixir, which seems to be doing quite well – but that introduces new semantics like homoiconicity + macros and protocols.

Re:A set of efficient persistent immutable data structures f... by cies on Tuesday March 28, 2017 @05:10PM (#13980752)
There's some neat stuff in the Reason syntax, apart from the make-it-less-weird-for-those-coming-from-JS/Java/C#/etc., for instance: JSX[0] and named curried functions[1]. Both are fitting in really nice when doing FE dev't like with `react-reason`[2].

If you are interested in this, I recommend some talks. First one by Cheng Lou, a main contributor of Reason and FB employee on React Conf 2017[3]. And a talk by Sean Grove[4] on Reason in general.

With the power of FB behind this new techonolgy (they have currently written 25% of messenger.com in Reason), this might well become very big. A general purpose strongly typed functional prog lang, that has a vast ecosystem, now an approachable syntax, and compiles to both native and JS. Sounds good nuh?

[0]: https://facebook.github.io/reason/#diving-deeper-jsx

[1]: https://facebook.github.io/reason/#diving-deeper-curried-fun...

[2]: https://github.com/chenglou/reason-react-example/blob/master...

[3]: https://www.youtube.com/watch?v=_0T5OSSzxms

[4]: https://www.youtube.com/watch?v=8LCmLQ1-YqQ&t=517s

Re:A set of efficient persistent immutable data structures f... by thedufer on Tuesday March 28, 2017 @06:22PM (#13981326)
Can you explain how named curried functions differ from ocaml's named arguments? It looks exactly the same, other than the syntax.
Re:A set of efficient persistent immutable data structures f... by chenglou on Tuesday March 28, 2017 @06:43PM (#13981519)
They are the same. I don't think cies was implying they were different.
Re:A set of efficient persistent immutable data structures f... by thedufer on Tuesday March 28, 2017 @06:53PM (#13981605)
The wording seems to pretty clearly say otherwise, but I appreciate the confirmation that I'm not missing anything.
Re:A set of efficient persistent immutable data structures f... by jordwalke on Tuesday March 28, 2017 @06:47PM (#13981538)
They're not different than OCaml's, but Reason's JSX is an interesting / useful application of labeled arguments that appeals to React developers.
Re:A set of efficient persistent immutable data structures f... by cies on Wednesday March 29, 2017 @03:40AM (#13984178)
My bad. They're the same (as others noted). Was not familiar with them.
Re:A set of efficient persistent immutable data structures f... by mirekrusin on Tuesday March 28, 2017 @05:13PM (#13980775)
> (...) Coffeescript is the closest thing that comes to mind, but it's dying out as ECMAScript absorbs its most appealing features. (...)

CoffeeScript seems to be doing well, they're working on version 2.0 (currently in alpha) aka coffeescript@next [1] with async/await (with similar approach as they did with generators where only `yield` keyword is used and the function is implicitly lifted to generator, similarly using `await` implicitly lifts function to async, so there's no need to mark function as async explicitly - very good idea IMHO), ES2015 classes and some other changes.

CoffeeScript is still what it was before - making code easier and more pleasurable to read and write: less verbose, everything is an expression, existential operator, better switch, comprehensions, prototype access operator, chained comparisons, block regex, implicit returns, range loops...

[1] http://coffeescript.org/v2/

Re:A set of efficient persistent immutable data structures f... by jordwalke on Tuesday March 28, 2017 @07:14PM (#13981763)
Also note that there are some language features which are surprisingly syntactic - which are well within the scope of Reason : For example, some basic facilities for export/import as well as async transformations. These are all being discussed/proposed in the Reason channel, and they can be implemented in an opinionated syntax without needing to fragment the OCaml ecosystem - providing full interop between existing OCaml packages / tools. Once/if a build system is standardized in the OCaml community, there are even more interesting features and tools that can be built, and can be given first class syntactic treatment from within Reason.
Re:A set of efficient persistent immutable data structures f... by chenglou on Tuesday March 28, 2017 @03:53PM (#13980062)
I work alongside the Reason team. We're using it on messenger.com. 25% converted over already. 4 bugs during conversion, and only a single runtime bug in the converted part since last half.
Re:A set of efficient persistent immutable data structures f... by tekknolagi on Tuesday March 28, 2017 @06:48PM (#13981561)
> work alongside

Cheng, you're pretty much a full time contributor :P

Re:A set of efficient persistent immutable data structures f... by zem on Tuesday March 28, 2017 @04:09PM (#13980184)
messenger.com is written in ocaml? that's pretty neat!
Re:A set of efficient persistent immutable data structures f... by chenglou on Tuesday March 28, 2017 @04:11PM (#13980207)
Converted. From reactjs to reason-react https://github.com/reasonml/reason-react

Which imo is a bigger achievement! Being able to gradually convert a js codebase over is one of our main goals.

Re:A set of efficient persistent immutable data structures f... by zem on Tuesday March 28, 2017 @04:55PM (#13980603)
indeed! i would love to read a blog post about the conversion.
Re:A set of efficient persistent immutable data structures f... by Touche on Tuesday March 28, 2017 @04:13PM (#13980221)
The front-end or back-end? The front-end isn't what I would call an endorsement of whatever framework/language is chosen.
Re:A set of efficient persistent immutable data structures f... by chenglou on Tuesday March 28, 2017 @04:46PM (#13980522)
Ooooouh that's harsh lol. Sorry for your experience. We're trying to improve it but we're a tiny team that also maintains other features.
Re:A set of efficient persistent immutable data structures f... by Touche on Tuesday March 28, 2017 @08:27PM (#13982196)
I didn't mean to offend, and I understand. But it's 1.4mb of JavaScript that takes 4 seconds to load on my high-end Macbook.
Re:A set of efficient persistent immutable data structures f... by 49531 on Tuesday March 28, 2017 @04:12PM (#13980213)
messenger.com is 25% Reason
Re:A set of efficient persistent immutable data structures f... by tyoverby on Tuesday March 28, 2017 @05:44PM (#13980995)
I tried using Reason for a side project. Getting the build tools and the package manager for ocaml took too long so I gave up.
Re:A set of efficient persistent immutable data structures f... by chenglou on Tuesday March 28, 2017 @05:46PM (#13981015)
If you're still willing to give it a second chance, we've got https://github.com/chenglou/reason-react-example which uses only npm Sorry for the crappy initial experience.
Re:A set of efficient persistent immutable data structures f... by tyoverby on Tuesday March 28, 2017 @05:51PM (#13981050)
I did see that, but I discounted it because I wanted to make a serverside (native, not serverside-js) application, and I assumed that the reason-react-example was only for making compile-to-javascript applications.
Re:A set of efficient persistent immutable data structures f... by jordwalke on Tuesday March 28, 2017 @06:50PM (#13981580)
Just so we don't miss the opportunity to learn - would you mind stating what you would find valuable in a toolchain for building a server side native system? What kind of things about project management/install appeal to you?
Re:A set of efficient persistent immutable data structures f... by tyoverby on Thursday March 30, 2017 @03:43PM (#13998309)
The most important part of language tooling for me is reproducability. I should be able to do the following to any project:

    git clone <project name> && cd <project name>
    <build tool> build
And have it fetch all of that projects dependencies, and then build the entire system.

Anything that requires machine-wide package installation is immediately disqualified (user-wide package installation is almost as bad).

Re:A set of efficient persistent immutable data structures f... by Flow on Wednesday March 29, 2017 @03:21AM (#13984099)
When will ReasonML use the latest OCaml? Maybe it doesn't matter much, but it's still quite an old version.
Re:A set of efficient persistent immutable data structures f... by jordwalke on Wednesday March 29, 2017 @06:59AM (#13984930)
We are compatible with 4.03 and 4.04 via opam!
Re:A set of efficient persistent immutable data structures f... by Flow on Wednesday March 29, 2017 @07:07AM (#13984970)
That's great to hear. It's often a bad sign when base-something can't be upgraded and lags for years.

I think you need to update this page since it mentions 4.02.3 still. https://github.com/facebook/reason/blob/master/README.md#ins...

Re:A set of efficient persistent immutable data structures f... by jordwalke on Thursday March 30, 2017 @01:30AM (#13993151)
Thanks for the reminder.
Re:A set of efficient persistent immutable data structures f... by david-given on Tuesday March 28, 2017 @06:54PM (#13981612)
I had much the same experience. I'd be interested to try it for general purpose programming, but the setup procedure is so tied into doing web work that I couldn't figure out what I was supposed to be doing.

What's Reason's debugger story like?

Re:A set of efficient persistent immutable data structures f... by bordoley on Wednesday March 29, 2017 @05:25PM (#13990712)
Red (https://github.com/reasonml/red) provides a useable frontend to the ocaml debugger. If your code compiles with bucklescript (most code will), the debug experience using node and the chrome inspector is surprisingly good even without source maps. The compiled ocaml maps to remarkably straight forward javascript for most code. I used both while developing Immutable-re.
Re:A set of efficient persistent immutable data structures f... by tekknolagi on Tuesday March 28, 2017 @06:19PM (#13981301)
If you'd like, I can help you get set up on Discord: http://discord.gg/reasonml
Re:A set of efficient persistent immutable data structures f... by rixed on Wednesday March 29, 2017 @12:43AM (#13983461)
May I ask what you end up using?
Re:A set of efficient persistent immutable data structures f... by tyoverby on Thursday March 30, 2017 @03:37PM (#13998261)
Ended up just writing it in Rust which I've been using for years now. I wanted to try something new, it's hard to compete with Cargo for package management + build tools.