HNHacker News
TopNewBestAskShowJobs

jordwalke

1,558 karma · joined June 12, 2013

Building things at Facebook: React. ReactNative. ReasonML.

https://twitter.com/jordwalke

submissionscomments
jordwalke··on Warp – self-contained, single binary applications
I asked this question just yesterday. The challenge (the one I was interested in) was if this can be done in a general purpose way for arbitrary programming languages so long as they used libc to go through the file system. I actually think it might be theoretically possible using LD_PRELOAD and some equivalent on OSX. I don't know why I'm compelled to want the executable to leave no trace on disk, but it seems much cleaner. However, if you _write_ to the virtual file system, that will need to change the packed binary itself which might result in problems (the binary would grow/shrink as you pack more / less files into it at runtime by writing to the "disk").

https://twitter.com/jordwalke/status/1050277143085608960

Maybe it's just not worth it and a temp directory is not so bad. I just worry about little changes to the way `mktmp` works across OS updates etc. A totally self contained executable that leaves no trace, with virtual file system support is about as isolated and reliable as you could ever hope. I just don't think anyone has been determined enough to achieve it.

jordwalke··on Show HN: Sketch.sh - Interactive OCaml and ReasonML Sketchbook
This is already such a useful part of the Reason/OCaml ecosystem in its current state, and has even more potential longer term. Great work!
jordwalke··on Reason ML toolchain
The main advantage of building on the OCaml language is that it is possible to totally encapsulate an FFI binding in a way that doesn’t virally infect the code path that calls into it. In pure languages this may not be the case. OCaml is not a pure language and so neither is Reason.
jordwalke··on Deploying a ReasonML React app with Docker
I don’t mean to ignore your observation - it is valid. Bsb is a build system that works with a specific form of packages. What you suggest could work too. The only (small?) challenge is that people have bsb JS projects, and they aren’t configured for jbuilder/Dune etc. Because of JavaScript’s immense popularity, the largest number of people will start with whatever build tools integrate well with the JavaScript ecosystem and work from there. This plays out quite predictably. Just as an example, the most important thing to web developers is that each Reason input file becomes a commonJS (or es6) module. That allows integrating your Reason React app with existing web apps easily. So since people start with whatever tools integrate well with the JS ecosystem, they then reach for the easiest tool available to adopt native compilation.
jordwalke··on Reason ML toolchain
Thanks for the tip. Also, we are working on making it easier to isolate opam packages and npm packages side by side in one development environment so that problems like this are avoided. This allows you to build a project that depends on opam packages for build time tooling inside your JS projects. That project is called esy, and it’s a young addition to the ecosystem but something I’ve been using to greatly increase my own productivity for a while now. It will not make BuckleScript compile opam packages (that is not BuckleScript’s goal) but it will at least make the two ecosystems coexist simultaneously.
jordwalke··on Deploying a ReasonML React app with Docker
Reason is supported on every major version of the native OCaml compiler (currently versions 4.02.3 up to 4.06).
jordwalke··on Deploying a ReasonML React app with Docker
Hi, I work on Reason: To add to other comments: One thing that ReasonML can do that TypeScript cannot do, is take advantage of the world-class OCaml compiler to generate very fast native executables. If you learn Reason, then you are also a "native developer" in a sense.
jordwalke··on Does reference counting GC really use less memory than tracing GC
With RC, you might be able to predict when a final reference count goes to zero (though in practice in large apps that might be difficult - I don’t have enough experience) but it doesn’t seem to help you predict the size of the memory graph released as a result, and therefore the time it might take to release it. The size could be determined by lists of arbitrary length that cannot be known statically. The size could be determined by implementation details intentionally hidden from the API consumer to preserve encapsulation. I’m still willing to concede that RC is somewhat more predictable for current RC and tracing implementations, but in my brief experience I’ve observed that this predictability isn’t as significant as you would hope, and it’s very hard to make use of those predictions. One of the ways people try to make use of this predictability is by shipping references off to another thread to perform the decrement count off the main thread in case it hits zero and cascades into a large collection stall. That isn’t really a satisfactory solution and has its own problems.
jordwalke··on Does reference counting GC really use less memory than tracing GC
I think by “determinism” you mean “predictable” because OCaml’s GC is also deterministic (see Core_Bench benchmarking blog post which shows how you actually need to account for this determinism when benchmarking).

