4 ms·
Ask HN: Programming language power and 10 years to mastery
I've been thinking about the intersection between the variability in programming language power and expressivity (as discussed by PG in http://www.paulgraham.com/avg.html) and the 10 year (or 10,000 hours) road to expertise.
I’m around year eight of hacking away professionally and bumped against the dramatic power differential in programming languages when I primarily became a database developer. I started "thinking in sets" and found that I was much more effective. SQL got more work done in fewer lines of code in a simple way than hooking up my J2EE java junk via JDBC in more traditional programming. But it took the direct use of SQL for a couple of years before the experience pushed my coding to the next level. Much of this benefit was due to the fact that the apps I worked on were really data driven and "fit" the relational data model well, coupled with the fact that I was in a role that allowed me to do architecture design and low level implementation. And tear the design and implementation apart to do it again after finding all the nuances in the app and data.
The switch from imperative programming languages to a declarative programming language to take advantage of SQL has made me curious about Lisp and functional programming. I have an idea for a web app and I’ll use it as a vehicle to test out Lisp. Worst case, I pick up a language that purports to have almost mystical powers (all hail the mighty macro). Best case, a nice startup could grow out of the project. But the real point is to get real hands-on experience with a more powerful language than the standard C, Java, Perl, and SQL stuff I’ve already done. Plus, I’d hate to miss out on some key part of a hacker’s personal growth over that 10 year march . . .
That’s a lot of background to get to two simple questions.
Do any of the HN readers have any tips or advice on speeding up the transition to "thinking in Lisp"? I’ll probably be hacking away using Practical Common Lisp and On Lisp as my guides (SICP is probably somewhere in the mix). Have any of you followed a similar path as you head towards a decade of hacking and did the Lisp (or other fp language) dance grow your skills in a big way (ie, now I’m a faster developer in general or better algorithm designer or communicator of code ideas)? It would be great to hear specifics.
Thanks.
- anc2020 18y agoCommon Lisp changed the way I program because the macros open your eyes to a whole lot of code duplication that you can't avoid in other languages - this encouraged me to really work at those bits of code until they actually contain the bare minimum of boilerplate code possible. Haskell changed the way I program because laziness can allow you to express your code in much clearer and simpler ways - this encouraged me to use more memoization. Functional programming is definitely where we want to be in theory, so if practice permits, use it!
- thomanil 18y agoCheck out the book 'The Little Schemer'. Good way to ease your mind into functional programming. Also consider learning a dynamic 'scripting' language like Ruby or Python. They have some functional aspects, and will teach you programming style and idioms that you probably haven't picked up from Java and C.
- alanthonyc 18y agoI concur. The big advantage to picking up one of these Lisp-like languages (rather than Lisp itself) is that with their corresponding web-frameworks (Rails and Django), you will be able to put up some pretty cool apps pretty quickly. This helps your motivation as well as your bottom line personal ROI (they're both pretty marketable skillsets). I don't think you lose all that much, as far as the experience of picking up a functional paradigm goes. (This last bit is not fully backed up by experience with Lisp on my part.)
- javert 18y agoI wouldn't call Rails and Python "Lisp-like languages."
- silentbicycle 18y agoPython's lead designer is actively hostile to this, actually. (And Rails isn't a language, goshdarnit...) Lua is very Scheme-y, though, much the way Javascript is. While I don't use Ruby much (Python and Lua fit that niche for me), it seems more Lisp-y than Python.
- alanthonyc 18y agoYes, I did read his post about his basing Python more on C and Algol than functional languages. But then he goes on to explain how and why Python got more functional programming features. Also, I based my assumption that Python is "lisp-like" on a statement I remembered from one of PG's essays: "Each one is progressively more like Lisp. Python copies even features that many Lisp hackers consider to be mistakes. You could translate simple Lisp programs into Python line for line." If there is more context to all this that I am missing, then my mistake. Anyway, I wasn't looking to make any detailed comparisons between languages for the OP. I was just saying...hey, Python or something else could be fun to learn...
- FalconNL 18y agoI can't comment on Lisp, but I've been working with Haskell for about a year or so now, so I'll cover that instead. My personal history goes something like QBasic -> Visual Basic -> PHP -> Java -> C# -> Haskell. Since Haskell is a purely functional language there's no cheating like you could in, say, OCaml. This forces you to learn how to work with immutability, which I have become a big fan of. When working with C# I try to avoid mutability as much as possible (naturally this is quite a bit uglier than in Haskell, but it does avoid some problems). Most of my C# projects now acquire a Haskell.cs file fairly quickly, containing things like a Tuple class, zip, >>=, etc. In the time I've spent learning it, Haskell has quickly become my favourite language. It's not perfect (my current main wishes are existential types and an extensible record system), but it is considerably less painful than the other languages I know. As for speeding up the transition, I can't offer anything other than just diving in. At some point it will just click and you will wonder what all the commotion is about (another monad tutorial? why?). Granted, I still don't have the slightest idea about why I would want to use a hylomorphism or what to do with a comonad, but perhaps I will some day. Fortunately you don't need them in everyday Haskell programming :)
- Zak 18y agoIf you're doing FP in C#, why not use F#? It's not Haskell, but it's a step closer.
- FalconNL 18y agoI've tried it a bit, but I found the syntax rather ugly compared to Haskell. I know, I'm nitpicking and it really shouldn't matter that much, but it put me off the language. Perhaps when they finally release a full-blown implementation of F# for Visual Studio I'll give it another go. My main reason for still using C# at the moment is the UI integration with WPF and Windows Forms. Ideally there'd be an actively maintained Haskell.NET, but perhaps F# can serve as a compromise when Visual Studio 2010 comes out.
- asimjalis 18y agoIs your Haskell.cs file published somewhere?
- hs 18y agoin pcl ch3, the author demonstrates using cl instead of sql for database afaik hn doesn't use sql/rdbms either, i guess it's because threaded forum is better suited using a tree-like data structure instead of simple table i stopped using sql (after reading pcl and seeing the fact of hn) and just having a lisp process running, writing to disk every 5 mins i'm now experimenting with nginx's proxy_pass and upstream to many lisp unix sockets (weighted round robin) virgin territory for me, it's quite fun so far ... foolish and hungry :D
- Zak 18y agoThe PCL database is a very simple in-memory database with no indexing. It's intended as an example of the power of the language, not really as something you'd want to use.There are other databases for CL, including pure-Lisp data stores and interfaces to SQL databases.
- silentbicycle 18y agoHN's data set isn't big enough to really need one, though. Serious RDMBSs are designed for billions to trillions of entries.
- asciilifeform 18y ago>the 10 year (or 10,000 hours) road to expertise Why is this figure being bandied about as though it were an actual scientific fact?
- bluishgreen 18y agoBecause its a useful ball park.
- asciilifeform 18y ago>a useful ball park Why do you think so? What actual evidence is there for it?
- Beanblabber 18y agoI think the correct question is what actual evidence is there against it?
- asciilifeform 18y agoThe fact that Gladwell pulled the figure out of thin air?
- mroman 18y agoBecause for many folks, myself included, the opinion of a genius such as Norvig is solid enough to be treated as scientific fact.
- silentbicycle 18y agoAm I the only one who finds that kind of unsettling? This sort of behavior is why, even among scientists, a generation often needs to die out before new ideas can be seriously evaluated. (http://en.wikipedia.org/wiki/The_Structure_of_Scientific_Revolutions http://en.wikipedia.org/wiki/The_Structure_of_Scientific_Rev...)
- DougWebb 18y agoI also recommend "Javascript: The Good Parts". It and the jQuery library can teach you a lot about how Javascript is really a functional language with more in common with Lisp than with C++ or Java. A second excellent book is "Higher Order Perl", which shows how Perl, also, shares a lot more in common with Lisp than most developers realize. I'm on my 13th year as a professional developer and 27th as a hacker, and I still find some of the concepts in HoP challenging. I would also recommend learning XSLT. It's pure declarative, side-effect-free programming. If you're used to procedural code (including OOP), or even functional code, you'll still have to reattach your head sideways to learn to use XSLT effectively. It's well worth the challenge; there are problems that would be very difficult to handle in other languages which XSLT handles with ease; it's a powerful tool for your toolchest.
- Xichekolas 18y agoI found SICP was better for learning to "think functionally". PCL and On Lisp were both great in their own right, but idiomatic CL isn't as strictly functional as idiomatic Scheme tends to be (and neither enforces it like Haskell and Erlang do). As for improving my skills, that's an unequivocal yes. I think the biggest eureka moment came when I understood the idea of first class functions. That opened many doors to better code. Before, I used functions primarily like a writer uses paragraphs: to break up the narrative into chunks. After SICP, I saw functions more like (for lack of a better term) filters. They transform their input into output. The transformation is well defined, and the natural boundaries between functions become clear rather than arbitrary.
- tydok 18y ago""I started "thinking in sets" and found that I was much more effective."" Actually that is the power of Lisp. In Lisp, batch or stream data processing is not only straightforward, but the way to think and program.
- silentbicycle 18y agoWell, he's talking about relational databases, which approach sets from a very different angle.
- marcusbooster 18y agoI got into Lisp through Emacs, but more recently I've been understanding it using Clojure. For me, I need to be able to create something tangible. Having access to all the Java libraries gives me a lot of cool things to import, then play around with in functional ways.
- jamii 18y agoI'll second that, especially since you mentioned you already work with java. If you like SQL you might want to look at the recent clojure implementation of datalog: http://code.google.com/p/clojure-contrib/wiki/DatalogOverview http://code.google.com/p/clojure-contrib/wiki/DatalogOvervie...
- iamelgringo 18y agoIt sounds like you are trying to do two separate things: 1. Learn Lisp, and 2. create a web app startup. Both are very worthy goals, but I don't know if using Lisp, Haskell or erlang to write a web app is really a great idea right now. (Sorry PG). I think that is was true that writing web apps in Lisp probably gave you a huge leg up against the competitors in the mid 90's. I don't really know if that's the case now. Languages like Python and Ruby have tons of libraries, frameworks and documentation that really help you get productive making web apps. That's a huge plus in my book. Then again, maybe you're interested in rolling your own libraries and framework ala arc. If that's your thing go for it. I'm sure you'll learn a lot along the way.
- silentbicycle 18y agoFor Lisp, I found using Scheme and reading The Little Schemer and SICP more helpful than PCL. I've also been using and heavily customizing Emacs, but Emacs Lisp is kind of a crappy Lisp, and keeping track of its idiosyncrasies while also learning Scheme or Common Lisp's will probably be really confusing initially. Scheme is also a lot more my style than CL, though. YMMV. I also found learning OCaml to be a real eye-opener, both for learning FP techniques (it emphasizes a different set of them than Lisp) and how to work with, rather than against, static typing. (_The Little MLer_ helped, as well, and is at least as good for learning types as _The Little Schemer_ is for recursion, IMHO. Highly recommended.) There's not a whole lot of material published in English on OCaml (the Joshua Smith book is terrible!), but there's a translation of a French O'Reilly book online (http://caml.inria.fr/pub/docs/oreilly-book/ http://caml.inria.fr/pub/docs/oreilly-book/), and it's quite good for learning the main ideas. The first few chapters are on functional programming, imperative programming, and then their relative strengths & when to use each. (Their emphasis on using FP when appropriate, rather than treating it as the new best thing ever, suggests more insight to me than the blind enthusiasm for languages that tends to cycle through here and reddit.) Also: OCaml is not without its flaws. In particular, its errors can be cryptic, and it's standard library has some infuriating omissions. The language is fantastic for some kinds of problems (ML's forte is anything involving complex data structures), though, and it's a great way to learn some very useful techniques.
- triplefox 18y agoTo answer in sort of a roundabout way, I think the problem domain matters a lot for how much you relatively learn when switching languages. With web app backends, for example, most of the problems somehow relate to difficulty maintaining state over widespread, always-on networked systems - things like authentication, sessions, concurrency, large-scale, flexible datastores. So the systems architected gradually get more and more tuned towards serving this particular goal with little programmer effort. And because those problems are a good match to functional programming - because it eliminates state - functional has become popular. But if you were building an embedded system, statefulness is less of a problem: there's usually only one thread, and all memory can be mapped in an orderly way. Your performance constraints are reliant on a single fixed platform, so the methods of inspecting and debugging code change. So to get back to the original question, think about reframing your familiar problems in a way that would simplify the solution with a functional technique. Preferably, look for simplifications that are really big changes and throw out traditional assumptions - the use of relational databases in webapps is one common target for this. Even if you get it wrong you'll get a better understanding of where the functional solution can and can't work.