When I learned Haskell at college it felt like if a hardcore Mathematician with zero experience in programming was tasked to design a programming language solely based in the definition of what a programming language is.
My lord i've to learn haskell in 3 days for a college exam and came here to see if i could undertand a bit better haskell but this language is... estrange😵🤧🤧
@@_david_mp Haskell in 3 days???? Like maybe learn C in 3 days actually doable if you put 72 hours in, but you ain't learning Haskell completely in 3 days mate.
For the little more advanced users, here is an interpretation of the IO monad that I really liked: If you imagine that you put the state of our entire universe in a record World, then IO could be seen as a World Transformer. Thus, a function with side effects simply maps a state of the World to a new one. For example, putStrLn "Hello World!" takes a World where the screen is blank, and returns a World where "Hello World!" is on the screen :) I find this interpretation beautiful, and it doesn't violate immutability nor does it need side effects
All this is possible thanks to the runtime that says "I won't do this I/O effect now, but if I were, here's how I'd do it" and never tells the user how the world exactly changed. It would just let the user assume that the world changed in some way to maintain the illusion of "purely functional code" that is somehow useful...
Functional programming is so cool. Even if you don't like hardcore functional programming, you can still take parts of it and include it into your own code in for example JavaScript.
Yes, but it makes me sad that Guido said that python will never have tail calls, so out of the box my two loves can never be brought together :( JS is getting there tho.
Learning Haskell was one of the most fun experiences of my life. Even if you never use it, learning it will expand your mind and make you a better programmer.
@@just-do-halee7375 Haskell is basically Rust with a way better type system, also comes with a garbage collector so you don't have to worry about the compiler complaining for hours about pointer lifetimes
Learning Haskell is an adventure. You're learning about currying, pattern matching etc. and you're like "this is such a cool language". Then monads just come out of nowhere and hit you like a brick wall.
Seeing you got into functional programming maybe do a Prolog or Lisp in 100 seconds :)). I'm currently studying them in college and I found them a really nice eye opener for functional programming.
I think the main thing is that Prolog is relational/logical, it basically fills in the gap with everything that is true. X + 2 = 4 X = 2 or, validCourses(CS, X). X = a valid course, press ; for the next result. You probably knew that though.
@@begejekan1244 functional programming is a form of declarative programming. But prolog is usually considered a logic programming language, which is another form of declarative programming.
Pretty underrated language. I had to learn it a bit for an AI course, but it can be kind of fun for doing basic LeetCode-style questions. It would probably be more fun if I actually learned the difference between the 5 different ways to assign/bind/compare
I've only played with Haskell a little bit but the lib that blows me away is Parsec (parsing library). Being able to write interpreters in code that looks just like the BNF grammar sounds awesome! ( I haven't written one myself yet but have seen small examples.)
Oh, and the best part is Hoogle! If I don't know what function I need but I know what it would need to do, I can roughly describe it by writing it's type (what it should take and what it needs to give me) and I'll get all the functiona that match, (usually only a few, because the types are pretty specific). Of course searching by name works too
I am biased, being a tutor for functional programming/Haskell at uni, but... I believe the functional and "immutable by default" paradigm is crucial for going towards bug-free and reusable (re-combinable) code. Yes, it restricts code in certain ways (e.g. no "x = x + 1"), but these restrictions are extremely sensible and they allow a) the programmer to think more clearly (mathematically) and b) the compiler/runtime system to make powerful checks, guarantees and optimizations. For those wondering how incrementing a value a ("x = x + 1") would work in Haskell: You just introduce a new+different name for the new+different value - e.g. "y = x + 1"
@@arhamaneeq1323 I mean, i program in dyalog in my free time. I know it's not that big of a deal in practice. But would say that at least for me it did took a long time to get used to it. You can't just throw all this absurd (intuitive one you know then but totally arbitrary when you start) symbols at me and expect me to just start writing code normally. The learning curve of APL is a little bit absurd. And again, i say this a someone who loves that stupid language
@@sebastiangudino9377 I think with the tab function like those in TryAPL, that is not really that much of a problem. Or maybe that's because I was just started to get into the field of APL weirdness...
Haskell is a super interesting language. I mean you can write quicksort in one line using list comprehensions, you can check for list equality with the good ol ==, and so much. I wouldnt say I'd switch to it from my beloved C and C++, but it's definitely a fun toy language that can be really entertaining to use for coding challenges like advent of code for instance.
Best thing of learning Haskell is that you will never finish it. This is a thing with every language of course. But with Haskell is special because depending on your skill level and where you are at the learning curve you will use some tricks or others. Is just like doing Pure Maths, you come up with a trick for a specific problem and refine it further and further until you can define a pattern design or kind of a macro that generalises and then all of a sudden you are solving most of the problems of that field with that. Is much more "abstractable" than other languages.
Great video! Can you make a detailed video about different open source licenses like Apache, GPL, LGPL etc. It will be very helpful to everyone working with open source software and confused about the licenses.
idk if im late to realize but i just noticed that the "LIKE && SUBSCRIBE" at the end of the videos is Jeff's way of saying subscribe only if you like the video.
Haskell is not half bad. The infinite list / lazy evaluation is truly amazing. The lack of cycles/ having to use recursion/ foldr, etc is a bit crappy but understandable. Way better than Prolog
It would be my favorite language if it didn't have that many stupid gotchas, such as name collisions, data classes not used enough (Text / String fiasco), strings implemented as linked lists..
Being restricted is sometimes very important for learning new ways of thinking when tackling a problem, that's why I think it's important for all coders to do some purely functional programming
I think haskells true strength is in its ecosystem. Hoogle and cabal/stack + vscode language integration make everything so much easier. If i need some utility functions or just don't want to implement some algorithm i just use a library by writing single line in my cabal config. I don't think any other language can compete in terms of ecosystem usability.
This is really interesting! I recently created a project called Monad to share and discover code snippets, named after a philosophy concept, but it’s cool to see how it’s related to computer science.
As i was laying in bed I took my pen and started jotting stuff down, (please note I have programmed well scripted before) anyways I came up with a conclusion,.... functional programming ( of course i hadn't named mine that) instead i spent the day writing bits of code out, writing how I could compile them it, what else would be needed, looking at equations... to then stumble across a video or two on functional programming LOOL (fml), as I am not a massive programmer, and only used py here and there for silly little projects, So it is a massive world opened up to me especially as I thought i was on to something.. anyways great video.
These are so perfect for brushing your teeth. I'm never bored and I get to learn a little something. Very glad I found your channel this year. You've taught me a lot!
I did Haskell for a total of 1 assignment in college and I thought it was really cool. He gave us a definition for a Lambda calculus expression to be stored as a variable, and then step by step got us `to write all the functions necessary to perform a beta reduction on any lambda calculus expression (if I'm remembering right) The definition was something like the form: `Term = Lambda Term | Application Term Term | Var 'x'`, so you could represent any lambda calculus expression with that by replacing "Term" with any of the 3 possible values for Term recursively e.g. Application (Lambda Var 'x') (Application Var 'x' Var 'y') And then we'd just pass that expression into whatever function we're calling it for e.g. beta-reduce (Application (Lambda Var 'x') (Application Var 'x' Var 'y'))
Been learning Haskell for about 2 months now. Shit is maaaadd confusing but it’s really fun once you figure out. Even tho I say that about most languages this one feels even better to get right!
If anything, Haskell has a much more powerful abstraction over languages like JavaScript and especially C++ as those languages mimic more closely to how CPUs execute instructions.
Functional programming is cool but I feel like you have to be a mathematician to even begin to understand it properly. Imperative programming feels way more logical for me, even if it's more verbose.
Wrong choice of words, logic is math so technically functional programming is far more logical lol. But yeah imperative still is more intuitive in nowadays programming culture
@@eumim8020 Imperative is intuitive because you just read it from top to bottom and jump around using references, it's like reading through an encyclopedia, intuitive to anyone educated on any level.
I think i'm completly dumb because I didn't see that much of a difference in this video between Functional and Imperative, like he declared variables, he declared a function and then used it ? What is the clear difference between Imperative and Functional I'm confused
Yep, pretty much this. ^ I'd just add, that *all* the expressions and -variables- named expressions really evaluate to a single value. That includes the `main`! So for example, since both `print 5` and `print "Hello World"` have the type `IO ()`, you can glue them together into one single value and assign it to `main`. In that case, `main` would be an IO value that prints 5 and then prints the Hello World. What's awesome is that these really behave like regular values. You can juggle them around, put them in lists, etc. and they will do absolutely nothing until one shows up in `main`. Only then, the compiler will make it actually do stuff.
I'm always lost when reading the classic functional programming syntaxes. Codebase in F#, R or Haskell confuses me. It's a shame because the value you get from a functional programming architecture is often time very hard to refuse especially on scalable back-ends or IoT projects.
@@ultimatedude5686 Well yeah that's the exact issue I face though, when you come from a long background in C-inspired syntaxes it's harder to adapt. 😕 But I'll learn Haskell next year in my spare time, I'm sure I'll get a good use out of it someday soon.
Pure functional approach is perfect in it's nature, but in reality you can not have reasonably fast code without state and some imperative approach. Lazy evaluation is not entirely free of cost (checking is not free) and garbage collector... To quote (taken from "direction for ISO C++") "Some of the most powerful design techniques combine aspects of traditional object-oriented programming, generic programming, functional programming, and some traditional imperative techniques.". It's not like I'm a hater of Haskell or something but IMO purely functional approach (as a whole language) is too much aimed at perfection rather than pragmatism. "perfect is the enemy of good". Monads, currying, partial application and higher order functions - all of this is also possible in C++ (probably even more efficient), but the syntax and compile times are horrible. I just wish more languages (especially the C family) supported functional style better. Something like __attribute__((pure/const)) in GCC extensions or consteval keyword in C++20. OOP is not a panacea (looking at you, Java).
Such a great channel to find out about new things quickly so that I can focus on deciding whether I can utilize it or not in my project. Thanks Fireship!
Hearing the word haskell gives me the heebie jeebies from college, but great descriptor. Love how you just completely moved around monads and typing ;) Functors are like mini monads that also sucked