HNHacker News
TopNewBestAskShowJobs

a0

625 karma · joined March 16, 2013

http://rizo.odis.io
submissionscomments
a0··on TypeScript vs. ReasonML
I think I don't mind lack types as much in immutable languages. Clojure and Erlang are like that. But they're also both simple languages with simple semantics.

One issue I have with Clojure is when I have to work with nested datatypes to perform transformations. It's just too hard to keep the shape of that data in your head. Types help with that.

Another important thing is modelling business domains with types. By this I really just mean record and variant types and not some advanced type-fu. It really helps seeing what kind of data your application manages.

a0··on TypeScript vs. ReasonML
> Common reaction from them I receive very often "We never knew that JS/TS can do that"

Maybe it's about what you cannot do in ReasonML, and not about what you can do in TypeScript? :)

a0··on TypeScript vs. ReasonML
One problem with people selling ReasonML's type inference is that it's not depicting the actual developer experience.

The first thing to note is that you do interact with types to build a mental model! The editor will show them to you as you move your cursor around the code. It will do that for every single value. Just move the cursor over that `requestContext` argument and voilà, it'll show you the type.

Another important aspect is that you still have to define types. Have a person object with a bunch of fields? You do have to type annotate every single field. Have multiple actions to handle in reducers? You need to tell ReasonML in advance what those are using a variant type.

And finally, if you care about composition/abstraction you should provide interfaces for modules. This requires writing types for all functions explicitly to ensure that you are exposing a correct protocol. This is optional, but it helps both the author of the code and the consumers.

Type-inference is just a nice to have feature for the low-level implementation details.

a0··on TypeScript vs. ReasonML
ClojureScript is beautiful! If only it had types :)
a0··on TypeScript vs. ReasonML
Being a Vim/Merlin user I normally just type `<Leader>t` to see the type of the value under the cursor (this maps to `:MerlinTypeOf` if I recall correctly).

What I do use type annotations for is debugging. If the compiler finds a type error, in some situations it helps adding type annotations to find where the actual error is.

a0··on TypeScript vs. ReasonML
There was a workshop at the last ReasonLDN meetup. Here are the slides that were used, they include quickstart instructions: https://docs.google.com/presentation/d/1wuAveSHslRfKShD6SiVd...

If I recall correctly, everyone managed to set things up swiftly, with an exception of one Windows user who had some editor issues.

a0··on TypeScript vs. ReasonML
One place where clean build times do matter is in the CI. Having very fast builds and tests is great for speedy deployments.
a0··on TypeScript vs. ReasonML
This kind of comments make me really sad. Most ReasonML developers are actually "JavaScript developers".

ReasonML was specifically designed for JavaScript developers. Being JavaScript-friendly is in it's DNA really. I even see ReasonML a language that was specifically designed to work with React.

I can understand why you would feel this way though. I think the main problem is that ReasonML introduces new concepts that simply do not exist in JavaScript. Learning those concepts is hard. But if it wasn't hard, would you be learning anything or just writing JavaScript in a slightly different way?

Are there any specific examples of things that look too "distant" from JavaScript?

I'll finish this by saying that ReasonML will make you a better JavaScript developer. As will probably learning any other language that challenges the way you think.

a0··on TypeScript vs. ReasonML
Many interesting points! :)

> Why do people care about this? Writing type annotations is not that much work (...)

I personally care about this when I'm prototyping something. Not having to write types means that I can simply write what's on my mind. The benefit of good type inference is that the compiler can still help me highlight any mistakes I made during this process.

Another benefit is that some production code can get very complex. Having to type every single value is just too cumbersome and distracting. It contributes to boilerplate and increases cognitive load, in my opinion.

> Having really smart type inference makes your compiler slower and more complicated.

I would actually disagree with this. First of all, ReasonML's compiler is absurdly fast. No, seriously try it. Sometimes I go and double check the generated JS code just to be sure it actually did anything.

Regarding the "more complicated" part – the only reason why full type inference works is because it is based on a very solid theoretical foundation. It might be somewhat "complicated", but it will never be as complicated as something ad-hoc that needs to account for all inconsistencies that exist in untyped languages like JavaScript.

a0··on TypeScript vs. ReasonML
It's ok. There's pretty good support for linting and code completion. The plugins are fast and have a rich feature set.

Take a look at this: https://marketplace.visualstudio.com/items?itemName=jaredly....

The only problem that I have found is that in some situations it doesn't report errors correctly when adding new dependencies. Refreshing the window or rebuilding the project usually helps.

On the other hand, the compiler feels very solid. It can be annoying in the beginning because of how disciplined the code needs to be, and the error messages can be hard to understand.

After getting used to that, the dev ex is really smooth specially during complicated refactoring, the compiler and the IDE make things almost boring.

a0··on TypeScript vs. ReasonML
Many modern languages support type inference to some degree. The special thing about ReasonML is that the type inference is much more robust and complete.

In practice you don't need to provide any types annotations at all at any point in your program and you should still get the same safety benefits.

