Is the book in the OP better than learn you a haskell?
Jack Thomas
Probably. LYAH is a bit out of date.
Aiden Hall
No love for Scala?
Good Scala books: Functional Programming in Scala (Chiusano and Bjarnason) Atomic Scala (Eckel and Marsh) Programming Scala (Wampler and Payne) Programming in Scala (Odersky, Spoon and Venners)
Also, The Joy of Clojure is another very good Clojure book.
Luke Martinez
I'll be adding those.
William Edwards
>No love for Scala? Yes, exactly
Luke Bailey
bump
Landon Miller
So im reading through haskell book in OP and its pretty good. Are there any tutorials/books/youtube vids where someone makes something useful with haskell? For e.g if i were to learn c# i could just have fun by making keyloggers or whatever, and find bunch of youtube vids, on the other hand haskell vids seem to be just recordings of some talks and pretty abstract. I dont mind learning abstract its just i'd like to see concrete, practical examples
Cooper Lee
I hope you are still here, but the biggest difference between functional and imperative is that imperative is focused on assigning values to things, and these assignments change how your program works. Functional on the other hand, is focused on doing as many things as humanly possible while changing as little as possible.
The idea is that it is easier to reason about a system that doesn't rely on pieces of data that anything could have written to. This is because there are a very large number of possible combinations you need to consider if you do. Sometimes unexpected combinations of these values (called "state") can cause subtle bugs you don't realize, and can sometimes crop up in completely unrelated parts of the system and cause some serious headaches later.
Functional tries really hard to limit the state you need to a bare minimum.
However, generally speaking, imperative code is faster than functional code. This means historically the norm in game development is imperative, because highly-optimized engine code and graphics programming can be more optimized with it. However, this is not a rule--I think a good thing to do is to use the tools that you like the most, because game development is faaaar from a short process, and you don't want to lose motivation partway through.
So, I suggest you should use the things you like using the most.
Noah Adams
So, for imperative, pros: - It's faster - Easy to reason with on a small scale (This is why you should keep your inheritance shallow) - Amazingly easy to model real-life things with imperative styles - Tools for working with these languages often border on wizardry
Imperative cons: - Holy-shit levels of state permutations to account for - The wrong state in the wrong place hurts unexpected amounts - Very hard to test in comparison to functional code - All of this means technical debt is far easier to accrue, be careful!
For functional, pros: - Ridiculously easy to test - Many kinds of bugs become impossible naturally - You can experiment/play with your code in much more useful/fun ways - Abstraction is far more reliable, particularly as you layer it
And functional cons: - Tools for these languages are usually harder to get used to - You have to separate code that changes anything from everything else - Harder to organize - Not used nearly as often as imperative
For recommendations, I would say to pick up on an imperative language first, and then move to a functional one. That way you can better understand what state actually means to you, and get acquainted with all the neat tools and ways of solving problems that both sides use.
Brody Davis
For the two languages, I would say that Java and Clojure make a good pair. As a web developer and aspiring game developer, you can seriously benefit from both languages. Here is my reasoning for the two:
For Java: - There is lots of demand for Java in web development, so it is worth it even if you get nothing else out of it - It shows you Class-based Object Oriented - It gives you a tremendous head start for learning C++, the industry standard for game development - There is a lot of very nice game development libraries for Java - If you make games with it, they are cross-platform by default - Java development environments are some of the best in existence
And for Clojure: - It allows you to build programs from scratch as you are running them - It has amazing ability to let you experiment with anything and everything at any time - A lot of tutorials and books show you how to write games, as well as explain game development - You get concurrency for nearly free - It shows how to work with a functional language, while letting you use your Java knowledge - ...and speaking of, it runs everywhere Java does - ...and you can use Java code in Clojure, as well as vice versa - ...or even embed one language in the other, so you can use them at the same time if you want - Clojure is surprisingly amazing for web dev, so it is worth it even if nothing else comes of it
Kevin Jenkins
Write a -interpreter/compiler
Kayden Cook
If I am maybe just intermediate level with imperative languages like C++, Java and Python, is it still worth me trying to pick up a functional language or am I better off just sharpening my c++ skills or something?
Henry Johnson
nobody is better off with c++
Isaac Reed
Why cant you do both? Its also possible that learning new paradigm might improve your c++ skills right?
Brandon Ramirez
> web developer and aspiring game developer, you can seriously benefit from Java and Clojure > Java and Clojure > game development Wew, lad. Also you forgot to mention that most modern imperative languages like C#, Swift and Rust implement most of useful concepts from functional programming, making them the best from both worlds.
Zachary Richardson
I'd say it's definitely worth it, because it gives you more ways to solve problems which can definitely be applied to C++.
Joshua Martinez
"How to Design Programs" should be high up the Scheme list.
Henry Cox
Except people who want to be employable (although other languages would get you more money I assume)
I guess so
Yeah I'll continue with it then
The main problem I have is finding things to make, so I don't end up coding a lot and stop improving, so I started learning Haskell a little because of it. Hopefully I can learn some more and think of some cool things to make
Nathaniel Barnes
I'll be adding this.
Jonathan Lopez
Yes, I suggest Clojure for game development.
Even the book the OP suggests for Clojure is about making games, plus there are some very nice libraries for doing just that. You don't even need to target the JVM for this. I mean, a lot of ClojureScript demos are games too, and it does that quite well.
To make things even better, it all has a ton of other benefits for the person asking.
Those were my reasons.
>Also you forgot to mention that most modern imperative languages like C#, Swift and Rust implement most of useful concepts from functional programming, making them the best from both worlds. Well Java implements a lot of that too. Not on the level of Rust, mind you, but it is enough to be quite nice for some more functional code in the language.
However, none of these languages implement all of the most useful functional concepts IMO.
Then again, I am biased.
>Hopefully I can learn some more and think of some cool things to make I'm sure computers have annoyed you before, right? A lot of these annoyances can make some pretty nice little practice projects.
If you have a hard time thinking of a project, try solving one of these..!
Ian Parker
>I'm sure computers have annoyed you before, right? I've recently started doing this (sorting folders, etc) but I haven't ran into anything major. Maybe i just subconsciously ignored them because I thought they would be too difficult
Angel Ross
Nice one.
Jaxson Baker
Any haskell resources to get me going in a weekend? I know C, Python, Java, Go and a bit of Common Lisp.
Christian Richardson
Where can I download Haskell Programming from First Principles?
The link on libgen is an out of date version.
Anthony Gray
version on libgen is from 2016, surely it cant be that big of a difference?
Christian Brown
bump
John Gray
Why is this allowed?
David King
>looking through Haskell book >mfw this language sucks me in Well, I should relax and let Haskell suck me whole?
Jacob Cruz
yes
Jason Hughes
Is Haskell a meme?
Just looks like a bunch of jarble, and i have been programming for 3 years.
Never touched a purely functional language before.
Owen Gomez
It's a really nice programming language
Brody Smith
Meme doesn't mean what you think it means. I get it, you're new here, but please at least try to learn what the words used here actually mean.
Nicholas Robinson
Will learning lambda calculus help me learn functional programming or should I not bother?
Xavier Morgan
why did you retards make a separate thread for your meme languages
Jaxson Walker
refer to
Adam Jenkins
Yes, it will help immensely The principles of FP are largely those of lambda calculus, + type systems
Dominic Martin
But generally learning an FP language means learning lambda calculus. Haskell for instance.
Austin Robinson
Cool. Is there a recommended lambda calculus book or something?
Julian Allen
I would honestly just recommend learning an FP language.
Here is the lambda calculus:
e,a,b : x : \x.e : a b
i.e. an expression such as e, a or b is either a variable (such as x), a lambda abstraction (bind a variable x in expression e) or an application of two expressions
that's it
Jayden Wright
yay, i learned functional programming
Chase Sanders
now you need to learn how to use it, and type systems
look at the haskell wikibook in OP
Anthony Watson
will learning a fp language also improve my lambda calculus? seems you would already have to be somewhat skilled in it to pick up the language.
Connor Bailey
it's more like lc is the basis of fp
if you can program you can probably figure out LC anyway learning haskell will involve learning LC
pure LC, by itself, isn't very useful as a language (but it is turing complete, so it can do anything)
Michael Jones
How does one make Brainfuck compiler in LC?
Jason Morgan
I need women "programming" images please, thank you.
I'm on chapter 3 of learn you a haskell for great good, should I switch to the link in the OP?
Nolan King
What do you mean?
const [True, False] is a function returning [True, False]
LYAH is fine
William Brown
It's cons8, not const. The types are not the same, lists contain elements of the same type.
Aiden Torres
But tuples do? What's the difference in their machine realisation?
Jonathan Ross
Yes, and tuples with different element types are different tuple types, eg
(True, False) :: (Bool, Bool) ((), False) :: ( (), Bool) (3, "hello") :: Num a => (a, String)
Oliver Mitchell
i never understood that "Num a =>" thing
Thomas Mitchell
It's a constraint You can think of it as meaning "where a is a numeric type"
Chase Harris
So for instance The type of (+) is Num a => a -> a -> a
i.e., a -> a -> a, where a has a Num instance (you should learn about type classes later)
Dylan Reed
ah that makes sense
Connor Brooks
Can you set multiple constraints?
Jace Williams
Can someone explain to me why some people on Sup Forums consider functional programming better than OOP?
Adam Torres
Yes. It's the same syntax as a tuple type.
(Num a, Eq a, Ord b) =>
Jayden Fisher
OOP isn't very good, and hasn't got any real basis other than trying to vaguely turn language into programming language ("nouns and verbs")
FP has strong foundations
Jackson Nguyen
It's not better, it's just better than false OOP languages like Java, where "everything is an object' isn't entirely true. The only reason Java doesn't support multiple inheritance, is because they were too lazy to solve the diamond case, so they came up with the hack called interfaces. It's not just my opinion here, even Uncle Bob thinks the same. SmallTalk did OOP right. Python does OOP right.
Adam Taylor
I am complete noob and i just started learning c# (so OOP), i have to admit, f# sure looks sexy, but i still can't find any characteristics of functional languages that makes it more preferable than OOP languages
Christopher Murphy
Do you use LINQ? Do you use lambdas? Do you use that async syntax? Do you use tuples?
Connor Hall
Functional programming is incomprehensible to code monkeys, with their tiny brains. It makes us feel superior.
Cooper Myers
Where is JAVASCRIPT???? fucking weeaboo
Parker Ramirez
Not programming Not a language Not functional Not functional
Luis Garcia
Look up the Facebook Spam Filter. It's written in Haskell. Look up the Ocaml teams at Facebook. Functional programming works better in a lot of cases(not all), so it's used where preferable.
Henry Watson
>Do you use LINQ? Yes, very useful
>Do you use lambdas? same as above
>Do you use that async syntax? written first yesterday and fucked up, UI thread is still freezing, i have to learn way more about async/await
>Do you use tuples?
no
Liam Hall
those are all functional
Colton Reyes
I use those in c#, i don't get it
Lincoln Martin
C# is not a strict OOP language, it has a lot of very useful functional elements brought over from F#
Easton Johnson
those are functional features of C#
Nathaniel Thomas
So, linq was in f# before c#? interesting, i didn't know that
John Turner
I don't think that F# had LINQ originally, but that's aside the point.
Hunter Jenkins
only retards don't understand js got news for you , it is a language of course it's functional, JS can do everything, that's why ur butthurt
Bentley Bell
does LINQ have a function that takes a single element and converts it into an enumerable?
JS isn't functional in either sense of the word a language is, by definition "the method of human communication, either spoken or written, consisting of the use of words in a structured and conventional way." >structured
Jack Thomas
Javascript has no place in this thread. Leave.
Brandon Morgan
Tuple can contain any types but it's fixed. List is free but it can contain only one type.
Why? Why it's so useful? Can I contain any type and not be fixed? >inb4: list of tuples
Evan Walker
The only function that would work on such a type would be the length function or (:).
You're better off just using natural numbers.
To explain that, you need to start realising that what you can do to a value depends on what its type is. You can add integers. What if you had to make something that works with ANY type? Well, you can't add literally any type. So that's out of the question. You can't display it as a string. You can't do anything, because you don't know anything about it. All you can work with is the structure.
It's like having a list of unit values.
Bentley Cox
>All you can work with is the structure. I mean if you've got a list of any type.
You CAN have useful heterogeneous lists, using existential types. But it's rarely what you want.
The thing about existential quantification is it's like this:
data Showable = forall a. Show a => Showable a instance Show Showable where show (Showable x) = show x
Since we can only put "things that can be shown" into the box (the Showable constructor), then we know, by discovering the showable constructor, how to show that item. It's like OOP style polymorphism.
Bentley Gutierrez
So in this example,
Showable 3 and Showable False both have the same type. So you can put them in a list
[Showable 3, Showable False, Showable "Hello"]
Joseph Lewis
Haskell can compile to C, right? Is there any way for me to see the C code equivalent of a Haskell program?
Jeremiah Robinson
Maybe you should try looking at the C-- code instead
{-# OPTIONS_GHC -ddump-cmm #-}
pragma, or just the flag -ddump-cmm
Owen Butler
You can also look at the core language GHC has like 3 intermediate languages or something
Grayson Williams
In what irl situations and by irl I mean work, have you used functional programming?
exactly the same situations i've used OOP and imperative programmign
Samuel Jones
So why should I learn functional if it is the same? Does it just feel better to write and read or what?
Dominic Watson
It is a new way of thinking. You shouldn't always think so narrowly. Sometimes, learning a new language makes you a better programmer, just because it broadens your thinking space.
Zachary Gomez
Just a few of the companies using clojure along with datomic
Amazon Netflix Apple Deutsche Bank Salesforce Soundcloud Staples
and many more.
Functional programming is still used loads. But they are behind the curtains doing the job big companies need. And not making a fuss or trying to look fancy for nu-coders in starbucks yacking about small startups.
Zachary Cox
Just a quick question, I need a function that takes the difference of two functions. f :: a -> b g :: a -> b [\code] I could always write a lambda expression diff f g = \x -> f x - g x but was wondering if there was a more haskell idiomatic way to define diff?
Joseph Powell
Strangely I never thought about it that way. So where do you recommend to start? What language, what book?
Adam Evans
Nobody uses Lisp these days, but it is the most powerful language on Earth, and it was created 50+ years ago. Get a weekend in Lisp, write some recursive functions, get to macros, and then you can safely get to more modern functional languages like Haskell, Clojure or OCaml(used extensively at Facebook), or Erlang(if you want to write highly concurrent architectures - Golang is for normies, doesn't even come close).
Joseph Carter
>Nobody uses Lisp >Clojure Yeah what?
Ethan Torres
I meant Common Lisp
Ethan Perry
I'm not sure but that looks sort of common There's definitely a function for doing something like
f x - f y f x * f y
But I'm not sure about your case. Maybe in Arrows?
Owen Wright
Oh shit, I just thought. If you've got profunctors,
dimap f (lmap g)
this is also the same as
lmap f . rmap (lmap g)
(->) is a Profunctor rmap (lmap g) is because a -> (b -> c) is a nested profunctor, so you're saying "with the right hand side (b -> c), lmap it"