Live data from Hacker News

Functional Programming Is Great. But It Ain’t Magic

moaboelez.medium.com

11–18 of 18 posts

Re: Functional Programming Is Great. But It Ain’t Magic

#11

OTOH, It does seem like magic if you have dealt with Java in your previous life

I dunno if I'd say that. At least using recent versions of Java and some F#, I find the latter much nicer, but don't do things so extremely differently. It's just more concise and less keyboard typing when refactoring.

Having worked with Rails codebases I tend to avoid magic when not needed.

The best effect is using FP, then going back to what you used before and adopting more FP style: single assignment to local vars, immutable datastructures, less imperative control flow, etc.

Re: Functional Programming Is Great. But It Ain’t Magic

#12

I'm not a huge fan of this post - I feel like it adds to the confusion where it tries to enlighten. First, a pedantic point - a proper pure functional language will not have "side effects", it will have "effects" (either through algebraic effects or through monads or something) - nothing "side" about them. Side effects are effects that happen in addition to the main value of doing something (this medicine has side ef…

The post is entirely useless from any technical perspective. It talks about pure FP languages. Then about OCaml and concurrency without much detail or distinction.

The only useful thing it almost says clearly is that FP doesn't have to be magic and can be used effectively by normal folks, but instead flips the title (for clicks) to imply it's not as good as they say.

Re: Functional Programming Is Great. But It Ain’t Magic

#13

OTOH, It does seem like magic if you have dealt with Java in your previous life

I dunno if I'd say that. At least using recent versions of Java and some F#, I find the latter much nicer, but don't do things so extremely differently. It's just more concise and less keyboard typing when refactoring. Having worked with Rails codebases I tend to avoid magic when not needed. The best effect is using FP, then going back to what you used before and adopting more FP style: single assignment to local var…

The major differences between Java and F# are:

- Discriminated unions and pattern matching

- Global type inference

- Tail call optimisation

- Syntactic sugar for monadic code (computation expressions)

Java is more “FP” than it used to be, but it is still not minimum viable FP

Re: Functional Programming Is Great. But It Ain’t Magic

#14
post #8

I'm not a huge fan of this post - I feel like it adds to the confusion where it tries to enlighten. First, a pedantic point - a proper pure functional language will not have "side effects", it will have "effects" (either through algebraic effects or through monads or something) - nothing "side" about them. Side effects are effects that happen in addition to the main value of doing something (this medicine has side ef…

Thank you. I’ve frequently found myself annoyed when people conflate the terms “effects” and “side effects”.

I like to think of "effects" in this context as "managed effects"

Re: Functional Programming Is Great. But It Ain’t Magic

#15

Earlier quoted context omitted.

I dunno if I'd say that. At least using recent versions of Java and some F#, I find the latter much nicer, but don't do things so extremely differently. It's just more concise and less keyboard typing when refactoring. Having worked with Rails codebases I tend to avoid magic when not needed. The best effect is using FP, then going back to what you used before and adopting more FP style: single assignment to local var…

The major differences between Java and F# are: - Discriminated unions and pattern matching - Global type inference - Tail call optimisation - Syntactic sugar for monadic code (computation expressions) Java is more “FP” than it used to be, but it is still not minimum viable FP

Java has sum types and is in the process of getting pattern matching (some basic form is already available, but `case Sphere(Point(int x, var y), var r)` already works in preview).

For sum types, the syntax is like this:

  sealed interface Expression permits Add, Mult, Identifier {}
  // possibly later
  record Add(Expression a, Expression b) extends Expression {}
  record Identifier(String name) extends Expression {}
I do like global type inference, but for anything that gets committed I often come to prefer at least Rust’s restriction of top level definitions needing types, as that aligns well with how I would also write Haskell and alia. Java imo made a good decision of only adding optional local inference, anything else would have been too disruptive for Java, given its existing talent pool’s background.

Re: Functional Programming Is Great. But It Ain’t Magic

#16

Any sufficiently advanced technology is indistinguishable from magic. It's magic. Functional programmers are witches/warlocks. What else is the turbofish other than an arcane rune for magical purposes?

> What else is the turbofish other than an arcane rune for magical purposes?

I'm reminded of the Codeless Code short story where the young acolyte visits a Haskell monastery, looks upon an engraving of the monad definition, and wonders "and this mystical inscription - this is code?"

Re: Functional Programming Is Great. But It Ain’t Magic

#17

Earlier quoted context omitted.

I dunno if I'd say that. At least using recent versions of Java and some F#, I find the latter much nicer, but don't do things so extremely differently. It's just more concise and less keyboard typing when refactoring. Having worked with Rails codebases I tend to avoid magic when not needed. The best effect is using FP, then going back to what you used before and adopting more FP style: single assignment to local var…

The major differences between Java and F# are: - Discriminated unions and pattern matching - Global type inference - Tail call optimisation - Syntactic sugar for monadic code (computation expressions) Java is more “FP” than it used to be, but it is still not minimum viable FP

Definitely I would not call Java an FP language, even Rust has a flavoring of FP. Besides the monadic constructs not having proper sum types/d.unions is really annoying. Sealed enums are not the same utility.
Post reply on HN