News for hackers. Stuff that matters.
Re:Why is learning functional programming so damned hard? (2... by yodsanklai on Sunday August 15, 2021 @06:06PM (#28192979)
It's not hard at all. It's routinely taught to beginners.

However, it's not a silver bullet. I found that basic software engineering principles are way more important than the language. I've seen extremely messy OCaml code and super clean C code. What is important is how the code is organized at high level. Whether you use a for loop or a fold, an error monad or an exception mechanism matters less.

I'm also wary of functional programming gurus that tend to over-abstract things and use all the language latest features, making code very hard to read.

Also, when developing in a niche language, you tend to miss important tools and need to rely on unstable third-party libraries.

I used to be quite enthusiastic about FP, but I think I'd stick with more mainstream languages unless there's a good reason not to.

Re:Why is learning functional programming so damned hard? (2... by swiley on Sunday August 15, 2021 @06:11PM (#28193015)
Programming is about clearly communicating theory.

Mariners use "port" and "starboard" for vehicle relative directions not because it's "cool" but because it's clear and unambiguous. Problem decomposition works the same way: some problems decompose better with FP (I would argue databases do) some with OOP, some with EF etc. The more you know the clearer code you can write and the faster you can extract the theory from other people's code.

Re:Why is learning functional programming so damned hard? (2... by tdeck on Monday August 16, 2021 @01:13AM (#28195124)
Fun fact: the "port" side used to frequently be called "larboard" until the British Royal Navy realized it was too easily confused with "starboard" and ordered sailors to stop using the term. After that it gradually fell out of favor.
Re:Why is learning functional programming so damned hard? (2... by IIAOPSW on Sunday August 15, 2021 @06:29PM (#28193143)
What makes you say "port" and "starboard" are more clear than "front" and "back"?
Re:Why is learning functional programming so damned hard? (2... by jyounker on Sunday August 15, 2021 @07:24PM (#28193499)
"Port", "starboard" are unambiguously defined relative to the vessel. "Left" and "right" require specifying or guessing a point of reference.

For instance if you're facing port and I ask you to take two steps forward, you could either take two steps to port or two steps towards the bow. If I tell you to take two steps to port then the direction is unambiguous.

Re:Why is learning functional programming so damned hard? (2... by warble on Sunday August 15, 2021 @10:38PM (#28194460)
In theater you always specific 'stage left' or 'stage right' for the same reason, even though it's more syllables.
Re:Why is learning functional programming so damned hard? (2... by temp0826 on Monday August 16, 2021 @01:00AM (#28195076)
I've told my doctor that I had a problem with my passenger-side nostril before
Re:Why is learning functional programming so damned hard? (2... by xyzzy123 on Monday August 16, 2021 @03:16AM (#28195696)
One fun thing about this is that I have to guess what country you're in to know which side you mean.
Re:Why is learning functional programming so damned hard? (2... by lupire on Monday August 16, 2021 @10:46AM (#28198744)
The passenger side is where the booger is sitting.
Re:Why is learning functional programming so damned hard? (2... by coldtea on Monday August 16, 2021 @07:34AM (#28196929)
It's still ambiguous.

"Stage left" as if I'm standing looking towards the stage from the audience, or looking from the stage towards the audience?

Re:Why is learning functional programming so damned hard? (2... by dboreham on Monday August 16, 2021 @10:14AM (#28198347)
No it isn't because the term was invented specifically to avoid this confusion -- it means "left from the perspective of the performer facing the audience".
Re:Why is learning functional programming so damned hard? (2... by fsckboy on Sunday August 15, 2021 @09:58PM (#28194266)
ok, but forward on a boat is toward the bow, as unambiguous port and starboard
Re:Why is learning functional programming so damned hard? (2... by hn_go_brrrrr on Sunday August 15, 2021 @10:17PM (#28194349)
It's the difference between "forward for you" and "forward for the boat". Without words like "port", you might do the wrong thing when I say "take one step forward". Did I mean for you to go further in the direction you're already facing, or did I want you to step towards the prow?
Re:Why is learning functional programming so damned hard? (2... by shagie on Sunday August 15, 2021 @11:06PM (#28194591)
We use similar approaches with terrestrial navigation too.

At the intersection of Main and Oak, go two blocks east. The building will be on the north side of the street.

Those instructions are the same no matter what direction the person is facing or direction they came from.

However, on a ship, the absolute positions of NSEW (relative to the Earth) aren't as useful as the ship may be heading any direction (and may be going forward or reverse). So a different absolute coordinate system is use - fore, aft, port, starboard.

Re:Why is learning functional programming so damned hard? (2... by lupire on Monday August 16, 2021 @10:47AM (#28198759)
Terrestrial navigation is also multidirectional.
Re:Why is learning functional programming so damned hard? (2... by LanternLight83 on Sunday August 15, 2021 @10:28PM (#28194416)
It's not as unambiguous because, to the guy with his back to starboard, forward could just as easily mean port! It may seem clear if someone's shouting, and pointing, at the bow, but if I'm recounting the action of a tense combat scene and say he "slips on a banana peel and falls 'forward'", you can't know for sure what I mean- does he fall straight towards port, or does he a break a leg, twisting, tumbling toward the bow? c:
Re:Why is learning functional programming so damned hard? (2... by voidreaper on Sunday August 15, 2021 @10:18PM (#28194353)
You can step forward to any side of the boat.
Re:Why is learning functional programming so damned hard? (2... by gnubet on Sunday August 15, 2021 @10:54PM (#28194535)
In Soviet Russia, the boat can step forward to any side of YOU!
Re:Why is learning functional programming so damned hard? (2... by coldtea on Monday August 16, 2021 @07:37AM (#28196946)
It's not, because forward depends where you are looking it. That is, the front part of the boat might be on your back.

So "move forward" doesn't say much, whereas "toward the bow" e.g. does.

Same for left/right compared to port/startboard.

Re:Why is learning functional programming so damned hard? (2... by byroot on Sunday August 15, 2021 @06:32PM (#28193162)
It's not "front" and "back" it's "left side of the boat" and "right side of the boat".
Re:Why is learning functional programming so damned hard? (2... by WalterBright on Sunday August 15, 2021 @06:59PM (#28193340)
More correctly, the "left side of the boat" and "no, the other left side of the boat."
Re:Why is learning functional programming so damned hard? (2... by IIAOPSW on Sunday August 15, 2021 @06:58PM (#28193337)
Oops.
Re:Why is learning functional programming so damned hard? (2... by swiley on Sunday August 15, 2021 @07:11PM (#28193424)
I'm sorry you got downvoted, it's a reasonable question to ask and I would have voted it up if my noprocrast hadn't run out.
Re:Why is learning functional programming so damned hard? (2... by raxxorrax on Monday August 16, 2021 @08:34AM (#28197295)
Aft and forward would be back and front.
Re:Why is learning functional programming so damned hard? (2... by swiley on Sunday August 15, 2021 @06:31PM (#28193159)
The alternatives are left and right respectively. They're more clear because left and right are usually relative to the speaker or listener who may be facing each other and are often moving around.
Re:Why is learning functional programming so damned hard? (2... by noir_lord on Monday August 16, 2021 @08:23AM (#28197222)
Also the problem of right having another meaning.

“You want me to turn right, right?”

Re:Why is learning functional programming so damned hard? (2... by dllthomas on Monday August 16, 2021 @01:50PM (#28200829)
Or worse, "You want me to turn left?" "Right!"
Re:Why is learning functional programming so damned hard? (2... by noir_lord on Monday August 16, 2021 @04:44PM (#28202704)
"You want me to turn left? "Right" "Right right?" "No left".

After that Port/Starboard would make sense and I'd be chucking someone over one of them.

Re:Why is learning functional programming so damned hard? (2... by tcmart14 on Sunday August 15, 2021 @10:50PM (#28194524)
As a former US Navy Sailor, port and starboard are pretty clear. Along with Forward and Aft. These are things relative to the ship and points in which everyone is aware of on a ship. If I say starboard, that is right of the center of the ship. Port is left of center line of the ship.
Re:Why is learning functional programming so damned hard? (2... by caconym_ on Sunday August 15, 2021 @06:34PM (#28193176)
a) They refer to left and right, not front and back (which I believe would be "forward" and "aft").

b) With the possible exception of "forward", if you hear one of these words you always know it's specifying a direction relative to the direction the boat is pointing, which is not true for "left" and "right".

Re:Why is learning functional programming so damned hard? (2... by dan-robertson on Sunday August 15, 2021 @07:05PM (#28193386)
Often just fore instead of forward, or a particular pronunciation like for’d for “the front of the boat as opposed to in front of the speaker”.

Lots of other jargon too for other directions or places (leeward, windward, amidships, athwartships, etc) but that is all much less common than the four listed above.

Re:Why is learning functional programming so damned hard? (2... by mypalmike on Sunday August 15, 2021 @08:50PM (#28193899)
Windward and leeward are still commonly used in my experience.

Also, there's a fun additional distinction for forward and aft, which is that they tend to refer to locations within the vessel. Ahead and astern are used to refer to locations outside of the vessel.

After about 8 years of sailing fairly regularly with various crews, I still get many of the terms mixed up. For instance, stanchions and shrowds are terms that are useful, but they never seen to come to mind when I need to communicate them.

Re:Why is learning functional programming so damned hard? (2... by buzzin__ on Monday August 16, 2021 @07:55AM (#28197054)
Yes, I always found "left" and "right" so unclear and ambiguous.
Re:Why is learning functional programming so damned hard? (2... by Cycl0ps on Monday August 16, 2021 @12:46PM (#28200093)
Right! Why use port when left is right? Nonmariners left starboard right at port, left port there as well. Maybe modern mariners should port left back to their lexicon before they're left behind.
Re:Why is learning functional programming so damned hard? (2... by blacktriangle on Monday August 16, 2021 @08:11AM (#28197144)
Correct, turn right

I left the cheese on the left side

Re:Why is learning functional programming so damned hard? (2... by omegalulw on Tuesday August 17, 2021 @04:36AM (#28207550)
How are those terms less ambiguous than left and right?
Re:Why is learning functional programming so damned hard? (2... by eins1234 on Monday August 16, 2021 @01:31AM (#28195213)
> I'm also wary of functional programming gurus that tend to over-abstract things and use all the language latest features, making code very hard to read.

Wanted to echo this point.

I'm a huge FP proponent, and I do believe that liberal use FP paradigms can result in code that's in many ways measurably more expressive and less complex than code that make liberal use of imperative looping, in-place mutation, and inheritance, etc. When I'm coding on my own for side projects, I always strive to use the most elegant and expressive FP constructs I can think of.

However, at the end of the day, most of the coding we do is part of a social activity. And in a social setting, familiarity matters.

Writing slightly less expressive, more complex code in a way that most people who read it will be already familiar with can result in more productivity in aggregate than writing code that's super expressive and simple but requires everyone reading it to first learn the paradigms/patterns that enabled the code to be written that way, especially in a fast growing startup where people are constantly onboarding into the codebase.

Optimizing too much for familiarity can also become detrimental though, in that it results in stagnation and closes the doors to paradigms/patterns that can have an outsized impact on overall productivity compared to their cost in learning/education.

The real challenge is striking a good balance between familiarity and expressiveness in the choice of paradigms/patterns to use.

Re:Why is learning functional programming so damned hard? (2... by branko_d on Monday August 16, 2021 @02:45AM (#28195554)
> What is important is how the code is organized at high level.

This was often forgotten about OOP as well, as Alan Kay himself reminds us...

"The key in making great and growable systems is much more to design how its modules communicate rather than what their internal properties and behaviors should be."

http://wiki.c2.com/?AlanKayOnMessaging

Re:Why is learning functional programming so damned hard? (2... by heavyset_go on Sunday August 15, 2021 @07:06PM (#28193394)
> However, it's not a silver bullet. I found that basic software engineering principles are way more important than the language. I've seen extremely messy OCaml code and super clean C code. What is important is how the code is organized at high level. Whether you use a for loop or a fold, an error monad or an exception mechanism matters less.

Agreed, developers are great at finding new ways to write questionable code no matter what languages or programming paradigms claim about their respective abilities to reduce code errors and smells. I know because I'm one of them.

Re:Why is learning functional programming so damned hard? (2... by perryizgr8 on Sunday August 15, 2021 @10:40PM (#28194478)
I try to be as functional as possible with my C and C++. You can't reach perfection obviously but I feel it has made my code much better.
Re:Why is learning functional programming so damned hard? (2... by mbrodersen on Monday August 16, 2021 @11:53PM (#28206041)
Agree. I can program in pure languages like Haskell, Idris etc. but still prefer to program ‘in anger” in OO languages. Having easy access to mutable state is just so damn convenient. As long as you are careful how you do it. Mutable state is a very sharp tool so be careful when you use it.
Re:Why is learning functional programming so damned hard? (2... by fulafel on Tuesday August 17, 2021 @12:01AM (#28206105)
Simpler fp languages that are hosted on some bigger ecosystem exist though. Like Clojure(Script) and maybe F#.
Re:Why is learning functional programming so damned hard? (2... by fulafel on Tuesday August 17, 2021 @12:01AM (#28206101)
Simpler fp languages that are hosted on some bigger ecosystem exist though. Like Clojure(Script) & F#.
Re:Why is learning functional programming so damned hard? (2... by baby on Sunday August 15, 2021 @07:25PM (#28193508)
For one, languages like golang prevent over engineering or bad practice. I’ve never read unintelligible golang code. Some might abuse the interface{} but that’s the worse that you’ll see. Not bad compared to some other languages.