Showing posts with label programming languages. Show all posts
Showing posts with label programming languages. Show all posts

Saturday, July 3, 2010

My Plan for Programming Language World Domination

I've recently been playing around with prolog (of all things). This happened after reading in "Coders at Work" that Erlang was originally written in prolog. This blew my mind. My impression from a few weeks of prolog usage in a programming languages course and another few weeks in an AI course that it was a *cute* idea but not really anything like a general purpose language. I guess this just emphasizes the point that you don't really know enough to have a valid opinion after such a short exposure. FWIW, I've been pleasantly surprised at the feel of declarative programming.

This sort of reactivated a crazy idea I had in my youth. Back in high school I had this notion of being a polyglot. At one point I had a different language for each day of the week (French on Mondays, German on Tuesdays, etc.). Needless to say this overwhelmed me and I never really mastered any of them (though I retained an interest in linguistics).

But I still love this idea of learning lots of languages. But now it occurs to me that I *can* do this with programming languages. The main flaw (besides the audacity) of my original goal was that I didn't have access to any native speakers with which to really practice my language skills. But with programming languages you can always practice to your hearts content.

So here is my plan. I will rotate through my list of "keeper" languages as I run through my usual diet of "99 problems", "euler problems", ACM contest problems and other puzzlers I come across. After I confirm that I can comfortably solve relatively interesting (though smallish) problems in my current list of "keeper" languages I'll start work on getting another language up to speed to add to my Bat utility belt.

Part of my interest in such a plan is that I just love learning to think in new ways. OK, that's a lie. Sometimes it's interesting. Sometimes it is maddening. But in either case it feels important and useful like going for long runs and eating right. I don't love exercise, but sometimes it feels good and I'm more worried about what will happen if I *don't* do it than discomfort/nuisance of actually doing it.

My other concern is related to the fact that I quite luckily have been able to program primarily in python for the last 9 years. This has been fun, but I worry that I could be missing out on other cool emerging technologies and that while python is a decent way to express your thoughts, it is not perfect and I shouldn't stop exercising different ways to bend computers to my will.

So here is my initial list of languages that I presume that I can currently solve programming puzzles in: python, prolog and haskell. Haskell is my language of the year and prolog has been quickly ramping up again. After I verify that these guys are reliably at my fingertips the next few languages will likely be from this short list:

  • oz: Gives me an excuse to read CTM and it feels like and important laboratory for programming ideas
  • c: I feel guilty that I've lost my fluency in this. I want to get comfortable with thinking at that level again.
  • java: this is a lingua franca that I should be comfortable with (though I think it has the least to teach me). I used to be paid to do this, but I don't miss it.
  • a lisp (commonlisp/scheme/clojure/emacslisp): Do I need a reason? OK, probably scheme so that I can go through SICP all the way and be able to wield the ninja star of continuations with confidence.
  • smalltalk: Is there a more direct road to OO mastery? I've spent some time before but probably didn't give it enough of a chance. Also being different is sort of the point of this exercise.

There are many more that seem worth cultivating, but I don't dare write them down for fear of overwhelming myself too early on.

Any way, here we go again.

Friday, February 26, 2010

One Language a Year: Haskell - update 2

Not much to report, except that I am still trucking along through Real World Haskell (currently chapter 7). This is much better than last year (the year of smalltalk) where I was already having lots of trouble with motivation by this point.

I've been thinking alot about what the chances are that haskell will become one of my daily use power tools like python is. Or what the chances are that haskell will "take off" like a python.

I've already (mostly) gotten over one of my haskell phobias: dealing with "do" blocks. When I only had a passing understanding, I always got confused with "<-" and "lets" and "return"s in do blocks (and nested do blocks) and the rules seemed rather arbitrary, etc. Of course I'm no expert now, but at least I don't look at them as magical things. They have a precise use and logic and now I (mostly) get them.

A couple things from python I miss in haskell: list access syntax (e.g. x[2:]), default args/kwargs, etc. Both of these haven't really hurt me yet but just the thought that I don't have them available makes me sad.

Monday, February 1, 2010

One Language a Year: Haskell - update 1

So one month in and so far Haskell is treating me much better than Smalltalk did a year ago. What is better? Well to start with my main learning period is a 20 to 30 minute window each morning before work. For whatever reason Smalltalk put me directly to sleep and I would often literally find my forehead mashed into my keyboard. I haven't had that problem at all yet with Haskell. One thing is for sure, if you want to learn a new programming language, you have to be awake.

What is the difference? For one it may just be that I like functional rather than object oriented thinking better. I'm fairly comfortable with object design ideas, but things like design patterns more often than not seem like bandaids over language problems rather than powerful solution cookie cutters. Also I admit that I generally expect object based solution to be over engineered. There is such a thing as beautiful OO solutions, but they seem to be the exception in my experience.

