Archive for January, 2009

Why Python rocks.

Posted in Programming and Internet on January 13, 2009 by chaosincarnate

It’s probably pretty clear Python is my language of choice.  What I haven’t made clear is why. There are lots of reasons, including no compile step,  clean, readable, but powerful syntax… the choice between OOP and procedural programming. (While OOP is generically better, to quick-test a bit of code or concept, a much faster procedural test is awesome.).

Also awesome, is the fact that it’s been ported to two managed languages. Java (Jython), and .NET(IronPython). Now, you may be wondering why you’d port one programming language to another. The short form, is A: As a scripting language, and B: To access the libraries written in Java and .NET through Python. Basically, IronPython makes Python a .NET language (I.E, on level with C# or VB.NET), and Jython means python can access Java libraries and functions. mod_python is awesome if you’ve got a fresh Apache set up, but if you’ve already got a whole bunch of Java servlets… well, fitting in a few Python servlets to either prototype with, or make use of python’s exceptional agility, starts to look really appealing. 

Which brings me to the last point of Python’s Awesomeness. A live console. I’d reccomend installing python anyway, but if you want to get the idea first, go here. You’ll have to approve a security warning, as it’s an appalet running a full Python console via Jython. It’s on GNUCitizen, but if you’re the paranoid type, source is available here.

And probably the best way to get used to a new language is to play around with it a little. So here’s a quick primer.

First, the basics. (Just type this into the interactive console, hit enter to go to a new line, no real worries.

A simple math test.

print 2 + 2

This is building a list.

list = [1,2,3,4,5,6,7,8,9,0]

Printing the list.

print list

Look, an iterator!  (Just hit enter after the colon, then hit enter twice after the n.)

for n in list:
	print n

Basics out of the way, lets look at something a little more substantial (This only works in Jython, as it refrences Java code.) A more-or-less linear translation of Sun’s Swing hello world. (Put into procedural form to make it easier to type out into the console.)

from javax.swing import *
frame = JFrame("Hello, Jython!")
label = JLabel("Hey, a label!")

At this point, a Java window should pop up. Now, if you would, window your web browser with the console in it, and arrange it so you can see both the new Java window, and the python console, and type this line.

label.setText("Look, Dynamic!")

When you hit enter, notice anything? Like, how the label changed instantly, without any need to recompile, relaunch, or otherwise fiddle with it? You can do the same thing with WinForms in IronPython, and Tkinter in stock (CPython). (Though, the procedure in Tkinter is different). Overall, it provides a really agile and quick way to develop. Plus, the syntax is dead simple.



Posted in Rants and Perspectives on January 2, 2009 by chaosincarnate

Someone asked me what I would say if my employer (or a potential employer) ran across this blog. I just kinda shrugged, and apparently, I should have been concerned. I was warned about how I should care about what I post on the internet, and how I should care about my “Personal Brand”. Right about there is where my brain clicked into rant-mode.

First off, the idea that I should be in “buisness-mode” and looking out for how I can ease my fit into someone else’s expectations 24/7 just pisses me off. But it does a lot more than that. It makes me really believe that something is deeply and truly wrong. But there’s more to it than just that. The fact that someone can pass judgement on my life, even though they’re no part of it…

Let me clarify. In my private life, I listen to metal, wear lots of spiky clothing, play violent video games, and wear t-shirts with interesting remarks on them. I do such, because I like said clothes, I like said music, and said games are fun. That said, I bet a lot of people would think I’m an evil, horrible person, ill suited to do more than flip hamburgers. I won’t dispute the evil bit, but the rest of it is a bit inane. Also consider, that whenever I’m not playing a game, I’m hacking on Python, running web, email, and FTP servers for fun, running a network rig worthy of a small buisness, and usually watching the Discovery or Science channel. Now, if you took the spiky clothing, sarcasam, and metal out of that, what would you have? The local geeky kid that everyone thinks is going to grow up to be the next Bill Gates? (Though, I think we could use another Linus Torvalds more.)

It’s the old truisim that you can’t judge a book by it’s cover. But there’s more to it than that. Frequently, what someone does in their off -time (Another rantworthy concept) has precisely zero connection to what they do at work. Lets be honest about expectations here. I expect to get paid for providing a service, and you expect to recieve said service in exchange for paying me. Pretty straightforward. So, I have to ask, what part of this involves you googling for my blog, reading it, and deciding if I’ll be a “good fit” for the company? Now, if you want to see what I have to say, that’s fine. But basing an employment decision off of if the hiring manager likes what I write personally is troubling. 

Besides, who in their right mind bases their opinion of the company, by the people that work there? Besides the customer-service aspect, customers generically have little-to-no connection with your employees.  Quality-of-product is a lot more important than your employees being your kind of people.

Outside of that, most people are capable of compartmentalizing their life. I don’t insult your stupid customers, but I do fix their computers. You pay me, and you don’t worry about what I do once I go away. It seems like a good deal to me. This brings up a good point. Why should you care if someone drinks, or smokes, or gets high off the clock? In fact, most of the employers don’t care if people drink off-the-clock, or over weekends.

Why should an employer care if someone smokes pot on the weekend? Because that shows a habit? What about the people that go and get smashed every weekend? Last I checked, alcohol was more habit-forming than marijuana. Because it’s illegal? So’s driving home drunk, or drinking underage, or speeding, or running red lights. Yet, nobody freaks out about that as much. But most places do drug tests. It’s not like they’re even impairment tests. It just tells them if you’ve taken any illegal drugs in the last random timeframe. Not terribly useful to see if you’re high/drunk/wasted on the job. So, it’s basically just another lifesytle test.

In short, just another way for employers to keep track of the personal lives of their employees. Somewhere I don’t believe the employer has any place.

Rich Web Apps, in Python.

Posted in Programming and Internet on January 2, 2009 by chaosincarnate

Web apps have always been something I’ve had a lot of difficulty with. I really don’t like Java, largely for subjective and unjustifyable reasons. Also, I work at about 1/8th of the speed in Java. So, looking around online (I think for a much simpler alternative to Django), I run across Jython. Now, considering my poor google-fu, it’s not surprising I didn’t know of this before. But, considering that I frequently have need to write stuff using Java, this is one of the coolest things I’ve found. Especially once I came to the realization that, hey, I can write servlets using this! So, a simple tomcat setup later, I’ve got Python servlets, in a normal Java environment.

But, that alone wasn’t enough to get what I was going for. I had found the Google Web Toolkit before, but that would require me to write tons of code in Java. Which is theoretically possible, but really annoying, and really, really slow for me. This is where Pyjamas comes in. It’s a Python-to-Javascript compiler, with widgets. All in all, fantastically cool. It’s not as far along as the GWT, but still very useful. I’m still learning and working my way around with it, but it looks really promising.

My New Year’s Resolution:

Posted in Uncategorized on January 2, 2009 by chaosincarnate

Try to post more. That, and add more content besides just ranting. I’ve had a few interesting things happen in the last 6 months (Which is largely why this blog has not been posted to, truth be told.) Like, I live in Boise now. Oddly enough, the Boise metro is a lot bigger than where I used to live. (Lincoln, Nebraska).  But, there should be lots more shiny stuff coming this year.