Do I qualify as a polyglot programmer? A matter of distinction.
If I could teach myself to write hello world in twenty languages that would not do it! Clearly a ridiculous way of measuring isn’t it. But seriously how do we go about qualifying whether our knowledge in a given language is of any value (to anyone, including ourselves).
A common mantra of the polyglot programmer (as espoused by some) is to learn a new language every year. This is an interesting idea, however in isolation it sounds perhaps somewhat of a generalisation without a clear purpose. It’s my experience that we human beings have an equally strong capacity to forget as we do learn (not in equal measure), and without
exercise we can easily lose some our fluency and dexterity when working with languages. If I were to learn a language every year I would no sooner forget much about them without regular usage. Can we really be expected to employ a host of languages in our day to day work and is that even the goal? I think a specialised meaning for the word ‘learning’ is what’s missing here but let’s come back to that later.
I must profess that I am extremely interested in learning new programming languages, I find it stimulating for a variety of reasons; someone (I forget who – sorry) remarked on twitter recently about how fabulous it is to feel totally unknowing at the outset of learning something totally new. Over the course of the past year I have invested significant personal time in learning both Ruby and then Python and did enjoy some small opportunity to put IronPython into practice commercially in 2009. I do not consider myself a strong Python or Ruby Developer, far, far, far from it; C# continues to enjoy my most significant attention and depth of knowledge, a reasonable outcome given it is the language I spend most days plying my trade. I do however consider myself strong enough as a developer to leverage my existing knowledge in programming and capacity to be resourceful, to employ new languages to my benefit if they are the right tool for a given job. No doubt over time and with more experience my rating with Python will increase but I am happy with where it is right now, it’s somewhat in line with my planning, expectations and requirements.
My interest in Python at this point is quite singular, it is a window to the Dynamic Language Runtime and specifically one of the languages which can be leveraged to script the more significant C# projects I am engaged in. Do I need to become equally knowledgeable in Python to leverage it in this manner? Must one exercise mastery of all chosen languages with proportionate levels of precision? My current mode of thinking on this point is we don’t need to, however, as always I am open and curious to hear other points of view.
How does one choose which language to learn next. I don’t think developers should pressure themselves into making hasty decisions in this regard. My own approach was to sample them both first – study a reasonably significant language guide (from each) and spend some time (1 hour a day) writing code (in each) – then make up my mind. After going through the ‘sampling’ exercise, I chose to Python initially however that doesn’t mean I wont one day decide to invest more time into Ruby, I like Ruby. One of the most commonly touted value propositions in learning a new language, is that it helps us become more rounded as developers opening our minds to a broader range of programming techniques and design possibilities. I think we are mature enough these days (as a profession) that the religious language wars are becoming consigned to the past, part of our less enlightened and evolved communal selves.
Most recently I have emerged myself in learning Erlang. Erlang’s established position in the world of highly concurrent distributed systems is the key to driving my interest here, I want to better understand the wider implications and possibilities in the language and platform. A secondary motive is that it will give me a good opportunity to learn a functional language after having now tasted the fruits of statically typed and dynamic languages. Does this mean I will tie myself to the Erlang banner now? Not at all, it’s just the starting place for me, I will look at AXUM and F# over the coming twelve months. AXUM may never get out of MS Research, who knows, but going on what Luke Hoban said at the PDC09, F# may reap some of the benefits from AXUM’s research, making distributed message passing a part of the language.
Will I become an advanced user of Erlang – I don’t know, for now all I plan to do is read Joe Armstrong’s book and type of bit of code at the Erlang Shell, but that doesn’t preclude the possibility that I will use Erlang in a professional capacity at some point in time.
So am I a polyglot programmer? Does it require commercial implementation or does personal study aimed at greater understanding qualify. What level of command of languages does one ascertain to become a true polyglot programmer? What languages qualify for polyglot distinction – what about JavaScript, CSS and XML, surely most web developers must find themselves in a default position of being a Polyglot just to survive in their jobs?
No commentsSpecification Pattern in IronRuby
The Specification Pattern is one that I admire and have used often and most recently to good effect with both LINQ To SQL and the Entity Framework. This little gem of a pattern came in very useful with both ORM’s to enable dynamic queries built off Expressions or to be precise Expression<Func<T>>. If you want to know more about these implementations, then look here.
More recently in my travels down the polyglot road, I wanted to give the pattern a run with IronRuby. And boy I wasn’t disappointed. Getting a specification together in IronRuby was noticeably quicker and easier however please note that it lacks the happy ORM by-product as detailed above. Best to dive straight in to the code:
class Specification def initialize(expression) @expression = expression end def Matches(match_object) @expression.call(match_object) end end
And that’s all folks. Compared to C# it’s certainly less code and I can’t help but enjoy it’s brevity. Let’s add some spice with a user defined class to test with specifications.
class Customer def Name @name end def Age @age end def initialize(name, age) @name = name @age = age end end
And now let’s test this baby out:
#pass some code to test if a given number is less than 200 spec = Specification.new(lambda {|num| num < 200}) num_to_spec_on = 123 number_is_less_than_two_hundred = spec.Matches(num_to_spec_on) puts "It is #{number_is_less_than_two_hundred} " + "that #{num_to_spec_on} is less than 200" #use a user defined class to test with a specification cust = Customer.new("Simon Segal", 35) spec = Specification.new(lambda {|cust| cust.Name == "Simon Segal"}) customer_name_is_simon_segal = spec.Matches(cust) puts "It is #{customer_name_is_simon_segal} that the customer is Simon Segal" #combining lambdas into more complex specifications l1 = lambda {|num| num > 1} l2 = lambda {|num| num < 100} l3 = l1 && l2 num = 54 spec = Specification.new(l3) number_between_1_and_100 = spec.Matches(54) puts "#{number_between_1_and_100} #{num} is between 1 and 100"
The Result’s
Looking at this code, you will see that we have dialled up an explicit arithmetic specification to test a given numbers value is less than 200 followed by an evaluation of a Customer object, testing if it’s name is equal to my very own moniker. Finally, an example of combining lambdas to produce more complex specifications. Here are the results (I am still using Ruby In Steel, which I prefer to the other options and it’s still free).
Download my learning IronRuby Visual Studio Project and code
No commentsBecoming a polyglot or dilettante programmer?
Learn a new language each year. Or so the polyglot mantra goes. Sounds feasible enough right? After all, the more experienced we get as programmers the lower the barriers to entry in learning new languages right?
Over the last six months or so I have been trying to learn Ruby / IronRuby with mixed success. First up I started by reading some free information aimed at learning POR or plain old Ruby as I call it - sorry excuse the tongue in check but I couldn’t resist the chance coin my very own ‘Plain Old’ acronym given half the chance :). I started by reading Mr Neighbourly’s Humble little Ruby Book and taking all the examples and writing them (in NetBeans Ruby Edition) and then adding to those examples with some further experimenting of my own. This was all going nicely until the real world (working life) got hold of me in one way or another and my time in following through with Ruby started to wane. I have since then attempted to reorganise aspects of my daily life in a way that would incorporate Ruby in the hope of picking up the momentum again, for example I am posting some of my Patterns series in Ruby and even bought Ivan Porto Carrero’s rough cuts of his unfinished book, but still I feel it’s not enough to really let the early work take root and ferment.
So what’s required to really learn this new language? If you think about how we learn languages and develop our skills in them, it relies heavily on becoming active in developing with the given language, however most of us are employed in an environment where the expectation is that we will be developing (with some specialisation) in a single language and on a single platform. In my opinion I believe that what is needed is a project that is persistent and on going, all of which is easier said than done, there always seems to be an omnipresence of DotNet related learning and on the surface that should take precedence; how do I choose?
This year I am going to continue my learning of XAML based UI technology, develop a DSL for data transformation in a particular domain of interest, continue my learning of the Entity Framework as deeply as possible and really give NServiceBus a lot more time and use it at every (appropriate) opportunity and of course I will continue to write this blog. So where is my quality Ruby time going to come from? Answer I don’t know but I feel strongly that being a polyglot programmer of any depth means taking on significant projects in your newly chosen language of learning. Perhaps I have to settle with being a polyglot dilettante in the shorter term?
I would love to hear some other opinions on all this.
4 comments








