Thursday, December 30, 2010

Resolutions for 2011

  • Travel to Europe again.
  • Travel to Asia or Africa.
  • Visit a Disney park.
  • See a place in the USA I've never been.
  • Drop the waist size 2 inches and not break any bones.
  • Go to Pycon and present or teach.
  • Go to DjangoCon and present or teach.
  • Present at LA Django
  • Continue my Muay Thai and Capoeira studies, get back into Eskrima, learn some more BJJ, and practice the forms I know.
  • Work out at least three times a week.
  • Go back east and teach martial arts for a day.
  • Finish some outstanding legal proceedings.
  • Launch a site that does cool stuff and somehow brings in money.
  • Get to the point with LISP where I can do cool stuff in it without needing a textbook.
  • Blog once a week. That is at least 52 blog entries!
  • Explain why I wrote Diversity Rocks.

Recap of 2010

This has been an unforgettable year. I can't believe all this stuff happened. I've moved many times, met wonderful people, and seen my life change in ways I could have never predicted.

The good:
  • Met a whole new bunch of wonderful people - relationships to last a lifetime. Arthur, Audrey, Celso, Cody, Daniel, Jacob, Jeff, Lahn, Moriah, Skyler, Todd and others I'm certainly forgetting to my undying shame. Thanks for your awesomeness!
  • Presented and taught at Pycon 2010.
  • Had a blast in the blizzard of 2010.
  • Prepped my house of 9 years for sale and sold it.
  • Paid off my debts. I sleep so much better now.
  • Left NASA after 5 years and 3 months for freelancing pastures. Thanks Eldarion LLC, Revsys LLC, Holdenweb LLC, and Bryan Klein. Being exposed to some of the incredible code and developers on these projects has made me a better developer. Show me more!
  • Flew enough in the spring to put me ahead of notorious traveller James Tauber for about 2 months in sheer mileage accumulated.
  • Got to reconnect with a cousin and met his lovely wife and handsome son. Also hung out with my Uncle Al and Aunt Sandra.
  • Got a tour of Ames Research Center thanks to Michael Sims. He'll probably be presenting at Pycon!
  • Attended another NASA wedding by Mark and Ariel.
  • Took a cruise to Mexico on a ship that caught fire just months later.
  • Said goodbye to Virginia and moved to Lawrence, Kansas to run with the unicorns and 5 months later to Los Angeles, California.
  • Road tripped across the Western half of the country! Twice! Spent 3 days in Las Vegas over Halloween!
  • Learned fundamentals of Capoeira from Celso Wills. Wish I could learn more from him. :(
  • Learned how to drive and bought my first car.
  • Worked on another course for Holdenweb LLC.
  • Launched Django Packages.
  • Presented at DjangoCon 2010.
  • Started Muay Thai classes in Los Angeles. I've done quite a bit of it, but these were the first regular classes I've had in about 16 years.
  • Brought my son to Los Angeles so I could spend a week with him for the first time in 15 months.
  • Almost up to 7 years without a broken bone!
  • Worked another year in Python related technologies.
  • Started learning LISP and played a lot more with JavaScript (especially JQuery and JQuery UI).
The bad:
  • Left my students in Virginia. The young ones were especially hard to let go.
  • Had to say goodbye to friends in the DC area. Some people I'll miss are Alex, Beth, Brandon, Chris, Dave, Daye, Eric, Jim, Joe, Katie, Muhammed, Pilar, Rich, Renee, Ron, Sarah, Sebastion, Shawn, Steve, and Whitney. I know I'm missing some names!
  • I'm far from all my immediate family: Carla, Ciana, Dad, Doug, Michele, Midori, Mom, Seth, and Timiri.
  • Watched NOVA Django falter after I left the DC area. 
  • Had to wait 15 months between spending more than a day or so with my son.
  • Didn't really practice much Eskrima all year.
  • Didn't blog enough. Last year I blogged almost twice as much!
  • Frustratingly, haven't been able to finish something that prevents me from writing about certain things. Yes, this is quite vague, and my hope is to clarify it in a few weeks.

2010 Resolution Summary

Items that are crossed out are completed.
  • Sell the house, pay off the remainders of my debts, and get my own place to stay. And get a car too.
  • Travel to another country.
  • Take my son to another country.
  • Drop the waist size 2 inches and not break any bones.
  • Go to an amusement park, visit the beach, and also see a part of the USA I've never been.
  • Do more educational work for Python related technologies, and that includes getting the Django Education Foundation really rolling forwards.
  • Throw away at least half my current stuff. I don't have much stuff now, and I want even less. Also, If I don't use or interact with any one of my non-book remaining possessions by 2011, I'm throwing it away.
  • Move my blog to my own system and blog at least once a week.
  • Get a mountain bike and have reasons to use it.
  • Get back into Eskrima, focus more on BJJ, get into Capoeira.
  • Hire a maid. I'm not messy, but I want someone to do the fine tuning of my place.
  • Go to Pycon, DjangoCon, and a new conference.
  • Have a beer with Thomas, Andy, Andy, Tony, Garrick, Bernd, and the rest of Ye Aulde Gange.

Monday, December 6, 2010

Reactions to "Stupid Template Languages"

My blog post on Stupid Template Languages has had some excellently crafted responses by Armin RonacherMike Bayer, and Steve Holden. I respect and admire each of these developers, and their combined projects have made a real impact on my career. I'm happy that our community is large enough to have a difference of opinion, delighted that our base language of Python allows us the power to play with different options so easily, and hope that we can debate our differences of opinion this year at PyCon. The first round of drinks are on me!

Friday, December 3, 2010

Stupid Template Languages

For years I've been absolutely certain that I really prefer stupid template languages any time I'm generating HTML. The less the template language can do the better. Since I spend most of my time coding in Python you might assume this applies just to Python, but I think it also applies to anything where you have the power to readily mix HTML generation and code.

The biggest annoyance I have with smart template languages (Mako, Genshi, Jinja2, PHP, PerlColdFusion, etc) is that you have the capability to mix core business logic with your end views, hence violating the rules of Model-View-Controller architecture. While the web can be hard to match to MVC, in general you aren't supposed to do that sort of thing. I've made the mistake of putting core logic in the wrong places in the past, but I'm proud to say I've gotten good at avoiding that particular mistake.

I don't work in a vacuum.

I often work on projects crafted by others, some who decided for arcane/brilliant/idiotic reasons to mix the kernel of their applications in template function/macros. This is only possible in Smart Template Languages! If they were using a Stupid Template Language they would have been forced put their kernel code in a Python file where it applies, not in a template that was supposed to just render HTML or XML or plain text.

What it comes down to is that Smart Template Languages designers assume that developers are smart enough to avoid making this mistake. Stupid Template Languages designers assume that developers generally lack the discipline to avoid creating horrific atrocities that because of unnecessary complexity have a bus factor of 1.

So what is a Smart Template Language?

In my own vernacular, template languages that let you write functions/macros are what I call a Smart Template Language. Some of them are brilliantly executed, the example of Jinja2 comes to mind, but invariably I suffer through abuse of its Macro control structure as implemented by others.

Misery Cubed a.k.a. Genius Template Languages

Next comes Genius Template Languages, which take things a step further. These template languages allow you to not only define functions/macros, but also let you embed unrestricted Python (or Java or Ruby or whatever) in the template. This 'feature' lets you code your entire application in the templates!  In the Python world what comes to mind is Mako and Genshi, but I'm sure there are many other tools with this 'capability'.

I like Stupid Template Languages!

Stupid Template Languages don't let you define functions/macros. They don't let you embed Python code. They barely let you define variables and often have simplistic control architectures.

For Django efforts, which is about 70% of my work, I like the Django Template Language (DTL). Since it is used by a huge community, there are a ton of useful apps which have it as a dependency. Switching away from it would mean cutting myself off from a large ecosphere of tools I can use to not reinvent the wheel.

Back in my Zope/Plone days I really, really enjoyed the Template Attribute Language (TAL) because it was stupid too. If I needed an XML generation template language and could import it easily I might consider using it again, or perhaps Chameleon, which is a new, improved version . The downside is that they come paired with another tool paired with it, METAL, which gave it macros. My own experience with METAL is that it was all too easy to do what we developers do with Smart Template Languages.

But DTL and TAL are slow!

So what?

If you want to boost your performance, first try caching. There are a ton of tools you can use, with Varnish being one I keep seeing in action. Read the docs on your favorite web framework's caching engine and apply what you learn. And Djangonauts should read up on Mike Malone as much as possible.

If after all that the site still delivers slow content and it appears to be a template language issue, then identify the bottleneck content and consider alternatives for that one portion. My favorite response is a bit of AJAX. Use your framework to render the content as JSON and have JavaScript parse it into legible content, a task which JQuery makes trivial.