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.

Functional programming jargon in plain English

557 pointsby mgliwkaalmost 3 years ago

35 comments

mjburgessalmost 3 years ago
These definitions don&#x27;t really give you the idea, rather often just code examples..<p>&quot;The ideas&quot;, in my view:<p>Monoid = units that can be joined together<p>Functor = context for running a single-input function<p>Applicative = context for multi-input functions<p>Monad = context for sequence-dependent operations<p>Lifting = converting from one context to another<p>Sum type = something is either A or B or C..<p>Product type = a record = something is both A and B and C<p>Partial application = defaulting an argument to a function<p>Currying = passing some arguments later = rephrasing a function to return a functions of n-1 arguments when given 1, st. the final function will compute the desired result<p>EDIT: Context = compiler information that changes how the program will be interpreted (, executed, compiled,...)<p>Eg., context = run in the future, run across a list, redirect the i&#x2F;o, ...
评论 #31975345 未加载
评论 #31975484 未加载
评论 #31975431 未加载
评论 #31981282 未加载
评论 #31975435 未加载
评论 #31980435 未加载
评论 #31976062 未加载
评论 #31978650 未加载
nailloalmost 3 years ago
&quot;A homomorphism is just a structure preserving map. In fact, a functor is just a homomorphism between categories as it preserves the original category&#x27;s structure under the mapping.&quot;<p>Oh ok. Plain english.
评论 #31979217 未加载
评论 #31978480 未加载
评论 #31976209 未加载
评论 #31978162 未加载
pseudosavantalmost 3 years ago
I didn&#x27;t really understand FP until I read Functional Light JavaScript by getify&#x2F;Kyle Simpson. It is so well written and approachable by mere mortal coders. I&#x27;m not an FP wizard, but it is the coding paradigm I mostly use now. I&#x27;ve even adapted some aspects (e.g. composability) to the CSS I write using `var()`.<p>You can buy the book or read it on GitHub:<p><a href="http:&#x2F;&#x2F;fljsbook.com&#x2F;" rel="nofollow">http:&#x2F;&#x2F;fljsbook.com&#x2F;</a><p><a href="https:&#x2F;&#x2F;github.com&#x2F;getify&#x2F;functional-light-js" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;getify&#x2F;functional-light-js</a>
Lattyalmost 3 years ago
Lists like this tend to be a bit overwhelming without context, because a definition can often seem to focus on things that don&#x27;t make sense if you don&#x27;t understand the use case, even if you understand the words.<p>Even if you&#x27;ve read the definition of functor first<p>&gt; Lifting is when you take a value and put it into an object like a functor. If you lift a function into an Applicative Functor then you can make it work on values that are also in that functor.<p>Is a pretty rough sentence for someone not familiar. I think Elm does a pretty good job of exposing functional features without falling into using these terms for them, and by simplifying it all.<p>It does pay for that in terms of missing a lot of the more powerful functional features in the name of keeping it simple, but I do think it makes it a great entry-point to get the basics, especially with how good the errors are, which is very valuable when you are learning.<p>I know it&#x27;s a controversial language on HN to some extent (I certainly have my own issues with it <i>shakes fist at CSS custom properties issue</i>), but I genuinely think it&#x27;s a great inroad to functional programming.
TrackerFFalmost 3 years ago
While I appreciate FP using terminology from its math origins - I do think it&#x27;s a huge barrier for entry, and not really sure languages that cling onto them, will see much real mainstream success.<p>But then again, I don&#x27;t think the language maintainers et. al. are too concerned with widespread success. Just some observations, but the majority of people I know that actively use FP languages, are academics. I&#x27;ve encountered some companies that have actively gone with a FP language for their main one - but some have reverted, I guess due to the difficulty of hiring.<p>With that said - functional elements are becoming more common in widespread languages, but not all the way.
评论 #31977023 未加载
评论 #31978611 未加载
评论 #31975931 未加载
goto11almost 3 years ago
Pet peeve: The word &quot;just&quot; when used to gloss over something with the author don&#x27;t know how to explain. Using &quot;just&quot; shift the burden from the author to the reader, since it signals it is the readers fault if they don&#x27;t understand.<p>&gt; A homomorphism is just a structure preserving map. In fact, a functor is just a homomorphism between categories as it preserves the original category&#x27;s structure under the mapping.<p>How about removing the &quot;just&quot;:<p>&gt; A homomorphism is a structure preserving map. A functor is a homomorphism between categories as it preserves the original category&#x27;s structure under the mapping.<p>Much clearer. Although most readers would now ask what &quot;structure&quot; and &quot;structure preserving&quot; means, since this is never explained.
评论 #31976189 未加载
评论 #31976260 未加载
评论 #31976348 未加载
评论 #31976193 未加载
评论 #31978184 未加载
评论 #31976055 未加载
rbonvallalmost 3 years ago
Let me present this intuition I&#x27;ve developed.<p>• You have a producer of Cs, then you can turn it into a producer of Ds by post-processing its output with a function g: C → D.<p>• You have a consumer of Bs, then you can turn it into a consumer of As by pre-processing its input with a function f: A → B.<p>• You have something that consumes Bs and produces Cs, then you can turn it into something that consumes As and produces Ds using two functions f: A → B and g: C → D.<p>With pictures: <a href="http:&#x2F;&#x2F;mez.cl&#x2F;prodcons.png" rel="nofollow">http:&#x2F;&#x2F;mez.cl&#x2F;prodcons.png</a><p>If you understand that, you understand functors:<p>• producer = (covariant) functor;<p>• consumer = contravariant functor;<p>• producer-consumer = invariant functor;<p>• post-processing = map;<p>• pre-process = contramap;<p>• pre- and post-processing = xmap (in Scala), invmap (in Haskell);<p>• defining how the pre- and post-processing works for a given producer or consumer = declaring a typeclass instance.<p>It doesn&#x27;t mean that &quot;a functor <i>is</i> a producer&quot;, but the mechanics are the same.
labradoralmost 3 years ago
When I was an assembly programmer, I knew C could help me<p>When I was a C programmer, I knew OOP could help me<p>When I was a JavaScript programmer, I knew TypeScript could help me.<p>I don&#x27;t know how functional programming can help me, but I&#x27;ll keep trying to find a reason because people say it can
评论 #31978804 未加载
评论 #31978370 未加载
评论 #31985162 未加载
wodenokotoalmost 3 years ago
Not a bad list of definitions but definitely not plain English.<p>It’s quite technical even for experienced programmers.
nine_kalmost 3 years ago
It looks like the Partial Application section is missing the most widespread form of partial application, known as &quot;creating an instance&quot;.<p><pre><code> class A: def foo(self, x): # do something a = A() foo(1) # self is already &quot;applied&quot;.</code></pre>
评论 #31976485 未加载
ncmncmalmost 3 years ago
This is more helpful than anything I have ever encountered on the topic.<p>Comments:<p>1. It should explain map somewhere before it is used.<p>2. For the more abstruse and abstract concepts, a comment suggesting why anybody should care about this idea at all would be helpful. E.g., &quot;A is just a name for what [familiar things] X, Y, and Z have in common.&quot;<p>3. It goes off the rails halfway through. E.g. Lift.
评论 #31978060 未加载
jacquesmalmost 3 years ago
&quot;Category<p>A category in category theory is a collection of objects and morphisms between them. In programming, typically types act as the objects and functions as morphisms.&quot;<p>Much clearer now...
ijidakalmost 3 years ago
This is great. Finally understand monads a little better.<p>Definitely saving this for later.
评论 #31975485 未加载
评论 #31975057 未加载
_benjalmost 3 years ago
Without being very versed in FP and having only read the first two (arity, HFO) this seems super helpful!!<p>Even if imperfect and I need to research further, this glossary provides a way to attach new knowledge to existing one.
ufoalmost 3 years ago
I get why they chose to do this in Javascript, but I can&#x27;t help but feel it&#x27;s an awkward choice. Many of the examples (e.g. currying) look unnatural in javascript.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;hemanth&#x2F;functional-programming-jargon" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;hemanth&#x2F;functional-programming-jargon</a>
crossroadsguyalmost 3 years ago
I think the title should have `JS` in it, because for quite few people it just might not make sense. Besides the examples are such that the author seems to have been simultaneously competing in a obscured code brevity competition. Plus, language is definitely not &quot;plain English&quot; wrt jargons.
automatic6131almost 3 years ago
The absolute state of github projects.<p>This project should be exactly 1 (one) file. The readme.md.<p>LICENSE - There is a license? Why? Someone might steal the text for their own blog post? So what? The license won&#x27;t stop them.<p>package.json - to install dozens of packages for... eslint. Just install globally. It&#x27;s just markdown and code examples. Yarn.lock - ah yeah let&#x27;s have this SINGLE, NON EXECUTABLE TEXT FILE be opinionated on the javascript package manager I use. Good stuff We have a .gitignore, just to hide the files eslint needs to execute. wow. FUNDING folder - wow we have an ecosystem of stating the funding methods?<p>This should have never been a github repo. This is a blog post. It&#x27;s a single, self contained post.<p>I hate this crap. We have 9 files just to help 1 exist. It&#x27;s aesthetically offensive.
评论 #31978158 未加载
评论 #31977970 未加载
评论 #31977973 未加载
评论 #31978622 未加载
GnarfGnarfalmost 3 years ago
Can someone clarify something for me? If you build a linked list or a dynamically growing array in a Functional program, am I correct in understanding that the array is never modified, instead a copy is made and the new element is added to the copy of the array?
评论 #31976800 未加载
评论 #31976742 未加载
Jemmalmost 3 years ago
As someone who learned coding in the days of Pascal and Fortran; can I just say: WTF and why!
synualmost 3 years ago
It would be cool if this also told you why you might want to do the thing it’s describing.
mgaunardalmost 3 years ago
Looked at first one (arity), saw &quot;argument&quot; when what was actually meant was &quot;parameter&quot;, and therefore dismissed the document.<p>If you want to make a glossary, at least try to be precise.
评论 #31976188 未加载
k__almost 3 years ago
I like it.<p>Could need a bit of clean up. Some points could need more explanation, simpler examples, and every point could follow the same structure.<p>But for a beginner, I think it&#x27;s a pretty starting point.
ribitalmost 3 years ago
Now can someone do the same for web dev? I just started getting into it for a hobby project and the terminology is so incredibly idiosyncratic.
ww520almost 3 years ago
I thought this guide is great. Not sure why people are upset with it. It’s not the be all end all definite guide to the topic, but it definitely helps.<p>I especially like the examples given that remove ambiguity in explaining the concepts.
leetroutalmost 3 years ago
Are there a lot of people writing JS with leading semicolons like these examples?
Dagonflyalmost 3 years ago
Some helpful explanations in there!<p>Though I think the closure example doesn&#x27;t actually show capturing context. It&#x27;s just a partial function application unless you count the literal &#x27;5&#x27; as a local variable.
aaaaaaaaaaabalmost 3 years ago
<p><pre><code> Constant Functor Object whose map doesn&#x27;t transform the contents. See Functor Constant(1).map(n =&gt; n + 1) </code></pre> Ummm… how is this constant?
评论 #31980187 未加载
epolanskialmost 3 years ago
Every time I see these kind of posts I always think maths behind it is much easier than the &quot;dumbed down&quot; versions.
pacomerhalmost 3 years ago
I love these definitions and will bookmark. But there&#x27;s a point where you can&#x27;t really explain FP concepts in plain English right?.
risalmost 3 years ago
And no explanation of fixed points.
eddyschaialmost 3 years ago
Obligatory &quot;Hitler reacts to Functional Programming&quot;<p><a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=ADqLBc1vFwI" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=ADqLBc1vFwI</a>
AtNightWeCodealmost 3 years ago
Oneof? Discrete data? Fuzzy logic?
anewpersonalityalmost 3 years ago
The ROI on learning FP is absurdly low.
hoosiereealmost 3 years ago
They forgot &quot;reason about&quot; and &quot;blazingly fast&quot; which get thrown around all the time without ever being defined.
singaporecodealmost 3 years ago
All these niche functional programming languages are an exercise in pseudo intellectualism<p>Give me an object oriented language any day. The world is made of state and processes, (modern niche) functional programming goes too far to derecognise the value of state in our mental models<p>The good thing about functional programming is stressing to avoid side effects in most of the code and keep it localised in certain places…
评论 #31975468 未加载
评论 #31975353 未加载
评论 #31975519 未加载
评论 #31975824 未加载
评论 #31979791 未加载
评论 #31975572 未加载
评论 #31975632 未加载