HN user

dmjio

119 karma

[ my public key: https://keybase.io/dmjio; my proof: https://keybase.io/dmjio/sigs/H8Hn3RInXPBmNeax-ylskoTXk4V1DvbCgB4YnChWpno ]

Posts14
Comments30
View on HN

Yes, miso uses the JS backend in GHC, and mobile phones have embedded JS interpreters (e.g. JavaScript Core). These interpreters can access native libraries to draw native views, or access native device APIs.

Projects like lynx and react-native automate this process using something akin to node-gyp, exposing kotlin / swift libraries via C ABI w/ a JS API. Miso accesses the kotlin / swift native modules by FFI'ing into the JS that exposes them.

The JS doesn't get compiled, but on Android it does get JIT'd. So it's "native" in the sense that the views drawn are native (not WebViews), and the device APIs are native, but not "native" in the sense that it's compiled.

There is a company that has a 400 module miso application and the bundle size is not an issue (https://www.polimorphic.com). After closure compilation GZIP'ing, pre-rendering and caching of the JS, it's a one-time cost, and is negligible due to pre-rendering. We build websites for users, who care only about experience, not about how large the payload is. Payload only matters insomuch as it adversely affects user experience. This argument is strictly a developer concern and is in no way correlated with end-user feedback. There are many <1MB js payload size websites with 0 users.

Why thank you kind sir :) Using advanced optimizations with google's closure-compiler, the todo-mvc example can get down to 500kb. Compressed it might even be smaller. This is why having the "isomorphic" part is important. This way the user will see content immediately while the app bootstraps in the background and sets up event delegation. Then events will get routed through the vdom to pure haskell functions and the app is responsive again.

The choice of using Haskell was due primarily to 3 things.

1) Code reuse - The ability to share types on both client and server.

2) Hackage - by using Haskell you have access to 90% of Hackage on the frontend (this means nice lens and json libraries).

3) Types - Haskell's type system can express higher-kinded and poly-kinded types (something which Elm cannot afaik), this gives the user flexibility, expressivity and safety.

The code is quite performant, but for the fast stuff miso FFIs into hand-written js.

In regards to output size, the generated js can be very large. But, the generated code is in a state where it can use the closure compiler's ADVANCED optimizations. That combined with caching the rts.js and gzipping, you can probably get down to a few hundred kbs (which is large by a lot of people's standards), but workable

The RFC says all JSON text must be an array or object, null is a value. JSON text is made up of JSON values.

per the RFC,

"JSON can represent four primitive types (strings, numbers, booleans, and null) and two structured types (objects and arrays)."

"An object is an unordered collection of zero or more name/value pairs, where a name is a string and a value is a string, number, boolean, null, object, or array."

Haskell vs. C 13 years ago

To show that haskell and C can achieve equivalent performance on certain numeric calculations.

Haskell vs. C 13 years ago

I believe it is called stream-fusion. The intermediate data-structures are optimized away (since they're unboxed), allowing for faster operations.