Web Development

Functionally Speaking


Functional programming languages, while being merely rare in academic circles, are nearly unheard of within actual production environments. This goes back to what I wrote about a few weeks ago, in that there are considerations beyond technical qualifications for choosing a particular language. But I keep really, really wanting to start slipping some functional programming into my projects. I know that I keep saying this and never do.

There is one post regarding F# that keeps haunting me.

What burns me the most is that I know that it is not just F# that is like this. Scheme, from my experience is like this. By extension, that makes Lisp like this. Where Perl gets functional language-esque, it is like this. Even SQL (shudder) is like this in many ways (think of how many lines of C++ it would take to do what 1 line of SQL does). O’Caml is like this. Ruby may be somewhat like this. From what many of the readers lately have been telling me, APL is like this.

Read that post carefully. Ninety lines of code to do all of that work! My experiences with Scheme and Perl let me know that the lines are probably not too complex either, but there may be a touch of hackishness involved. Regardless. There is one salient point to be made here folks, and it is important: the few hours that a good programmer will spend to learn a language well enough to do this can deliver ROI on the very first use of it.

This eliminates a lot of the business objections to using these types of languages completely. If the language itself takes a few hours to learn at a basic level of proficiency, has enough library support (like F# and the .Net Framework, Perl and CPAN, Lisp and many mathematical function, etc.) or can communicate with code that has good library support (via UNIX pipes, BSD sockets, COM, process forking, whatever) then we knock down a lot of barriers. Get your top programmer cranking out code in one of these nifty little languages, get it blackboxed to your presentation and database layers that your other coders are working on, and we have a development model which is actually quite realistic.

I have been meaning forever to be learning a new language. It was going to be Ruby or possibly Python, but I am fairly convinced that it should be O’Caml/F# or APL. There is a company out there (APL Next) that makes a .Net version of APL, I am going to get in touch with them and see what their system is like. I still trend towards .Net, because of the quality and comfort of Visual Studio, my existing knowledge of the .Net Framework, and the ease of building Web and desktop applications within it without getting tangled up in a lot of plumbing. I will keep you informed with my progress on this. I would love to be able to put a few more arrows in your quivers when wanting to use a better language for a task than the language that everyone already knows. I will also hopefully have a small sample app together soon to show a three tiered development approach that works without everyone on the team having to learn new things.

J.Ja

About

Justin James is the Lead Architect for Conigent.

16 comments
techrepublic
techrepublic

Yo, people! What's the big deal in learning new concepts and languages? Pick a project, pick a language and just do it. If you think learning a new language and getting good at it is sooooo difficult, you are in the wrong business. Amateurs!

lluthien
lluthien

I've had experience with some functional language in college, but i wasn't convinced. i still am not for that matter. one or two examples providing the same results with less lines is hardly a reason to switch languages. the implications of having a particular part of your application developed in a different (for most programmers cumbersome) language in matters of work distriubution, code maintenance and interop between application parts is severe. personally i think the idea that programming an application and a database is already enough of a challenge to master. there is no need to introduce a third player. because while it might be doable to learn al three, it is a full time job to *master* and maintain all three. sorry, functional languages will stay at college in my view.

jdmercha
jdmercha

I know how to program, but I'm bad at it. I don't have a programmers mentality. On the other hand my son is a born programmer. He can quickly pick up any language you want to throw at him. But in reality there are too few people in the world like him. And most decent programmers can't keep up with more than three languages. (Flame on!)

lluthien
lluthien

quite a typical response for a consultant. there is nothing against learning more concepts and languages. but you only have time to specialize in so many. To speak in consultant-speak: every language you want to become good in and keep up to date with is going to add a % to your overhead time. you only have limited time.

Mark Miller
Mark Miller

Give this a look: "Beating the Averages" http://www.paulgraham.com/avg.html Ruby has some properties that are like a functional language. So does Python. Ruby is catching a lot of attention with Rails, though its popularity is not on par with the more established languages like C/C++, .Net, and Java yet. I think languages like Ruby (note I am NOT saying this about Ruby specifically) are the future for application development. They probably won't be purist and obtuse like Lisp, but be a combination of functional and object-oriented programming. F# is like this as well. Just take a look at what Microsoft is doing with the Linq Project. Get a glimpse of what's coming down the road for .Net. It looks a bit like functional programming. It adds dynamic types to C#, and lambda expressions to both C# and VB.Net. Both of these characteristics have been part of functional languages for decades.

Tony Hopkinson
Tony Hopkinson

It's quite popular in PLCs and some intelligent instruments. That's pretty low level, compared to what most of us work at, but the idea does lend it self very well to certain ways of expressing a routine. If this bends your head, try Prolog. :D I agree that it's so off the beaten track for most businesses, that you are only going to see it come from a management fanatic or an unmanaged super geek. JJ is both :D

Tony Hopkinson
Tony Hopkinson

The ability to program, despite what others would have us believe is not language dependant. The map is not the territory as it were. If he wants a laugh program in two languages at the same time, you invent new ones, like portran and fascal, very annoying.

NOW LEFT TR
NOW LEFT TR

just a flame poster, amateur at best.

Justin James
Justin James

"I agree that it's so off the beaten track for most businesses, that you are only going to see it come from a management fanatic or an unmanaged super geek. JJ is both " "Unmanaged super geek" I can understand... but "management fanatic"? Just because I haven't complained about my job lately doesn't mean anything... ;) But in all seriousness... There is definitely a break even point, I think, where an advanced/bizarre language or path to take achieves ROI. And I think you need to go well past that ROI point before it can be a real option. Not like "we can save 10 minutes and $15 dollars if we use Forth" but like "we can cut 1 month off of a 1 year project and save $30,000" worth of ROI. J.Ja