But probably the number one success factor for me is the fantastic book: Real World Haskell. 4 chapters in and I find the pacing quite nice. And there is no shying away from mundane things like reading and writing files and reading command line arguments. I swear I have a Haskell book that doesn't do any discussion of IO until chapter 17. I get that IO is about monads and monads are serious mind benders, but you still need to crank out a "Hello World" program early on. RWH gets that and many other things right.

One of my main rules for making sure I understand everything as I'm going along is to retype in *all* code from scratch as I come across it and to do so without directly copying it. In other words I have to understand it enough to retype it in directly from memory. This is probably something I should always have done, but cutting and pasting is just so easy and there is so little time....

In any case, the year of Haskell is doing quite nicely so far.

Sunday, January 17, 2010

Is anything new/unique to Python?

Looking at haskell I see some of my friends from python. Significant whitespace, list comprehensions, interators (sort of like laziness), tuples. And then it struck me that all of these features in python are derivative. Not that that is a bad thing. But I was surprised that I couldn't think of anything definitively new/unique to python. (Obviously the way these things are combined/balanced is unique)

Hey, internets, did python invent any language features/syntax?

The only thing that I can come up with is maybe the __blah__ (unders before and after) style of exposing syntax overriding.

Monday, January 4, 2010

One New Language a Year: Haskell

Another year starts and so I try again to do the "Language a Year" thing. Last year it was a close decision between smalltalk and haskell. I went with smalltalk and for various reason it didn't really grab me and I ended up abandoning my efforts and switching to emacslisp.

So hopefully I've learned a little bit about the focus and dedication it takes to work on a new language and I'm ready to try this thing again.

First of all you need a goal or you won't know if you've succeeded (or failed). My goal is to essentially have a new python at my command. Another general purpose language that I can use as easily as I think for any sort of programming itch I happen to have. I originally learned python because I was looking for a new language that was different from what I was using at work. In 2000 or so I was mostly a Java and perl programmer. Python seemed interesting and different so I dove in. Relatively soon after that it became my full time work language and I sort of lost the idea of having a second language that I used in my free time.

So here I am again looking for a "fun" language. I've actually done occasional reading on haskell topics/blogs and have gone through a few short tutorials, but it's hardly a language I would say I'm at all comfortable in. In fact, unlike most languages that I have some familiarity in, random haskell code more often than not seems to have some scary new function/datatype/etc that I can't even start to grok from context.

The metaphor I have in mind as I dive in is that just as a professional builder uses tools that would be confusing and dangerous to a amateur builder there are programming tools/languages/concepts that are a level of effectiveness above the blub that I'm used to. It will take time/energy to master the more powerful tools but once you have, you will be working at a more advanced level.

I'm really curious to see if I can get a new language in my tool belt that is as concise (or more so) than python, faster, less prone to bugs, etc. Haskell seems as likely to provide this as any language as I'm aware of.

My plan is to use "Real World Haskell" as my main resource. By the end of the year I'd like to have gotten comfortable enough that I could use it interchangeably with python for random fun projects at home and even better to create a project and/or get involved in an existing project so that I have a reason to keep my skills fresh (since it ain't too likely to become my work language any time soon).

In any case I'll check back in a month or so and let you know how it's going.

Friday, May 22, 2009

One New Language a Year: (was) Smalltalk

OK, so I had this crazy plan of doing the "one new language a year" thing. I really like the idea of this. Get out of your comfort zone, prevent settling for a "blub" language, learn new techniques. So I choose smalltalk and thought this would fit the bill. I was really excited to work with turtles all the way down. "Real" object oriented programming. Etc.

And here it is May and I'm just not doing so well. Best laid schemes and all that. In fact I've decided to abandon it for, get this, emacslisp. Only time will tell if this was a good decision or just my normal fickleness.

Part of this decision is just pure pragmatism. My learning windows for this plan are of necessity going to be early in the morning before breakfast or late at night after the family's in bed. I've tried both slots for a month or more and both put me to sleep. You can't learn much while you are asleep so no matter the plan/desire I have to be doing something that engages my attention.

OK, I said it. Smalltalk puts me to sleep. And I feel bad for saying it. I really want to be the guy who likes smalltalk and wields it with authority. But there is just so much I don't enjoy about it and while I'm sure there are some cool things to learn from it, it just doesn't entice me. At least not at 6 am. We'll see if emacslisp can do better.

Smalltalk is like this quirky, fairly attractive girl who on paper seems like a good match for you ("Wow, you like continuations? Me too!") but for whatever reason just doesn't ignite that spark. In addition, she has lots of eccentricities that if she was "the one" would be charming/braggable. But if you are indifferent to her they just come off as irritations/oddities.

