Edge case removed: for i=0 to 10 {print(a[i])} vs for x in a {print(x)} With functional programming it gets even better: a.filter {}.map{print} Pseudo code, of course. I list several “functional“ examples in Swift here: https://github.com/melling/SwiftCookBook/blob/master/functio... Functional programming is also a higher level language. map, reduce,filter, flatten, flapMap, drop, take, zip, ... Learn the concepts in…
While it does remove edge cases, the code also becomes more opaque. At least to me, functional style programming seems much harder to read and then reason about.
The general value of typed functional programming lies in leaving no edge cases
71–80 of 172 posts
Re: The general value of typed functional programming lies in leaving no edge cases
#72Earlier quoted context omitted.
While it does remove edge cases, the code also becomes more opaque. At least to me, functional style programming seems much harder to read and then reason about.
It's subjective. My experience is exactly the opposite. A pipeline of sequence operations is something I can skim at a glance, but a for-loop is a pile of code that I need to stare at before I understand what it represents. This does not invalidate your experience. It's common, and with good reason. This sort of dissimilar experience with the same code is why coding standards need to be views as social norms for the…
The functions map and filter are nice and restricted. If you want more power, you use eg a fold. And if you need even more power, you write a new recursive function.
So a quick look at the code will tell you what to expect.
Re: The general value of typed functional programming lies in leaving no edge cases
#73I am not sure this is the only value, but it is generally true. And this is one of the great advantages of haskell. By the way, now that I know some haskell, I see this edge case sloppiness all the time and it is really annoying. For example, here is something that annoyed me just recently. You go to yahoo finance and there they will show you the revenues of a company as well as the revenue growth from past year. But…
Ive noticed other languages with this feature, they call them optional types, you can pass in a null or a type value. /s slightly, maybe more snarky, but seriously, optional types are way overhyped. Null objects are far more useful than optionals. Optionals tend to leak all over the show.
Re: The general value of typed functional programming lies in leaving no edge cases
#74I am not sure this is the only value, but it is generally true. And this is one of the great advantages of haskell. By the way, now that I know some haskell, I see this edge case sloppiness all the time and it is really annoying. For example, here is something that annoyed me just recently. You go to yahoo finance and there they will show you the revenues of a company as well as the revenue growth from past year. But…
Ive noticed other languages with this feature, they call them optional types, you can pass in a null or a type value. /s slightly, maybe more snarky, but seriously, optional types are way overhyped. Null objects are far more useful than optionals. Optionals tend to leak all over the show.
Re: The general value of typed functional programming lies in leaving no edge cases
#75I am not sure this is the only value, but it is generally true. And this is one of the great advantages of haskell. By the way, now that I know some haskell, I see this edge case sloppiness all the time and it is really annoying. For example, here is something that annoyed me just recently. You go to yahoo finance and there they will show you the revenues of a company as well as the revenue growth from past year. But…
Swift has this as well, but calls them “Optional”. The concept is definitely useful!
Re: The general value of typed functional programming lies in leaving no edge cases
#76Earlier quoted context omitted.
Isn't this akin to saying I don't like wearing seatbelts because it makes me more complacent in my driving?
Someone once describing the forces acting on a race car pointed out that the horizontal forced in a curve were high enough to throw you from the car if not for the five point harness (F1 probably doesn’t have this behavior due to the cockpit design). Sometimes safety equipment lets you go faster.
Even simpler: brakes let you go faster.
When I was cycling a while ago, my brakes broke in the middle of a cross-country ride. I didn't want to push the bike back all the way, but you can bet your hat that I rode extremely slowly and cautious.
Re: The general value of typed functional programming lies in leaving no edge cases
#77Earlier quoted context omitted.
Isn't this akin to saying I don't like wearing seatbelts because it makes me more complacent in my driving?
It could actually be the case that seat-belts make drivers more complacent but the key difference in the case of coding is that you won't die if you make a typo in your code. If designed correctly, your tests will catch it anyway.
And of course, lines of code that you didn't have to write are less likely to have bugs in them.
Re: The general value of typed functional programming lies in leaving no edge cases
#78I am not sure this is the only value, but it is generally true. And this is one of the great advantages of haskell. By the way, now that I know some haskell, I see this edge case sloppiness all the time and it is really annoying. For example, here is something that annoyed me just recently. You go to yahoo finance and there they will show you the revenues of a company as well as the revenue growth from past year. But…
> You can create a type that can encompass all kinds of edge cases and information about them. This is not unique to functional programming languages. Haskell was definitely a trailblazer for this, but plenty of conventional languages support this now with relative ease.
I don’t know of any mainstream language that has bolted on that level of verification.
Re: The general value of typed functional programming lies in leaving no edge cases
#79Earlier quoted context omitted.
While it does remove edge cases, the code also becomes more opaque. At least to me, functional style programming seems much harder to read and then reason about.
This is a learning thing, honestly. Once you start thinking in types, it clicks: you're thinking at a higher level of abstraction, so the code is less important than understanding how the programmer put the types together in their head to solve a problem.
Re: The general value of typed functional programming lies in leaving no edge cases
#80Earlier quoted context omitted.
Ive noticed other languages with this feature, they call them optional types, you can pass in a null or a type value. /s slightly, maybe more snarky, but seriously, optional types are way overhyped. Null objects are far more useful than optionals. Optionals tend to leak all over the show.
Only if you are speaking of Scalia?
:)