Show HN: Functional programming on Perl 5
functional-perl.org
functional-perl.org
I guess the layout is pretty old-fashioned, and I might have too much text; I'm trying to cater to people who are not used to functional programming yet, but I'm not sure I'm achieving that. I guess it's also a rather difficult sell when many Perlers prefer to use the upcoming Perl 6 instead, and others decide to leave for a more proper functional programming language implementation.
I'm rather proud that I've managed to base lazy sequences on lazily evaluated linked lists, i.e. based on purely functional principles down to the cells, instead of using iterators as many function libraries for sequences for non-functional languages (like JavaScript or C#) do. Not sure how much it matters in practice, but at least you can write lazy sequences with this the same way you do in Haskell (see fibs and primes examples).
There are some good points doing FP in Perl 5 compared to some other non-FP languages (you can do optimized tail-calls pretty cleanly), and some bad points (you have to care about memory handling in some places). I've got ideas how to improve on both fronts but that will depend on the uptake of the project.
That is definitely not a thing.
Also, i recommend putting it on cpan. It's perfectly fine to put alpha modules on there.
Edit: I see now that it was mentioned on the page. Consider this comment another recommendation then. If you are interested in perl and functional programming, check this book out!
It's more appropriate to compare it to SNOBOL and AWK.
It takes five minutes of a good tutorial to understand what references are and how they work. Yet it's not rare to see so called senior developers still failing to use them properly and introducing bugs because of it.
In a way my project improves a bit over this, since you're often not using Perl base data structures directly anymore; OTOH of course that means writing out a function or method call, and while this is more universal (which I like) it also uses more space to type. Also, sigils are getting more pointless when using libraries (I usually don't use % and @ anymore, always references, the good part of which is that this is giving a bit more consistency).
Dealing with a reference-counting GC is a bit of a nuisance when occasionally having to help it along manually, after getting used to a real GC, but it can also be beneficial: memory usage is deterministic and rather low.
Perl is also slow handling data structures compared to languages like Java, Clojure or Haskell, unless you implement those / the bottlenecks in C, which functional-perl currently does not do.
Perl is very hacky, in both the good and bad senses: it's not a simple and clean language or ecosystem (kind of the anti-thesis of Scheme), but it's also very malleable: core perl allows you to do a lot of things for which you would need macros or similar features (I still don't know how Ruby works in this regard) in other languages, and various approaches to extend it exist nowadays (e.g. you want something nicer than "sub { my ($x)=@_; ... }"? Today you can write a module that allows you to write "fun ($x) { ... }" pretty cleanly (also someone implemented[1] one for this example already)). Also, I've been positively surprised to find good hackers in the Perl community when I returned; perhaps that's correlated.