Tony Hopkinson
Tony Hopkinson

a little too literally. :D I shall use anyone who know's their arse from elbow from now on. The elbow is the bendy bit in your arm, arse is not an english mule.

NOW LEFT TR
NOW LEFT TR

"Anyone who can see lightning and hear thunder can write a program" So a deaf persoon can't write a program then? a blind person can't write a program then? Or have I picked this up wrong?

Tony Hopkinson
Tony Hopkinson

You must be clever ! Not really is my usual response. Anyone who can see lightning and hear thunder can write a program, the enjoyment you get out of making it better is what makes a programmer though. I despised maths when I was a kid, came back to it later on and enjoyed it. That was when someone taught me the axioms and the logic behind it instead of the monkey see monkey do stuff I got at school. Pity my teachers couldn't think laterally.

Justin James
Justin James

Some people are "born" to it, some are "trained" to it. At the end of the day, the people who do well in abstract sciences like math, physics, etc. tend to do very well in programming. Some people ("born programmers") just "get" math, and they "get" programming just as well. Some people ("trained programmers") need a lot of study and work to "get" math and programming. And then there is there are "shake 'n bake programmers." Make no mistake, they are well trained (they have to be, to be able to program despite having little aptitude for it), but they just are not able to think in the abstract manner that the top programmers can. It is not a lack of intelligence, it's a lack of being able to think *in a particular way*. On that note, there are some programmers who are fantastic at optimizing little bits of code but lousy at doing the overall architecting, or who are awesome at figuring out databases but lousy with GUIs, or who can do some funky Lisp-y stuff but struggle with OO concepts. There are all sorts of different ways of thinking, and programming as a general field requires many (sometimes paradoxical, like wide angle vision AND details orientedness at the same time) modes of thought which most people simply do not have. J.Ja

Justin James
Justin James

Yeah, that makes more sense now! I do have a LOT more decision making authority over the code than most programmers in a corporate environment have. My uncle programs PLCs, and he just happens to be an electrical engineer as well. :) It's funny, he can do some really tricky stuff with a PROM, but is baffled by what I do, and vice versa. It's like I said in another post, there isn't just a "programming mindset", there are so many subsets of it! What kind of hurts is that there were things I could do when I was 15 that I struggle with today. J.Ja

Tony Hopkinson
Tony Hopkinson

You manage yourself and so you can push through cool stuff, and see it happen :D Whether is was sensible or not :D : D Functional block programming in PLCs can save you a fortune in development time. It's a different conceptualisation of the standard ladder diagram, which most electrical engineers are more comfortable with. If you've never programmed a PLC, think of it as a series of assignments linked by gotos. FCB lets you aggregate the steps so you can picture them as black boxes with inputs and outputs in that environment.

Editor's Picks