4 ms·
Not sure where the hostility is coming from. I didn’t read anything disparaging about Haskell in hencq’s comment. He/she just made a factual statement about Clo
by adamkl 6y ago
Not sure where the hostility is coming from. I didn’t read anything disparaging about Haskell in hencq’s comment. He/she just made a factual statement about Clojure’s approach to data types being analogous to Unix/strings when it comes to composition.
It comes with the same drawbacks (the lack of static typing is similar to strings with Unix; you have to be aware of the details of the data coming in and out because there is no type system to save you - unlike Haskell), but the benefit is easier composition.
- hencq 6y agoYeah, I didn't mean anything disparaging about Haskell at all. I only mentioned Haskell as an example of a functional programming language. I tried to make a point (apparently poorly) about the easy composition that using a limited number of (dynamic) types enables. Of course all the usual dynamic vs static tradeoffs apply. Thanks for doing a better job explaining that :-)
- crimsonalucard5 6y agoI don't think dynamic typing or static typing really applies. In either case you have to compose functions With the correct types otherwise you hit an error. The difference with dynamic types and static types is when this error occurs. Run time for dynamic types and compilation time for static types. Either way some type of error will always occur regardless. Though I agree with you if you have a limited number of types things become easier to deal with.
- slifin 6y agoClojure's static analysis tools can warn you of incompatible types I.e. this will warn (inc "hello") in clj-kondo
- mrslave 6y agoIt was kinda funny, and not nasty at all. Let's assume good faith here?
- mcv 6y agoThis is something that also works well in the nicer parts of javascript. Now nobody is ever going to accuse javascript of being a good functional language (disparage away), but at its core, you've pretty have arrays, maps, numbers, strings, booleans and functions. An Object is really just a map of key-value pairs where some values are functions. You can .map() an array of objects to an array of strings by feeding it a function that turns an object into a string. It's really nice to build those little blocks and cobble them together into something that accomplishes something more complex.
- crimsonalucard5 6y agoI use to be pretty negative about JS, but typescript saves the day. The lego aspect of functional programming always becomes more evident when you have static types.
- mcv 6y agoI've been getting more mixed about Typescript lately. Quite often, you end up with everything being `any`, and every time you write something, the compiler makes you hunt down the missing types. But being able to specify interfaces for lambdas is absolutely fantastic. Something like: "this function takes an object and returns a function that can take either a string or a number and returns a number" is easy to do in Typescript, and useful for figuring out where the lego block fits.
- crimsonalucard5 6y agoI just go strict. Never use Any unless I absolutely must. Hunting down the types is just the price you pay for what is basically a huge reduction in hidden runtime errors.