Saturday, January 30, 2016

Fast Object-Oriented Heap Implementation

There comes light to the darkness of your heaps.

This is the third post of a series of heap-related ones. See here and here for the back story.

In the last post, we found the heapq module lacking important features. Average Joe Dev doesn't want to clutter up his source code and and re-implement the same features all over the place to rectify the shortcomings of heapq. Understandably, Python core devs don't want to compromise on the performance of heapq either—being fast is the mission of a heap.

Tuesday, January 26, 2016

heapq and Missing Features

You sometimes need a bit more convenience than a barrel to store your water.

Recently, I wrote about heaps in Python and promised a sequel. Here, you are. This time, we ponder over the shortcomings of Python's heap module, heapq.

So, what's wrong with it? Nothing at all if you have the basic needs: fast push and pop onto a heap. However, as usual, at a certain point, you want more features in your program which in turn set the requirements higher for the heap implementation you use. If that happens, you usually

Heaps in Python

This time, we dig into the matter of how we can use heaps in Python. As a starter, you want heaps when there's a job to do like the following:

queue=[]
while necessary:
    ...
    queue.append(an_item)   # or two
    ...
    ...
    next_item = min(heap)   # what's next
    ...
    queue.remove(next_item) # we're done; remove it
    ...

Thursday, January 7, 2016

PostgreSQL 9.5 released

Congratulation to the PostgreSQL Global Development Group for finishing another release of a great piece of software. There is pretty massive set of release notes online of which I'd like to cover the most notably changes and additions.

Tuesday, January 5, 2016

Boon and Bane of IDEs

I have come to know many different people and engineers in the recent years. Many of them use IDEs for the day-to-day work. So far, so good. Though, I noticed some of them are not able to help themselves our of weird situations where an IDE corrupted some project config files or generated other strange output. Some of them don't even know how to use subversion or git without a GUI.

Sunday, January 3, 2016

Next Programming Language

Most engineers have a preferred programming language. If you are new to programming, you might ask what's the best language to learn in the first place. If you already familiar with some languages, you might ponder which one to learn next. Depending on the situation, you have many options to choose from.

Existing Projects
When joining an existing company/team, you will not reinvent the whole product line but instead improve existing software step by step. So, the question of your language skills is basically set then. You can acquire missing knowledge via tutorial, cookbooks or blogs from around the Web to get started. Deeper knowledge is gained by practicing, reading documentation, filing bug reports and submitting pull requests.

A New Projekt
If you start your own project, you can pick from the following options in descending order of priority:
  1. research what is necessary for a particular application
  2. research what others use for a particular field
  3. use Python
Option 1 should be your primary driver for learning new languages. There are various fields of computer science out there; so I might illustrate my point by providing two examples. If you want to develop Web applications, there is no way out of learning HTML, CSS and JavaScript right now. If you need to process data through Relational Database Management Systems, there is not way out of learning SQL. These are de-facto standards in their own field and you definitely need to master them.

If there's not a single way of solving a particular application domain, we go to option 2.

Option 2 basically builds on the assumption that more people can help faster. Quantity is not always a guarantee to a quality answer but there better be one at all. So, as somebody new to a language, you definitely want quick answers and involvement. A big and vivid community can help you out of misery almost instantly. I recommend Stack Overflow for this purpose. They have almost all sorts of fields related to software and hardware.

Still no idea what to use? Then we go to last resort Option 3.

Option 3 is my fallback for Turing-complete languages when I want things done (so take it with a grain of salt). There is basically nothing Python, its standard library and the bunch of openly available, third-party libraries cannot handle (except women, maybe)—may it be Web and database work (Django), dataset processing (pandas), strings, dicts/maps, dates and times and and and…

Executable pseudocode is a win-win for everybody involved. You can communicate ideas properly and even non-programmers can understand short passages of Python well enough to tell things apart. Even more and more universities switch from Java to Python for teaching programming. Furthermore, I don't like solving already solved problems. I consider that a waste of time for business applications (need job done) and teaching (get idea across).

Beware, there is more than programming when it comes to computers in general. Read on.

Broaden Your Horizon
You definitely should give different languages a try over your lifetime as an engineer. I can tell you it will give you a huge amount of satisfaction in the long run. It helps you to master computers and increase your value tremendously even though you never use some of learned language for a real project.

Not all languages are the same. They differ in several key aspects in part influenced by their history. The following list gives you a glimpse on how diverse computer languages are. Each time you pick a language make sure it fits into different categories. Thus you develop a deeper understanding when and where to use each kind of languages + its surrounding ecosystem (libs, IDEs, communities, etc).
  • Purpose (programming, data, matching, etc)
  • Style (imperative, declarative, functional, logical, etc.)
  • Chomsky hierarchy (Turing-completeness is only a part of it)
  • Old vs. New
  • Syntax and Formatting
Example List:
I wish you all the best at learning your first or next computer language.

You might ask what's the language I learn and practice currently: it's go. Why? It's because one project I am contributing to uses it as it's primary programming language. You'll see a post of that soon.

Best,
Sven

Saturday, January 2, 2016

Happy New Year!

Welcome back in 2016. I hope you are fine and made it injury-free into 2016.

Back into the lab, this post probes the suitability of blogger.com for developers. We first need some way of presenting code; preferably with a monospaced font and gray-backgrounded:

>>> print('Hello New Year')
Hello New Year