Starting in the Middle
Programming in the 21st Century - James Hague - October 24, 2011When I start on a personal project, I’m bright-eyed and optimistic. I’ve got an idea in my head, and all I need to do is implement it. Wait, before I can begin working on the good stuff there are some foundational underpinnings that don’t yet exist. I work on those for a while, then I get back to main task…until I again realize that there are other, lower-level libraries that I need to write first.
Now I’m worried, because I’m building all this stuff, but I’m no closer to seeing results. I charge ahead and write one-off routines and do whatever it takes to get a working version one-point-oh. Then I hear the creaks and groans of impending code collapse. I shift my focus to architecture and move things to separate modules, refactor, sweep out dark corners, and eventually I’m back to thinking about the real problem. It’s only a short respite. As the code gets larger and more complex, I find myself having to wear my software engineering hat more and more of the time, and that’s no fun.
That’s the story sometimes, anyway. When using functional programming languages I take a different approach: I pick an interesting little bit that’s right in the middle of the problem and start working on it. I don’t build up a foundation needed to support the solution. I don’t think about how it integrates into the whole. There’s a huge win here that should be the selling point of functional programming: you can build large programs without worrying about architecture.
Okay, sure, that architecture dodge isn’t entirely true, but it’s dramatic enough that I’m surprised functional programming isn’t the obvious choice for anyone writing “So you want to learn to program?” tutorials. Or at least that it isn’t the focus of “Why Functional Programming is Great” essays. If nothing else, it’s a more compelling hook than currying or type systems.
How can starting a project in the middle possibly work? By writing symbolic code that lets me put off as many design decisions as possible. If I’m writing the “move entity” function for a video game, the standard approach is to directly modify a structure or object representing that entity. It’s much easier to return a description of the change, like {new_ypos, 76} or {new_color, red}. (Those are both Erlang tuples.) That avoids the whole issue of how to rebuild what may be a complex, nested data structure with a couple of new values.
If I want to multiply the matrices M and N, the result is {'*', M, N}. (This is another Erlang tuple. The single quotes around the asterisk mean that it’s an atom—a symbol in Lisp or Scheme. Those quotes are only necessary if the atom isn’t alphanumeric.) The function to transpose a matrix returns {transpose, M}.
It looks like the essential work is being dodged, but it depends what you’re after. I can write code and see at a glance that it gives the right result. I can use those functions to create more interesting situations and learn about the problem. If I find my understanding of the problem is wrong, and I need to back up, that’s okay. It’s more than okay: it’s great! Maybe it turns out that I don’t need to multiply matrices after all, so I didn’t waste time writing a multiply routine. Maybe the transpose function is always called with a parameter of {transpose, Something}, so the two transpositions cancel out and there’s no need to do anything.
At some point I have to stop living this fantasy and do something useful with these abstract descriptions. Hopefully by that time my experiments in symbolic programming have better defined both the problem and the solution, and I won’t need to spend as much time thinking about boring things like architecture.
(If you liked this, you might enjoy Living Inside Your Own Black Box.)
Categories: Blogs Programming in the 21st Century
Comments
You should also read this essay from Paul Graham, it pretty much agrees with what you are saying (he’s talking about Lisp, but the points apply equally to Erlang, Haskell etc).
http://www.paulgraham.com/avg.html
The issue is one of FUD in business I’m afraid. I am working on a new project, boss wants it in Java. I know that I can get it done 10x faster in Erlang, but convincing the suits is hard. Don’t forget many of the suits (40-50+) grew up learning C, C++. Java isn’t too alien for them, so that’s what they choose.
As Paul pointed out. It’s like a continuum. If you know Java, for example, you think anything more low-level than Java (C,C++) is complex, hard and inefficient. More higher-level languages just look strange to them, too strange to learn, they look strange so they ignore them. Also more worrying, is that they’ve invested years learning and becoming proficient in their language of choice, and that new strange language is stealing work and power away from them.
I don’t have an answer, other than starting in the universities. I am shocked that Java and Python are the languages of choice at university these days. It’s no wonder that many companies struggle to find students with the right skills. They only know one language (with a particular tool-set) and have no understanding of the fundamentals of programming. When I was at university we learned C first (to understand data structures, how memory is accessed etc), then we did C++, a bit of assembly and Prolog to get a grounding in other programming methodologies. No one would’ve thought of using a higher-level language (not that they existed then).
Posted by Matt Evans on 28 Oct 2011 at 14:55one time credit report score - I just want to say that it is an elegant blog that have useful information. I will visit this site again for more information. Take care & carry this job of sharing nice information with others.
Posted by shine on 05 Nov 2011 at 05:42I am sure I follow this stuff. Its not the case that reader must be completely agreed with author’s views about article. So this is what happened with me, anyways its a good effort, I appreciate it.Eastern Mountains Sport Coupon
Posted by claiser on 29 Nov 2011 at 19:16It is very clear written.I really enjoyed it. Walk along the way.I like to read this post. Happy as the way in which you filed your information.I have saved this site and really intend to visit in the coming days.perfumes affiliate programs
Posted by lasoman on 30 Nov 2011 at 09:42I was deeply admired by your blog and its posts. I’m really happy to read it and be able to share my thoughts about it. I take this opportunity to say that I am impressed with the way you presented this blog.casino postepay
Posted by linised on 30 Nov 2011 at 16:22The messages are very unique and permanent for performance excellence, creativity and new ideas and different news concepts.Really I’m waiting a little more you.Keep Excellence and efficiency at the same levels.business phone numbers
Posted by kllusers on 01 Dec 2011 at 21:19I really appreciate your well-written and researched information you’ve really shown how well-versed you on this topic. I agree with many of your viewpoints. I will continue to follow your writings.New Jersey Signs
Posted by leonard on 03 Dec 2011 at 11:45This article is really useful and have been looking for information on the state and an accident is very popular.Simply amazing what you have done here. It is a delight for the eyes, to express from the heart and clarity in this regard, the content can be easily seen.Wholesale K Cups
Posted by Incarone on 05 Dec 2011 at 20:40Truly insightful information thanks a ton. I’m sure we’d all like to read a lot more helpful info much like this in the future.I really trust you actually can certainly persist your current prolific authoring style. Gift Baskets
Posted by codern on 10 Dec 2011 at 14:52I select an exciting little bit that is right in the center of the issue and activate on it. best hcg guide never develop up a groundwork required to aid the option.It looks like the important function is being dodged, but this will depend what you are after.He can create value and see at a look that it gives the right outcome.
Posted by georgen on 12 Dec 2011 at 15:42Just the beginning made a big blast. You must be aware that you really have an awesome site. Does exactly what it sets out to do. Stimulating me to read much more of your post. Hope to see a lot more excellent posts from you shortly.t shirt design
Posted by georgesan on 12 Dec 2011 at 19:40Amazing products from you, man. Ive research your products prior to and you are just as well amazing. I appreciate what you have got right here, like what you are revealing and the way you say it. You create it interesting and you even now handle to help keep it prudent.
bamboo rugs
I must say that overall I am really pleased with this site. It is simple to see that you are impassioned about your composing. I wish I had got your capability to create. I look ahead to more improvements and will be coming.
vaporizer
Unique lot of products to be mentioned. That is why I’m here. I want to master about selection. And mostly it is fun. I would like to know more facts when you get it.
strooizout kopen
The articles are very exclusive and also out status efficiency with the new imagination and excellency with the new different thoughts and thoughts.Really I am awaiting some more new content from you.Keep up your excellency and overall efficiency in this same levels.
dehydrated food
Eventually i came here and found it very informative blog the blog it self so informative the article and the resources of the blog is very good and valuable the title of your blog is also very appealing like Public Knowledge.
sleep sacks
It’s vividly written.I definitely enjoyed. Go along such way.I delighted to read such post.I liked the way you presented your information.
Posted by johnscarbrough on 07 Jan 2012 at 16:27In recent past it was just ok to get a master degree in any of the running field and set your career we are much more into virtual studies and doing all those stuffs where we can explore and learn more.. a lot certifications introduced by Microsoft, Cisco and other international certifications in which you can study and get a good career too. I am so happy to be part of this revolutionary field and do suggest you too. because at the end “it always up to you to decide”...thanks!!
best paintball gun
Life is like dancing. If we have a big floor, many people will dance. Some will get angry when the rhythm changes. But life is changing all the time. Motorverzekering vergelijken
Posted by leonardod on 11 Jan 2012 at 13:36BMI calculator Does anyone know how to become a CRNA if you got your BSN in the Philippines?
Posted by BMI calculator on 15 Jan 2012 at 18:19Add comment
Erlang on Twitter
» rezasur (Reza Surya): Haha makasi ya sodara ularrr ☺ RT @indrasan: selamat ulang tahun saudara reza erlang @rezasur semoga makin banyak proyek nya ya.
» bagus_erlang (bagus): Marah aja kerjaan…
» jamescarr (jamescarr): Working my way through “Learn you some erlang for great good!” tonight. http://t.co/DDTJwDJO
» bagus_erlang (bagus): Capek bngt nyanyi (kemesraan)
» AngginiMaulani (Δnggini MF): Kenapa mamah jdi ngomongin erlang gini:/
» wolfeidau (Mark Wolfe): Submitted update to the #erlang package on #OpenWRT http://t.co/4Brn63XU if anyone wants to test it please ping me /cc @ErlangEmbedded
» ivansyahhsn (ivansyah): Iya dewa erlang hbd,awas ya siksamu menanti RT @indrasan: selamat ulang tahun saudara reza erlang @rezasur semoga makin banyak proyek nya ya
» CzarneckiD (David Czarnecki): It was like Mr. Toad’s Wild Open Source Ride here tonight: Erlang, Riak, CouchDB, Ruby and Python. #nofastpassrequired
» yang_yihming (Yiming Yang): @vw009 Which language do you often use in parallel programing? Ocaml? Erlang? C01? Or some other language?
» tengkushara (T Muni Fahtu Zahra): RT @fathiaamandaaa: RT @indrasan: selamat ulang tahun saudara reza erlang @rezasur semoga makin banyak proyek nya ya.
Statistics
Number of aggregated posts: 10503
Number of comments: 2137
Most recent article: May 21, 2012
Latest comments
» Erno on 100,000 Lines of Assembly Language: Excellent posting. Undoubtedly you are an expert when it comes to this writing. This is absolutely the first time I…
» Jessica on 30 September 2011: Basho Technologies, Erlang Solutions and Trifork AS Announce Big Data and NoSQL R: yeah of course. I just thought that everything will be just alright and I want to have these kind of…
» DRS786 on 25 May 2012: Poznan Erlang User Group Event: I’m going!