News for hackers. Stuff that matters.
Re:Phoenix 1.7.0 Released: Built-In Tailwind, Verified Route... by h0l0cube on Monday March 06, 2023 @08:18AM (#35040585)
> the OTP library is often treated as a core part of the language and that did take a fair amount of learning before it clicked.

For me, probably the 2 most foreign concepts coming in with a non-functional mindset were GenServers and tail-recursion. They require a shift in mindset about how to handle state and do flow control. These two things would be stumbling blocks to beginners, especially someone who claims to prefer "sloppy" code

Re:Phoenix 1.7.0 Released: Built-In Tailwind, Verified Route... by toolz on Monday March 06, 2023 @08:45AM (#35040886)
tail-recursion is just an implementation detail...but with recursion, I find non-programmers struggle no more with them than simple loops. It's only programmers who develop a strong familiarity with loops that feel some sense of unnecessary friction. Neither are more than code that says "do this thing until this condition is met"
Re:Phoenix 1.7.0 Released: Built-In Tailwind, Verified Route... by h0l0cube on Monday March 06, 2023 @08:57AM (#35041018)
I agree. As I said it’s those programmers coming in from non-functional languages (likely the majority). When you’re conditioned to using for loops with mutation, it can feel strange to use these new patterns. I think comprehensions, map, and reduce are becoming more common in other non-functional languages, so maybe newer programmers would instinctively reach for these first.
Re:Phoenix 1.7.0 Released: Built-In Tailwind, Verified Route... by weatherlight on Monday March 06, 2023 @09:37AM (#35041503)
genservers aren’t a functional construct and are specific to languages on the ErlangVM/BEAM.

They are more closely related to the Actor Model.

https://courses.cs.ut.ee/MTAT.08.024/2020_spring/uploads/Mai...

Re:Phoenix 1.7.0 Released: Built-In Tailwind, Verified Route... by h0l0cube on Monday March 06, 2023 @05:55PM (#35048984)
Ah yeah sorry, you're right. It was actually the GGP talking about OTP that inspired me to write the comment, but it is actually relevant to the immutable aspect of Elixir (which is something you don't really see outside FP) as GenServer provides a way to keep state the way someone might use global variables or singletons via named processes.