Every value in your code will automatically have one single type assigned to it based on how it is being used. When the compiler finds contradictions it will let you know about it. On the other hand, Typescript will try to unify the type to some sort of Any, which is probably not what you want.

a0··on Cmm_of_wasm: From WebAssembly to Native Code via the OCaml Back End
WASM currently does not have a GC but that's precisely why one is needed. Languages that target WASM need to implement their own GC but there's already a proposal to integrate a GC implementation into WASM[1].

[1]: https://github.com/WebAssembly/gc/blob/master/proposals/gc/O...

a0··on ReasonML: Strict, powerful and forgiving
In principle it seems like a significant limitation but in practice it is rarely an issue.

ReasonML does support parametric polymorphism so it is still possible to write generic code.

Some language features conveniently help to avoid boilerplate. For example it’s possible to have a `Float` module with arithmetic operators and “open” it like this: `Float.(10.0 + 0.5 / 3.0)`.

There’s also a work in progress project called Modular Implicits that will introduce ad-hoc polymorphism.

a0··on ReasonML: Strict, powerful and forgiving
I used OCaml in production for a 2 years and it was a very pleasant experience. Recently I started using ReasonML at my team to implement a Kubernetes configuration tool. It’s surprisingly easy to use ReasonML for backend development with dune and esy.
a0··on Show HN: Personal avatar generator built in ReasonML
Great seeing more apps being built in Reason! How was your experience with it?
a0··on Braid: A functional language with Reason-like syntax that compiles to Go
I think implementing a Go backend for Reason would be a better approach. Existing libraries, could be reused and it would be easier for people familiar with Reason/OCaml to learn the language.
a0··on A curated collection of OCaml tools, frameworks, libraries and articles
There’s also a desicated list for ReasonML now: https://github.com/vramana/awesome-reasonml
a0··on Show HN: Sketch.sh - Interactive OCaml and ReasonML Sketchbook
This is a brilliant tool that fully shows the potential that Reason/OCaml provide as a platform.

Good job!

a0··on Introduction to Functional Programming in OCaml
For everyone interested in learning OCaml, there's a very active Discord community where you can ask questions: https://discord.gg/ZBgYuvR

Join and say "hi"! :)

a0··on Goodbye Python, Hello Go
If you want something closer to Rust, consider looking into Reason. It’s essentially OCaml with braces and semicolons.
a0··on Goodbye Python, Hello Go
Single-process concurrency is great in OCaml. It’s flexible and composable with libraries like Lwt and Async. On the other hand true multicore backend is where the most work is moment. For the latest update on that see: https://discuss.ocaml.org/t/ocaml-multicore-report-on-a-june...

(Tl;dr: It will be officially merged in 2019.)

a0··on Unix system programming in OCaml (2014)
This is such a great book. OCaml’s type system feels like a superpower specially in the context of Unix development which is traditionally done in C.
a0··on Plans for OCaml 4.08
The most unique feature is the type system which allows you to both model domain problems effectively and guarantee consistency. This reduces a huge number of bugs in compile-time.
a0··on Plans for OCaml 4.08
Syntax errors are suboptimal. They are usually reported at correct location and it's relatively easy to spot them.

On the other hand type error messages are simply awesome.

a0··on Plans for OCaml 4.08
It's really great seeing this contributions from JaneStreet. If you're interested in learning more about recent progress in the OCaml's ecosystem, I recommend watching this talk: https://www.infoq.com/presentations/ocaml-browser-iot
a0··on New implementation of Git in OCaml
There’s a beginner’s guide to OCaml’s beginner’s guides: http://blog.nullspace.io/beginners-guide-to-ocaml-beginners-...
a0··on Why ML/OCaml are good for writing compilers (1998)
Just want to note that, while not frequently seen, you can use more powerful abstractions (monad transformers, parser combinators, etc) in OCaml.

As an example consider looking at the Angstrom[1] parser combinator library and my Pure[2] functional base library.

[1] https://github.com/inhabitedtype/angstrom

[2] https://github.com/rizo/pure

a0··on JSCaml: A compile-time transformation from JavaScript to OCaml
JavaScript, OCaml, Reason, BuckleScript – such a language ouroborus!

It's amazing how this kind of language interoperability can enable new development and deployment approaches.

a0··on Ask HN: Have you created a programming language and why?
I'm working on Fold – a modern functional language with lisp-like macro-system on top of OCaml.

- https://github.com/fold-lang/fold/wiki/Language-Overview

The language syntax is defined as a library and can be extended, which makes Fold ideal for DSL implementation. The powerful macro system can also be used to perform many static optimisations. My goal is to have a very flexible and performant language specially suitable for data processing.

a0··on Pyret – A language exploring scripting and functional programming
> there are a few minor things i'd probably have done differently, but on the whole i find pyret code very pleasant to read.

Curious to know what would you have done differently. I'm working on a programming language based on OCaml with Ruby-like syntax.

Page 1 of 3Next →