Functional languages: Is anyone using them?

(Andy Wootton) #1

At @paulspencerwilliams talk at Agile Staffordshire, showed us Clojure. I’ve been away from coding for years and I didn’t realise that Clojure was a Lisp dialect, running in a JVM.

I had a fairly unpleasant experience with Lisp and a fuzzy logic add-on, at university, due to a lack of documentation or support to learn it but have always fancied giving it another go.

Who is using Lisp-like or other functional languages in their daily work and why? How well have they been integrated into modern environments? Are they used in very specialised ways.

(Michael Brett) #2

I’ve had a dabble with Clojure and I really dig it. If you want to have a crack at a few problems I recommend 4clojure.

Haven’t really had a crack at ClojureScript yet - it’s on my list though.

Hashtag career development as the (lame) kids would say.

(Nick Banford) #3

F# in production for parsing data from one database into another and processing it.

I did it for pure speed of using type providers rather than other Ado or Entity Framework. Doing so was about 100x faster and scaled well with larger datasets.

Sad to say I haven’t touched it much since but definitely want to do more F#.

(Andy Wootton) #4

Thanks. I like the idea of relying on a Google utility to make JavScript targetted at Firefox OS too :slight_smile:

(Andy Wootton) #5

Interesting! You wouldn’t have chosen to use LISP for speed. I wonder if the improvements are due to processor design or interpreter/compilation improvements, or just that all the competitors are interpreted too, now so they’ve slowed down.

(Daniel Hollands) #6

You’re going to have to go way back to basics on this one for me, but what is functional programming? I’ve heard the term mentioned a few times, but I’ve never looked into what it is. I’m still trying to get my head about object-oriented programming - am I going to have to throw that all out the window and learn something new?

(Andy Henson) #7

The short answer would be “pretty much, yes” :smile:

@paulspencerwilliams is probably best placed to answer this but my limited understanding of it is that it’s a declarative style and everything is built using functions and, unlike in typical OO languages, you avoid changing state or mutating data. The idea is that you should be able to call a function twice with the same input and will produce the same result every time. This is supposed to make it easier to understand and predict the behaviour of the system.

I just won a couple of books from Michael Fogus so I’m looking forward to digging into Clojure and learning about applying a functional style to Javascript. Maybe after that I’ll be able to tell you more.

(Andy Wootton) #8

If in doubt, WikiP it!

Except I’m not entirely sure I understand this one. I’d say it’s when you call chunks of code (functions) that return a value as their result. They are fun because functions can call themselves recursively which allows ‘different’ algorithms.

(Michael Brett) #9

You might want to check this video out. Really good overview of Clojure by its creator, Rich Hickey.

(Paul Williams) #10

I’ve used FP to varying degrees at work using Scala, and most recently Clojure but mainly use OO day to day. The lines are starting to blur nowadays especially in languages like Ruby and Scala.

My views are strongly linked with Clojure’s simplicity concepts. Ideas like removing the ‘incidental complexity’ of object instantiation and lifecycle, and ensuring code stays truer to the problem domain - simply behaviour (functions) and data.

Only a couple of weeks ago, I started Birmingham Function Programmers Meetup which aims to explore these concepts.

(Colin Smith) #11

I don’t use FP in my daily work, I’ve had a look at a few languages, particularly F# which I would really like to get into, time allowing. I’m not sure how it would fit in with what I do on a daily basis which is predominantly web development. If I remember right functional programming aspires to mimic the perfection of functional mathematics with varying degrees of success.

(Andy Wootton) #12

Haskell was getting a lot of ‘press’ recently too, wasn’t it? I’d forgotten about that one. It always surprises me how long it takes a new language to get traction. They’re all older than you’d expect; except maybe F#, because Microsoft.

(Matt Walker) #13

I’ve been learning Clojure and ClojureScript for a while as I wanted to learn a lisp. I wrote a post on it last year.

(Andy Wootton) #14

That looks a useful resource @walkermatt

My first language (that I’m willing to admit to) was Algol 68 in which all statements had a value so I identify with your reasons for liking LISP but why did you choose Clojure rather than any other dialect? I’m slightly uncomfortable about coding on Linux in any way that depends on a JVM (or Mono.) I never agreed with the Linux community’s mistrust of Sun but I don’t trust Oracle or Microsoft.

(I’m torn on whether to write “LISP” or “Lisp”. LISP is traditional because LISt Process… but it seems to have gone out of favour)

(Matt Walker) #15

I did initially do a little Common Lisp, I think the main draw of
Clojure was the fact that it’s a modern implementation with an active
community. I was dubious about it being hosted on the JVM but I can
appreciate the practically. The new kid on the block is pixel-lang
( which is influenced by Clojure
but removes the JVM dependency.

I’m finding learning about FP great fun, it’s definitely adding how I
write JavaScript and Python.

(Andy Wootton) #16

I’ve just discovered closure-clr too, targetted at the .Net Common Language Run-time

(Marc Cooper) #17

Surprised not to find more mentions of FP in the archives.

I’ve tried haskell and scheme in the past but never got on with them :frowning:

This past couple of weeks, I’ve been learning the latest hotness: elixir and this

I mostly use ruby these days (ruby rather than rails, though I know rails very well too, although I prefer sinatra + sequel) and I tend to write in a fairly functional style — hashes, collections, map, reduce/inject, immutables, etc. — albeit with objects, so elixir is coming to me fairly naturally, especially as it borrows heavily from ruby’s syntax. After all, its creator is #5 rails committer.

elixir is built on erlang’s engine (BEAM — equivalent to Java’s JVM) which offers some amazing benefits (e.g. inbuilt pubsub, concurrency, & distribution), and fits the current web development model like a glove. Where it really shines for an upstart language is both its tooling (very ruby/rake-like) and by making the commenting system a first class.

In addition, elixir has a rails-like framework called phoenix ready to go, which utilises a sane db mapper called ecto.

I’ve not had so much fun with a language since I found ruby all those years ago. Sure, you need to switch to FP thinking with its pattern matching, immutability, prevalence of lists and tuples, and recursion, but when you leverage erlang’s BEAM and spawn processes (not unix processes, but kind of threads without mutexs, so more like firing off things to an event bus) the sum of the parts is so much bigger than them.

Will I be using FP? Yup. Next project, I’m rolling out elixir + phoenix. It’s the only way to learn :slight_smile:

(Steve Jalim) #18

*adds Elixir to The List*

(Dave Evans) #19

There’s a Birmingham Functional Meetup group - next meeting in January.

Or if you’re into mobile as well then the next Xamarin meetup is all about F# on December 9th at Impact Hub.

(Alastair McGowan-Douglas) #20

As I’ve learned more Haskell I’ve made my JavaScript more functional. I can’t claim to be aiming at pure functional because, ultimately, the DOM is mutable and the JS is a state machine, but with a plugin for curry and a plugin for compose it is possible to use functional principles to make JS not suck.

But I don’t actually use any FP languages for anything because I don’t know how to structure a program that is constantly creating new universes.