Don’t Distract New Programmers with OOP
Programming in the 21st Century - James Hague - March 16, 2011When I get asked “What’s a good first programming language to teach my [son / daughter / other-person-with-no-programming-experience]” my answer has been the same for the last 5+ years: Python.
That may be unexpected, coming from someone who often talks about non-mainstream languages, but I stand by it.
Python is good for a wide range of simple and interesting problems that would be too much effort in C. (Seriously, a basic spellchecker can be implemented in a few lines of Python.) There are surprisingly few sticking points where the solution is easy to see, but there’s a tricky mismatch between it and the core language features. Erlang has a couple of biggies. Try implementing any algorithm that’s most naturally phrased in terms of in-place array updates, for example. In Python the sailing tends to be smooth. Arrays and dictionaries and sets cover a lot of ground.
There’s one caveat to using Python as an introductory programming language: avoid the object-oriented features. You can’t dodge them completely, as fundamental data types have useful methods associated with them, and that’s okay. Just make use of what’s already provided and resist talking about how to create classes, and especially avoid talking about any notions of object-oriented design where every little bit of data has to be wrapped up in a class.
The shift from procedural to OO brings with it a shift from thinking about problems and solutions to thinking about architecture. That’s easy to see just by comparing a procedural Python program with an object-oriented one. The latter is almost always longer, full of extra interface and indentation and annotations. The temptation is to start moving trivial bits of code into classes and adding all these little methods and anticipating methods that aren’t needed yet but might be someday.
When you’re trying to help someone learn how to go from a problem statement to working code, the last thing you want is to get them sidetracked by faux-engineering busywork. Some people are going to run with those scraps of OO knowledge and build crazy class hierarchies and end up not as focused on on what they should be learning. Other people are going to lose interest because there’s a layer of extra nonsense that makes programming even more cumbersome.
At some point, yes, you’ll need to discuss how to create objects in Python, but resist for as long as you can.
(If you liked this, you might like How I Learned to Stop Worrying and Love Erlang’s Process Dictionary.)
Categories: Blogs Programming in the 21st Century
Comments
No comments so far, you could be the first.Add comment
Erlang on Twitter
» winda_lestari63 (winda cliquers): gg usja di pikirin prins ank itw gjhe..RT:@Prinsia_2140
@Erlang_ABNIC @ji_bero @erlang_abnic @rb_120511
» ErlangSolutions (Erlang Solutions): Want to join the best of the best of the best? ESL is hiring 40 engineers! Join our Linkedin Group to keep updated http://t.co/CDB7qYeI
» Prinsia_2140 (˘⌣˘ pRiNsiAH ˘⌣˘): @Erlang_ABNI : http://t.co/j61ODMNv
» Erlang_ABNIC (Erlangga .A): JERA :) RT @AgnesMonicaFanz: #acakhuruf A-R-J-E . klue : kapok,lagu. jawab yuk NIC !
» Fedora_Updates (====================): Fedora 17 Update: erlang-misultin-0.9-1.fc17 http://t.co/u3ABUDkz
» HornedKavu (Max Riveiro): RT @shwars: Вчера в докладе career.ru на #itedu были озвучены новые востреб.профессии на IT-рынке: Haskell-, Lisp- и Erlang-программист!
» phyrexianengine (Vasily K.): RT @shwars: Вчера в докладе career.ru на #itedu были озвучены новые востреб.профессии на IT-рынке: Haskell-, Lisp- и Erlang-программист!
» Erlang_ABNIC (Erlangga .A): @cjerikho829 selamat shooting ♈o kak.. Nitip salam buat kak @Bellaudya829.. ☺ Semangat (งˆヮˆ)ง
» dessyrosalia (♡pesek mancung♥ ): Erlang ke rumahku donk kangen nih
» si_erlang (Erlangga Adhitya): 75% dalane jahanam
Statistics
Number of aggregated posts: 10498
Number of comments: 2115
Most recent article: May 15, 2012
Latest comments
» cheap soccer jerseys on Memory Models in Erlang vs Java: Nice discussion here,you are doing a great job. i was looking for this information. i found it on your page…
» mandesejohn on Couchbase Meetup at new HQ: Thanks for sharing experience. It should be really a great post. It should be knowledgeable and informative. Keep it up. flower delivery columbus ohio
» vermaseo on Scale means Skills: I’m surprised people are still commenting about this. George has been moved on to bigger and better things with the president for awhile now.ledikanten