The Artima Developer Community
Sponsored Link

Python Buzz Forum
perverted by language

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Rod Hyde

Posts: 23
Nickname: rodhyde
Registered: Aug, 2004

Rod Hyde is a UNIX sysadmin who has had a Road to Damascus experience with Python
perverted by language Posted: Aug 25, 2004 12:24 PM
Reply to this message Reply

This post originated from an RSS feed registered with Python Buzz by Rod Hyde.
Original Post: perverted by language
Feed Title: The landscape.
Feed URL: http://www.bloglines.com/blog/RodHyde/rss
Feed Description: The technical landscape through the eyes of an occasional indie games programmer who now uses Python as his language of choice.
Latest Python Buzz Posts
Latest Python Buzz Posts by Rod Hyde
Latest Posts From The landscape.

Advertisement
This article in the Harvard University Gazette seems to suggest that sensitivity to non-native language drops after the first year of life. This probably explains why I could never come to terms with Prolog. Joking aside, I wonder how much that applies to programming languages. Does the choice of programming language affect the way you approach a problem? Can you be blighted for life by your first programming language?

When I first started programming at the tender age of 12 way back in 1980, I started with TRS-80 Level II BASIC, progressing fairly quickly to Z80 and 6502 assembler, then flirting with the likes of Forth and Logo before learning Modula-2, 68000 assembler, then a little LISP and a large amount of C at university.

Out of those, the one that probably had the biggest effect on my programming technique was Modula-2, mostly because it was big on data hiding, encapsulation and the separation of interface from implementation. These ideas were a godsend when the size of program that I was being asked to write was nearly always one or two orders of magnitude larger than anything I'd written previously.

On leaving university, I got a job writing FORTRAN, quickly moving back into C as my employer moved towards UNIX systems. I certainly carried some of the idioms of Modula-2 into my C programming, particularly the separation of interface from implementation. As a result, most of my C programs were highly portable, nicely decoupled, and, perhaps more importantly, they were extremely maintainable.

Along came C++. I liked the idea of classes, and later templates, and found both very handy indeed. But again, for a long time I would program it as if it were Modula-2. Then there was Java. Everything was a class. Whether you wanted a class or not, you got a class, but at least it came with a good standard library, which meant that I gained productivity through not having to reinvent quite so many wheels. Most of my recent programming has been either C++ or Java, according to need.

Where am I going with this? Well, for the last 2 months, my spare time (what little there is) has been taken up with writing a simple 2D game using Python, with the goal being to learn Python. A couple of weeks ago, I did some work on the collision detection code for the game. Back in the early nineties I had written a lot of 2D code, including pixel-perfect collision detection. The brute force way of doing this is to figure out where two sprites overlap, then individually compare the pixels in the overlapping area. Not very efficient, but it was usually implemented in assembler and was quick enough compared to the bottleneck (before hardware acceleration) of drawing the actual sprites.

When I approached the same problem recently, I kept putting it off, thinking that Python would be too slow and that this level of collision detection would have to be written in C++. Yet, when I finally came to think about it, I started writing some pseudocode (in Python) and to my surprise came up with a new solution to the problem after about 30 minutes. How did Python help? Well, quite simply, by using Python, I didn't need to worry about types, classes, brain damaged idioms, memory management, or any of that other rubbish which doesn't help you solve the problem. All of a sudden, I found myself using a language which allowed me to think about the problem I wanted to solve and noth 1000 ing else. As an added bonus, the algorithm I came up with turned out to be fast enough in Python.

Would I have come up with the same solution had I not been using Python? Perhaps. I can't help but think that I'd have also got there in Java, only not as quickly.

Does the choice of programming language affect the way I think? I don't know, but next time I approach any programming problem, I'm going to use Python to do my thinking.

Read: perverted by language

Topic: Dunglish Previous Topic   Next Topic Topic: Unintended Consequences

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use