8 ms·
Functional programming jargon in plain English
- ijidak 4y agoThis is great. Finally understand monads a little better. Definitely saving this for later.
- jstx1 4y agoWhy do monads come up so often when people talk about FP? Is it a meme or are they really an important and difficult to understand concept?
- lopatin 4y agoThey come up because people who don't understand them think they are important and people who do understand them want other people to know. Also, speaking of memes: https://www.youtube.com/watch?v=ADqLBc1vFwI https://www.youtube.com/watch?v=ADqLBc1vFwI
- xigoi 4y agoHaskell uses monads as an escape hatch for performing side effects, so they come up often there.
- endgame 4y agoNot as an "escape hatch" (that would be something more like `unsafePerformIO :: IO a -> a`), but as a principled way to compose (among other things) IO actions. A Haskell program executes the IO action at `Main.main`, which must have type `IO ()`. `putStrLn :: String -> IO ()` is a pure function - if you give it the same input, it always the same IO action as a result.
- ogogmad 4y agoMonads are (for better or worse) contagious. So when one function calls a monad, then it needs to be included in the monad as well. It makes introducing memoisation to a file, randomisation, and memoisation not-to-a-file (without using lazy evaluation to express it) difficult. I don't know whether the alternatives (effect systems for instance) help with this. I personally don't use functional languages because I find them too difficult given the needs and interests I have. I think about computations sequentially most of the time.
- ratww 4y agoMonads themselves aren't really contagious, it's the actions that would otherwise have side-effects that are, and also the fact they have to be executed in sequence. This is also true for other things in other paradigms, such as async functions in javascript. This is a good thing, however. In imperative programming, you have invisible temporal coupling. In pure-FP you have the same coupling, but it's exposed.
- garethrowlands 4y agoWhile I broadly agree with you, I think the post you're responding to has a point. You can't, in general, get a value back out of a monad, so if you call a monadic function, you may well have to return a monad. The obvious example is IO: there's no (safe) way get the `a` from `IO a`, so IO is kinda contagious. Then again, there are lots of monads, such as `Maybe` and `List`, where you can get values out. These aren't contagious at all. I agree with you that this is a good thing. Effects show up in the type signature - and it's all about those effects and managing them.
- ratww 4y agoYes, this is what I mean. IO is contagious for reasons unrelated to it being a Monad.
- endgame 4y agoI think that applicatives and monads feel more contagious than they really are, because at first people tend to write functions that consume values of type `f a` too readily. This is because it takes some time to become comfortable with `fmap` and friends, so the new Haskell programmer often doesn't write as many pure functions.
- frogulis 4y agoMany important "effects" (e.g. non-determinism, IO, asynchrony, environmental context, state... etc) are modelled as monads in Haskell. You _can_ write Haskell code without understanding what a monad is, but composing and creating these things is going to be a little painful without that understanding. Additionally, it seems to be a harder concept to grasp than e.g. functors or monoids. I think this can be partly attributed to many Haskell programmers first being introduced to monads that are less than ideal for understanding the concept. Shameful plug, I've written some thoughts on this here: https://frogulis.net/writing/async-monad https://frogulis.net/writing/async-monad
- tymscar 4y agoI think this was some amazing insight. I understand monads and I can use/write them but I feel like the concept hasn’t FULLY clicked yet. While even now it hasn’t, I feel like your blogpost got me that step closer to it, so thank you!
- alpaca128 4y agoI'd say both. For me the difficulty comes from the formal explanations/definitions, those always manage to confuse me. Result & Option types seem to have something to do with it so I may already have some understanding of the concept. But many explanations containing the word Monad also contain various other abstract mathematical terms. Trying to explain the concept to someone without mathematical background can be tricky.
- lucasdicioccio 4y agoThere is a myth that "monads" are magical insights of some sort -- it's not. Difficult to understand: likely yes because the myth is not groundless. What "monads" capture is how to combine things with a lot of ceremony: (0) the things that we want to combine are sharing some structure/properies (1) we can inspect the first thing before deciding what the second thing is (2) we can inspect both before deciding what is the resulting combination. What requires a lot of thought is appreciating why "inspect, decide, combine" are unified in a single concept. Important: indeed, because in Haskell-like languages monads are pervasive and even have syntactic primitives. It's also extremely useful when manipulating concepts or approaching libraries that implement some monadic behaviour (e.g. promises in JS) because the "mental model" is rigorous. If you tell someone a library is a monadic-DSL to express business rules in a specific domain, you're giving them a headstart. Some final lament: there's a fraction of people who found that disparaging (or over-hyping) the concept was a sure-fire way to yield social gain. Thus, when learning the concept of monads, one situational difficulty that we should not understate is that one has to overcome the peer-pressure from their circle of colleagues/friends. Forging one's understanding and opinions takes more detachment than the typical tech job provides.
- goto11 4y agoThey are used pervasively in Haskell, less so in other functional languages. In Haskell, you can't write a "Hello world" program without using monads, so you cant really avoid learning about them. IMHO monads are only really useful in Haskell because it has specific built-in syntax sugar to support them. Without this syntax sugar, they would be very cumbersome to use. So it's not really the monad type per se which is interesting, it is the code style which the syntax sugar enables.
- IAmYourDensity 4y agoAnd the reason you can't write "Hello world" in Haskell without using a monad is that functions in Haskell are "pure", meaning they cannot have side effects like outputting to the console. Preventing side effects, including reading and writing global state, helps prevent bugs and makes it easier to understand and refactor Haskell code. Some would argue that the extra layers of abstraction from category theory and unpredictable order and number of lazy evaluations can actually make it harder to understand and refactor Haskell code. Anyway, in order to perform I/O in Haskell, you evaluate your pure functions as a sequence of actions that are executed by the Haskell runtime. The construct that helps you build the sequence of I/O actions and allows you to bind their intermediate values to arguments to be used by subsequent actions is called the 'IO' monad.
- garethrowlands 4y agoWhile it's true that `IO` in Haskell has a `Monad` instance, you don't really have to know that to do `IO` in Haskell. Certainly you don't need to know `Monad` in the abstract to use `IO` concretely. I like Haskell's `do` notation, which is its syntax sugar for monads, but it's really not that bad without. For example: do name <- getLine putStrLn ("Hello " ++ name) isn't really that much nicer than: getLine >>= \name-> putStrLn ("Hello " ++ name) or even: getLine >>= \name-> putStrLn ("Hello " ++ name) The main reason that monads are important in Haskell is that programs that do IO simply are not functions in a mathematical sense. If Haskell were limited to functions, it wouldn't be able to do IO.
- goto11 4y ago
- AtNightWeCode 4y agoI think it is because monads can be used for handling side effects, even though side effects do not exist in FP. :)
- imtringued 4y agopublic static void main(String[] args) Why does this come up so often when people talk about Java? Because beginners are confronted with the IO Monad if they want to write a Hello world program. Monad is a typeclass that any datatype can implement. Monads have a then or flatmap like function that takes a Monad and a function that operates on the contents of the monad but also returns another monad of the same type which is then combined according to the implementation details of the specific monad that implements the monad typeclass.
- pdpi 4y agoIf you want a lazy-by-default language, you need to deal with a problem — laziness means you don't need to actually evaluate the reads until you use `a` and `b`, and the print uses `b` before `a`, so the two reads can be executed in reverse order: a = read() b = read() print("{b}, {a}") One of Haskell's original goals was precisely to be lazy-by-default, which necessitated coming up with a way to solve this problem, and monads are the solution they came up with that gave us reasonable ergonomics. From a practical point of view, monads are just types that have reasonable implementations for three simple functions: `pure`, `map`, and `flatten` # lists as monads: pure 1 = [1] # put a value "inside" the monad map f, [1, 2, 3] = [f(1), f(2), f(3)] # apply the function to the "inside" of the monad flatten [[1], [2, 3]] = [1,2,3] # take two "layers" and squish them into one # also, the simplest, but least useful, way to use functions as monads: pure 1 = (x -> 1) # putting a value inside a function is just giving you the constant function map g, f = (x -> g(f(x))) # map is just composition flatten f = (x -> f(x)(x)) # you squish by returning a new function that performs two nested calls ("reasonable" here largely means "they follow the principle of least surprise in a formal sense") The trick is that, once you know what monads are, you can use them in any language (with varying degrees of support), and you can see instances of them everywhere, and it's an incredibly useful abstraction. Many common patterns, (like appending to a log, reading config, managing state, error handling) can be understood as monads, and compose quite well, so your program becomes one somewhat-complex data type, a handful of somewhat-complex functions that build an abstraction around that data type, and then lots of really small, really simple functions that just touch that abstraction. I have a .class parser written in Scala that exemplifies this general structure, need to put it up somewhere public.
- ufo 4y agoI think one of the reasons for the meme is because there's so many monad tutorials. When a Haskeller is introduced to monads they'll run across all these monad tutorials with abstruse analogies for what a monad is. Is a monad a burrito? Or a space suit? Odds are that none of these analogies will make much sense and the programmer will have to figure out on their own, what is the deal with monads after all. At some point they might have an epiphany; monads are the sort of idea that is actually pretty neat when it "clicks". They will feel compelled to write a monad tutorial, and thus history repeats itself.
- Akronymus 4y agoBecause once you /get/ monads you see them everywhere.
- ratww 4y agoBtw, that "chain" function is available natively in Javascript, as "flatMap". Monads aren't as mysterious as we make them look.
- _benj 4y agoWithout being very versed in FP and having only read the first two (arity, HFO) this seems super helpful!! Even if imperfect and I need to research further, this glossary provides a way to attach new knowledge to existing one.
- eddyschai 4y agoObligatory "Hitler reacts to Functional Programming" https://www.youtube.com/watch?v=ADqLBc1vFwI https://www.youtube.com/watch?v=ADqLBc1vFwI
- wodenokoto 4y agoNot a bad list of definitions but definitely not plain English. It’s quite technical even for experienced programmers.
- Latty 4y agoLists like this tend to be a bit overwhelming without context, because a definition can often seem to focus on things that don't make sense if you don't understand the use case, even if you understand the words. Even if you've read the definition of functor first > 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. 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. 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. I know it's a controversial language on HN to some extent (I certainly have my own issues with it shakes fist at CSS custom properties issue), but I genuinely think it's a great inroad to functional programming.
- mjburgess 4y agoThese definitions don't really give you the idea, rather often just code examples.. "The ideas", in my view: Monoid = units that can be joined together Functor = context for running a single-input function Applicative = context for multi-input functions Monad = context for sequence-dependent operations Lifting = converting from one context to another Sum type = something is either A or B or C.. Product type = a record = something is both A and B and C Partial application = defaulting an argument to a function 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 EDIT: Context = compiler information that changes how the program will be interpreted (, executed, compiled,...) Eg., context = run in the future, run across a list, redirect the i/o, ...
- stingraycharles 4y agoI completely understand what you’re saying, but assuming that this guide is aimed at people entirely unfamiliar with these concepts, I’m not sure whether these “ideas” provide any meaningful explanation to them. Demonstrating by example what e.g. currying actually looks like is much more powerful, at least from my point of view. In that regard, I’m actually pleasantly surprised this guide does a very good job at that.
- mjburgess 4y agoCurrying is one of those cases where the code is the explanation I think in many cases this isnt right, eg., Monads. The reason flatMap() "flattens" is just that "flattening" is really just sequencing, denesting the type using a function requires a sequenced function call: f(g(..)) This applies to many of these "functional design patterns"... theyre just ways of expressing often trivial ideas (such as sequencing) under some constraints.
- ncmncm 4y agoWe need an explanation why we should care about support for currying. Where it is really just to support variadic argument lists, it is a big hammer for a little problem.
- deleted 4y ago[deleted]
- singaporecode 4y agoAll these niche functional programming languages are an exercise in pseudo intellectualism 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 The good thing about functional programming is stressing to avoid side effects in most of the code and keep it localised in certain places…
- rswail 4y agoFunctional programming is actually mathematics based on lambda calculus. Imperative programming isn't. OOP is a failed metaphor, unless you use composition, not inheritance, even then, the actual basis for OOP was about the messages between objects, not the internals. > The world is made of state and processes No, the world is made of objects that have state and messages (events) between them.
- jimbob45 4y agoThe lambda calculus is an entirely arbitrary way to organize things in math. It’s not based on nature or truth at all. The real problem, though, is that FP doesn’t do anything well. It’s never the fastest method of programming, which means that it needs to excel in some other way for its proponents to be right about it. Is it the most maintainable? Maybe if you have zero side effects but then any paradigm would be in that case. Once you introduce state, it becomes a nightmare to maintain, unlike OOP. It’s certainly not the most readable.
- ebingdom 4y ago> The lambda calculus is an entirely arbitrary way to organize things in math. It’s not based on nature or truth at all. Lambda calculus, category theory, and logic are essentially 3 sides of the same coin (the Curry-Howard-Lambek correspondence). The rules of lambda calculus match those of natural deduction. It runs quite a bit deeper than you're suggesting here. It's not just some arbitrary formalism.
- onlyfortoday2 4y ago
- synu 4y agoIt would be cool if this also told you why you might want to do the thing it’s describing.
- ribit 4y agoNow 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.
- Linda703 4y ago[dead]
- naillo 4y ago"A homomorphism is just a structure preserving map. In fact, a functor is just a homomorphism between categories as it preserves the original category's structure under the mapping." Oh ok. Plain english.
- psychoslave 4y ago約束は守られた
- marcosdumay 4y agoWell, it's not nested.
- cratermoon 4y agoBest comment in this thread. The guide does a so-so job of building on terms previously defined. The term accumulator, for example, is not defined before use. The first appearance of it is under Catamorphism, where the guide says, "A reduceRight function that applies a function against an accumulator and each value of the array (from right-to-left) to reduce it to a single value." I note, in passing, that the actual guide is just titled "Functional Programming Jargon". It does not claim to be "in plain English".
- eddyschai 4y agoMaybe if I explain what a Monad is in Plain English it'll help you understand functors? A monad is just a monoid in the category of endofunctors.
- mypalmike 4y agoI think you need to explain endofunctors. An endofunctor is the category containing monoids such as the monad.* *This is probably wrong. Please don't explain.
- eddyschai 4y agoSo in all seriousness a functor is a mapping from one category to another, and an endofunctor is a mapping from one category to the same category.
- ncmncm 4y agoThis is more helpful than anything I have ever encountered on the topic. Comments: 1. It should explain map somewhere before it is used. 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., "A is just a name for what [familiar things] X, Y, and Z have in common." 3. It goes off the rails halfway through. E.g. Lift.
- sanderjd 4y agoExpanding on your #1, I think they could use some more definitions. As you say, they use "map" in its functional programming sense before defining it, but I think more confusing is this one: > A category in category theory is a collection of objects and morphisms between them. What is a "morphism"? I think this is a great starting point though, which could use some expansion.
- ncmncm 4y agoJa, that "morphism" bit matches my #3.
- goto11 4y agoPet peeve: The word "just" when used to gloss over something with the author don't know how to explain. Using "just" shift the burden from the author to the reader, since it signals it is the readers fault if they don't understand. > A homomorphism is just a structure preserving map. In fact, a functor is just a homomorphism between categories as it preserves the original category's structure under the mapping. How about removing the "just": > A homomorphism is a structure preserving map. A functor is a homomorphism between categories as it preserves the original category's structure under the mapping. Much clearer. Although most readers would now ask what "structure" and "structure preserving" means, since this is never explained.
- cinntaile 4y agoThis is left as an exercise to the reader.
- minraws 4y agoJust to be clear, that's quite literally the Wikipedia definition. > In algebra, a homomorphism is a structure-preserving map between two algebraic structures of the same type (such as two groups, two rings, or two vector spaces). Not sure if this is rude but many definitions there seem a bit, not plain English. I am assuming we are aiming for something close to ELI5 if the title says plain English. Ofc that could not be what the author intended and is just but that's how inferred the title. I will see if I can find time to improve and send some PRs for the ones that are in deep need of simplification, hopefully OP is open to discussing changes. Also like Arity, Arity is not just for functions, it can sometimes be interchanged with Rank and apply to even Types. higher ranked types. higher arity types... I do understand they are not something most people like, because of their issues but that's not a complete definition so I assumed it was for the means of simplifying to explain to beginner programmers. [reference to issues with HRTs](https://www.sciencedirect.com/science/article/pii/S0168007298000475 https://www.sciencedirect.com/science/article/pii/S016800729...) Again this is not meant to be rude to the author, just hopefully the title could be better formed to explain the intent of the work. Or my opinion might be minority and we can decide against it as well ofc.
- 4y ago
- ufo 4y agoI get why they chose to do this in Javascript, but I can't help but feel it's an awkward choice. Many of the examples (e.g. currying) look unnatural in javascript. https://github.com/hemanth/functional-programming-jargon https://github.com/hemanth/functional-programming-jargon
- TrackerFF 4y agoWhile I appreciate FP using terminology from its math origins - I do think it's a huge barrier for entry, and not really sure languages that cling onto them, will see much real mainstream success. But then again, I don'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'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. With that said - functional elements are becoming more common in widespread languages, but not all the way.
- ncmncm 4y agoA "functional language", like an "object-oriented language", is an exercise in futility. But support for a functional approach in a general language will often be useful.
- dkarl 4y agoI think using math terminology is honest, in that it gives an accurate expectation of how the ideas can be communicated and learned. They are simple ideas that can be communicated in their entirety in just a few symbols, but it takes time, exposure, and practice to develop facility in their use and a feeling of "understanding." That's the math experience. I know people hate that and would much rather it be a matter of reading some a nice explanation and then "aha" but there's no such explanation yet and after years of people trying to develop one there's no point in expecting one right around the corner.
- ebingdom 4y agoI agree about the math terminology, but I think it would be more confusing if we created a completely different set of vocabulary for the same concepts. So I don't really know what to do: refer to something by its proper name, or create a new, less precise name to make it sound less scary? Why do we find certain identifiers scary in the first place?
- IshKebab 4y agoI don't. FP terminology is so bad that clearer names (Mappable, Chainable, etc.) would really help adoption. You might say "but it will make it more confusing for people who already know the FP terms", but those people are a tiny minority of programmers so it doesn't make sense to cater to them. At least if you want your language to be popular among anyone except academics.
- mgaunard 4y agoLooked at first one (arity), saw "argument" when what was actually meant was "parameter", and therefore dismissed the document. If you want to make a glossary, at least try to be precise.
- mtreis86 4y agoThey said 'a function takes arguments', which is correct. The arguments are passed into the function, aligning to and being bound to the function's parameters. So arity applies both to arguments the function can take, and the parameters the function has.
- mgaunard 4y agoThe way it's phrased and the examples makes it clear whoever wrote this didn't understand the distinction.
- nine_k 4y agoIt looks like the Partial Application section is missing the most widespread form of partial application, known as "creating an instance". class A: def foo(self, x): # do something a = A() foo(1) # self is already "applied".
- chongli 4y agoThat's a very good point. People think of functional programming languages and OOP languages as entirely separate worlds that, like oil and water, do not mix. In reality they're equivalent, they just have different ergonomics. For example, lambdas can be translated to anonymous inner classes.
- imbnwa 4y ago>For example, lambdas can be translated to anonymous inner classes. That's how Java 8 more or less implements them, no?
- leetrout 4y agoAre there a lot of people writing JS with leading semicolons like these examples?
- hoosieree 4y agoThey forgot "reason about" and "blazingly fast" which get thrown around all the time without ever being defined.
- GnarfGnarf 4y agoCan 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?
- olodus 4y agoThe result should be that after the addition you should not have affected the old array yes. The most basic way of implementing this is what you described. However, there are a number of different ways to optimize this. Since you know that the elements are immutable, if you add the new element to the start of the list you could just point it to the old elements and you now have two lists which share the majority of their elements. If you are interesting to learn about this more I would recommend looking into how for example Clojure implement their "persistent data structures". Most functional languages have similar things so you could find it elsewhere as well if you want.
- GnarfGnarf 4y agoSo... what happens when my array grows to 2GB, and I have millions of copies because I added millions of entries?
- Jtsummers 4y ago1. You switch to a pragmatic language that gives you an escape hatch to mutate data. 2. You use a persistent data structure that lets it grow without needing to make millions of copies for millions of new entries. 3. You use a different constructor pattern to avoid the allocations. For (3), a common way around this (with lists) would be to build it in reverse and then reverse it (assuming that the order actually mattered at all, if it doesn't you don't need to reverse it at the end). This is done in Erlang, for instance, as a common pattern: make_something_n_times(0, Acc) -> reverse(acc); make_something_n_times(N, Acc) -> make_something_n_times(N-1, [f(N) | Acc]). You end up with two copies of the list, one in the constructed order and the reverse ordered version, but the constructed order one will be garbage collected in short order. Two copies, better than millions of copies. You also see a pragmatic solution in Erlang with iolists. These are lists that contain items that you'd want to send to, well, IO functions. But instead of forcing you to allocate whole new strings for concatenation (a common thing to do with strings) like this: S1 ++ S2 %% results in allocating a new string and copying contents from at least S1 You can do this: Concatenated = [S1,S2] Now it's a two-element list that references the two prior ones, you've allocated some new memory, but just enough for a new list. Now you have a third string you want to prepend? [S3,Concatenated] Again, minimal amount of allocation and copying (there is no copying). You can use this pattern in other situations and only flatten when needed, or "flatten" it by recursing over the structure to access all the elements but never actually constructing a flattened version.
- Jemm 4y agoAs someone who learned coding in the days of Pascal and Fortran; can I just say: WTF and why!
- k__ 4y agoI like it. Could need a bit of clean up. Some points could need more explanation, simpler examples, and every point could follow the same structure. But for a beginner, I think it's a pretty starting point.
- rbonvall 4y agoLet me present this intuition I've developed. • 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. • 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. • 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. With pictures: http://mez.cl/prodcons.png http://mez.cl/prodcons.png If you understand that, you understand functors: • producer = (covariant) functor; • consumer = contravariant functor; • producer-consumer = invariant functor; • post-processing = map; • pre-process = contramap; • pre- and post-processing = xmap (in Scala), invmap (in Haskell); • defining how the pre- and post-processing works for a given producer or consumer = declaring a typeclass instance. It doesn't mean that "a functor is a producer", but the mechanics are the same.
- automatic6131 4y agoThe absolute state of github projects. This project should be exactly 1 (one) file. The readme.md. LICENSE - There is a license? Why? Someone might steal the text for their own blog post? So what? The license won't stop them. package.json - to install dozens of packages for... eslint. Just install globally. It's just markdown and code examples. Yarn.lock - ah yeah let'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? This should have never been a github repo. This is a blog post. It's a single, self contained post. I hate this crap. We have 9 files just to help 1 exist. It's aesthetically offensive.
- jhrmnn 4y agoThe document appears to have 80 contributors, that's hard to do with a blog post. It could have been a wiki page. But then I'm not sure if hosting a single repo on Github is harder than hosting a wiki. And of course Github provides superior platform for collaboration compared to a wiki.
- seandoe 4y agoI think it's cool that it's a repo. Now other people can submit pull requests and improve it. As for the files, bah whatever. Go find a squirrel to bark at.
- Otek 4y agoWow, where should I start > LICENSE - There is a license? Why? Someone might steal the text for their own blog post? So what? The license won't stop them. But it’s still good that author underlined that he don’t want it to be copied. What’s wrong with that? > package.json - to install dozens of packages for... eslint. Just install globally. Then other contributors won’t know what version he used, what config he had, he won’t be able to easily recreate it on different computer, etc… > Yarn.lock - ah yeah let's have this SINGLE, NON EXECUTABLE TEXT FILE be opinionated on the javascript package manager I use. That’s author choice. Any good argument against it or you will just criticize for the sake of it? > This should have never been a github repo. This is a blog post. It's a single, self contained post. It’s a blog post with 270 different revisions, 80 contributors and a bunch of different languages. Show me how to easily do that with a blog post. > I hate this crap. We have 9 files just to help 1 exist. It's aesthetically offensive Why number of files is offensive to you? We have a couple tools good at what they do to keep things consistent and organized. Better to have these tools to keep standards than not.
- AtNightWeCode 4y agoOneof? Discrete data? Fuzzy logic?
- labrador 4y agoWhen I was an assembly programmer, I knew C could help me When I was a C programmer, I knew OOP could help me When I was a JavaScript programmer, I knew TypeScript could help me. I don't know how functional programming can help me, but I'll keep trying to find a reason because people say it can
- Akronymus 4y agohttps://fsharpforfunandprofit.com/ https://fsharpforfunandprofit.com/ This might provide a pathway to groking FP. As you mentioned in another comment to have c# experience, you should already have all the tools installed to get started in f# as well.
- aeonik 4y agoThe biggest benefit I see is lack of side-effects. With a functional program you can be sure that your can safely call any function without having to worry about the current state of your app. A proper functional program can start to do very cool things safely: like hot reloading of code. When I'm debugging a Clojurescript app I can have a live running game, and update the physics without even reloading the page. It's all live. A proper functional program really looks like a series of mappings from a collection of data sources to a collection of data sinks. The keyword for this is referential transparency: https://www.braveclojure.com/functional-programming/ https://www.braveclojure.com/functional-programming/ There are other benefits like composability, designing your programs this way will give you access to algorithms that works otherwise not work with your code. The simplest example is Map, Filter, and Reduce. These functions are by their very nature parallel because a compiler knows that there are no intermediate steps, unlike a for loop.
- labrador 4y agoI should probably add that I program mostly C# so I'm getting Functional benefits like Map and Filter because Eric Meijer added LINQ. He made it his life's work for a few years to bring functional programming to the masses. But I was minimizing state long before that because state makes any program much harder to understand. Confessions of a Used Programming Language Salesman: Getting the Masses Hooked on Haskell http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.72.868&rep=rep1&type=pdf http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.72....
- ww520 4y agoI 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. I especially like the examples given that remove ambiguity in explaining the concepts.
- jacquesm 4y ago"Category 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." Much clearer now...
- aaaaaaaaaaab 4y agoConstant Functor Object whose map doesn't transform the contents. See Functor Constant(1).map(n => n + 1) Ummm… how is this constant?
- debugnik 4y agoIt ignores the mapping completely: constant.map(...) == constant Constant functors are only ever useful if you need to thread a simple value through code that asks for an arbitrary functor. I'd say that's rare even for abstract, type-level heavy code.
- Dagonfly 4y agoSome helpful explanations in there! Though I think the closure example doesn't actually show capturing context. It's just a partial function application unless you count the literal '5' as a local variable.
- ris 4y agoAnd no explanation of fixed points.
- jtdev 4y ago
- anewpersonality 4y agoThe ROI on learning FP is absurdly low.
- pseudosavant 4y agoI didn't really understand FP until I read Functional Light JavaScript by getify/Kyle Simpson. It is so well written and approachable by mere mortal coders. I'm not an FP wizard, but it is the coding paradigm I mostly use now. I've even adapted some aspects (e.g. composability) to the CSS I write using `var()`. You can buy the book or read it on GitHub: http://fljsbook.com/ http://fljsbook.com/ https://github.com/getify/functional-light-js https://github.com/getify/functional-light-js
- pacomerh 4y agoI love these definitions and will bookmark. But there's a point where you can't really explain FP concepts in plain English right?.
- crossroadsguy 4y agoI 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 "plain English" wrt jargons.
- epolanski 4y agoEvery time I see these kind of posts I always think maths behind it is much easier than the "dumbed down" versions.