3 ms·
> Folks who prefer dynamicly-typed languages are generally of the opinion that working with compiler error messages sucks. This is not at all why I prefer dyna
by Touche 11y ago
> Folks who prefer dynamicly-typed languages are generally of the opinion that working with compiler error messages sucks.
This is not at all why I prefer dynamically typed languages. Try doing some JSON parsing in Haskell for a non-trivial payload (like something with nested objects) without wanting to pull your hair out.
- spion 11y agoIts an upfront cost for sure, but it more than pays out throughout your program later as you have guarantees for the shape of the data
- rtfeldman 11y agoIt doesn't have to be like that just because the language is compiled, though...for example, Elm's JSON parsing is quite nice: http://elm-lang.org/blog/announce/0.14#making-json-easier http://elm-lang.org/blog/announce/0.14#making-json-easier
- eru 11y agoGood point. Small nitpickery, compiler is not equal to statically typed. Counterexamples: Common Lisp is dynamically typed, OCaml and Haskell are statically typed. All three languages have both compilers and interpreters. (Some crazy persons even wrote C interpreters, for what it's worth.)
- Touche 11y agoI can't tell from those examples if it's good or not, the json shown is all trivial 1 level deep json that you rarely encounter in real life. How it handles nested objects and array, deeply nested objects and arrays is what I'm interested in. Not the ability to handle a Point payload. I know in dynamic language it's typically a 1 liner. I'll endure a little more work than that, but my experience from Haskell was quite painful.
- japesinator 11y agoHave you tried https://github.com/bos/aeson https://github.com/bos/aeson? It's extremely fast and also quite easy to use.
- palmtree3000 11y agoI've been doing exactly this, and lenses make this pretty painless: https://github.com/rocurley/Nations-Graph/blob/master/NationsGraph/HTTP.hs#L50-L60 https://github.com/rocurley/Nations-Graph/blob/master/Nation...
- JoshTriplett 11y agoThat's much less a function of static typing, and much more a function of immutability. There are programming constructs to help with that (such as lenses, mentioned in another comment), but there's also nothing stopping you from writing very compact statically typed code that mutates a value three levels down in a JSON tree, if you had a mutable data structure.