You could make the claim that RC is more predictable by humans. I think you just have to decide if that’s true for current and specific implementations of RC and tracing. I am not convinced it is an inherent property of RC - and that the same or greater levels of predictability cannot be achieved in hypothetical or even existing implementations of tracing. What if you only performed traces during times that the user was not interacting? If you can explicitly control that, couldn’t that be even more “predictable” than when releasing a final RC reference and hoping it doesn’t cause a cascading chain of destructors of hard-to-predict size?

jordwalke··on Type-safe GraphQL with OCaml
This is some solid feedback, thanks for taking the time to write it up. I work on ReasonML, so a lot of this feedback describes problems we’d like to help the OCaml community solve. We are making progress on the popularity front by leveraging the JS ecosystem and it is proving to be an effective approach due to the size and openness of the JS community. Meanwhile the OCaml ecosystem (libraries, compilers, build systems(see jbuilder and its docs)) have been improving in the last two years so I would recommend checking it out sometime soon again.

I had a different experience with OCaml libraries. I’ve found some great gems in the OCaml ecosystem. For example, Menhir is an excellent parser generator used in Reason itself and it’s well documented and very powerful. I think many of these great pieces of the ecosystem stay hidden due to the exposure problem you mentioned, which comes back to popularity.

Another major missing piece of the library story was a way to build web apps using the most common web frameworks so we developed Reason React as part of the ReasonML project. https://reasonml.github.io/reason-react/ It’s definitely not a “bolted on” approach to React - it’s carefully thought out and in my opinion the API improves significantly upon React in ways that can only be done with language level type system features. Reason React is how I wish React always was.

Apologies for hijacking the GraphQL library thread to plug our project.

jordwalke··on Type-safe GraphQL with OCaml
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.
jordwalke··on Type-safe GraphQL with OCaml
> “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).

jordwalke··on Reason 3
Currently: lexer, and parser, and AST printer (bidirectional parser you could say), with a few lightweight ppx macros included for UI development.
jordwalke··on Reason 3
Noted and thank you for the constructive feedback. Various people in the OCaml community are working on some of these and we might contribute to some of these missing pieces as well.
jordwalke··on Reason 3
Hi, I’m the original inventor of React and I really like SML, however SML just didn’t have a few of the escape hatches or advanced features that were needed to implement a very usable, extensible, and type safe React interface or implementation, so I eventually explored the OCaml type system and I found that it has many of those missing links. One surprise was that when showing it to fellow UI developers, I would constantly be met with confused looks and after digging into people’s feedback, I found that most developers weren’t seeing the same thing that I was seeing on the screen so they weren’t able to see the ideas expressed in the code. The syntax was very commonly cited as a major point of friction. I don’t see anything wrong with OCaml’s syntax but my opinion alone doesn’t matter because a major goal of software is to collaborate with other people - who matter.

To fix the problem, a couple people from various parts of Facebook got together and started building/testing Reason together, and eventually we shipped what is likely the largest (in terms of machines (billions)) OCaml deployment ever via Reason React.

There’s still many pieces of OCaml beyond syntax that should be improved and we would like to continue fixing all the blockers to adoption that we can. Thankfully the rest of the OCaml community has the same goal and are doing great things at deeper parts of the toolchain and compiler. Our story started from the UI use case so our work and messaging so far has centered around it.

jordwalke··on A ReasonReact Tutorial
You already have that option. Reason's syntax is for the vast majority of developers that do not prefer OCaml's syntax, the majority of them not being OCaml programmers.
jordwalke··on A set of efficient persistent immutable data structures for Reason and OCaml
Thanks for the reminder.
jordwalke··on A set of efficient persistent immutable data structures for Reason and OCaml
We are compatible with 4.03 and 4.04 via opam!
jordwalke··on A set of efficient persistent immutable data structures for Reason and OCaml
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.
jordwalke··on A set of efficient persistent immutable data structures for Reason and OCaml
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)).
jordwalke··on A set of efficient persistent immutable data structures for Reason and OCaml
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.
jordwalke··on A set of efficient persistent immutable data structures for Reason and OCaml
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?
jordwalke··on A set of efficient persistent immutable data structures for Reason and OCaml
They're not different than OCaml's, but Reason's JSX is an interesting / useful application of labeled arguments that appeals to React developers.
jordwalke··on A set of efficient persistent immutable data structures for Reason and OCaml
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.
jordwalke··on A set of efficient persistent immutable data structures for Reason and OCaml
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.
jordwalke··on A set of efficient persistent immutable data structures for Reason and OCaml
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.

