When 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
Functional programming jargon in plain English
171–180 of 191 posts
Re: Functional programming jargon in plain English
#172This is great. Finally understand monads a little better. Definitely saving this for later.
Why 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?
Re: Functional programming jargon in plain English
#173While 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 encount…
I 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?
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.
Re: Functional programming jargon in plain English
#174Earlier quoted context omitted.
Monads 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…
But then monads are a way to think about computations sequentially. If I write highly sequential code in a C-like language, in many cases most of the code is just boilerplate made necessary by the absence of native support for monads: int ret = doStepOne(); if (ret == RESULT_OK) { ret = doStepTwo(); } if (ret == RESULT_OK) { ret = doStepThree(); } return ret; would just be doStepOne() >>= doStepTwo() >>= doStepThree(…
Re: Functional programming jargon in plain English
#175When 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
The 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'…
Re: Functional programming jargon in plain English
#176Earlier quoted context omitted.
Assuming that this guide is aimed at people entirely unfamiliar with these concepts, I think it fails to explain the concept. Yes, it is plain English, but it is not simple or common English, and it's mostly code examples. I'm familiar with the concepts, but not fluent, and functional programming jargon I already knew is not clearer to me now than it was before I read it. Good sample code, though. It only required me…
I agree, and not just the English. There is use of particular notation that does not explain anything unless you already know what it means: > f is a morphism from a -> b, and g is a morphism from b -> c; g(f(x)) must be equivalent to (g • f)(x) If I don't already understand (g • f)(x) this is not helpful at all. This other one especially jumped out at me (perhaps because I've personally never seen this "bent equals…
Normally, `f ≍ g` means `f \in \Theta(g)`. Here, the author is using it as an equals sign. I have no idea why.
Re: Functional programming jargon in plain English
#177Earlier quoted context omitted.
But then monads are a way to think about computations sequentially. If I write highly sequential code in a C-like language, in many cases most of the code is just boilerplate made necessary by the absence of native support for monads: int ret = doStepOne(); if (ret == RESULT_OK) { ret = doStepTwo(); } if (ret == RESULT_OK) { ret = doStepThree(); } return ret; would just be doStepOne() >>= doStepTwo() >>= doStepThree(…
You can have support for monads without using them for IO.
[1] https://dilbert.com/search_results?terms=Random+Number+Gener... [2] https://xkcd.com/221/
Re: Functional programming jargon in plain English
#178Earlier quoted context omitted.
I'm not trying to dodge your question, but the answer to your question is that until you work with it for a while you're not going to understand it. Any blog-sized, bite-sized snippet isn't impressive. You have to work with it for a while. I speak many computer languages, and one of the ways I measure them is, "what do I miss from X when using Y?" The answers will often surprise you; the thing you'd swear up and down…
Couldn't I "curry" a function f(x,y) to "partially apply" it on x=3 with just: function(y) { return f(3,y); } ? And then I've "partially applied" f. Is this what currying is? The syntax I posted is ambivalent about which arguments you're partially applying, isn't that superior to only being able to provide the first argument?
The end result is you need a lot more noise in the partial call to indicate what it is you are doing, no matter how you slice it, and it interacts poorly with default parameters (which almost every language has nowadays) anyhow.
Re: Functional programming jargon in plain English
#179Earlier quoted context omitted.
I'm not trying to dodge your question, but the answer to your question is that until you work with it for a while you're not going to understand it. Any blog-sized, bite-sized snippet isn't impressive. You have to work with it for a while. I speak many computer languages, and one of the ways I measure them is, "what do I miss from X when using Y?" The answers will often surprise you; the thing you'd swear up and down…
That's an example of why Haskell code is often hard to read, and why I'm glad this isn't available in other languages. Why not write out the callback given to map using a let block? Then you can give meaningful names to intermediate values so it's easier to see how the pipeline works. (Though, functional programmers would probably pass up the opportunity and use one-letter variable names.)
In real code I probably would have named it, but example code is always silly.
Re: Functional programming jargon in plain English
#180Earlier quoted context omitted.
They 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…
While 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 isn't really that much nicer than: getLine >>= \name-> putStrLn ("Hello " ++ name) or even:…
do name
But you cant write: do name
You have to write: do let name = "Buddy"
putStrLn ("Hello " ++ name)
Now try to explain that without basically explaining what a monad is.