11 ms·
What Elm and Haskell are teaching mainstream JS [video]
- VeejayRampay 11y agoReading the site's description of the video, it's more like "how languages like Haskell and Elm are informing the design of Javascript libraries like Redux". So it's not so much Elm and Haskell TEACHING "mainstream" JS (whatever that is) but one library merely taking hints from other programming domains that are relevant to the particular use case it's trying to cover.
- albemuth 11y agoOn a podcast interview, the author of Redux mentions learning about Elm until later, so it's more like "some libraries have converged on similar design principles".
- joshuacc 11y agoSo, that's sort of true, but sort of not. Dan (author of Redux) has said that he read the Elm Architecture document before creating Redux, and didn't fully understand it. But he believes that it did influence the design of Redux. > JAMISON: So had you played with or heard of ELM beforehand or did you just realize the parallels afterwards? > DAN: Yeah. There's been this, I'm feeling guilty about it because I had this Twitter exchange with Evan. Evan was a bit uncomfortable with me not mentioning Elm as much as he thought I should. I felt that yeah, he's probably right because I read about Elm a few times before actually creating Redux. I'm not sure if… when you get inspired by something but don't fully understand it and later you kind of reproduce it but you don't really get this connection and you only get it later. So I think that's kind of what happened because I distinctly remember reading about ELM architecture but I was thrown out by the syntax, so I didn't fully understand what's going on there. Later after some initial iterations of Redux, Andrew Clark actually showed me how it's similar to Elm if we changed some things. We did change them. > Yes, I have not actually played with Elm yet. I've seen other people playing with it. I've seen some demos but I have not actually played with it myself. I really want to but I'm stuck in maintaining and GitHub issues and I can't find the time. I don't know. Maybe I'm just afraid it's going to be so awesome that I'll just try the JavaScript development. Source: https://devchat.tv/js-jabber/179-jsj-redux-and-react-with-dan-abramov https://devchat.tv/js-jabber/179-jsj-redux-and-react-with-da...
- crimsonalucard 11y agohttp://www.purescript.org/ http://www.purescript.org/ Worth mentioning when talking about this topic. Purescript is a Haskell like language that was designed for the frontend. I'm surprised as it seems like the presenter doesn't even know about purescript.
- mikemcgowan 11y agoPureScript is mentioned on one of his slides.
- marrs 11y agoIt's nice that JS devs are continuing to discover functional programming techniques, but it irks me a little that this is considered to be some sort of new development. JS has always attracted SICP-inspired programmers because of its strong resemblance to Scheme. Doug Crockford popularised prototypical inheritance and function programming techniques in JS on his blog nearly 10 years ago. KnockoutJS has been around for a similar amount of time and data flow was a big part of its design. React and Elm are evolutions of design that has been a part of front-end dev for a long time.
- jahewson 11y agoFirst class functions are only one aspect of functional programming. Immutaility is a core feature which has only recently seen popular adoption in JS, with projects such as immutable.js. Out of the box JS doesn't offer the data structures necessary to code naturally in a Scheme-like manner. Couple this with the new concept of Virtual DOM as pioneered in React and you get purely functional UI on the web, a radical departure from the status quo of just a few years ago. Defintely a new development for JS. Indeed, React Native suggests that this could be an important development for UI in general.
- kyllo 11y agoExactly. Vanilla JS (and JQuery and friends) have the semantics of mutating a tree (the DOM) in-place. A key differentiator of these functional libraries is the immutable data structure semantics.
- rprospero 11y agoAs a recovering schemer, I often heard how Javascript is very closely related to Scheme, but I've never really seen the resemblance. Granted, both languages possess: * Dynamic Typing * Garbage Collection * First Class Functions However, Python also meets those requirements. Now, looking at it from the Scheme perspective, Python is missing * Tail Recursion * Macros * Continuations * Concise Language Spec However, Javascript is also missing those same factors (though I might be wrong about the tail recursion). Yet, I rarely hear of Python described as an infix version of Scheme, yet I often hear that remark about Javascript. I really want to like Javascript and I already do like Scheme, so I have a vested interest in seeing the connection, but I'm still missing something. What's the strong resemblance between Scheme and Javascript?
- DarkTree 11y agoAs a year-deep front end developer, I have recently taken a strong interest in functional programming principles and am trying to learn their use-cases. Does anyone have ideas for small projects I can complete that will really drive home the importance/benefits of functional programming?
- 1971genocide 11y agoRead "Learn you a good haskell" - and practice the exercises in that book. It helped me a lot to understand the practical side of functional programming. For a book that maximizes the utility of functional programming in your everyday life I would recommend "functional javascript" by the famous author of underscore.js
- SpaceCadetJones 11y agoNot a project, but maybe check out the book JavaScript Allonge which I believe is free to read online
- nine_k 11y agoDirectly available as https://github.com/raganwald/javascript-allonge https://github.com/raganwald/javascript-allonge
- eddd 11y agoElm tutorial walks you through simple "mario bross" game. It is quite fun. http://elm-lang.org/examples/mario http://elm-lang.org/examples/mario
- hepta 11y agoCuriously, the biggest benefits (of typed functional languages) for me are revealed with larger codebases or spiked code that I have to revisit some weeks later.
- imakesnowflakes 11y ago> that will really drive home the importance/benefits of functional programming.. From my experience with Haskell, on a practical level, I think it really comes down to a guarantee that you will not be able to mess the code up beyond a certain extant. I am not really sure if it should be attributed to the type system or to functional programming in general. A functional programming language require a really good type system, because you need it maintain sanity with you have to chain together functions a lot more than you do in an imperative language. So I think it has to be a mix of both.
- estebanrules 11y agoElm is definitely a very interesting language. I would recommend the following if anyone is interested in seriously learning it: https://pragmaticstudio.com/elm https://pragmaticstudio.com/elm
- danneu 11y agoAnd for Redux, the creator (Dan Abramov) recently released a bunch of tutorial videos for free on egghead.io: https://egghead.io/lessons/javascript-redux-the-single-immutable-state-tree https://egghead.io/lessons/javascript-redux-the-single-immut...
- sedachv 11y agoSome developers are taking a really "creative" interpretation of the lessons of functional programming. I am currently dealing with a codebase (CoffeeScript) full of: _.reduce some_array, (result_array, object) -> ... result_array.push xyz ... return result_array , []
- 15155 11y agoIn a lot of languages, stdlibs, what have you, map is implemented in terms of a reduce like this. In a non-lazy language, this kind of a reduce is usually necessary when you want to omit an item efficiently from the resultant array - map does not offer a way to do this.
- sedachv 11y agoDid you miss the explicit side-effects in the code above? This isn't like a map/filter in terms of fold, it is a very stupid way of writing a 'for' loop.