Fast Development Time with Python

Python is a dynamic language.  In a nutshell, this means it is really easy to develop something quickly.  This fits in really well with a lot of the programming environments I have been in: we must have it finished yesterday!

Python Logo

In addition, Python is quick to learn.  If you are familiar with an existing programming language, it should be a quick study.

The language also promotes the sharing of open source code through libraries.  These can easily be installed with the pip command.

Finally, unit testing is quite easy (compared to other languages).

The overall result is quick development.

Let’s look more into these benefits of the Python language.

It Is Fast to Develop Something New

The best way I can describe this is something a co-worker once told me:

“When I develop in Python, it seems I’m talking more about the actual problem than how to solve it in the programming language.”

When I discuss solving a problem in some languages, the discussion revolves around how to implement things in the language.  With Python, I talk about the actual problem.

The language is not an obstacle to the solution.  Rather, it is an aid.  When I code things in C++, I usually spend some time thinking about the right data structure.  How can I introspect on this class in order to print out its name?  Oh, did I clean up memory properly?

Sometimes those issues are important.  A lot of times, they aren’t.  When they are not important, the main issue usually revolves around how quickly I can finish a project.

In that case, I want the language that helps me develop solutions the quickest.

Python facilitates that nicely.

Quick to Learn

Learn

If you already know how to program, Python should be quick to pick up.  The biggest “gotchas” will probably be spacing being important and no types.

No types means the code is simpler to write (but may cause some maintainability issues – I’ll write more on this next post).

I actually like the spacing – rather than braces, Python uses spacing.  This means the line after an “if” statement is indented over to indicate it is part ofthat block.

The interpreter can be used to quickly test a piece of code outside of your script.  Need to test something?  Simply open up a terminal, type in “python”, and test out your code before you put it in your script.

This is a very quick way of testing new things.  Code can be tested before putting it in your script.  No need to compile and execute the code before testing it.  It is a dynamic language, so the code can be executed immediately.

Sharing of Open Source Code through Libraries

There are a lot of libraries out there that people have developed and put on the PyPi repository.

PyPi is Python’s package index.  Just think of it like the package repository for Linux.  Just like you can “apt install” something in Ubuntu, you can pip install something in Python.

It really is that simple.


Seriously, it took me about 15 seconds to install that Python package and use it within the interpreter.

Using functions such as dir(flask) allows me to see what flask can do.  Even if a library has poor documentation, dir(lib) allows me to see the objects, functions, and attributes of that module.

That type of introspection is really powerful in order to save time during development.

Easy Unit Testing

One thing I really appreciate about this language is the ability to write unit tests without much effort.

Technical Issues

This comes from a unittest example on my Github account.

Source code:

Unittest code:

With newer versions of Python, the unittest library is build in.

If you add…

to the test file, you can run the test script as a normal Python script.

Or, you could install nosetests and run tests that way.

Either way, unit testing can quickly be added to a project.

When I compare this to C++ unit testing, it does not require different compile flags or a library to download.  For example, C++ has several unit testing frameworks.  I’m sure Python may have several different ones also, but one of them is baked into the language (with the default libraries in the Python installation).

Conclusion

If your team values really quick development, Python is a good language to consider.

Prototyping something quickly, and even releasing entire frameworks is possible.

If you are starting a new project and don’t have firm requirements on a language, give Python a shot.  You won’t be disappointed!

One comment:

Leave a Reply

Your email address will not be published.