Earlier quoted context omitted.
Could someone explain why refactoring is so much easier in functional languages?
One practical example: if you have a union of A|B, and you decide to add a third shape C to it, your program won't compile until logic for C is written in all the places where A and B are already being matched against. Refactoring often means changing data models, then letting the errors walk you through the actual implementation details.
Simon Peyton Jones interview
21–30 of 49 posts
Re: Simon Peyton Jones interview
#22Earlier quoted context omitted.
Could someone explain why refactoring is so much easier in functional languages?
Because it is more difficult to make a change that affects other code without a change in types occurring, which will make compilation fail until all affected code is updated.
It means you can run your unit tests without having to change everything everywhere all at once.
The flag is -fdefer-type-errors
Re: Simon Peyton Jones interview
#23Around 7:50 in Jones says this: “So, one of the great things about Haskell actually, that is spoken about and I think it’s the sort of killer app for Haskell, is that it’s so refactorable, right? You can do a heart or lung transplant on GHC and make truly major changes and the type checker just guides you to do all the right things.” Freely refactoring the code with worrying about unit tests, etc seems quite appealin…
Could someone explain why refactoring is so much easier in functional languages?
Re: Simon Peyton Jones interview
#24Why is Haskell, a comparatively obscure language (to Python, C++, etc.), so popular with topics in the orbit of "web3" (blockchain, crypto, metaverse, etc.)?
Python/C++ come with their issues and when starting a project from scratch (e.g. a blockchain), there's more flexibility in the choice of language. In the blockchain field, throwing buzzwords has proven useful to gather money and make some projects stand out (functional programming, formal verification...). Also academics love these language, so starting a project in Haskell/OCaml can get you contributions from academia, possibly some big names joining your team. And of course, strongly typed languages with a clean semantics give you more safety which is important in some fields.
Re: Simon Peyton Jones interview
#25Around 7:50 in Jones says this: “So, one of the great things about Haskell actually, that is spoken about and I think it’s the sort of killer app for Haskell, is that it’s so refactorable, right? You can do a heart or lung transplant on GHC and make truly major changes and the type checker just guides you to do all the right things.” Freely refactoring the code with worrying about unit tests, etc seems quite appealin…
Could someone explain why refactoring is so much easier in functional languages?
all state is factored, so it can easily be refactored.
Re: Simon Peyton Jones interview
#26Earlier quoted context omitted.
I don't think it's a universal property of functional languages. Haskell is also strongly (excessively) typed, down to the level of modeling computation itself, and it's lazy. See, when you are defining a Haskell program, you are conceptually creating a tree of thunks that eventually get executed by the GHC runtime. Those thunks are typed, meaning they have typed inputs and outputs, and are either side-effect-free or…
> Because side effects are controlled, you are forced by the type checker to handle runtime errors (or crash). This is generally true in idiomatic Haskell code, but in fact even pure functions in Haskell can throw runtime exceptions, and you are not forced to handle these.
aside from that, you'd just need to worry about OOMs and faults in native code.
Re: Simon Peyton Jones interview
#27Around 7:50 in Jones says this: “So, one of the great things about Haskell actually, that is spoken about and I think it’s the sort of killer app for Haskell, is that it’s so refactorable, right? You can do a heart or lung transplant on GHC and make truly major changes and the type checker just guides you to do all the right things.” Freely refactoring the code with worrying about unit tests, etc seems quite appealin…
Could someone explain why refactoring is so much easier in functional languages?
Re: Simon Peyton Jones interview
#28Why is Haskell, a comparatively obscure language (to Python, C++, etc.), so popular with topics in the orbit of "web3" (blockchain, crypto, metaverse, etc.)?
Re: Simon Peyton Jones interview
#29"So, for me, that’s as far as increasing our ability to give you statically guaranteed theorems about Haskell programs.
My money’s on Liquid Haskell at the moment and I hope that we the Haskell community"
My experience is that other refinement type systems are way less complex. See: https://github.com/hwayne/lets-prove-leftpad
In particular, compare https://github.com/hwayne/lets-prove-leftpad/blob/master/liq... to https://github.com/hwayne/lets-prove-leftpad/blob/master/daf...
For me this has been a bit of a disappointment.
Re: Simon Peyton Jones interview
#30Around 7:50 in Jones says this: “So, one of the great things about Haskell actually, that is spoken about and I think it’s the sort of killer app for Haskell, is that it’s so refactorable, right? You can do a heart or lung transplant on GHC and make truly major changes and the type checker just guides you to do all the right things.” Freely refactoring the code with worrying about unit tests, etc seems quite appealin…
Could someone explain why refactoring is so much easier in functional languages?
you can unplug, replug stuff at will