TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Learn Functional Programming Visually

354 pointsby polyrandover 4 years ago

20 comments

j1eloover 4 years ago
This I don&#x27;t understand: Seems like whenever functional paradigms are discussed, the whole same stuff is always repeated without failure: on one hand fuzzy generalizations like &quot;pure functions&quot;, &quot;no side effects&quot;, &quot;no state&quot;... on the other, all examples always talking about using map, filter, fold, flat, zip. One would think that &quot;functional programming&quot; _is_ using those functions. That FP is all about Iterators and what things you can do with them.<p>But I never see contrived real-world examples, those that <i>really</i> show how things are different from imperative or procedural programming. I want to see how you use stateless functional programming to control a garage door actuator. Or how you model a Car which can have their doors open or closed either by the class itself or external actors. How do you receive UDP packets, including a buffer implementation that is able to sort out-of-order packets and send retransmission requests for missing ones? That kind of stuff.<p>Are there any resources that show these kind of &quot;here is a list of problems, how they are typically solved, and how you could solve with FP&quot; style examples?<p>EDIT: This message was actually to say thank you and that TFA is an awesome resource to help understand how the Iterator methods work! And then I got lost in my semi-rant and forgot to actually say thanks :)
评论 #26134922 未加载
评论 #26135716 未加载
评论 #26135121 未加载
评论 #26134777 未加载
评论 #26135596 未加载
评论 #26134470 未加载
评论 #26134488 未加载
评论 #26137074 未加载
评论 #26285751 未加载
评论 #26136726 未加载
评论 #26137500 未加载
评论 #26139569 未加载
np_tediousover 4 years ago
Cool game!<p>Headline here might be a little grandiose. Author has &quot;A puzzle game inspired by functional programming&quot; on the project&#x27;s Github. I find this more apt
maartenhover 4 years ago
This reminds me of the tree diagrams I wrote during the Term Rewriting Systems course at the Vrije Universiteit [1].<p>Functional programming really started to resonate with me at that time. Properties like confluence were very useful to understand distributed systems algorithms later on, and e.g. how eventual consistency plays out.<p>[1] The teacher was awesome too. If you&#x27;d like to learn more about term rewriting systems, go take a peek at his slides <a href="http:&#x2F;&#x2F;joerg.endrullis.de&#x2F;teaching&#x2F;#trs" rel="nofollow">http:&#x2F;&#x2F;joerg.endrullis.de&#x2F;teaching&#x2F;#trs</a> (Note, just noticed that they are behind a password. A gentle email will probably get you the slides though :)
评论 #26132184 未加载
auggieroseover 4 years ago
Cool game, but I don&#x27;t think it is actually a good idea to see this as &quot;learning functional programming&quot;.<p>After all, this shows some very convoluted ways of getting a simple end result ;-)<p>Also, I&#x27;ve only played the first few easy levels, so I guess there will be more than &quot;map&quot; later on? Otherwise I would just leave the &quot;map&quot; word out of it.
评论 #26136731 未加载
评论 #26136533 未加载
austincheneyover 4 years ago
The biggest challenge with teaching functional programming is that people tend to take the word <i>function</i> or the concept way to seriously. They start mandating restrictions on input&#x2F;output, what functions should be used for, and all kinds of other unnecessary nonsense. It’s like they need some sort of self imposed guardrails to qualify making better or more common use of functions. Like they need an official invitation before joining the party.<p>Perhaps some of that stupidity is bound to a developer’s understanding of their language at hand. Some languages are more expensive than others. This is where the sad confused developer mandates that functional programming must be declarative... until you point out the languages <i>Red</i> and <i>Rebol</i> are functional imperative languages. It’s not some shallow wishful opinion. That is how those languages describe themselves and it’s what they look like.<p>When you take all the stupidity, assumptions, and restrictions away functions are most universally a bag of instructions, as are classes and various other things. Functions are unique from other instruction bags in that they execute. That creates potential for instruction reuse and thus portability.<p>Different languages impose different restrictions on where or how functions may present. In JavaScript functions are first class citizens which means they can be used anywhere a primitive may be used, which is almost everywhere. Functions can also be nested in that language which just means subdivided layers of portability&#x2F;reuse. In this case, in a highly imperative way, functional programming can mean programming with a mindset of functions first, as opposed to other means of structure or extension. Again that interpretation of functional programming tends to make people uncomfortable as there are no restrictive guardrails or super specific defining rules.
评论 #26132250 未加载
评论 #26132585 未加载
评论 #26165231 未加载
评论 #26132170 未加载
t0astbreadover 4 years ago
Good idea but I was able to solve most of the puzzles without ever thinking about what my program was actually doing, especially in the &quot;math&quot; levels. In the sense that I knew what was going on, I got the concepts but I never &quot;evaluated&quot; the program in my head. I just made some educated guesses based on what I thought the patterns might turn into. Maybe that&#x27;s deliberate here but I thought that&#x27;s usually not what puzzle games want.
评论 #26136742 未加载
alisonkiskover 4 years ago
Since the model is an array of pillars, the visualization has a wall is confusing. Would be better to add some space between columns, and remove the 3D&#x2F;isometric effect.<p>The mathematical problems break the &quot;visual&quot; model. They are harder to understand when you have to spend most of your energy doing 8 simultaneous mental conversions to base 8 while solving.
roguasover 4 years ago
I love it. It goes to show why I love&#x2F;hate Haskell. . Im pretty sure most of you just look at signatures(colors) only, further I think most of you just tried a couple of different options until &quot;type&quot; clicks.<p>It is pretty evident that during this you involve yourself in code puzzle &#x2F; code golf. Rather than understanding the problem at hand. This is fine - until some of your &quot;low-level&quot; stuff leaks or your understanding of it leaks. There is also third possibility for failure - trusting the system too much, despite types being expressive they hide away a lot of &quot;internal&quot; logic, sometimes something looks the same, but it&#x27;s not and type system doesn&#x27;t capture it.
MauranKilomover 4 years ago
I had fun playing through all the challenges. But I don&#x27;t think I walked away with a better idea of functional programming. This is closer to &quot;learn LINQ&quot;, seeing as we&#x27;re only chaining functions.<p>I would be interested in seeing this expanded to include passing functions to functions (that is, make the user build a tree of functions, not a list). And yes, that might put you into hot water regarding how to communicate signatures and such.
bhargavover 4 years ago
The way this works technically is really great. Kudos to the developer. The game itself ... I do not think it helped me learn anything.
franknineover 4 years ago
This game reminds me of Infinifactory by Zachtronics <a href="https:&#x2F;&#x2F;store.steampowered.com&#x2F;app&#x2F;300570&#x2F;Infinifactory&#x2F;" rel="nofollow">https:&#x2F;&#x2F;store.steampowered.com&#x2F;app&#x2F;300570&#x2F;Infinifactory&#x2F;</a>
shaneprrltover 4 years ago
Really cool! If you had the time&#x2F;energy, this would be an enjoyable mobile game.
omginternetsover 4 years ago
I don&#x27;t understand &#x27;stack&#x27;. What&#x27;s it doing, exactly?
评论 #26138153 未加载
spiralganglionover 4 years ago
This is cool. It would be improved by adding the CSS <i>#controls { user-select: none }</i> (with various vendor prefixes). A bit of refinement to how dragging is detected wouldn&#x27;t hurt either.
xxxmasterover 4 years ago
In case you are looking for the answers -&gt; <a href="https:&#x2F;&#x2F;pastebin.com&#x2F;tbrJreNn" rel="nofollow">https:&#x2F;&#x2F;pastebin.com&#x2F;tbrJreNn</a>
keyleover 4 years ago
This is really cool but I am not sure it helps a person devising a plan towards the solution. It&#x27;s more of an exploratory stumble-upon-solution activity.
julienfr112over 4 years ago
What about Excel ? ;)
bionhowardover 4 years ago
Looks useful but I wish it fit on the screen on mobile! Just gotta change the width with media queries
blackrockover 4 years ago
This was an overly complicated example to learn what functional programming is.
wodenokotoover 4 years ago
What is the programming equivalent of stack equal columns?<p>I get the map and filter operations but I can’t remember ever coming across a function like that before.
评论 #26134855 未加载