Live data from Hacker News

Functional programming is finally going mainstream

github.com

21–30 of 171 posts

Re: Functional programming is finally going mainstream

#21
post #2

Functional programming with immutable state cannot possibly win in the general case. There are two truths that ensure the dominance of imperative software: 1. At some level of software complexity, programmers MUST start to organize data into composite objects. They have to do this because working outside of well-defined problem domains is a recipe for buggy software and spaghetti code. 2. Copying memory around to ena…

> At some level of software complexity, programmers MUST start to organize data into composite objects.

I don't understand this point. All functional programming languages have algebraic data types and records, which are composite types. If this is not a "composite object", you'll have to clarify what you mean.

> Copying memory around to enable to facilitate these immutable structures is SLOW.

Slower than what and in what context? Append-only logs in relational databases are immutable data structures, and they enable multiversion concurrency control, which is faster and more scalable than locking when there's lots of contention.

Unqualified claims like "immutable data structures are slow" is just wrong.

Re: Functional programming is finally going mainstream

#23
post #22

Great I am looking forward to seeing mode code like this: timeslotRepo.findAll().stream().filter(timeslot->timeslot.getEndDate()==null).first().ifPresentOrElse(()->{}, ()->{new Timeslot(DateTime.now())})

Well, that's an ignorant reduction of functional programming but suit yourself.

Re: Functional programming is finally going mainstream

#24
I'm not sure how I feel about this.

If you look at my code in "multi-paradigm" languages like typescript, there's not a heck of a lot of loops, mutations or side effects. I like expressions, and immutability, and higher order functions. They make things shorter and means there's less state for me to keep track of - or screw up.

But at the same time, I like objects. Almost all of mine are immutable. I went through a phase of using plain old data + a collection of functions that transform them, but found a good object where all of that was self contained simplified things a lot.

I also have to say that sometimes FP programmers don't seem to understand OOP a lot. I'm of the opinion that working on an old school opinion that a legacy Java codebase doesn't really make you an expert on OO.

So while I'm glad we're thinking about purity, and avoiding side effects, I'm kind of sad that there's an object backlash. They're fantastic contstructs.

Re: Functional programming is finally going mainstream

#25
post #2

Functional programming with immutable state cannot possibly win in the general case. There are two truths that ensure the dominance of imperative software: 1. At some level of software complexity, programmers MUST start to organize data into composite objects. They have to do this because working outside of well-defined problem domains is a recipe for buggy software and spaghetti code. 2. Copying memory around to ena…

Clojure

Re: Functional programming is finally going mainstream

#26

I'm not sure how I feel about this. If you look at my code in "multi-paradigm" languages like typescript, there's not a heck of a lot of loops, mutations or side effects. I like expressions, and immutability, and higher order functions. They make things shorter and means there's less state for me to keep track of - or screw up. But at the same time, I like objects. Almost all of mine are immutable. I went through a p…

With immutable objects, aren't you just left with syntactic sugar around structs and functions? I'm picturing CLOS, which is undoubtedly an OO system but lacks 100% of what you use objects for. Are there languages which let you use dot-syntax for "methods" which just wrap normal functions?

Re: Functional programming is finally going mainstream

#27

I'm not sure how I feel about this. If you look at my code in "multi-paradigm" languages like typescript, there's not a heck of a lot of loops, mutations or side effects. I like expressions, and immutability, and higher order functions. They make things shorter and means there's less state for me to keep track of - or screw up. But at the same time, I like objects. Almost all of mine are immutable. I went through a p…

With immutable objects, aren't you just left with syntactic sugar around structs and functions? I'm picturing CLOS, which is undoubtedly an OO system but lacks 100% of what you use objects for. Are there languages which let you use dot-syntax for "methods" which just wrap normal functions?

What does CLOS lack that you want from an OO system?

Re: Functional programming is finally going mainstream

#28

I'm not sure how I feel about this. If you look at my code in "multi-paradigm" languages like typescript, there's not a heck of a lot of loops, mutations or side effects. I like expressions, and immutability, and higher order functions. They make things shorter and means there's less state for me to keep track of - or screw up. But at the same time, I like objects. Almost all of mine are immutable. I went through a p…

With immutable objects, aren't you just left with syntactic sugar around structs and functions? I'm picturing CLOS, which is undoubtedly an OO system but lacks 100% of what you use objects for. Are there languages which let you use dot-syntax for "methods" which just wrap normal functions?

With immutable objects, aren't you just left with syntactic sugar around structs and functions?

Yeah I've gone down this thought experiment. Conclusion I came to is that while you could view it that way, there's something powerful about Just Having One Thing, not structs + functions. It's almost a mindset shift as well, like you're requesting the object to do something and don't care how.

Are there languages which let you use dot-syntax for "methods" which just wrap normal functions?

Yeah, Dlang has that.

https://tour.dlang.org/tour/en/gems/uniform-function-call-sy...

Re: Functional programming is finally going mainstream

#29
post #22

Great I am looking forward to seeing mode code like this: timeslotRepo.findAll().stream().filter(timeslot->timeslot.getEndDate()==null).first().ifPresentOrElse(()->{}, ()->{new Timeslot(DateTime.now())})

So you're filtering specifically for timeslots where the end date is null and therefore guaranteeing that you return a timeslot dated to now?

Re: Functional programming is finally going mainstream

#30

I'm not sure how I feel about this. If you look at my code in "multi-paradigm" languages like typescript, there's not a heck of a lot of loops, mutations or side effects. I like expressions, and immutability, and higher order functions. They make things shorter and means there's less state for me to keep track of - or screw up. But at the same time, I like objects. Almost all of mine are immutable. I went through a p…

With immutable objects, aren't you just left with syntactic sugar around structs and functions? I'm picturing CLOS, which is undoubtedly an OO system but lacks 100% of what you use objects for. Are there languages which let you use dot-syntax for "methods" which just wrap normal functions?

Haskell[0]? Idris2[1]?

[0] https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4532#not...

[1] https://idris2.readthedocs.io/en/latest/reference/records.ht...

Post reply on HN