I also wonder if watching this video put the final nail in the coffin: "what killed smalltalk" (also). Just hearing about smalltalk being dead (I'm not defending this thesis) sort of activated my pragmatism module which some how grabbed the reins of my brain and executed veto power.

The thing that bugs me is that I don't see myself as a practical dude. In fact, I find the thought of being practical a little bit horrifying. I'm always doing things just because they are interesting, not because I'm trying to be more efficient, etc. And here I am making a practical decision. Ugg.

I wonder what the rules are about abandoning your "one new language a year" language halfway through the year. Is there some governing body I should contact? Do I need to ask permission first?

For what it's worth, smalltalk is not permanently abandoned; it is just pushed down on the list. If I stick with the language a year program I will almost certainly head back to smalltalk at some point. We'll see what happens next time around.

Does working with python as your primary language makes it harder to learn new languages? Every language that I've learned so far has been a productivity boost or has some other sweetener (my language history: basic -> pascal -> c -> c++ -> java -> perl -> python). emacslisp is a booster just because it is the only option in emacs (I will be looking into pymacs though). haskell looks like it might be a next step in the awesomeness hierarchy. But smalltalk doesn't *seem* (in my limited experience) like a significantly more productive tool past python. smalltalk feels like a language from which many great ideas have been lifted. And the ones that haven't yet are either in the process of being stolen (pypy - turtles all the way down) or aren't worth the trouble (image files, etc).

What's funny is that I've talked to others who have had the same initial fascination with smalltalk and then given up on it due various pain points or lack or practicality.

I guess in the end part of it is that smalltalk doesn't seem to solve a problem that I'm having in a vastly superior way and (surprisingly to me) isn't more fun. On paper it seems it should be. And I actually feel guilty for not liking smalltalk. I've failed the gods of language geekdom.

Any way, on to the new hotness of, er, emacslisp.

So why emacslisp? At the start of the year I was trying to decide between smalltalk and haskell. I was in sort of an object-y mood at the time so smalltalk won out. I'm not defaulting to haskell at this time primarily because I want to give it the full year (and it just feels like it has to be a calendar year starting in January). emacslisp works because I know it will be useful. It will make a real difference to my productivity immediately (I mostly live in emacs) and I like lispy languages (though I've only dabbled and/or used them for a semester in an ai class). *And* I don't feel too bad about giving it only half a year.

My goal with emasclisp is to get to the point where I can program in it as easily as I think (how it is for python with me now). I want to be able to whip out useful helper functions like this and be able to write my own modes and/or hack on existing emacs packages.

Any way, smalltalk, it's not you it's me. When I get my head right maybe we'll meet again and give it another shot. I wish you all the best. (but please don't call - I'm not sure emacslisp would understand us "just being friends").

Saturday, February 28, 2009

My Dangerous New Obsession

I think if I had to blame anyone, I'd start with Alan Kay. I recently read the following quote by him:

I think it is safe to say that most of the Squeak community is dedicated to making this Smalltalk more useful and accessible, and not devoted to making something so much better as to render Smalltalk obsolete (a fate I would dearly love to see happen).

Alan Kay wants smalltalk to go away? Well, if I'm going to use the man's language I should also have the decency to try to improve upon it and replace it.

So that was the start of a tiny little snow ball. And the snow ball grew. And now I find myself keeping notebooks full of ideas for creating a new programming language.

And that is my obsession. I've got it in my head that I could create a new language. And that this is somehow a good use of my time. So I'm constantly comparing and contrasting the various features that different languages have. Looking for a good idea to steal or a wart to avoid. I've been shopping around for language parsers and VMs to use.

And you know what? It's fun as hell. I actually don't have any illusions that I'm going to set the world on fire or that anyone but me will ever use my language. Or, let's be serious, that there is much likelihood that I will get past the vaporware stage. But I really feel like I'm seeing the landscape of languages with new eyes. Sort of like when you take a class on drawing and your brain starts learning how to do the "switch". And you can almost magically just draw things. I feel like my eyes are really seeing languages and language features for the first time.

So what is my language like? Not much. I've actually been avoiding trying to commit to any specific syntax. Which is probably going to make it lisp like if I'm not careful. (Not that there's anything wrong with that). When I start committing to various features it's been coming out something like a pythonized haskell (or a haskellized python) with strong nods to smalltalk minimalism. In a word its sort of an incoherent jumble. But I keep circling around and trying new things.

And like I said it's really fun. And I'm learning a lot. (And I've become addicted to starting sentences with "and").

I wonder if this is a common or rare affliction. I've never met anyone who said that they were trying to create their own language. Perhaps others are too smart to go down that road in the first place or too ashamed to admit they did and failed.

In any case, be prepared for the next big thing. Any decade now....