Dear Functional Bros | Prime Reacts

  Рет қаралды 174,269

ThePrimeTime

ThePrimeTime

4 ай бұрын

Recorded live on twitch, GET IN
/ theprimeagen
Reviewed video: • Dear Functional Bros |...
By: / @codeaesthetic
Become a backend engineer. Its my favorite site
boot.dev/?promo=PRIMEYT
This is also the best way to support me is to support yourself becoming a better backend engineer.
MY MAIN YT CHANNEL: Has well edited engineering videos
/ theprimeagen
Discord
/ discord
Have something for me to read or react to?: / theprimeagenreact
Kinesis Advantage 360: bit.ly/Prime-Kinesis
Hey I am sponsored by Turso, an edge database. I think they are pretty neet. Give them a try for free and if you want you can get a decent amount off (the free tier is the best (better than planetscale or any other))
turso.tech/deeznuts

Пікірлер: 689
@asdqwe4427
@asdqwe4427 4 ай бұрын
Yes, at the end of the day we all have shared global state. We call it “the database”
@user-tx4wj7qk4t
@user-tx4wj7qk4t 4 ай бұрын
A database is a persistent data structure, aka immutable with history
@asdqwe4427
@asdqwe4427 4 ай бұрын
@@user-tx4wj7qk4t datomic is, most databases are not.
@fullfungo4476
@fullfungo4476 3 ай бұрын
Is this like an argument to something? I don’t see how this is relevant.
@user-tx4wj7qk4t
@user-tx4wj7qk4t 3 ай бұрын
@@fullfungo4476 because prime and that guy in that video, both who have very little knowledge of fp or engineering in general, say extremely ridiculous things like "fp has no global state". Or even better you'll hear people say things like "fp has no side effects or state and you can't do anything". As op pointed out, you always can have a global state, the point is it's not mutable.
@nyahhbinghi
@nyahhbinghi 3 ай бұрын
functional databases I guess can work lol, always making copies
@TAP7a
@TAP7a 4 ай бұрын
“There shall be no state” Didn’t know Marx wrote programming languages too, man that guy gets around
@bullpup1337
@bullpup1337 4 ай бұрын
isnt that anarchy tho? Marxism loves bug government
@soundrightmusic
@soundrightmusic 4 ай бұрын
😂😂😂
@tauiin
@tauiin 4 ай бұрын
Cant forget the classics like "The conquest of Functions"
@superuser8636
@superuser8636 4 ай бұрын
More like the subhuman Chomsky.
@diadetediotedio6918
@diadetediotedio6918 4 ай бұрын
It would not be Marx, more like an actual anarchist like Spooner.
@Telhias
@Telhias 4 ай бұрын
You see... Functional programmers hate transistors. The very idea that a component within your machine can change its state depending on external factors deeply frightens them.
@matt.loupe.
@matt.loupe. 3 ай бұрын
Transistors are functional though.
@michaelschmid2311
@michaelschmid2311 3 ай бұрын
Well not after I set my cpu voltage to 2v
@0x41f13
@0x41f13 2 ай бұрын
the transistor is a function the leads are inputs
@weakspirit_
@weakspirit_ 2 ай бұрын
​@@matt.loupe. deluded. like actually never understood how transistors are all different depending on manufacturing and environment.
@slipperyeel9206
@slipperyeel9206 2 ай бұрын
There is only one solution. If there is ambiguity then that means you have not researched the problem correctly or completely.
@BudgiePanic
@BudgiePanic 3 ай бұрын
Everybody gangsta till the recursive "iteration" blows up the stack and ravages the heap
@ultru3525
@ultru3525 Ай бұрын
that's what tail call optimisation is for
@mitchhudson3972
@mitchhudson3972 29 күн бұрын
​@@ultru3525 that's a lot of bs to simply use a branch instruction
@ultru3525
@ultru3525 27 күн бұрын
@@mitchhudson3972 yes every single assembly-level instruction is simple by itself, but once you start combining them to actually do something noteworthy, there is a point where the simple instructions start becoming exponentially more difficult to understand than the bs, or abstractions as they're more commonly called.
@mitchhudson3972
@mitchhudson3972 27 күн бұрын
@ultru3525 in no universe will a for loop be more complex or difficult to understand than a bunch of recursion. With performance at best it just ends up being the same thing and at worst blows up your stack
@ultru3525
@ultru3525 26 күн бұрын
@@mitchhudson3972 Sure, if you ignore the entire history of formal mathematics. Why do you think ancient mathematicians defined the Fibonacci sequence using recursion instead of a for-loop? Because recursion is the mathematical approach which is modelled by human reasoning. For-loops OTOH only came into existence when we needed to translate our reasoning into something a smarter-than-average rock can work with.
@Satook
@Satook 4 ай бұрын
At 12 mins. It is currying and currying is not quite the same as partial application. Currying is where multi-argument functions are instead represented as a sequence of single argument functions that return a new single argument function until all arguments are provided, then the last one returns a value. So f(a,b): -> c would instead be f(a) -> (f(b) -> c).
@struggopuggo
@struggopuggo 4 ай бұрын
Yeah, I would say the use of .bind is partial application as it allows for passing multiple initial arguments and returns a new function which wants the remainder arguments.
@tauiin
@tauiin 4 ай бұрын
yep, thats why haskell type signatures look like: foo :: a -> b -> a and not something like foo :: a, b -> a
@Tigregalis
@Tigregalis 4 ай бұрын
​@Satook why is this good though?
@DavidAguileraMoncusi
@DavidAguileraMoncusi 4 ай бұрын
@@Tigregalis Currying (one argument at a time) allows you to partially apply a function, which makes things a little bit easier (especially when the language supports them). For example, the function "userIdEquals" from the video, if curried, it'd be called as "userIdEquals(userId)(receipt)". This means we can then use this function partially applied as: "receipts.filter(userIdEquals(userId))", which saves as the trouble of creating an intermediate function: "receipts.filter((r)=>userIdEquals(userId,r))". In languages like JS, curried functions can be cumbersome, because each arguments has to be wrapped in parentheses. But languages like Haskell don't have this trouble: you can call the function with as many arguments as you want -- give them all and you'll get the result; provide the first few, and you'll get a partially applied function that's waiting for the rest. Hope this helps!
@Tigregalis
@Tigregalis 4 ай бұрын
@@DavidAguileraMoncusi that actually does help. first time in my life i've understood the benefit, specifically using it to avoid an intermediate function
@tepumasutasauno8671
@tepumasutasauno8671 4 ай бұрын
Currying is not partial application) It is splitting function of multiple arguments into sequence of functions of 1 argument. This is currying, meaning we don't need functions with arity greater than 1 Btw, we also don't need variables, because we can have functions with 0 arity returning constant value
@HrHaakon
@HrHaakon 4 ай бұрын
Which is incredibly helpful if you're in academia and need to prove things, because your proofs become easier since it's all just unary functions.
@HrHaakon
@HrHaakon 4 ай бұрын
@@anon_y_mousse Just memoize the results and you can reuse them! :p
@vitalyl1327
@vitalyl1327 4 ай бұрын
@@anon_y_mousse in the real world you must prove correctness too. But of course CRUD coders won't ever get anywhere close to applications that need this kind of rigour.
@vitalyl1327
@vitalyl1327 4 ай бұрын
@@anon_y_mousse and reducing the implementation to pure lambda (or, even better, combinatory logic) is one of the easiest ways to prove things. Luckily, nothing stops you from doing it with even a pretty heavily imperative code. But as an intermediate representation, a curried CPS is one of the most powerful and easy to reason about forms. Your source language does not really have to support currying, it's all down to intermediate representations.
@iverbrnstad791
@iverbrnstad791 4 ай бұрын
@@anon_y_mousse I mean, it becomes a stylistic choice at the end of the day. You give up varargs for seamless partial application. Otherwise the curried languages, Ocaml and Haskell being maybe the most famous, have both pretty decent performance and are pretty quick to develop in.
@thomassynths
@thomassynths 4 ай бұрын
For clarification on "curring" vs "partial application". They are related but distinct. While curring _yields_ a new function that implicitly _supports_ partial application, the return value of `curry(f)` is not a partially applied function. No arguments were provided yet.
@thomassynths
@thomassynths 4 ай бұрын
@@samuraijosh1595 That's not true. It's possible to partially apply arguments to a function without currying the function prior.
@shampoable
@shampoable 4 ай бұрын
a shorthand for currying identification could be if you can do foo()()
@spookyconnolly6072
@spookyconnolly6072 4 ай бұрын
also currying is a stricter subset than partial application. as currying is typically understood for use w/LC or rather single arguments in general rather than splitting the input domain N times, which currying does for N arguments
@qosujinn5345
@qosujinn5345 3 ай бұрын
@@shampoablewell thass wild, i do that in JS all the time juss cause it’s more intuitive to write if returning a function is what i’m doing. neat.
@MeriaDuck
@MeriaDuck 4 ай бұрын
More languages than just haskell (and other 'pure' functional languages) should implement tail recursion optimization. That is a strategy that does not create a stack item for a function call when it is the last thing in the function, and is a recursive call to itself. Java for instance does not do that and the call stack for the recursion becomes too large after a few thousand. So implementing a loop the recursive way leads to trouble.
@silentobserver9095
@silentobserver9095 4 ай бұрын
Tail call recursion optimization was one of the features that was promised in ES6 in JavaScript. But sadly only Safari implemented it... Which is surprising to say the least. Chrome, Firefox and others never really implemented it.
@awesomedavid2012
@awesomedavid2012 4 ай бұрын
Kotlin has a tailrec keyword that enforces a function is tail recursive and performs this optimization
@MeriaDuck
@MeriaDuck 4 ай бұрын
@@awesomedavid2012 cool! Didn't know that. Maybe Java will get it in a dozen years too then 🤣
@Reydriel
@Reydriel 4 ай бұрын
Many compiled languages already do this optimisation, though it usually isn't 100% guaranteed (as with a lot of other optimsation techniques)
@morphles
@morphles 4 ай бұрын
F yes, tail call best call :)
@peteruelimaa4973
@peteruelimaa4973 4 ай бұрын
*Pets LINQ*, "See they like you, they just don't know you!"
@ytnathandude
@ytnathandude Күн бұрын
linq is poggers
@petrus4
@petrus4 4 ай бұрын
This video was a classic bait and switch. The initial French kiss, followed by repeated kicks in the stomach.
@evanhowlett9873
@evanhowlett9873 4 ай бұрын
There is state, it's just explicitly passed around instead of hidden by class variables and global mutables. I wrote this on the original, but the issue with using functional techniques in a language like JavaScript is that A) The language doesn't have tail-call optimization and therefore recursion blows up the call stack B) Sometimes, functional languages are able to support loop fusion where, in the pipeline example, all the steps happen in a single loop instead of iterating multiple times.
@adicandra9940
@adicandra9940 4 ай бұрын
I always wondering how this kind of approach (the currying, multi-step-loop functions) would affect performance. Thanks for addressing this concern.
@hosspatrick
@hosspatrick 4 ай бұрын
fwiw re: B) - you can easily build transducers in JS (or use a library), which allows you to write declarative transformations but avoid a bunch of additional loops/instances. To me one of thing I hate about FP with JS is that there isn't currying by default (again, you can supplement with libs), which makes the whole thing feel super un-ergonomic. It makes composition harder and less intuitive, which makes small, pure functions feel less valuable. FP techniques synergize in a really satisfying way, so when you have to do all this extra leg work to enact them, of course it feels like going all in on FP is a pain.
@firetruck988
@firetruck988 4 ай бұрын
The other issue is when you work in embedded and you have to modify state in place because of cpu and memory constraints.
@mixed_nuts
@mixed_nuts 4 ай бұрын
JS(ES6) does have TCO its just that V8/Firefox doesn't support it.
@evanhowlett9873
@evanhowlett9873 4 ай бұрын
@@mixed_nuts then it doesn't. A standard without an implementation is like saying I have a PhD from MIT because I can see their outline of their PhD program online.
@CTimmerman
@CTimmerman 4 ай бұрын
Recursion is a dangerous form of iteration that can overflow the stack if it's not being tail call optimised.
@ra2enjoyer708
@ra2enjoyer708 4 ай бұрын
And the worst part in case of errors the call stack is completely useless without first (which started the whole chain and holds initial value) and the last (the reason for the error) calls.
@fullfungo4476
@fullfungo4476 3 ай бұрын
And a loop can run out if memory if there is no garbage collection. How is this any different?
@CTimmerman
@CTimmerman 3 ай бұрын
@@fullfungo4476 Just clean up when needed, which is easier to handle than a recursive control flow.
@bilbo_gamers6417
@bilbo_gamers6417 3 ай бұрын
​​@@fullfungo4476 it's infinitely easier to debug and you can easily Tell when you run out of memory in a loop. because you get a Seg Fault or malloc can't get any new memory instead of Stack Overflow with the stack trace pointing to one function. Using the program stack like this is just not a good idea.
@silience4095
@silience4095 Ай бұрын
@@fullfungo4476 And this is one reason why I love RAII, though, as the_mandrill suggested, it should probably just be called Scope-Bound Resource Management (SBRM)
@KevinPfeifer
@KevinPfeifer 4 ай бұрын
Its cool that functional programming is explained with the usecase of map, filter, sort and slice but looking at what is being done at 21:20 it feels to me like all of this should have been done on a database level in the first place. map => join | filter => where | sort => order by | slice => limit Then you don't need to fiddle around in JS and waste a bunch of time and memory doing stuff in JS which should have been done in SQL (or an appropriately designed API)
@guitarszen
@guitarszen 4 ай бұрын
Rookie that doesn't understand functional and where databases got their ideas from.
@JaconSamsta
@JaconSamsta 4 ай бұрын
Yep! Database queries are one of my favourite examples of functional programming. I'd argue you need to be a bit careful, as they can be hard to test/verify and SQL is honestly not that great and has pretty poor IDE support, but you can get a lot done before you ever send the data out over the network.
@user-tx4wj7qk4t
@user-tx4wj7qk4t 4 ай бұрын
SQL is a declarative language
@guitarszen
@guitarszen 4 ай бұрын
functional programming is declarative@@user-tx4wj7qk4t
@jhonnyrodrigues
@jhonnyrodrigues 4 ай бұрын
For curiosity about tips (16:40), in Brazil it is common that restaurants auto calculate a 10% tip. You can either pay or not pay it, but basically nobody will tip a different value
@henriqueprado9205
@henriqueprado9205 4 ай бұрын
Eu nunca vi um restaurante cobrar gorjeta aqui kkkkk
@joseeduardorussoperis4668
@joseeduardorussoperis4668 4 ай бұрын
É o 10% burrão ​@@henriqueprado9205
@fidelicura
@fidelicura 4 ай бұрын
That's really the most kind, prewatched and funny video. Thanks 💖
@wolfgangrohringer820
@wolfgangrohringer820 4 ай бұрын
I am doing a lot of DSP and data processing, and I found myself drawn to the style of creating some kind of "pipeline" since it makes it really easy to understand on a high level what kind of steps a given analysis is going through (much more so than, say, a nested loop with all the interesting stuff going on in the innermost loop). Since in Rust / C++, I find myself falling back to good old procedural idioms quite often out of habit, I started to use some F# for smaller scripts and recently Advent of Code, forcing myself to embrace the functional style. On the one hand, the code turns out to be quite readable, composing functions feels good, and I have less issues bikeshedding how to organize code compared to an object oriented approach, where there are always multiple ways to split up functionality into different classes, and usually the first choice turns out to be flawed some time down the road. On the other hand, I find that the FP style has more "surface area" to learn (knowing as many algorithms / operations available for a given type of container is critical), I find it hard to reason about the performance of certain steps (compared to a procedural style where working with contiguous memory and avoiding copies already gets you quite far, and it's usually obvious when copies happen), and, most critically, the debugger seems really useless. So I'm torn. It seems a bit like sugar, some FP style in some places (mainly high-level "business logic"?) is awesome, but in the more involved interna of a codebase, I find that keeping things procedural may actually be better to stay on top of what's going on, at least based on the debugging experience I had so far. Ofc it might just be a skill issue at this point.
@catchychazz
@catchychazz 4 ай бұрын
IMHO, nothing beats Scott Wlaschin's conference lectures on "Domain Modeling Made Functional" and "Functional Design Patterns" for introducing functional programming in a really intuitive way.
@giorgos-4515
@giorgos-4515 4 ай бұрын
came here to say this, glad someone is also on board
@mciejgda88
@mciejgda88 4 ай бұрын
Yes! Are you also one of the 5 F# programmers?
@giorgos-4515
@giorgos-4515 4 ай бұрын
@@mciejgda88 not yet unfortunately, but i have almost read all of the articles from Scott's blog. I want to do as an experiment the domain modelling with F# thing in a real context with domain experts
@erfling1
@erfling1 4 ай бұрын
I also got owned by reverse last week. Totally forgot it mutates arrays
@perigord6281
@perigord6281 4 ай бұрын
Learning Haskell as basically my first language (C++ was my actual first, but I quickly grew disinterested in the language). Has caused quite an interesting learning journey.
@user-xf6ef8ec4z
@user-xf6ef8ec4z 4 ай бұрын
Currying is taking a function that has an arity greater than 1 (n) into a group of single arity functions whose members total n. Currying will result in high order functions (but not all HOFs will require you to curry, a function with a callback for instance, can be a high order function but it is not a curry) since high order functions take a function as an argument or return a function
@jakubkucera1973
@jakubkucera1973 4 ай бұрын
Arity being the number of arguments a function takes for my Dysfunctional bros.
@D4ngeresque
@D4ngeresque 4 ай бұрын
And here I thought he just misspelled parity... I think at the end of the day most people would rather just learn a programming language than relearn English to learn a programming style then learn a programming language to implement it in. That's probably why this stuff hasn't gained more traction.
@user-xf6ef8ec4z
@user-xf6ef8ec4z 4 ай бұрын
@@D4ngeresque I can appreciate hyperbole but I think comparing learning a couple new words (which are long standing English words) to relearning English is a bit too hyperbolic for me. I thought the same thing when I first saw "arity" but I took two seconds to google it and I now I can understand any text that uses the term. 2 seconds of investment; lifetime of value. I'd also add that you will need new language for all new things you learn so this really isn't an inherent issue to FP. I'm not saying you need to learn it either just don't avoid it for arbitrary reasons like being novel to you.
@alberthadonlyone
@alberthadonlyone 4 ай бұрын
Haskell has a special place in my heart because it got me interested in programming
@samuraijosh1595
@samuraijosh1595 4 ай бұрын
Same 😅
@azmah1999
@azmah1999 4 ай бұрын
Damn, I can't imagine raw dogging Haskell as a first programing language. Did you major in math?
@alberthadonlyone
@alberthadonlyone 4 ай бұрын
@@azmah1999 Yes and it wasn't technically my first language. That was Java but I could barely write hello world at that point.
@perigord6281
@perigord6281 4 ай бұрын
It was my 2nd but it was also the one that got me really into programming
@TazG2000
@TazG2000 Ай бұрын
21:00 The standard javascript library is the problem here. These functions SHOULD accept and return iterators (where you can dump it back into an array at the end if you need to). Still, you don't really need to break up the code to debug this though. You could start by stepping through the "map", then remove that breakpoint if you are satisfied there are no bugs there, skip ahead to "filter" and so on, until you find a bug.
@dberweger
@dberweger 4 ай бұрын
🎯 Key Takeaways for quick navigation: 00:00 🎉 *The video starts with a discussion about functional programming and the term "functional bros."* 02:10 💡 *Functional programming emphasizes pure functions without side effects, making it elegant and predictable.* 03:44 🧐 *Functional programming eliminates mutable state and relies on functions to compose and manipulate data.* 06:04 🔄 *Recursion is discussed as a key technique in functional programming for tasks like looping.* 09:30 🤔 *The video explores currying and partial application as functional programming techniques.* 11:35 🧩 *Lambda functions are introduced as a way to create functions that carry extra data for specific conditions.* 14:58 🤓 *Functional programming methods like `filter`, `map`, and `take` are used to process data in a declarative and concise way.* 18:10 🔄 *The video demonstrates how to apply functional programming techniques to solve a problem involving restaurant receipts.* 20:18 📺 *Focus on being actively engaged when watching videos, especially if not live.* 21:26 💡 *Functional programming allows for elegant data pipelines, which are common in many programming tasks.* 23:10 🧠 *The best parts of functional programming have been incorporated into popular languages.* 24:05 🛡️ *Reducing state and using data pipelines can bring significant benefits without excessive restrictiveness.* 24:44 🚀 *Exploring multi-threading and parallelism in Rust can lead to improvements in performance.*
@dv_thai
@dv_thai 4 ай бұрын
I agree that functional programmers are bad marketers because, somehow, they make this guy think about FP as “There Shall Be No State”. This is hilarious 😂
@user-tx4wj7qk4t
@user-tx4wj7qk4t 4 ай бұрын
Prime is the best example of somebody who has no idea what he's talking about but read some very surface level things on the topic and now talks about it with authority. That's not FP's problem, it's the problem of soydevs thinking they know everything without actually studying.
@ragnarok7976
@ragnarok7976 4 ай бұрын
Seems to me like it's more about reducing the use of state and trying to make sure its impacts are known when it does get used. I'm just starting to look into it but those are the benefits I'm seeing right out of the gate.
@user-tx4wj7qk4t
@user-tx4wj7qk4t 4 ай бұрын
@@ragnarok7976 sortve but really the idea is to avoid shared mutable state so that you can achieve pure functions, which are functions that are: Total Deterministic Side-effect free This allows those functions to be referentially transparent so they can be optimized and memoized even by the compiler. This also let's to do property based tests instead of unit tests which test what these functions actually "are" instead of testing some example observations. And it essentially makes 90% of your code nearly error free so you can go focus on only the things that can cause issues instead of running up and down your code with a debugger
@Boxing_Gamer
@Boxing_Gamer 4 ай бұрын
Yes of course there is state..it is just immutable. So once you alter it, you just get a new copy. The copy is smart though, nothing like Rust's "Clone"
@Boxing_Gamer
@Boxing_Gamer 4 ай бұрын
@@user-tx4wj7qk4tAnd they are a whole lot easier to test
@MasterHigure
@MasterHigure 4 ай бұрын
18:10 You can both call array.sort() to just sort it, but you can also use it in a dot-chain of functions. I call that a win. At least as long as it doesn't actually clone the thing.
@Muaahaa
@Muaahaa 4 ай бұрын
Rust iterators are such a big win over the JS way map|filter|reduce or implemented
@SimonBuchanNz
@SimonBuchanNz 4 ай бұрын
JS has a proposal to add those and many more to iterators.
@eddiemeekin9180
@eddiemeekin9180 4 ай бұрын
I’ve just started a programming course and I’m currently making my first JavaScript project. I was worried that I didn’t have any kind of “loop” in my code. I just have functions that call each other when certain criteria is met. The first 7 mins of this video made me feel a LOT better.. am I becoming functional bro?? 😂
@NeilHaskins
@NeilHaskins 4 ай бұрын
f(str) return str + " " + f(str) f("One of us.")
@eddiemeekin9180
@eddiemeekin9180 4 ай бұрын
@@NeilHaskins yeah I wish I knew what that meant 😂❤️
@nnnik3595
@nnnik3595 4 ай бұрын
No you are not writing useful code yet.
@eddiemeekin9180
@eddiemeekin9180 4 ай бұрын
@@nnnik3595 oh I’m very aware that I am still at the base of mount stupid 😂
@dsdy1205
@dsdy1205 2 ай бұрын
Bro discovered callback hell
@joshuakb2
@joshuakb2 4 ай бұрын
You don't step through the functional code with the debugger, you test the functional code with different inputs to see where it doesn't do what you wanted it to. Then you break it apart into its smaller parts to understand where you've gone wrong
@tuchapoltr
@tuchapoltr 4 ай бұрын
QuickCheck for Haskell is amazing for this, but there aren’t as many good analogs in other language ecosystems…
@ryanleemartin7758
@ryanleemartin7758 4 ай бұрын
unless it's javascript or some other mutation first language cosplaying as a functional language. Then good luck with that!
@joshuakb2
@joshuakb2 4 ай бұрын
@@tuchapoltr you can just use the repl. It's pretty easy to use in both haskell and JS
@mskiptr
@mskiptr 4 ай бұрын
Indeed! Step-by-step debugging doesn't make sense anywhere except in code executed step-by-step. For simple, pure functions you only want to see what various parts of the call tree evaluate to. More complex types would maybe warrant specialized debuggers tho.
@joshuakb2
@joshuakb2 4 ай бұрын
@@ryanleemartin7758 I do this in JS all the time lol
@ThatJay283
@ThatJay283 3 ай бұрын
i really like constexpr functions. like, you reduce state by having something where the output depends only on all inputs (even for constexpr classes, since `this` is a hidden parameter) and you don't have to deal with any of the bullshit with "pure" functional programming such as not being able to mutate local variables leading to things being overly complex and leading programmers to iterate and exhaust stack space.
@BJ-sq1si
@BJ-sq1si 3 ай бұрын
In Haskell, It’s not just because it’s pretty or because it’s elegant or because it’s easier to reason about once you understand it, it’s useful for making increasingly complex programs require less code to write (even under the hood) through the use of generalizations of functions on types and type classes. It’s the low cost or cost free abstractions that allow you to have automatic optimizations that the compiler can now prove using the type system that it wouldn’t be able to make without it. In some cases this even allows optimizations you wouldn’t be able to get writing well written C unless you used inline assembly. It literally lets you write more performant programs using less total code asymptotically as you scale. And imo it’s more pleasant to write. And for the record, I love C and assembly. Calling C and assembly in Haskell when generalizations don’t yet exist to get you comparable performance for that specific function is practically standard practice for a Haskell dev when performance matters.
@blubblurb
@blubblurb 4 ай бұрын
Full agree on the debugging part, exactly that, remove the return at the beginning, make multiple variables and then return it is also how I debug those things.
@Altrue
@Altrue 4 ай бұрын
"No state" but you use a secret parameter that will influence the result of your nested function.. in other words : State with extra steps.
@u9vata
@u9vata 4 ай бұрын
No. Pure functional programming languages like "clean programming language" for example model the whole universe with no state changes (including the computer memory) - then how you run interactive programs is that both your functional program can create a new universe - then the user as a function also can create a new universe from that - then functions run over it again. You need no state this is just recursion with a completely new universe being born all the times haha. Then haskell has the other approach with monads - but I find the "Clean" approach to be theoretically cleaner indeed. Fun-fact: Clean and Haskell are nearly fully compatibly even to the syntax level and you could not tell which code is from which - despite the therory and inner workings being so different...
@arkeynserhayn8370
@arkeynserhayn8370 4 ай бұрын
​@@u9vata What you are describing is the theoretical underpinnings of FP, the real implementations dont abide by that.
@u9vata
@u9vata 4 ай бұрын
@@arkeynserhayn8370 What I describe is the SEMANTICS of said languages so real implementations DO totally abide that in both circumstances. Just of course - as every sensible compiler - they optimize whatever they can and whenever possible given the given circumstances when the compiler is good. Still this is the programming model that you see when you are coding. There are "not purely" functional languages, where the semantics enable more, but in case of Clean and Haskell the semantics are purely functional.
@theboydaily
@theboydaily 2 ай бұрын
I love high order functions. And I love to use them in Go.
@m4rt_
@m4rt_ 4 ай бұрын
I think he's mixing up Functional Programming and Pure Functional Programming. There is a difference.
@zekiz774
@zekiz774 Ай бұрын
No he doesn't. 22:50
@michaelmueller9635
@michaelmueller9635 4 ай бұрын
Lol, I commented - as one of the first comments - under the original 'Dear Functional Bros': "This one is going to hit ThePrimeagen hard xD"
@MiezoT
@MiezoT 4 ай бұрын
for good introductions to fp i can recommend scott wlaschin's articles and videos
@paulzupan3732
@paulzupan3732 3 күн бұрын
The confusion behind currying is probably with the nomenclature, currying is the process of turning this type signature: f :: (Int, Int) -> Int Into this type signature: f :: Int -> Int -> Int
@slava6105
@slava6105 4 ай бұрын
6:15 the nature of javascript: you don't get error on out of index, you get error on accessing field on null.
@TehKarmalizer
@TehKarmalizer 4 ай бұрын
Changing state is how you get things done. Heard it here first.
@TRex-fu7bt
@TRex-fu7bt 4 ай бұрын
currying is turning f(a, b, c) into g(a)(b)(c). partial application is where you create a new function with some argument values pre-set (partially applied).
@georgehelyar
@georgehelyar 4 ай бұрын
Do you really need to know the names of them in order to use them though? I think the video was mostly about scaring new people off.
@Joorin4711
@Joorin4711 4 ай бұрын
@@georgehelyar Using is second to *reasoning* about the concepts. Without the language and definitions of concepts, how do you convey the meaning and semantics?
@TRex-fu7bt
@TRex-fu7bt 4 ай бұрын
@@georgehelyar it’s a programming pattern and it’s good to have a consistent name for the pattern 🤷‍♀️
@georgehelyar
@georgehelyar 4 ай бұрын
People use these things all the time without knowing what they are called though. It's just that the names are scary to people who have not heard them before, and that makes people think FP isn't for them.
@hoodiegal
@hoodiegal 2 ай бұрын
I'm a hobbyist programmer and I've only got experience working with procedural and object oriented programming. This stuff is mindboggling to me. I can clearly see that it works, but I do not understand how the heck it does. It's like I've been building houses using nails and screws all my life, and then someone shows up and tells me about wood joining and shows me that you can build a whole house without any screws or nails. I can clearly see that you put a house together, but I have no idea why it's not falling apart.
@RandomGeometryDashStuff
@RandomGeometryDashStuff 4 ай бұрын
03:56 I wonder is "Code oriented: state is code" possible no ifs, no loops, but instruction to replace instruction (branchless self modifying code)
@SystemAlchemist
@SystemAlchemist 4 ай бұрын
You mean like Forth or Joy?
@JoshuaMaciel
@JoshuaMaciel 4 ай бұрын
I like my for loops and you can never take them away
@JamesJones-zt2yx
@JamesJones-zt2yx 4 ай бұрын
Haskell Curry realized that all you need is functions with one argument, as long as you can return a function. (Moses Schoenfinkel realized it first, but you and the guy with the video would REALLY complain if you had to talk about schoenfinkeling a function.) Haskell notation is designed to make it easy to schoen...uh, curry.
@SimonBuchanNz
@SimonBuchanNz 4 ай бұрын
On the other hand, the programming language Moses probably would be way more popular. To their chagrin!
@ragnarok7976
@ragnarok7976 4 ай бұрын
You could consider "bind" to be syntactic sugar (or salt in this case) for currying. Essentially you are just adding the scope of the parent function and using it within the child function. This would be exactly the same result as simply just calling the child function inside of the parent function. Using bind is also less readable and I would argue introduces the same state-like problems you are trying to avoid. That being the functions being bound together is a state in itself but that state can be set up outside the scope of the function meaning there are cases where your function could fail and you'd have no idea just by looking at the function itself, rather you'd have to probe the context of the state around the function. At that point you might as well just use the state and keep the readability. Save you typing bind constantly too 😂
@valcron-1000
@valcron-1000 4 ай бұрын
I suggest reading "The Curse of the Excluded Middle" to understand why this "using the bests parts of FP" approach eventually falls apart in practice.
@ajfalo-fi3721
@ajfalo-fi3721 4 ай бұрын
Can you explain a bit?
@user-tx4wj7qk4t
@user-tx4wj7qk4t 4 ай бұрын
It's complete nonsense too since that's not how things work and the original video is mistaken on at least half of what they're saying. This is why FP gatekeeping hard is good, it keeps these soydevs out
@handomize
@handomize 4 ай бұрын
Prime: never gives attention to KZbin comments doesn't put anywhere that he's doing that Also prime: i wonder why I don't have traction on KZbin.
@Drazzz27
@Drazzz27 4 ай бұрын
Well, there is "LIVE AND READ CHAT ONLY ON TWITCH" in the description of his live streams.
@handomize
@handomize 4 ай бұрын
@Drazzz27 oh my bad didn't see that
@FractalWanderer
@FractalWanderer 4 ай бұрын
To be fair, I see him respond to KZbin comments all the time (including myself.) Just not while live lol
@snickersanyone
@snickersanyone 4 ай бұрын
Could it also be the content he throws at KZbin nowadays? Reaction video after reaction video, zero original content, just him hitting space on KZbin videos every second. Like idk, dude’s free to do whatever he wants and he obviously prefers Twitch but it feels pointless to sub to him now. Such a stark contrast to the channel he’s reacting to…
@worgenzwithm14z
@worgenzwithm14z 4 ай бұрын
The peak of Prime's KZbin content was when he was on paternity leave. Dude is a Netflix Engineer™️ and has a few children iirc. He's just busy
@williambergqvist4130
@williambergqvist4130 4 ай бұрын
Functional bros do use HashMaps occasionally but often we use immutable maps based on binary trees.
@zionen01
@zionen01 3 ай бұрын
Love functional , use it at my job with the OOP language and the code never gets changed, must work right
@nomadshiba
@nomadshiba 3 ай бұрын
0:40 you can combine two chats into one
@thapr0digy
@thapr0digy 4 ай бұрын
That last minute is hilarious!
@s3rit661
@s3rit661 3 ай бұрын
11:46 Yeah, it is currying, basically if you have a function that does the sum between 2 numbers, gets a number as input, that's the function that does the sum of x + 5 (assuming you passed 5 as first argument) and you specialize the function x + y with y = 5. If you pass both of them in this way (x)(y), you are actually changing both of the x and y. TECHNICALLY what he did it's called closure in python world, but it's the same principle of currying
@adud6764
@adud6764 4 ай бұрын
The reviewed video is not properly linked in the description.
@krzysztofzabawa2212
@krzysztofzabawa2212 4 ай бұрын
It never is, which I hate. I always have to google source videos and articles... :
@user-tx4wj7qk4t
@user-tx4wj7qk4t 4 ай бұрын
Good because it's a terrible videofull of misinformation
@c4tubo
@c4tubo 4 ай бұрын
Typical all-paradigms-are-good take. Software is remarkable among fields of engineering (civil, mechanical, electrical, etc.) in that nothing ever gets taken out. Legacy code and recalcitrance keep every approach in-play along with their defenders, the good and the bad.
@ilangated
@ilangated 4 ай бұрын
FYI the "reviewed video" link in the description links to THIS video, not the CodeAesthetic video
@atrus3823
@atrus3823 3 ай бұрын
Every function is a pure function. You just have to conceptualize it as the new state being part of the output and the current state as being part of the input.
@thomassynths
@thomassynths 4 ай бұрын
The sad thing is all these coding youtubers only understand surface level stuff about FP. It's not actually all about pure functions and such. It's all about explicitly modelling computation.
@ericb7937
@ericb7937 4 ай бұрын
I look forward to your youtube video expanding on these concepts
@thomassynths
@thomassynths 4 ай бұрын
@@ericb7937 I've honestly been toying with the idea of making some tech videos on youtube. Perhaps sooner than later.
@sfulibarri
@sfulibarri 4 ай бұрын
Cool story functional bro
@llIlllIIlIIlllIlllIl
@llIlllIIlIIlllIlllIl 4 ай бұрын
Could you care to elaborate? I understood nothing from this sentence, and this is from someone who tried to learn FP (I quit at monads) (Edit: Semi jokes aside I think it might have also been Traversables or something)
@MilanRubiksCube97
@MilanRubiksCube97 4 ай бұрын
You just gotta learn Clojure to get it
@williamdrum9899
@williamdrum9899 4 ай бұрын
Technically all functions modify state because you're modifying registers
@kardashevr
@kardashevr 4 ай бұрын
0:58 the most genuine laughter
@khatdubell
@khatdubell 4 ай бұрын
Currying and partial application are related, but not equal. All partial application is currying, but not all currying is partial application.
@thomassynths
@thomassynths 4 ай бұрын
"All partial application is currying" is false by definition. Also currying is never partial application. The only thing you wrote that is correct is saying that they are related.
@khatdubell
@khatdubell 4 ай бұрын
@@thomassynths Currying is a function that returns a function. Partial application is a function that returns a function with some of the arguments fixed. I stand by what i wrote.
@thomassynths
@thomassynths 4 ай бұрын
@@khatdubell Currying is a function that takes in a function with tuple arguments and turns a new function that takes unary arguments and returns successive functions. Partial application merely returns a new function with some argument values already provided. These are different things. `curry(f)` returns a function that has nothing partially applied it it. Currying is one mechanism to facilitate partial application, but it is not the only one. Mathematically, currying `(a, b)->c` is `a->(b->c)`. Notice that no partial application has yet been performed, yet the currying operation is completed once the `a->(b->c)` value is returned. Mathematically, partially applying `a` to `(a,b)->c` yields `b->c`. Notice that `patial_apply(f,a)` takes more than just the function as an input, unlike `curry`
@user-tx4wj7qk4t
@user-tx4wj7qk4t 4 ай бұрын
@@thomassynths You're right of course but I'm curious why this is the topic you seem to be concerned with when nearly half of this video is incorrect information. Prime has absolutely no idea what he's talking about and the guy he's reacting to is even worse
@fdg-rt2rk
@fdg-rt2rk 3 ай бұрын
​​@@user-tx4wj7qk4the and other soydevs always love sh*tting on functional programming and when asked why? They don't know sh*t on how to elaborate on functional programming
@_MB_93
@_MB_93 4 ай бұрын
FP might one day be better than procedural / OOP if colleges start teaching its concept, so the next junior seeing my (beautifully :) written functional code doesn't curse me behind my back
@alexaneals8194
@alexaneals8194 4 ай бұрын
FP has it's uses, but trying do everything in FP is like a carpenter discovering a framing hammer and using it to drive a bolt into concrete.
@ricardocruz4235
@ricardocruz4235 4 ай бұрын
Hey, at Cornell they teach OCaml in a pretty fundamental course so we're a bunch of closet functional nerds wondering what to do with ourselves!
@IvanGreguricOrtolan
@IvanGreguricOrtolan 2 ай бұрын
if you test the pure functions in between there is no need to debug anything!
@lukekubat3882
@lukekubat3882 4 ай бұрын
The great thing about functional programming is that I spend less time debugging multiple issues because I have to spend more time debugging each individual issue.
@draakisback
@draakisback 4 ай бұрын
I watched this video a few weeks ago and just was baffled. This guy clearly doesn't understand FP at all, and that's disconcerting.
@SirDrinksAlot69
@SirDrinksAlot69 4 ай бұрын
Damn it, I wish i saw this when it was live on twotch. I have so many things to say about why I hate JavaScript so much and this is like the ultimate example. Impossible to debug code coupled with the complete lack of comments and the absolute disdain for having to explain a single character. Say what you want about perl but perl devs are so proud of what they crapped out its been my experience they comment every line with excruciating detail. Although maybe thats just to remind them what those hieroglyphics they made means because even they dont understand.
@nickwilson7241
@nickwilson7241 4 ай бұрын
I remember getting owned by reverse so hard that I memory holed what it was that I did wrong, ensuring I will eventually get owned by it again in the exact same way at some point
@Remiwi-bp6nw
@Remiwi-bp6nw 4 ай бұрын
Ironically exactly when he says youtube can be a part of this video this one time, my KZbin app crashes lol
@RoninX33
@RoninX33 3 ай бұрын
Learning F# right while getting a deeper learning of concurrency in .Net. Brain melting.
@carlbartels3611
@carlbartels3611 4 ай бұрын
Your closing comment made me cry a little bit inside. Concurrency in Rust is hard. It took me a couple months to get used to the borrow checker when learning. Now I have a process that I’m trying to speed up with the various concurrency tricks, but nothing actually works. Everything compiles and runs and gives correct results, but everything with concurrency makes things 5 to 50 times slower. Rayon, channels, etc. nothing works. I feel like I did back before I was able to think of the borrow checker as something to work with instead of something to fight with. This is one thing that the rust book actually makes look easy, but that implementing in a real world problem gets hard.
@skunkwerx9674
@skunkwerx9674 4 ай бұрын
It might be a better exercise to first implement as non blocking pool threads to discover if the problem is congruent to coroutines. I find it’s easier to move to coroutines from that.
@ora10053
@ora10053 4 ай бұрын
just rewrite it in Go
@ZantierTasa
@ZantierTasa 4 ай бұрын
12:04 Currying is not partial application. I know people have sort of answered this, but I'll try to provide a more complete answer in relation to bind. Say we have a function with multiple parameters: f is (number, number, number) -> string bind performs partial application. You're absolutely correct. f.bind(null, 1) returns (number, number) -> string Currying, on the other hand, is the transformation of f into f2 :: number -> (number -> (number -> string)) i.e. We end up with a "curried" function, that makes us pass parameters to it 1 at a time. For partial application, instead of bar = f.bind(null, 1) we now just go: bar = f2(1) Currying can happen at runtime: Haskell literally has a "curry" function. But in this video, he is currying the function manually at dev-time. Here's how partial application looks on userIdEquals before and after currying: userIdEquals(userId, receipt) userIdEqualsCurried(userId) Partial application (these give the same result): userIdEquals.bind(null, 1) userIdEqualsCurried(1) 12:52 You mention that he's using a closure, whereas bind isn't, but if you think about how to implement bind, it almost certainly returns a closure.
@ThePrimeTimeagen
@ThePrimeTimeagen 4 ай бұрын
correct bind is using a closure, but its as close to "partial" application as i can get in javascript
@ZantierTasa
@ZantierTasa 4 ай бұрын
@@ThePrimeTimeagen It IS partial application! :) (I go into more detail above)
@tbethenerd
@tbethenerd 4 ай бұрын
Recursion is just a fancier way to smash your stack.
@CodeThatVoid
@CodeThatVoid 4 ай бұрын
It is a damn good intro :D
@jeffreyepiscopo
@jeffreyepiscopo 4 ай бұрын
You put the fun in function
@Apollo1_
@Apollo1_ 4 ай бұрын
hot damn its prime time baby
@pillmuncher67
@pillmuncher67 4 ай бұрын
@ThePrimeTime, whenever you summed up a list of numbers you did a catamorphic operation, you probably did it during the last few weeks.
@georgehelyar
@georgehelyar 4 ай бұрын
This is the point though. Hearing "catamorphic operation" scares people off, and you don't really need to know the name of it in order to use it.
@isodoubIet
@isodoubIet 4 ай бұрын
The problem with category theory is that it's so abstract and general that there's some construct in category theory that will describe what you're doing. Except, naming things for the sake of naming them gives you nothing useful.
@pillmuncher67
@pillmuncher67 4 ай бұрын
@@isodoubIet Knowing the basics of CT can lead you to seeing your programming problems differently. I recently wanted an embedded DSL for Logic Programming (with cut!) in Python, and I implemented it in Python with a triple-barrelled continuation monad. I'm very pleased with the simplicity of the code. I ported it to C# in one evening without much prior knowledge in that language. The structure of the code made it also very easy to add tail call elimination via thunks and a trampoline.
@isodoubIet
@isodoubIet 4 ай бұрын
@@pillmuncher67 yeah parsing is one of those things for which functional patterns in general are very well suited
@GokuMercenarioSC
@GokuMercenarioSC 4 ай бұрын
You can hear functional programmers break when they see a break.
@valseedian
@valseedian 3 ай бұрын
switch is probably the most inherently functional aspect of most programming languages (aside from functions) and that uses break.
@redpepper74
@redpepper74 3 ай бұрын
@@valseedianyeah considering it’s pretty close to pattern matching (see Java switch expressions)
@GokuMercenarioSC
@GokuMercenarioSC 3 ай бұрын
@@valseedian I mean, they can't break in the same way normal for loops work in a forEach function, only continue by doing return.
@karl9681
@karl9681 4 ай бұрын
The reviewed video link causes a recursion.
@skeleton_craftGaming
@skeleton_craftGaming 4 ай бұрын
I've been doing a lot of web dev recently, so yes... I do consider myself a functional bro right now
@terryriley6410
@terryriley6410 4 ай бұрын
If you use Maybe Purescript or Just elm you are indeed an F bro, if you don't use Either you are not.
@Avaritia-wl9yi
@Avaritia-wl9yi 4 ай бұрын
Xxx
@OhsoLosoo
@OhsoLosoo 4 ай бұрын
The higher-order function/currying always gives me a lot of trouble. I can't seem to wrap my mind around it. I also can't justify not using loops at all. I'm reinventing the wheel. In the end, I'm left coding some abomination of functional/non-functional. Where I use functions to handle everything but still use loops & conditions to make the program operate. If anybody has some good resources or recommendations let me know!
@benniecopeland7388
@benniecopeland7388 4 ай бұрын
A higher-order function is simply a function that takes another function as input. The map function is a good example of this type. Say for example, you have a function that takes a number and doubles it, and you have a list of numbers you want to run through the function. Map takes both that function and the list and returns you a new list of the doubled values. Currying is taking a function with two or more parameters, and converting it to a nested collection of single parameter functions. This , in that you can provide each parameter one at a time. In JavaScript it would look like this: const calcTax = (taxRate, quantity, price) => (price * quantity) * (taxRate / 100); const r = calcTax(7.5, 5, 3); // forced to call it with all three values const curriedCalcTax = (taxRate) => (quantity) => (price) => (price * quantity) * (taxRate / 100); const r2 = curriedCalcTax(7.5)(5)(3); // forced to call three functions each with a single value const salesTax7point5 = curriedCalcTax(7.5); // partially apply the 7.5 percent sales tax to create a new function with the value baked in const r3 = salesTax7point5(5)(3); const salesTax7point5quantity5 = salesTax7point5(5); // partially apply the quantity const r4 = salesTax7point5quantity5(3); // left with a single parameter function Functional languages do this currying for you automatically, and it is useful to bake in values like connection strings, or adapting the shape of your function to match a higher-order function's requirement. Loops themselves are not necessarily bad or "non-functional" in my opinion. It's about controlling side effects. You can have a loop with a mutable counter inside the boundaries of a function, and that function still be "pure" because it only relies on the inputs and any mutable state is kept within the boundaries of that function call. There is no pure side effect free program. It can't exist. Everything needs a way of getting input, providing output, storing and retrieving data, etc. But FP prefers to limit the places that these "impure" actions take place to the start and end points of a calculation. Mark Seemann calls this the "impureim sandwich".
@OhsoLosoo
@OhsoLosoo 12 күн бұрын
@@benniecopeland7388 4 months later and I finally got this, I appreciate your example so much.
@rahuljindal-ik4zv
@rahuljindal-ik4zv 3 ай бұрын
This is much cleaner and readable until promise are not put into the equation, where things will start to look messy fairly quickly.
@code-dredd
@code-dredd 4 ай бұрын
It was actually currying. Def: *Currying:* _The technique of transforming a function that takes multiple arguments into a function that takes a single argument (the first of the arguments to the original function) and returns a new function that takes the remainder of the arguments and returns the result._
@prism223
@prism223 Ай бұрын
Higher order functions are horrible for debugging--in systems that have imperative-style debuggers. I'll give you an example for how a functional programming language made in the 80s and standardized in the 90s handles higher-order function debugging: Since addition in this language only works on numbers, handing it a number and a string causes an error. E.g.: map(lambda: x => x+2,[1,2,3,"hello"]) => ERROR But, what does this error condition mean? It means you now are in a debugger which allows you to pick any number of restart options (retry execution, substitute value, abort, ignore error etc.). While in the debugger, you are also able to view the code used to generate the function as well as all stack frames up to the point where the machine instructions were about to apply to invalid data, which is what the language prevented from happening as it has both static and dynamic type checking. I pulled a fast one on you: The language above only half-exists. The real code looks like this: (map 'list (lambda (x) (+ x 2)) (list 1 2 3 "hello")) It's Common Lisp. The rest is true. What I wish modern languages would do is simply learn from the past rather than repeating mistakes and implementing half-versions of what already existed decades ago. It's OK to not like one syntax or another, or wish that a language had more modern assumptions about systems. But, having a language like JavaScript that runs the entire internet and supposedly supports higher order functions, minus one of the most important tools for actually using them--a decent debugger--is like deconstructing a Cadillac so that you can build a coal-powered car that only works when it's not raining.
@arkie87
@arkie87 4 ай бұрын
IMHO opinion, not having state is reasonable. But carrying that over to, you cant have for loops because the iteration counter is a variable that is written to and is therefore state, is stupid. Having no state, IMHO, means that the same input will result in the same output, every time. That is it. There can be internal "states" as long as the same input will result in the same output.
@user-vu5bj1pg4b
@user-vu5bj1pg4b 4 ай бұрын
I would also recommend ignoring that explanation. Local mutations and state are possible in functional languages, but you don't need them for a for loop. e.g. a local Ref can be used to achieve this in Scala, OCaml, and even Haskell Using map, filter, flatmap are preferred as you do not need to write the looping implementation where mistakes could be made, it's easier to reason about (likewise using recursion), and can take advantage of any optimisations Last time I looked map in Scala was just a classic loop in Java under the hood 😅 Trust me, 90% of the stuff I read about FP (like in JS) is not really FP. It's procedural code using FP concepts -- and there's nothing wrong with that at all
@digitalspecter
@digitalspecter 4 ай бұрын
There are pretty much purely functional programming languages (like Flix) that allow local mutation as long as it doesn't escape the scope.
@landonyarrington7979
@landonyarrington7979 4 ай бұрын
List comprehensions: 5/5 😊 Nested list comprehensions: 0/5 😠
@SirBearingtonSupporter
@SirBearingtonSupporter 4 ай бұрын
The way the credit card transactions occur for restaurants with tipping is the original amount is placed as a HOLD. This means it will show as “pending” on the credit card statement. When it is finally posted we will have a different amount. The problems with this startup is we need to not go after the $1 holds that become a normal amount. You also won’t see a pending / posted amount specific types of restaurants. - like if you provide a tip amount prior to them running your card.
@v2ike6udik
@v2ike6udik 4 ай бұрын
Comuter crash - nasty proton flux, 100x beyond baseline. Hurts me too, not just the computer.
@MrAntice
@MrAntice 4 ай бұрын
recovering functional bro here.
@guitarszen
@guitarszen 4 ай бұрын
Ah yes, the lament of the procedural douchebag.
@catomajorcensor
@catomajorcensor 3 ай бұрын
Currying = function taking its arguments one at a time, returning intermediate functions along the way. OCaml (and other functional languages) does this automatically. You'd have to explicitly pass your arguments together (instead of a' -> b' -> c', to do (a' * b') -> c') to avoid it. Conversely, in JavaScript, which doesn't do currying automatically, you have to explicitly instantiate new functions. You can make this slightly more concise by using arrow functions: const add = m => n => m + n; Using bind() emulates currying, but doesn't actually do it properly, since you have to call it every time for every argument. You can do this programmatically using the length property, but it feels wrong: const curry = f => { if (f.length curry(f.bind(null, x)); }
@catomajorcensor
@catomajorcensor 3 ай бұрын
Note that JS doesn't do tail-call elimination so all of this is useless anyway
@Tony-dp1rl
@Tony-dp1rl 4 ай бұрын
Three steps to slowing down your JS by an incredible amount, step 1: map(), step 2: filter(), step 3: slice()
@ra2enjoyer708
@ra2enjoyer708 4 ай бұрын
Yeah running map() before filter() is especially triggering, as it will run n transforms, where n is the array length, regardless of output of filter().
@quarteratom
@quarteratom 4 ай бұрын
Web-developer opinions don't matter.
@nekoill
@nekoill 4 ай бұрын
As a (semi-)functional bro, the man is absolutely correct, like 100% correct.
@justyourregularboyscout9613
@justyourregularboyscout9613 4 ай бұрын
everytime I saw your yt pfp, I always thought it looks like a communist leader paintings
@ThePrimeTimeagen
@ThePrimeTimeagen 4 ай бұрын
that was my goal
@CarlosEstebanLopezJaramillo
@CarlosEstebanLopezJaramillo 3 ай бұрын
It is currying, its also a factory pattern, and it seems a higher order function as well? damn how many patterns do we have to learn??
@Dazza_Doo
@Dazza_Doo 3 ай бұрын
This is why I'm learning C for the last time. Procedural Rul'z and abstraction drools
@nikarmotte
@nikarmotte 3 ай бұрын
If you want to be a true functional programmer, you need to be born this way, because you cannot change by design.
@AhmedShariffGplus
@AhmedShariffGplus 4 ай бұрын
I use to hate OOP until I saw learned how common lisp (which is supposedly a functional programming language) does OOP.
@DryBones111
@DryBones111 4 ай бұрын
Nested list comprehensions? All my homies use
@SimGunther
@SimGunther 4 ай бұрын
This is proof that you can meme on a shoddy "code-tuber" like the one Prime's reacting to and still learn something valuable!
@tuchapoltr
@tuchapoltr 4 ай бұрын
I’m really sad because Code Aesthetics has some good takes and amazing animations… but sometimes, they just miss the mark.
@user-tx4wj7qk4t
@user-tx4wj7qk4t 4 ай бұрын
@@tuchapoltr He's wrong about nearly everything. He's a pseudointellectual soydev who thinks he has it all figured out and hides behind animations and giant piles of his terrible code to justify anything he wants to say, which he always says with an authoritative tone like he knows the answers to things that literal geniuses still debate.
@cloogshicer
@cloogshicer 4 ай бұрын
@@user-tx4wj7qk4t Holy shit dude calm down.
@fuzzy-02
@fuzzy-02 4 ай бұрын
And on the 8th day, He said... There shall be no state. And oop was born a day after.
@indrajitsarkar3169
@indrajitsarkar3169 4 ай бұрын
functional shenanigans
@freedmen123
@freedmen123 Ай бұрын
"There shall be no state" is incorrect. It's that state needs to be explicitly passed in as an argument, and only mutated by functions. You can do this with an atomic reference that updates in a transaction. This is why React is the way it is. The new state is a return value of the old state being passed to some function. That also is an example of currying, because currying is not partial application generally. It's using partial application to break up one large n-arity function into a chain of single argument function calls. You can do that with repeated calls to bind which is analogous to calling partial with said n-arity fn and supplementary arguments, but you can also do that by just refactoring the code into single argument fn calls.
I Just Need A Programmer | Prime Reacts
18:26
ThePrimeTime
Рет қаралды 162 М.
The Most Amazing Software Ever Created
20:02
ThePrimeTime
Рет қаралды 271 М.
Мама забыла взять трубочку для колы
00:25
Даша Боровик
Рет қаралды 2,2 МЛН
О, сосисочки! (Или корейская уличная еда?)
00:32
Кушать Хочу
Рет қаралды 4,9 МЛН
Зу-зу Күлпәш. Стоп. (1-бөлім)
52:33
ASTANATV Movie
Рет қаралды 964 М.
FIRED For Using React?? | Prime Reacts
33:16
ThePrimeTime
Рет қаралды 328 М.
You dont know OOP
50:48
ThePrimeTime
Рет қаралды 262 М.
OCaml in 90 Seconds
2:07
Carrio Code
Рет қаралды 6 М.
They got away with this??
1:21:04
ThePrimeTime
Рет қаралды 1,1 МЛН
Reacting to Controversial Opinions of Software Engineers
9:18
Fireship
Рет қаралды 1,9 МЛН
I Made A Game In Two Days | Prime Reacts
14:21
ThePrimeTime
Рет қаралды 55 М.
Vim As Your Editor - Introduction
12:24
ThePrimeagen
Рет қаралды 753 М.
The Ultimate Tier Programming Tier List | Prime Reacts
26:57
ThePrimeTime
Рет қаралды 286 М.
ExFAANG Engineer Watches ExFAANG Take JavaScript Quiz | Prime Reacts
28:07
Рекламная уловка Apple 😏
0:59
Яблык
Рет қаралды 822 М.
Готовый миниПК от Intel (но от китайцев)
36:25
Ремонтяш
Рет қаралды 385 М.