First off I decided not to build a unit test set-up as we are talking about writing a single class (to do the mandelbrot) and the web handlers, in all its just under 5,000 lines of written code and comments. So how did I get on? The timings are of course approximate, all I did was note minutes of time spent
So what did this tell me? Well first off the things I like
Python has a Complex number type that made the mandelbrot code easier
The Templating engine that Google have included is easy to use
Otherwise this was a poor language learning experience for me. Sure there wasn't the complexity and raw anger that C seemed to demonstrate when I had 7 days to justify claiming in a stage 1 interview that I knew C. Python just seemed to have a lazy disdain for what I was doing. I was using the SPE editor and quite frankly it was less advanced than Emacs at giving decent language support. It doesn't do any checking of the code you are writing against the variables and functions that exist and doesn't do autocomplete on functions unless you type it in yourself. My person favourite was something called PyCheck which I assumes was meant to help me improve my code.... nice idea but probably a better one if it didn't have an error in it
I'm sure there must be better editors out there, but frankly SPE was like coding in VI but without the performance advantages.
Traceback (most recent call last):
File "/Applications/SPE.app/Contents/Resources/_spe/plugins/Pycheck.py", line 121, in OnProcessEnded
del self.list[0]
IndexError: list assignment index out of range
The common errors early on were around scoping. Having to do self."variable" was a bit unusual in an OO language but I soon got used to it. The truly awful thing however about Python is that it is an indentation sensitive language, which was a trick employed in the 1970s to make compiler writing easier and something that people came to dread with makefiles.
Thanks to a combination of the language and an editor that didn't help overcoming the language deficiencies the cycle was "write, run, check error log" the difference between this and the Java "write, auto-compile" and the "write, auto-highlight-error" approaches that I've been used to felt like a leap backwards into the land of C.
It wouldn't be fair for me to write a similar test using Java as I've been doing that for over ten years but what I would say is that after 7 days of learning C I then had 5 hours in which to write a fairly complex address book application. My first C++ programme was a distributed CORBA system and my first Java programme was an interactive VRML app. Python's productivity I would rate as worse than C++ as a development cycle and only above C++ overall due to its prevention of segfaults via a fairly reasonable exception and pointer strategy.
Before people leap forwards, the libraries are the things that make Python better for C++ for the web. The templating library Django was a better development environment that Python itself, I especially like they way they've limited it to only those things that make sense in a templating language thus making sure that you split out the view bits and the code bits. Even down to using "end" markers for loops and ifs because it can't rely on indentation just made it feel better and more stable than the programming language. This is certainly the first time I've ever felt that the templating environment was better than the coding one.
Python is a toy language. Its quite good to knock things up with and probably rewards people who are less structured in their approach. For myself however it was certainly not a productivity gain and I became thoroughly annoyed at a sequence of typo errors wasting minutes of time. Some people will leap up and say "well you can see the changes straight away" because as a scriptoid language Python is "dynamic" and the code changes are "automatically" applied. Errr but I do that in Java as well via an ant script so the fact that I don't actually have to run a bloody test to check a syntax or semantic error is a bit of an advantage.
Its really hard to see what the fanfare is around Python, its a scripting language, it uses indentation to indicate containment. With the largest proportion of my time spent in a break-fix cycle, most of which a decent compiler would have caught, this really doesn't scream to me a language of high productivity.
A better editor might have made the experience better and more effective, so any recommendations would be appreciated. I'm still playing with the App Engine so I can revise my thoughts.
27 comments:
Wow, I'm impressed! Not only are you able to judge a programming language after 12 hours of toying with it, you're not even afraid of publishing your opinion as fact afterwards.
I'm now around 24 hours in and I'm still impressed with Django but not impressed at all with Python. I did use the word "I" a lot in the post to make clear its what I think.
Remembering my first 12 hours with:
Java (hated the syntax, didn't see it as fully OO, but loved Javadoc)
C (WTF is with these pointers, seg-fault, syntax horrors, using the force to debug, oooo function pointers)
C++ (Oh god what is this evil thing? friends... you've got to be kidding)
Eiffel (This is BEAUTIFUL, what no threading?)
LISP (this language is evil... I like it, oooo self modifying code, my brain hurts)
Perl (Nope, this sucks I'll only use it when its quick and dirty and I'll never give the code to anyone else)
C# (hey look Java with a few words changed, VS isn't as good as eclipse)
(as a selection)
I have to say that first impressions count and have been pretty much born out by the subsequent experience.
I've missed out Ada as it was the first language I was taught so I didn't learn it just for myself. I would say that having done quite a few languages, and studied language design, it doesn't take long to spot a dud.
Putting my big head on I'd say that after 12 hours in a language I'm probably at an average programming level, which is quite a good point to judge from. If Python was pitched as an advanced language then I'd wait longer before judging, it isn't its pitched as an "easy" language.
Others might do some studies and find different splits of time but the ratios are holding pretty steady for me with the error cycle probably edging up.
The truly awful thing however about Python is that it is an indentation sensitive language, which was a trick employed in the 1970s to make compiler writing easier and something that people came to dread with makefiles.
Weird! Most people say that it is the best thing about python.
Python is a toy language. Its quite good to knock things up with and probably rewards people who are less structured in their approach.
reddit.com is written in python. Doesn't look like something knocked up ? :P
Disclaimer : I don't use python. But I really think you should give a language more that 24 hours.
The indentation as the best thing? Now that is plain weird! When refactoring stuff its been a right pain in the arse as you cut and paste into sub-methods then find out that code is being executed that you didn't want.
DJango (the templating engine) uses close blocks. I've had many fewer bugs as a result.
I'm still trying out Python and we'll see how I go, but right now.... better libraries than C++ or C and I really like Django, but as a language its poor.
A quick example is around "bool" if you do int("3") you get 3. If you do bool("False") you get.... true because EVERYTHING except zero and empty sets is considered false. This is "interesting" when looking at Checkboxes/radiobuttons et al...
Hi, you need to get over this indentation thing if you're going to progress with Python. Its nothing to do with a Fortran/Cobol formatting mentality (you've got your decades wrong by 20 yrs BTW) but a response to what programmers were doing anyway at the time the languages was invented in 80s - carefully laying out their code with indents, but sometimes messing things up if they missed out an else in a if () { } else { } construct. First time that happened to me around 1984 I spent days staring at the code.
I'm not sure I buy that as a reason. DJango (the templating engine) uses endfor and endif to mark blocks. If it was about highlighting errors then a more rigorous (and less dynamic) language would seem to be a better bet. I've had a few issues due to indentation errors, mostly when refactoring as the cut/paste of the code retains the old indentation and then behaves completely differently.
Meanwhile in DJango's blocks I'm not sure I've made an error yet around if statements and loops.
You realise that you can use Emacs, Eclipse or the like to edit Python, right? Emacs and Eclipse both support Python and do all the autocomplete type things you might want. There's also support for IronPython in the latest Visual Studio.
obviously there is still plenty of language partisanship out there. Your article is subjective, your reference to a toy language is not helpful or constructive. All these languages have strengths and merits. Those of us who care about the bigger picture get tired of these subjective programmer language fights. One of the main reasons I got out of programming!! You should get out more dude.
Wow .... joking ? trolling ?
Indentation is a really really cool feature, and save a lot of time. Life is easier without braces.
(In your editor, set 4spaces for a "tab")
Eclipse is well, but it's not really aware for dynamic languages. Use OpenKomodo, which is made for dynamic language. It's far far better than eclipse in this case. And a lot more configurable !!!
It's fun ... but I dislike "django templating", which are too poor, too slow ... compare to makotemplates. (or smarty/php)
Yes languages have different merits. But I'm unsure as to what was wrong about the research in the 70s and 80s which indicated that languages like Pascal and Ada with their more verbose syntax and more rigid approach tended to produce more maintainable and less bug free systems. I've probably missed the detailed research explaining how dynamic languages in fact overcome these problems.
Indentation, and yes I know about setting tab spaces, the issue is when you cut and paste or refactor that the indentation can lead to differing behaviour. Personally I don't like braces either I prefer more declarative blocks, but having lived through makefiles I can't really see how spaces have moved us forwards.
And when I refactor in Java because it uses blocks and not indentation it will automatically match the indentation to the required style.
In Python the indentation is the block, which is where the problem comes from.
That isn't quite true if I have
if (x){
(tab)dosummat()
}
morecode()
If I have some code elsewhere that is
(tab)ooo()
(tab)aahh()
Now if I refactor in Java for these to be _AFTER_ the block then it can reformat. In Python the IDE cannot know whether the paste is meant to go inside or outside the block and will assume that it is inside the block. This is a trivial example but explains the problem, one that IDEs can't fix as its a non-deterministic problem without the blocks.
A 2001 article from a company whose site was last updated in 2002 according to copyright and 2003 according to netcraft and whose opensource project sites are unavailable via a 503
Feeling the power indeed
The content of the article goes on about how good the open source tools that the authors (who are not IBM people) are.... so I don't think its odd to point out that the article you rate refers to tools that don't exist.
I love python, I have messed about with it for a couple of weeks now and I find the dynamic nature of the language something that compiled languages just get too complicated. I did try Haskell for a while but found the whole Monads thing a bit much, considering that computers are physical machines and not made out of mathmatical formulas. I been programming commercially for around 8 years using c#, and before that Delphi. As for Java hahahaha, it leaks. Haskell is the prettiest language I have ever used, just a shame about monads. I chose python as a compromise, and as for the comment of it being a toy language....hmmmm....the language is good, and I do believe it can be compiled, and the libaries are fantastic (I mean http can be done in three lines!), Nasa use it, rackspace use it, even educated bees do it...
Python can be re-factored easily as long as you use proper methods for design. But hey, as a programmer with so many years of development experience you know about this sort of thing.
Pascal did solve many of the issues of program design but you can write a program as dumb as you like. Globals, GOTOs recursive functions that run forever and run out of stack space.
As for using Classes, I am all for anthropomorphizing of real objects, but with Service Oriented Architecture and multi-core chip systems, I think functional programming will make a revival. C# 3.0 has it and they will be doing paralleled linq quiries. The GHC in haskell already got this with its comprehension syntax, but the problem with objects is that code becomes a mess when threading an object over many chips. This is where the functional stuff works and the idea of no side effects comes in handy.
You missing the good points of python, take a look at map, filter reduce and go back to functional programming. Nothing wrong with Object thinking in general terms but you got to change your thinking if your going multi-core.
You should try pydev + eclipse. Most of the worries raised (syntax, identation problems etc..) are detected and corrected by pydev
Java = GAY
Python = 0wnz.
If you have really problems with your indentation in Python, it is either an editor issue or your code is bad structured. If you stay with a maximum depth of two or three indents per function/method you won't run in any problem.
With a decent editor you won't run in the other issues as well. There is syntax checking while typing etc. if using the right tools.
Care to name the right tools for me? Happy to give things a go. But seriously indentation as blocking is a crap idea.
Post a Comment