jordwalke··on JSCaml: A compile-time transformation from JavaScript to OCaml
Hi, thanks for your interest.

You can check out the development here: https://github.com/chenglou/reason-react-example

Cheng also gave a talk at ReactConf about our efforts.

Things are still quite in flux, but you're welcome to contribute and help improve things.

jordwalke··on JSCaml: A compile-time transformation from JavaScript to OCaml
Hi I'm Jordan and I work on Reason(http://facebook.github.io/reason), and previously worked on ReactJS(https://facebook.github.io/react/), so this touches on a lot of things that are of interest to me. We currently use the OCaml language with the Reason frontend, for UI development, and use BuckleScript for compiling it to JavaScript. To some it might seem like this JSCaml project might be "backwards" in that it compiles from JS to OCaml, instead of the other way around, but both of these share one important / valuable thing in common - they use exactly one memory system, allocator, collector between two different languages. This is very different than embedding a separate VM/language/allocator as a library inside of another language runtime. If you've ever tried to bridge two completely different memory systems together without introducing leaks, you'll quickly realize why JSCaml gets the most important thing right, even if it is missing some JS language features - those missing features can be added over time, whereas unifying two inherently incompatible memory systems can be bankruptingly expensive.

Seamless memory lifetime interop without leaked cycles is essential for incrementally moving a code base from one language to the other. In browsers, that means your only hope is to target semi-idiomatic JavaScript if you want to incrementally move a large JavaScript system to another language. Wasm is currently great for whole-program rewrites from scratch, not incrementally moving over. That's why BuckleScript has been so helpful.

When not running in the browser, you have many more options, and if given the choice between running Reason/OCaml in a JavaScript VM, vs. running JavaScript in an ocamlopt runtime, the later offers many compelling advantages.

1. The ocamlopt runtime allows languages with sound static guarantees to take advantage of those guarantees to emit more efficient machine code, reaching the language's full potential. JavaScript will have to go through all the same dynamic (costly) checks due to its language complexity - at least for object property/method dispatch, but why should that mean that OCaml should have to as well? By running inside of the ocamlopt runtime, it can share one memory system without being limited by an unrelated dynamic language's weaknesses.

2. Depending on the approach, the emitted JavaScript might be able to take advantage of many of ocamlopt's ahead of time optimizations to reduce allocations, and inline function calls (F-lambda for example) without having to wait for the JIT to reach many of the same conclusions (which slows down startup time).

3. Even if the JavaScript compiled to ocamlopt runtime doesn't demonstrate as much throughput as it would with a JIT (once you wait for it to warm up of course), the approach of JSCaml allows you to seamlessly break off bottlenecks and write them in Reason/OCaml which could end up running even faster than JS with a JIT once warmed up (and without having to wait for the slow JS VM's startup initialization).

I'm sure there's a ton of work left on JSCaml until you can one-click deploy your JS programs and see performance wins, but I'm very interested in this general direction, as it has many uniquely compelling advantages that stand to help move the JavaScript ecosystem forward.

jordwalke··on Yoga: A cross-platform layout engine
Hi, I'm one of the contributors to ReLayout. I originally worked on ReactJS, and ReactNative which made use of Yoga (then, css-layout), and now I'm working on Reason and ReLayout (which is a port of Yoga to Reason). I definitely wouldn't call ReLayout the canonical way to compile Yoga to JS. While we intend to keep ReLayout up to date with the Yoga implementation, we're ultimately doing this because we'd like to experiment with combining ReactJS's API, the new Fiber architecture, with a deeply integrated Flex Box layout algorithm. Feel free to message us if you're interested in tracking the results of the experiment, but but for now, I'm just excited to see Yoga launch. The Yoga project and team have been incredibly helpful with our experiment and I'm excited to see more apps integrate Yoga going forward. Congrats! I can't go back to not using FlexBox now that I've gotten hooked on it. (edited: Formatting)
jordwalke··on Compile OCaml to JavaScript, use ReactJS, bindings to ReactJS, several examples
Sander sent a [Pull Request](https://github.com/facebook/reason/pull/647) to [Reason](http://facebook.github.io/reason/) which adds JSX syntax (which many React developers have found helpful)

Reason doesn't yet work with Edgar(OP)'s React bindings yet, but it could easily (and therefore JSX would work as well).

← PreviousPage 2 of 7Next →