Тёмный

Haskell for JavaScript programmers 

Tsoding
Подписаться 29 тыс.
Просмотров 57 тыс.
50% 1

Video about recursion: • What on Earth is Recur...
Waste your money: / tsoding
Thumbnail art by reximkut.deviantart.com/

Наука

Опубликовано:

 

1 июн 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 200   
@valcron-1000
@valcron-1000 5 лет назад
I learned more about FP in this video that in an entire semester at college
@Arijanitsalihu
@Arijanitsalihu 2 года назад
me to
@TravisWatson
@TravisWatson 6 лет назад
This video was awesome! I code a lot of functional(ish) stuff in JS and am interested in Haskell. When you said "no arrays" you broke my brain. I kept watching and it feels like my eyes were just opened! It's so clear now why recursion is important! Thank you thank you thank you!!!
@johnnyphoney5669
@johnnyphoney5669 6 лет назад
It's not really true about "no arrays", you could have it if your really need it (for performance-critical parts for instance), look at this package: hackage.haskell.org/package/array But how you work with this arrays differs from how you do it in imperative languages.
@johnnyphoney5669
@johnnyphoney5669 6 лет назад
See also hackage.haskell.org/package/vector
@bratezoran2102
@bratezoran2102 3 года назад
@@johnnyphoney5669 Was asking this as a standalone comment. Array/Vector is much more efficient if you do non-iterative stuff. In fact, lists are even discouraged in haskell for anything but iteration. Length, index, elem, everything that does more than `head` is discouraged. www.imn.htwk-leipzig.de/~waldmann/etc/untutorial/list-or-not-list/
@chromosundrift
@chromosundrift 3 года назад
Also note there are a lot of purely functional datastructures and the following book is a good resource for them: www.cambridge.org/core/books/purely-functional-data-structures/0409255DA1B48FA731859AC72E34D494
@KotoOo
@KotoOo Год назад
is that make any sense that we're rejecting arrays, but allowing hashmaps a.k.a objects? because hashmaps are more complicated in their implementation, and usually based on arrays under the hood. and if array are not allowed, does that mean that standard JS map/filter/reduce are not pure?
@Pitometsu
@Pitometsu 6 лет назад
Nix-shell, Haskell, Emacs. Good, very good! You had chosen the right side.
@cranknlesdesires
@cranknlesdesires 3 года назад
@Gabriel Klenner well I can think of one you might have missed, vim is not Emacs.
@obinator9065
@obinator9065 3 года назад
Gabriel Klenner VS Code + HLS + HLINT, emacs is for sheeps
@cranknlesdesires
@cranknlesdesires 3 года назад
@@obinator9065 man, microsoft marketing is taking a bazaar route these days.
@bratezoran2102
@bratezoran2102 3 года назад
@いあ I'm so torn apart. Using vim for a couple or years now, but only "really" using it for a couple of months to program. I don't want this big emacs ship, also vims community is much bighger. But so many advantages when using emacs as an IDE...I don't know.
@waltherstolzing9719
@waltherstolzing9719 3 года назад
@@bratezoran2102 I'm not a pro, so take all this with a truckload of salt -- but neovim remedies some of vim's disadvantages as a IDE (& some of its features are 'backported', so to speak, into regular Vim via plugins). The upcoming 0.5.0 introduces a native LSP client & syntax engine; & the RPC interface makes it easily extensible, as it makes it trivial to communicate with whatever else over tcp or unix sockets.
@nitinchandurkar3303
@nitinchandurkar3303 6 лет назад
Amazing. Never seen this style of presentation. Thanks. Learnt a lot about Haskell this way. Would like to see some more of these videos.
@CubOfJudahsLion
@CubOfJudahsLion 3 года назад
"Functional programming is about *composing* pure functions". Thank you! Many definitions of FP leave aside this essential component. We don't just compute with pure functions -- we combine code itself with some more code and into different contexts! Now *that* is reusability taken to its ultimate expression.
@andrepadez
@andrepadez 2 года назад
Awesome! only one suggestion to get rid of the "dirty" functions: const a2l = arr => [...arr].reverse().reduce((l, i) => pair(i)(l), null) const l2a = xs => (xs === null ? [ ] : [head(xs), ...l2a(tail(xs))])
@williaamlarsson
@williaamlarsson 3 года назад
This video made me understand Haskell more than any of the dussins of Haskell tutorials I've watched so far
@sumantkanala
@sumantkanala 6 лет назад
Alright, I'm gonna be a subscriber for life. You have so much knowledge in one video, it's too good to be missed. Recommended for any modern developer!
@bradynglines5898
@bradynglines5898 5 лет назад
I'm new to the functional world and you have helped me greatly understand what is going on. Thank you so much for this video.
@guillaumequittet9418
@guillaumequittet9418 4 года назад
I thought I knew functional programming. I was wrong. Since watching your videos I have been able to solve some problems with the functional code I made. Thank you !
@mnslr
@mnslr 5 лет назад
I love how you basically construct lisp in js here. Got here interested in JS and running emacs basically as an os, implying some lisp comprehension... gonna learn me some haskell now
@RoniellBerrios
@RoniellBerrios Месяц назад
Tsoding even though this video is old, your other videos inspired me to try haskell since it seems so cool and I don't know magical and this video helped me a lot, I finally made my own function that I understand!
@mohammedsalman3397
@mohammedsalman3397 6 лет назад
Great video, well explained. You should make more like this
@stephenjames2951
@stephenjames2951 4 года назад
Very succinct description of FP in JavaScript. I couldn’t help but thing of lisp with the FP list that you created
@SomeMrMindism
@SomeMrMindism 4 года назад
This is so cool, you type insanely fast! One of the limitation I would have highlighted for the passage to Haskell is strong typing, indeed fizzbuzz in JS returns a list of strings and numbers while the Haskell version returns a list of strings only. JS is more similar to Scheme in this sense
@jacobscrackers98
@jacobscrackers98 3 года назад
If you watch his streams you'll learn he doesn't. He probably just speeds it up.
@taragnor
@taragnor 3 года назад
I don't really think strong typing is all that new of a concept to most programmers, so it's something glossed over compared to things like currying. And really given Haskell's generic patterns and typeclasses, the strong typing isn't really as big an issue as most would expect. And honestly while you can pass in a bunch of weird arguments of different types into a JS function, you probably shouldn't. It makes the code a lot harder to understand.
@akritworanithiphong
@akritworanithiphong Год назад
This is so useful. Your explanation is so informative and insightful.
@w0xy
@w0xy 4 года назад
this is really amazing stuff, thanks for sharing! i've been wanting to try to apply some of the knowledge of fn programming to my js knowledge but didnt know where to start
@treseymour5788
@treseymour5788 3 года назад
Thanks so very much. I've made FP a personal study since 2013. I've wanted to break into Haskell and have been thwarted more than once. This is a great Haskell intro imho.
@skryonline5825
@skryonline5825 3 года назад
спасибо большое. Очень четко и ясно. хотелось бы больше таких примеров с чистыми функциями и сравнения JS c Haskell
@samirelsouki466
@samirelsouki466 3 года назад
This its increible bro!!! You are the best profesor of functional programming i see! A hug from Venezuela. Thanx
@ColePanike
@ColePanike 11 месяцев назад
Incredible. This helped me grok FP and haskell SO MUCH BETTER! Thank you!
@adjbutler
@adjbutler Год назад
THANK YOU VERY MUCH, VERY HELPFUL IN WHAT FUNCTIONAL LOOKS LIKE
@harshitjoshi3082
@harshitjoshi3082 4 года назад
That was a great video! absolutely loved it ❤️ you should have more subscribers.
@muhammadhadi1854
@muhammadhadi1854 4 года назад
Wow, this is mind bending
@georgespanos4680
@georgespanos4680 23 дня назад
You are great man, thank you for the content.
@Fc11235
@Fc11235 4 года назад
I learnt haskell because I wanted ro improve my recursional thinking. Now I’m in love with it. The best decision ever.
@rodelias9378
@rodelias9378 2 года назад
Really good and useful video! Thanks a lot!
@ramongonzalezfernandez8904
@ramongonzalezfernandez8904 2 года назад
I just decided to learn Haskell after seeing some of your videos, and after searching, this was the first thing I found
@waynee95
@waynee95 6 лет назад
Really liked that video!
@GuitarreroDaniel
@GuitarreroDaniel 3 года назад
This is the BEST FP video that I've ever seen. Thanks man.
@PedroPiquero
@PedroPiquero Год назад
I loved the explanation and now I am more interested in knowing Haskell.
@junnior8003
@junnior8003 Год назад
Amazing!!!!! I hadn't thought of it that way. you have a fan here brazil!
@trashcan3958
@trashcan3958 4 месяца назад
Excellent video.
@WilliamHolden0
@WilliamHolden0 4 года назад
Really slick, great video!
@Mentox2
@Mentox2 Год назад
This has to be one of the coolest coding videos i´ve ever seen.
@nicolareiman9687
@nicolareiman9687 5 лет назад
in the first argument it's actualy use a condition checker which is like if Statement. in recursion we must find a way to get out so if statement it's required i think.
@nicolashumbert8344
@nicolashumbert8344 Год назад
What a starting point. Pure genius.
@zacksargent
@zacksargent 3 года назад
This was really helpful! Thank you
@ongoinglives
@ongoinglives 3 года назад
amazing demonstration of haskell skill
@MarkusBurrer
@MarkusBurrer 8 месяцев назад
Even though I hate JS, this video is great. I learned so much about FP from your videos. I really hope you are doing well.
@eboubaker3722
@eboubaker3722 2 года назад
imagine he hits F5 in the middle of the video.
@MrBenjjj6
@MrBenjjj6 5 лет назад
That was amazing, thank you.
@vyacheslavogai
@vyacheslavogai 6 лет назад
Great video about pure functions! Similar to when you visit another country and meet new people and learn something new about theirs' culture :)
@juancasilla684
@juancasilla684 4 года назад
I thought I was gonna hate the video but turns out it was great, keep it up!
@ratkentheinfinity9841
@ratkentheinfinity9841 5 лет назад
Id expect n to return true.. Learned new on the JS side as a plus. Learning never ends!
@diegodorado
@diegodorado Год назад
Great video!
@hansschenker
@hansschenker 2 года назад
Every Javascript Programmer should learn this presentation by heart!!
@alexnd98
@alexnd98 4 года назад
This video is pure gold!
@kirilvedmidskiy
@kirilvedmidskiy 8 месяцев назад
great video, thank you!
@antontikhonov5028
@antontikhonov5028 Год назад
Great video! Bravo!
@hansschenker
@hansschenker 4 года назад
Very carefully crafted and easy to follow presentation! thank's a lot!
@notgate2624
@notgate2624 4 года назад
Incredible video
@marcusaccount1008
@marcusaccount1008 Год назад
this is pure gold
@nelsonjoppi
@nelsonjoppi 3 года назад
wow. amazing video, really!
@enverhoxha2698
@enverhoxha2698 4 года назад
masterful editing
@The14Some1
@The14Some1 6 месяцев назад
Mindblowing!
@user-qe6rh2qq9z
@user-qe6rh2qq9z 9 месяцев назад
This explanation is so damn good
@lucasa8710
@lucasa8710 2 года назад
genius, i'd never thought in this way
@andrueanderson8637
@andrueanderson8637 2 года назад
I do love me some javaskriept, great video!
@dawid_dahl
@dawid_dahl 5 лет назад
I love this video!
@Fullflexno
@Fullflexno 9 месяцев назад
Impressed!👌✨
@rezmed1144
@rezmed1144 Год назад
Mind blowing pedagogue !
@Brynjar1
@Brynjar1 4 месяца назад
Great way to explain
@pabloduran203
@pabloduran203 2 года назад
Amazing explanation. Maybe you should repeat it with porth (if you implement anonymous functions)...
@CaptainWumbo
@CaptainWumbo 3 года назад
I tried PureScript once but I could not for the life of me figure out how to write the type signatures of effects or really understand their syntax. The pure functional types make sense, but the others were very confusing.
@AllanMedeiros
@AllanMedeiros 5 месяцев назад
Fantastic!
@gonzalochristobal
@gonzalochristobal 4 года назад
awesome video! thanks :)
@dimitarivanov7249
@dimitarivanov7249 7 месяцев назад
That was beautiful
@Zorgatone
@Zorgatone 4 года назад
Name of the outro song?
@FunkschyIsWatchingYou
@FunkschyIsWatchingYou Год назад
Amazing ❤
@georgecernat6166
@georgecernat6166 5 лет назад
Great video
@joseagustinrios9666
@joseagustinrios9666 3 года назад
If you don't account the Array limitation, you don't need to re-implement map and arrays to list, list to array. I understand why you did that, but in practice the only thing you really need is ranges.
@dawid_dahl
@dawid_dahl 5 лет назад
Cool video, thanks!
@gargleblasta
@gargleblasta 3 года назад
Beautiful
@chadthunder6915
@chadthunder6915 4 года назад
quality content comrade
@SwarajDhumne
@SwarajDhumne 6 лет назад
When you implemented array2list why did you reverse the list instead of just iterating from xs.length - 1 down to 0?
@DavidAguileraMoncusi
@DavidAguileraMoncusi 4 года назад
They're equivalent solutions... so probably his was the first one that came to his mind
@jacobscrackers98
@jacobscrackers98 3 года назад
@@DavidAguileraMoncusi One is more efficient than the other though.
@chromosundrift
@chromosundrift 3 года назад
@@jacobscrackers98 efficiency is clearly not a high priority in these examples (although of course Haskell does gain efficiency through pure functional laziness).
@jacobscrackers98
@jacobscrackers98 3 года назад
@@chromosundrift If it doesn't cost anything extra, one should go for the more efficient option imo
@taragnor
@taragnor 3 года назад
@@jacobscrackers98 Efficiency in Javascript wasn't the point. Lots of stuff he's doing like function currying are horribly inefficient in JS, but the idea was to understand Haskell better. Keep in mind that in haskell the compiler optimizes a lot of these things for you. So a lot of inefficient practices in JS aren't inefficient in Haskell, because Haskell is designed for that style of solution in mind.
@dericbytes
@dericbytes 4 года назад
Thanks, this was cool.
@AndrewLewman
@AndrewLewman 4 года назад
Thank you so much because now i fan of fp
@hansdampf2284
@hansdampf2284 Год назад
The fact that you can just hammer that in the keyboard from the top of your head is impressive. When I program is more like hm hm hm think think *type thing in* hm oh no *delete again* hm think hm oh yeah *types thing in* I think people can hear the sound of an old modem coming from my brain in the thinking phases
@Gigasharik5
@Gigasharik5 4 месяца назад
Saaammeee
@peterostertag8699
@peterostertag8699 5 лет назад
Great fun!
@thepawday
@thepawday Год назад
Looks fancy, but how much Stack Overflows does occuring in functional languages?
@laurentgauthier8742
@laurentgauthier8742 4 года назад
Thank you for this video. I wonder though about the use of ternary operators... In a way, is it not like using a "if"?
@tomaszzielinski1704
@tomaszzielinski1704 3 года назад
In functional programing else is mendatory, because expressions always have value. Ternary operator enforces this constraint in procedural language.
@nilstrieb
@nilstrieb 3 года назад
if is a statement and returns no value, so it cant be used
@DJJOHN92
@DJJOHN92 4 года назад
I think as a disclaimer it should be made clear that types also have to be pure in functional languages. Having a function returning either an integer or string is not possible in Haskell without a unifying type.
@raphaelradespiel9970
@raphaelradespiel9970 10 месяцев назад
Why are ternary operators allowed but not other forms of conditionals? Are nested ternary operators allowed?
@RegalWK
@RegalWK 9 месяцев назад
Amazing
@ehza
@ehza Год назад
Thanks man
@waltermays5551
@waltermays5551 4 года назад
I'd like to contribute subtitles in English; would you please enable video subtitle submissions?
@stefanusayudha1853
@stefanusayudha1853 Год назад
that fisbuzz example using if statement. while you said we cannot using ifs ?
@valle6354
@valle6354 4 месяца назад
It's probably a bit late, but the Haskell "if ... then ... else ..." works like a ternary. The thing that's not allowed is just if ... then ..., because then there is no return value when the check fails.
@ne4to777
@ne4to777 3 года назад
Люто лайкую. Топчик.
@windmaomao
@windmaomao 3 года назад
No loop is a bit crazy to understand. Does that mean any arr.forEach, arr.filter is also not allowed in the classical way? Or these function isn't referred as a loop ? I think this needs to be clarified.
@0LoneTech
@0LoneTech Год назад
forEach indeed does not exist, because in pure functional code it could not do anything; it returns undefined. The closest equivalent in Haskell is forM_ which operates within a monad as a way to model side effects. filter, on the other hand, is one of three core higher order operations on collections: map, filter, and reduce. Each of these produce a result, using some number of calls to a worker function they've been passed (mapping, predicate or reduction). Such higher order functions (often based on folds) usually replace loops, but recursion is the core mechanism. The core reason is that looping relies on side effects (something must be changing for the loop to complete). Without side effects, programs are easier to reason about and we can do things like evaluate multiple portions simultaneously.
@NabeelFarooqui
@NabeelFarooqui 4 месяца назад
I knew what was going on and was lost simultaneously. Very strange
@Tattersail
@Tattersail 2 года назад
No Ifs - how is the ternary operator different than writing out an if / else?
@0LoneTech
@0LoneTech Год назад
It's different in that it forces each branch to produce a value, so all the logic is in the context of an expression. Basically, it works around having to remember to always include an else and two returns. Writing one language within another will tend to have awkward translations.
@bratezoran2102
@bratezoran2102 3 года назад
Any way to do stream fusion in JS?
@iambasanta
@iambasanta 9 месяцев назад
mind blown
@MuslihAlAqqad
@MuslihAlAqqad 3 года назад
Thank you....
@arshadpakkali
@arshadpakkali 3 года назад
This video just made a 501 in my brain
@dynamite-bud
@dynamite-bud 2 года назад
beauty
@bhavyakukkar
@bhavyakukkar 2 месяца назад
javascript can do all this but what do they use it for? let [count, setCount] = useState(0)
@Leonhart_93
@Leonhart_93 Месяц назад
Yeah well, good luck designing the modern extremely complex UIs with those strict pure functional rules. Especially the avoiding side effects part.
@bhavyakukkar
@bhavyakukkar Месяц назад
@@Leonhart_93 thanks
@bhavyakukkar
@bhavyakukkar Месяц назад
@@Leonhart_93 thanks
@SteinGauslaaStrindhaug
@SteinGauslaaStrindhaug 6 месяцев назад
I assume this "no arrays" rule is just to firmly disallow random access inside a list of data? For actual as functional as possible within JS code, just using arrays as if it is a list (map, filter, reduce, and only traversing it using recursion) will be much more performant while conceptually being the same as functional programming, right?
@Leonhart_93
@Leonhart_93 Месяц назад
Recursion is not more performant that straightforward iteration, it's the opposite. Firstly there is a call stack limit and if you reach it then the program crashes. Secondly, instead of a single CPU instruction like in a single iteration, an iteration using recursion also involves creating the function object.
@SteinGauslaaStrindhaug
@SteinGauslaaStrindhaug Месяц назад
@@Leonhart_93 yeah i know... Unless the language optimises tail call recursion, or you use recursive functions that isn't optimisable, it's quite limited in depth. But I meant using arrays in JavaScript is significantly faster than a homemade linked list would be. But I'm pretty sure the functional built in functional methods like map, filter etc. on the array objects are just as fast or faster than a for loop is in most js implementatons.
@Leonhart_93
@Leonhart_93 Месяц назад
@@SteinGauslaaStrindhaug I do not think they are faster than low level loops. There is no imaginable reason why they would be faster than doing i++. Their purpose is to simplify working with arrays and stuff, for faster dev implementation, and not for more efficient runtime.
@mo3ath12
@mo3ath12 4 года назад
😍👍😎 Awesome!!!!
Далее
What is IO monad?
36:32
Просмотров 66 тыс.
JSON Parser 100% From Scratch in Haskell (only 111 lines)
1:50:07
Never write another loop again (maybe)
10:48
Просмотров 248 тыс.
Recursion - To hone a skill, one must practice.
10:54
Secret Haskell Composition Technique
26:44
Просмотров 22 тыс.
How Monoids are useful in Programming?
9:24
Просмотров 45 тыс.
The purest coding style, where bugs are near impossible
10:25
I ❤ APL and Haskell
8:06
Просмотров 23 тыс.
Making Music with Haskell From Scratch
49:02
Просмотров 97 тыс.