4 ms·
Highly regular natural languages exist and thrive. I'd say that Japanese is a way, way more regularly structured language than English. Loving flaws like buffe
by nine_k 3y ago
Highly regular natural languages exist and thrive. I'd say that Japanese is a way, way more regularly structured language than English.
Loving flaws like buffer overflows looks more like a Stockholm syndrome to me: when the reality is terrible, people learn to find lovable bits in it, just to avoid insanity. C has its place, but its place is very, very close to hardware. (And I hope Zig will push it from there, too, eventually.)
I don't think that better static guarantees are going to come from direct adoption of languages like Haskell, or some tools like Coq or Agda. They will continue coming the same way Rust and Typescript gone mainstream: by integrating them into practical (not research) languages, and allowing escape hatches, prominently marked. Advanced features need adaptation to be ergonomic, after that they feel natural. This happens to every scientific achievement that has a large practical value: compare a laser on an optical workbench in a lab to a laser in a DVD drive, or a laser pointer.
I would likely laugh if someone told me in 1995 that pure FP approaches will conquer GUI development. Nevertheless, this happened twice: first with XSLT in 2000s, then with React in 2010s.
- eindiran 3y agoIt's funny that you picked the language with the single worst and most fundamentally broken orthographic system in the world as your example.
- valenterry 3y agoreact is not an example for a library that is supposed to be or even possible to be used in a pure functional programming way.
- adamwk 3y agoRight, there's definitely functional-inspired bones (e.g., a view is a function of state); but every hook is a side effect, even the redux ones. And I don't think it would even be improved by being pure; Elm has much more boilerplate to do similar things.
- valenterry 3y agohaha, Adam from SM, is it you?
- WorldMaker 3y agoReact can still be viewed as functional programming if you assume Hooks operate in/on/with an unnamed/untyped monad. ("Pure" of course depends on your take of monadic programming from there.) It might be nice if that monad were better typed and/or at least parametric (reflected in input or output parameters), but it all exists in an untyped language to begin with, so it is mostly fine how it works right now. Mostly.
- valenterry 3y agoI don't know. I haven't used hooks much, but while you might consider it pure-functional in a way within a component that uses (a single) hook, I think using multiple hooks and having everything integrated is certainly not pure-functional. It's easy to test right? Can you replace calls/expressions with their result-value? If no, it's not pure-functional.
- WorldMaker 3y agoLike I said, I don't think it counts as "pure" functional because it is heavily monadic. Many Haskell users still think non-monadic code is "more pure" than say anything that uses the IO Monad and Hooks are "worse" than the IO Monad. (Especially some of the "Suspense" project Hooks which combine IO and Futures and State and more from a Haskell standpoint into one super weird monad.) You can certainly replace most hooks with static return values. Many hooks are heavily memoizable and in turn heavily memoized which is how they find their performance in practice. Multi-hook interactions generally follow a lot of the laws of monadic binding and a lot of the "hooks rules" aren't that strange in terms of monads: monadic binds have sequencing that matters (and dependencies you might track). The order of hooks matter in the same way that the order of IO binds or the order of Futures/Promises awaits. Again, it is certainly hard to call it "pure" functional in most ways, it has a lot of impurity, but it is certainly "deeply" functional. There's not really a better paradigm to call what is React is doing with Hooks than "functional programming". The language of monads is somewhat helpful in reasoning about how Hooks work and where they sit in the paradigm. They definitely make everything a bit more "impure", especially from the strict mathematical sense of "pure functions are entirely dependent on their parameters". Especially with Hooks not being represented parametrically (which I did mention I think can be something of a problem and I wish wasn't the case).
- nine_k 3y agoLook, you have a large stream of pure functions that exchange immutable data. There is a place where you can thread in the effects, and it's not entirely like using >>=, but after it, it's immutable data and pure functions again. It's very different from jQuery and the callback hell, or from any two-way bindings all the way to Visual Basic. It teaches you to value immutability and purity, to crave it (then comes Ramda, etc). Also, Promises are not entirely monadic, and `async` is not entirely the do-notation, but you can use a lot of monadic approaches, and reap some of the benefits.
- valenterry 3y ago> and it's not entirely like using >>= Exactly, and that's why it is not pf. It's really as simple as that. It's also not as if it would be theoretical distinction that has no meaning for praxis. It does. For instance, since I cannot control the execution of React's cycle (including rendering) it becomes hard(er) to do certain kind of page animations that should happen between renders. > It's very different from jQuery and the callback hell Yes, it is nicer to use. But it is not pfp-style.
- nine_k 3y agoWhat would you suggest as a pure enough example of FP GUI? Anything besides Elm, I mean? :)
- valenterry 3y agoI have never worked with one professionally (I rarely do frontend work anyways) and for my own projects I used react, dirty and productive as it is. ;)
- c_crank 3y agoJavaScript has never been and probably never will achieve any sort of purity due to the design decisions made in its debut. Frameworks can only paper over that so much.
- valenterry 3y agoI mean, there are fp-ts and ts-effect. Sure, internally they do nasty things, but at least as a user I think it's possible to write pf or at least mostly pf code. (without commenting on whether that is a good idea or not)
- eyelidlessness 3y agoYou can actually type JS to be incredibly more strict than TS does if you have the motivation. It still won’t be impossible to reach runtime errors, but it can be very close to “you really have to try and mean it”.
- rirze 3y agoFunny enough, Japanese is incredibly fun and enjoyable when you use dialects and break the syntax to be "artsy"
- nine_k 3y agoBut even that does not increase the number of irregular verbs past two and a half (くる, する, ありえる). I don't know enough Japanese to say if one can invent forms like "swole" or "boxen" in it, so that they would remain recognizable.
- labster 3y agoArchaisms, slang, and alternate pronunciations definitely exist in Japanese. And dialects, of course.
- astrange 3y agoYou can invent a lot of things in written Japanese using textspeak and other alphabets. Spoken Japanese you can't break the rules because everyone else instantly becomes unable to understand you. They barely use local accents/dialects in media because of this.
- manquer 3y ago> Loving flaws like buffer overflows looks more like a Stockholm syndrome to me: Only if you are the developer (victim ) it is fun to work with buffer overflows if you are the security researcher (law enforcement) or a hacker (kidnapper )