Patrick C. Keaveny

The Wordy Coder

Home / Blog / Tech / Python

Python

Tech

This summer, I started to learn a lot about developing code in the business world.

During my time at VoterTide, I learned a lot about what technology is like in the real world. From what I could tell, tech businesses usually focus on the “brute force” approach to problem solving. Which is, quite simply: Get it done. It usually doesn’t matter a lot of the time how extensible or re-usable a solution is, as most times the focus is on time rather than efficiency. Fortunately I was given the opportunity to work on projects where my solution was evaluated based on both time and efficiency, yet occasionally I did find several tasks where the “get it done” approach was the focus. Which is why developing in Python seemed fitting for these kinds of tasks.

Python is a scripting language. Much like PHP or Lua it’s dynamically-typed and contains a lot of built-in functions, which makes it optimal for fast development. For instance, in Java if you wanted to open a file and do stuff with the contents, you would need a lot of code, such as this:


Scanner input = new Scanner(System.in);
String filename = input.next();
Scanner infile = new Scanner(new File(filename));
try {
while (infile.hasNext()) {
// do stuff
}
}
catch (java.io.FileNotFoundException e) {
System.out.println("File Not Found");
}

Whereas with Python, in all its dynamic glory, this same operation can be accomplished with the following:

file_one = open('r', (filename));
file_lines = file_one.read().splitlines();

Pretty stark contrast right? My thoughts exactly. With python, you can accomplish similar tasks in Java in probably half the time and a third of the code, making it ideal for the busy and fast-paced world of business technology.

Of course, the trade-off of using such a simple and dynamic language is efficiency. With Python’s level of dynamism there are exponential levels of abstraction, where you don’t need to know how a function accomplishes a task so long as it does. When I started developing in Python, I found it interesting that I spent less time actually writing code and more time debugging and trying to figure out what the hell was going on.

In general, I’d say that Python’s dynamic and fast development time is its strength. I wouldn’t say there’s many weaknesses associated with it, other than the ones mentioned above. My only frustration with the language is the fact that I had spent so much time learning all the rules of Java that I was very annoyed with Python’s ability to just “magically” accomplish tasks, which is true of most scripting languages. Over time, I found myself enjoying developing in the language, once I got used to the idea of not having to type out the type of every variable you declare (which turned out to be immensely liberating).

Python as a language is pretty fun to develop in, and I recommend it for anyone looking for fast development time. If however, you’re used to some of the more set-in-stone and unwavering rules of the Java language as I was, don’t be too eager to throw your chair out the window once you realize how many of those rules you can just forget about. You might even find it pretty relaxing after while. If not, then at least make sure you have an inexpensive chair and non-stained glass windows.