Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Variables may be immutable, but you can always do something with a variable and put the result into a new variable.
Anyway, it's not obvious whether immutability is a good thing. Yes, concurrency becomes easy, but at the price of dealing with possibly stale data. -
My advice, instead of learning FP + a new language, try to implement FP-techniques in a language you know.
-
inaba45895yImmutability is one of those things that, when you start using it in non-functional languages a lot of things gets a lot nicer.
A feature that I really love(d) about using F# is how null doesn't exist. What you have instead is something called 'None' which you have to be extremely explicit about. Like you can't just declare a string and set it to be none, you have to declare a string that can be either a string or none. What then happens every time you use that string the compiler will yell at you every time you use that string without checking for none. -
@Fast-Nop Haskell isn't immutable-only, it allows safe mutation through the ST monad.
ST's design is pretty neat, it uses the typesystem to ensure that stuff doesn't leak outside the controlled ST environment. Sadly mutation can't always be avoided because persistent data structures and functional patterns aren't always the most efficient ways to solve problems.
You can also do unsafe operations which break Haskell's guarantees, and there's always the (very simple to use) C FFI for really hairy situations.
@zetef think of the "variables" as the ones from mathematics - if I say X is 5, how can it become 6 later on? Or think of them "values" instead, or maybe even names for things ("X" is another name for "5" etc.), instead of the "box in which you put some value" interpretation that your traditional programming variables follows. -
arekxv10525y@zetef Just switch your mindset for Haskell from other non FP languages. It will help a lot.
Other languages: I am writing how things work line by line.
Haskell: I am defining what things are.
Also every loop becomes a recursive call in Haskell :)
Related Rants
-
dibbler6722Not a specifically dev related story, but absolutely rant worthy. Today I was working from home, and my wife ...
-
whatevel12So, today I was at my college library, working on an Haskell project that I have for my Functional Programming...
-
nzeetee7Well fuck me. Just went to my first meetUp with a group of Haskell programmers. I think they broke Enigma in ...
!rant
so the other day i was programming and suddenly i wanted to learn haskell. (i don't know why it hit me so suddenly, maybe because it's a 'pure' functional programming language and these 2 terms i knew nothing about)
and to be honest it's really hard coming from an imperative programming language (C/C++, yes, i know they are different in their ways). it's like learning to program again! you really have to get a different mindset and for me honestly it's hard to grasp the idea that 'variables' are immutable! like, that's soooo weird it still stucks to me. for example how did they define the max or min function without using a while loop? what are monads?
I am just 2 days in but it'll be a fun ride!
rant
haskell