2009年5月14日星期四

The Simplicity laptop battery

#7) The Simplicity

At first, I was pretty worried when going through the tutorial because it had me returning HttpResponse objects in the buff with no help. As I went through it though they corrected this, and it turned out that much of the code I was writing (or just pasting, 'cause I’m lazy) was very small for a lot of work done. Each paragraph of the tutorial made the code for a generic CRUD application smaller and smaller until they showed generic views eliminating most of it.


At Django’s most complex it was manageable, and their VGP-BPS8 documentation leads you down the path of seeing the more complicated guts, and then getting easier and easier. The end result of this is you see all the simplicity you can use, but you also get to know the more detailed ways in case you have to do something weird.


This simplicity seems to be everywhere. What goes in an app? Usually just a few files with some functions in them, sometimes some regex. How do you return a response? Just make a response object. How do you set variables to a template? Just use a hashmap.


I’m sure there’s lots going on behind the scenes, but for the most part it’s been refreshing to just look at a framework and not have to dig through mountains of meta-programming just to find out why my application is showing a nasty 500 error page with headers.


#8) The Jazz

Alright, so I’m studying Jazz, and the constant references to jazz in the community really makes me smile. I mean who doesn’t love that old school cheesy as hell love ballad jazz? That alone makes the project worth it, but check out Adrian play “Tenderly” by Chet Atkins.


Dude can play.


#9) The Python

When it comes down to it, Python’s just another scripting language. Whatever, it’s not better VGP-BPS8 battery or worse than the others. It’s not revolutionary, its syntax has some warts, but it’s well documented, doesn’t crash, and has tons of great libraries already made for me. For things like making web applications, Python is great.


People who try to learn Python however seem to get hung up on three things: the “syntax”, the “white space”, and the “functions”.


First, when I say syntax, I don’t mean the real definition of syntax, but the Java guy’s definition of “syntax” which means “Curly braces so I know where things begin and end.” To people who come from a bounded language like Java reading Python is like having your eyes fly off a cliff at every turn of a dark road. Really, it’s just something you have to get used to if you want to use Python. Every language you’ll switch to will give you the same problems, but working your way through it slowly will make you a better coder.


Second, the “white space” problem is really different from the syntax for people because what they mean is that they have problems typing in Python code. Usually I only hear this complaint from Emacs users because somehow Emacs fucked up the Python editing mode so that it uses inconsistent tabs and spaces. In Python code mixing tabs and spaces is the death! Yet, here’s Emacs just going at it chewing Python like mad. I usually recommend people use any other editor than Emacs, but if they do, beg for help tuning it specifically for Python first. Getting to where all code you edit in Python is always indented with spaces is important.


Third, the problem people have with Python’s “functions” is actually that they don’t sony VGP-BPS8 battery understand the reason behind things like "".join(stuff) or even worse str(mything) which then just calls __str__. The problem is in most other languages Objects have methods you access with “.” and rarely do they use multimethods. Python however mixes these multimethods with regular methods, and sometimes inconsistently. This design choice has advantages in that common things like converting to a string don’t pollute the public name space, but the disadvantage is that it is honestly kinda ugly.


If you can deal with these three things, then Python is actually very nice and easy. The most important advantage to using Python that I’ve found is that what you want to do and what you end up writing are actually very closely aligned. Given the above “problems” with the language (to outsiders) the end result is actually very readable. Things like docstring comments (if you start a block, don’t use pass to defer it, write the comment) and self for everything (never having to explain scoping is great) just make it easier to see what’s going on.


#10) Pinax

Pinax is a series of reusable Django components that you find on almost every site done today. Here’s the short list from their site:


openid support

email verification

password management

site announcements

a notification framework

user-to-user messaging

friend invitation (both internal and external to the site)

a basic twitter clone

oembed support

gravatar support

interest groups (called tribes)

projects with basic taskVGP-BPS9/B and issue management

threaded discussions

wikis with multiple markup support

blogging

bookmarks

tagging

contact import (from vCard, Google or Yahoo)

photo management

Now, normally when someone throws a laundry list of components at you, the experienced reader says, “Yeah, those will be great until I have to modify the damn curved corner to be cornflower blue.” In this case though, I’m seeing that because of Django’s heavy focus on allowing for modular components right from the start, you can use these or modify them easily without having to tear your hair out. If one of the above components doesn’t quite work, then you should be able to (in theory) write your own and plug it in.


My guess though is that you’ll probably end up just modifying what they have since there’s like 90% of the functionality you’d find on nearly any social network site. In fact, I’d say Pinax is basically the same functionality that companies have paid huge consulting fees sony VGP-BPS9/B batteryto have implemented.


I would be very careful running to use this on a major site or paid gig before you’ve actually sat down and put something real-ish together. James Tauber and friends are more than eager to probably work with you if you got ideas (and hopefully code), but if you start drooling when you read the above list and then expect it to magically reduce your time to delivery for a million dollar project, then you are probably going to get bitten.


Then again, I could see using Pinax to start many different sites and use it as the basis for getting your potential users/customers to tell you what they don’t like. My experience has been that users can’t tell you what they want since they can’t conceive of the web site in their head, but if you show them something they’ll have plenty of ideas and needs for you.


That’s My One Battery Review Of Django

Alright, so I’ve laid out what I like, but I really only found these things by giving Django a go. Will I use it in the future? Sure, I’m planning on changing Son of Sam’s name to something more reasonable and doing a couple of sites with it. Now that I’ve used Django, I’m just gonna integrate SoS with Django and make things easy on myself. The sites I want to do can easily reuse portions of Pinax so it’ll be interesting to see how far along I can get before I hit a wall.


At this point, the only warning I’ve received is that deployment is hard, but then, deployment VGP-BPS9/B battery is hard with every web application once you start getting serious. No reason why Django would be any easier or harder.


You Wanna Try, But You Don’t Know Python?

I’ll tell you a secret, I didn’t type much Python to go through this tutorial. I actually just whizzed through it and cut-paste most of the code right off the web page. My goal was to go through the sample to understand the system, not to exercise my typing abilities. If you don’t know Python, then just try some cut and paste yourself.


Or, if you want to just try setting up a real Django app for yourself, try this tutorial on getting Pinax running. That’ll let you play with some of the gear without doing much.


Then, try out the tutorial anyway. It’ll be interesting to see how far someone can get without actually knowing much Python.


Of course, if you find you need to first learn some Python, then please don’t tell anyone I told you to skip the RTFM ritual.


All content Copyright (C) Zed A. Shaw since like 2000 or something like that.

没有评论:

发表评论