|
ratbert90 posted:Yep, after the last page or so, I am now 100% in the impostor syndrome camp again. This is one of the few times where I don't feel hopelessly incompetent. The biggest offenders for me are probably discussions involving Haskell, or advanced C++ templates. You mention monads, you've probably lost me.
|
# ? Jun 19, 2019 01:32 |
|
|
# ? May 21, 2024 08:35 |
|
The number of people who really understand monads is far smaller than the number of people who sound like they do.
|
# ? Jun 19, 2019 01:41 |
|
it's like a burrito in the category of endofunctors
|
# ? Jun 19, 2019 01:42 |
|
Jabor posted:endofunctors Is that even a real word?
|
# ? Jun 19, 2019 02:04 |
|
Yeah it’s a ska band
|
# ? Jun 19, 2019 02:05 |
|
Imagine having to read this bad boy before having the slightest idea what the codebase you're working on even does: https://bartoszmilewski.com/2017/01/02/comonads/ Don't worry it follows trivially from the definition of monad. I'm sorta convinced that the principal benefit of functional programming is weeding out all the people who aren't dedicated enough to figure it all out.
|
# ? Jun 19, 2019 02:28 |
|
ultrafilter posted:The number of people who really understand monads is far smaller than the number of people who sound like they do. Monads are really simple, that's part of the reason they're so hard to understand. Also, the fact that they're an interface and not an object.
|
# ? Jun 19, 2019 03:01 |
|
Wanna punch those monads RIGHT INTERFACE!
|
# ? Jun 19, 2019 03:06 |
|
1337JiveTurkey posted:Imagine having to read this bad boy before having the slightest idea what the codebase you're working on even does: https://bartoszmilewski.com/2017/01/02/comonads/ Well, or one can just use an eager programming language (like the LISP and ML families), and just do stuff with side effects directly. Monads are more of a Haskell and functional purist thing rather than straight up functional thing, I think
|
# ? Jun 19, 2019 03:11 |
|
ultrafilter posted:The category of people who really understand monads is a subcategory of people who sound like they do. there
|
# ? Jun 19, 2019 03:13 |
Doc Hawkins posted:there but are "people who sound like they do" endofunctors??
|
|
# ? Jun 19, 2019 04:07 |
|
Phobeste posted:Yeah it’s a ska band For real, I've worked a bit with <algorithm>, so I have some idea what a functor is. I'm not even going to try to guess what you get when you add the endo- prefix though. Fortunately Google exists.
|
# ? Jun 19, 2019 04:11 |
|
zergstain posted:For real, I've worked a bit with <algorithm>, so I have some idea what a functor is. I'm not even going to try to guess what you get when you add the endo- prefix though. Fortunately Google exists. C++ functors are totally different from category theory functors (which are just abstract nonsense).
|
# ? Jun 19, 2019 04:26 |
|
you don't really need to understand the category theory definitions of functors and monads to understand them in haskell/c# etc. They were inspired by the theory but they aren't the same.
|
# ? Jun 19, 2019 04:40 |
|
OddObserver posted:C++ functors are totally different from category theory functors (which are just abstract nonsense). I realized I actually had no idea what a functor was when I tried to read up on what an endofunctor was. I was just thinking Haskell had a similar concept. Maybe I shouldn't have, since it's not really an OO language, is it? I don't think I'm going to dive into the category theory rabbit hole today.
|
# ? Jun 19, 2019 04:40 |
|
zergstain posted:I realized I actually had no idea what a functor was when I tried to read up on what an endofunctor was. I was just thinking Haskell had a similar concept. Maybe I shouldn't have, since it's not really an OO language, is it? In Haskell all functors are endofunctors because endofunctors are functors from a category to itself, and there's only one category xtal fucked around with this message at 06:46 on Jun 19, 2019 |
# ? Jun 19, 2019 05:28 |
|
Functional programming seems less like math and more like trying to express the Parmenides in psuedomathematical terms the more I hear people try to explain it
|
# ? Jun 19, 2019 07:12 |
|
Functors as a concept are simple. You have a type that's polymorphic in a single argument, and you have a function 'fmap' that lets you apply another function to the value "contained" in that type, without being able to know anything about the type or change anything about it - so fmap over a list can't change the number or order of items in the list, fmap over an optional can't change the presence or lack of a value, fmap over a function can't change the input type of that function and so on. Notably, there's no way to "put a value into" or "take a value out of" a functor. They only allow you to apply functions to the value they contain, for whatever meaning of "contain" makes sense for that particular functor. I put "contain" in quotes because the container analogy is more limiting imo than thinking of them in terms of "structure" or "context".
|
# ? Jun 19, 2019 07:28 |
|
qntm posted:Oh hey, let's trade dreadful JavaScript "utility functions". Nobody can beat this guy This is his best work, probably
|
# ? Jun 19, 2019 08:05 |
|
sunaurus posted:Nobody can beat this guy Surely that is a war crime
|
# ? Jun 19, 2019 08:07 |
|
quote:NASA, Microsoft, Target, IBM, Optimizely, Apple, Facebook, Airbus, Salesforce.com, and hundreds of thousands of other organizations depend on code I wrote to power their developer tools and consumer applications. that's why he has so many packages, he uses NPM as advertising for his company where he is of course the CEO and spends all day retweeting other javascript company "founders" who also retweet each other.
|
# ? Jun 19, 2019 08:38 |
|
I've read some of his posts online where he defends what he's doing. He has this amazing skill of making you sympathize with him - he can make it look like he's just an innocent naive person who loves coding and is constantly under attack by incompetent elitist developers. I still can't decide if he's straight up malicious and wants to have tons of unnoticed potential backdoors all over the web (who the hell can keep up with reviewing updates of hundreds of dependencies?), or if he's just sarcastically trying to show how stupid "npm culture" is.
|
# ? Jun 19, 2019 09:27 |
sunaurus posted:I've read some of his posts online where he defends what he's doing. He has this amazing skill of making you sympathize with him - he can make it look like he's just an innocent naive person who loves coding and is constantly under attack by incompetent elitist developers. one day he'll destroy it all and every node program on the planet will collapse simultaneously
|
|
# ? Jun 19, 2019 09:40 |
|
Jazerus posted:one day he'll destroy it all and every node program on the planet will collapse simultaneously the tragedy is it will go unnoticed for months "yeah don't worry about the build server errors it always does that"
|
# ? Jun 19, 2019 10:33 |
|
Jazerus posted:one day he'll destroy it all and every node program on the planet will collapse simultaneously That already happened
|
# ? Jun 19, 2019 11:40 |
|
sunaurus posted:I've read some of his posts online where he defends what he's doing. He has this amazing skill of making you sympathize with him - he can make it look like he's just an innocent naive person who loves coding and is constantly under attack by incompetent elitist developers. My interactions with him have me convinced that he is just a narcissist and derives his self worth from the popularity. There is no way he is ironic.
|
# ? Jun 19, 2019 11:54 |
|
I'm surprised he needed 57 commits and 4 major versions in https://github.com/jonschlinkert/isobject for this:code:
|
# ? Jun 19, 2019 12:23 |
|
jit bull transpile posted:Functional programming seems less like math and more like trying to express the Parmenides in psuedomathematical terms the more I hear people try to explain it A bunch of functional programmers wrap themselves in the holy shroud of logic, with the idea that because their tools are somewhat spiritually closer to the work of mathematicians, their own work, through some kind of mystical osmosis, is inheriting the correctness of the mathematicians that influenced the development of their tools. In practice, that specific breed of functional programmers will often write software that is really really strict in perfectly implementing the solution to a problem that was not well understood because it was more important to model it in types than actually understand the demands of people who will use it day to day. Elegance can't be bowed down to the needs of mere users, you see. You do have the full spectrum, though, with one end being the militants unwilling to depart from theoretical purity, to the other end of pragmatists-to-a-fault who purely focus on value, won't care for their tech and "who gives a poo poo just do what the user asks no matter the cost." It's just that by virtue of being mostly unpopular tech used by "passionate" folks, you far more often end up with a glut of users on the militant part than the overly-pragmatists you see in business-oriented software.
|
# ? Jun 19, 2019 14:01 |
|
Last time that JavaScript guy came up, megalodong noticed an obvious bug:megalodong posted:
The repository is read-only now, probably so he can focus on dozens of his other repositories. Maybe we'll find another bug?
|
# ? Jun 19, 2019 15:13 |
|
I mean, I do some functional programming and I'm not a theory nerd, and as a result monads are simple for me. They're literally a box you can put things of any type in and there's a way to change what's in the box without changing the box itself. That's all (and everything >95% of functional programmers ever need to know about them). And anyone who disagrees with this definition can go stick their sensitive bits in an endofunctor.
|
# ? Jun 19, 2019 17:54 |
|
sunaurus posted:Nobody can beat this guy Yeah that's the type of bullshit I was talking about. I'm pretty sure these people have brain damage, they certainly aren't self aware enough to avoid getting hired.
|
# ? Jun 19, 2019 18:05 |
|
My favourite is his module is-odd, which is somehow twelve lines long and cheerfully accepts non-numbers like '4567', '', true, false and null, while throwing exceptions when passed such numbers as 3.5 and 1e22. It's so flaky. And is-odd's primary consumer? is-even.
|
# ? Jun 19, 2019 18:10 |
Monads (in the Haskell sense) are types which take at least one type parameter (e.g. List<T> or Optional<T>) which implement two specific functions. (For this post I'll be using non-Haskell notation and semi-traditional names for these functions, to make things more clear.) The first of these functions, pure, has the signature pure(T) -> M<T> where M is the monad in question. So in the case of List, this would be pure(T) -> List<T>. You could imagine this being implemented as a function which when given a value, returns a list containing just that value. The second of these functions, bind, has the signature bind(M<T>, Function<T> -> M<U>) -> M<U>. (That second argument is any function which takes a T and returns an M<U>, where T and U are generic arguments.). In the case of a List, this would be bind(List<T>, Function<T> -> List<U>) -> List<U>. You could imagine this being implemented as a function which, given a list of Ts and a function which turns a T into a list of Us, applies that function to each T in the original list and then concatenates the resulting List<U>s. These functions have to obey a few rules, which are there to make sure you're not doing anything weird with your implementation. If these are confusing, it's IMO okay to just wholly skip over the details of these laws until you understand monads a little better, but I've listed them below for the curious.
Now that we have the definition of monads written out, we can get to the more important question: why do we care? It turns out that this is a surprisingly useful abstraction. In the case of Optionals, you can use it to chain lots of functions which each assume that their arguments are non-"null", and which produce potentially-"null" values. This chain can short-circuit if any of the produced values are null, so it can save you from writing a bunch of null checks. In the case of Lists, this can be useful to model the list of potential states of a state machine, where at each state can go to one of multiple potential states. Those are in a lot of ways the most classic monads (and I'm probably forgetting some other classic examples). But monads can also be used to model randomness, parsing, and I/O operations. This all really shines in a language like Haskell, with a lot of built-in machinery which makes using monads easy. Btw, since someone asked about comonads earlier: comonads are just monads "in reverse", which define
There's a deep sense in which monads are useful for modeling Producers and comonads are useful for modeling Consumers, which you can pick up as play around with them enough.
|
|
# ? Jun 19, 2019 18:13 |
|
Ever used "flatMap"? Congratulations, you understand monads.
|
# ? Jun 19, 2019 18:15 |
|
my informal intuition for monads is that they're the most specific class that includes both "a list of T" and "a random generator for T"
|
# ? Jun 19, 2019 18:38 |
|
Carbon dioxide posted:They're literally a box you can put things of any type in and there's a way to change what's in the box without changing the box itself.
|
# ? Jun 19, 2019 19:09 |
|
Monads are design patterns for people who are offended by the idea that they're using design patterns. Otherwise they're a tool for turning your utterly hideous problem into one only 90% as hideous except this time it's on Galois modules.
|
# ? Jun 19, 2019 19:20 |
|
Wow the coding horror is in the thread. While technically correct this is the kind of long winded stuff that chases good devs away from functional programming. And there's absolutely no need for an explanation like this. Several people in this thread have given oneliners that explain the concept pretty well (and no not the endofunctor meme where each word takes a book to explain) Jeb Bush 2012 posted:my informal intuition for monads is that they're the most specific class that includes both "a list of T" and "a random generator for T" Not entirely correct. Most importantly you don't need a random generator. All you need is a class constructor (just a standard java one). If your list implementation has a way to put stuff in the list you're already there. A java list is a monad cuz you can put stuff in and also you can iterate over the list and generate a new list where all values are changed in some way compared to the original. (Although functional programmers would say you need a dedicated function within the list class that takes a lambda as argument before it 'counts'). An Optional is just a list of 0 or 1 elements so it's also a list so it's also a monad.
|
# ? Jun 19, 2019 19:22 |
|
Carbon dioxide posted:Not entirely correct. Most importantly you don't need a random generator. All you need is a class constructor (just a standard java one). If your list implementation has a way to put stuff in the list you're already there. you're misunderstanding what I was saying. I'm not saying a monad is a random generator + a list, I'm saying it characterises the properties that a random generator for T and a list of T share in common
|
# ? Jun 19, 2019 20:26 |
|
|
# ? May 21, 2024 08:35 |
|
megalodong posted:Functors as a concept are simple.
|
# ? Jun 19, 2019 22:10 |