Jun 20
I have been doing some of the exercises at Project Euler lately. Project Euler describes themselves as:
A series of challenging mathematical/computer programming problems that will require more than just mathematical insights to solve. Although mathematics will help you arrive at elegant and efficient methods, the use of a computer and programming skills will be required to solve most problems.
It has been a lot of fun to code these up in my language du jour, Python. There are a couple of problems that Python’s built in libraries have made trivial. I have to admit the most enjoyable part for me is having problems that require efficiency in algorithm. For the simpler problems, I usually just quickly hack together the “naive” brute force method, figure out that it doesn’t scale and then start investigating how I can fix it. Doing this, you will exercise your mathematics, computer science and programming skills, something that a lot of programming doesn’t do.
I convinced my girlfriend to work with me on one of the exercises, and of course she picked one of the Prime Factorization problems. The naive brute force algorithm would not be an option for the large composite number given, so we ended up hacking together a Sieve of Eratosthenes. Ultimately, we got a version working, but it was still pretty inefficient, only returning the answer in about an hour. An optimal version should be able to do it within seconds. Obviously there is some “refactoring” to do.
Sep 27
# uname -a
Darwin Matt Michie’s iPhone 9.0.0d1 Darwin Kernel Version 9.0.0d1: Fri Jun 22 00:38:56 PDT 2007; root:xnu-933.0.1.178.obj~1/RELEASE_ARM_S5L8900XRB iPhone1,1 Darwin
# python
Python 2.5.1 (r251:54863, Jul 27 2007, 12:05:57)
[GCC 4.0.1 LLVM (Apple Computer, Inc. build 2.0)] on darwin
Type “help”, “copyright”, “credits” or “license” for more information.
Mmmmm tasty! iPhone with SSH, Python, BSD subsystem. Life is good.
Jun 29
Linux : FreeBSD :: Ruby : Python
Discuss.
Jun 17
Last month, a lengthy discussion kicked off on Ruby-Talk called “Why not adopt Python style indentation for Ruby?” .. it wasn’t anything particularly new, because a similar discussion occurred six years ago. Nevertheless, a coder called Jinjing has been inspired to create Lazibi, a Ruby pre-processor to allow one to use Python style indentation within Ruby code.
http://www.rubyinside.com/lazibi-python-style-indenting-for-ruby-532.html
Why not just adopt Python altogether? :-P So close and yet so far.
May 29
“Alan Kay of Smalltalk fame, friend of Seymour Papert of Logo, champion of One Laptop per Child (OLPC) has become our new keynote speaker (EuroPython by transmission) and provider of new hope to many a would be Python learner. That’s right, Alan has adopted Python as his new pet language”
From: http://worldgame.blogspot.com/2007/04/declassified-letter.html
May 24
I’ve noticed one of the problems I have writing this blog is that I prefer to have finished thoughts when I write up something, or at least to have a good understanding of a problem I am working on before committing it to ‘paper’. Unfortunately, this doesn’t lead to many updates. I’ll try to break this habit a little. Recently I heard the term ‘Monkey Patching’ after one of the Seattle Patterns Group meetings, in relation to Ruby on Rails.
A Monkey-Patch (also called Monkey Patch, MonkeyPatch) is a way to extend or modify runtime code without altering the original source code for dynamic languages (e.g. Ruby and Python).
Today, reading a blog entry from Chad Fowler, the term came up again with a Python developer saying:
You can monkeypatch code in Python pretty easily, but we look down on it enough that we call it “monkeypatching”. In Ruby they call it “opening a class” and think it’s a cool feature. I will assert: we are right, they are wrong.
When I read that, I felt almost relieved, because I was thinking the same thing. I can see a limited use for it, but it seems like something you should only do in dire circumstances, that it would be detrimental to good software engineering practices. I can’t prove this, nor am I totally convinced, but Ruby and Ruby on Rails in particular seems to play a little bit fast and loose. I suppose this fits in with Agility, but there does seem to be a mental divide between Python and Ruby people (even though they are really quite close linguistically). To date, I’m much more in the Python camp, but I’ve been deploying Rails apps at work, and I’ll be delving more into Ruby as I go forward. I have heard rumors that Zope does Monkey Patching, and this convinces me even more. Zope has almost single handedly destroyed Python’s reputation at my place of work. Thanks Zope!
Jan 12
Gary Wilson has written up a post detailing the cyclomatic complexity of Django (the Python web dev framework).
Wikipedia defines cyclomatic complexity as:
Cyclomatic complexity is a software metric (measurement) in computational complexity theory. It was developed by Thomas McCabe and is used to measure the complexity of a program. It directly measures the number of linearly independent paths through a program’s source code.
The concept, although not the method, is somewhat similar to that of general text complexity measured by the Flesch-Kincaid Readability Test.
Cyclomatic complexity is computed using a graph that describes the control flow of the program. The nodes of the graph correspond to the commands of a program. A directed edge connects two nodes if the second command might be executed immediately after the first command.
It isn’t often that you see software engineering metrics applied to open source projects. I wonder why that is?
Aug 27
Apparently Django might become the defacto Python framework. Django is pretty good, but I’m kind of surprised that Turbogears didn’t get the nod.
Link
Recent Comments