to type or not to type…

that is the question.  Rather than a Shakespeare reference, I’m here referring to a term in software development which determines how a language deals with variables, for example.

Define: type

When you create a variable in a computer language, it’s usually something like this:

var someVarName = 1;

In a case like this, we might infer that someVarName stores a number (an integer).  We might say that the someVarName‘s type is integer.  Using a pet-ownership metaphor, it’s like purchasing a dog house first (“someVarName”) and then next buying a dog to put into it (“1”).  You wouldn’t buy a fish bowl to store a dog… although this seems to work out great if you own a cat.  JavaScript, e.g., is like this picture:  it doesn’t seemingly care if you want to store a cat in a fish bowl.

cat-in-a-bowl

Two Schools of Thought

There are two camps out there:  those who like languages which force the variable type and those who don’t.

A statically-typed language usually involves a step in which your code is converted into something else (compiling) and any type-related issues must be fixed before a program can be created.

A dynamically-typed language is run “as is” and the code is evaluated at the moment of truth—determinations about the type of a variable are made at this time.  If there is a type-related issue, your end-user could be the first person to see the error.

Statically-Typed Dynamically-Typed
Java JavaScript
C++ Python
C# PHP
C Objective-C

The Pendulum Swings

Over the past three decades, the popularity of either approach has waxed and waned.  It’s safe to suggest for the moment that the less-strict languages are gaining rapidly in popularity over their stricter counterparts.

most-popular

We have the world of open source to thank for the popularity and speed of development we’re currently seeing in these dynamically-typed languages like JavaScript and Python.

Seeing the Future

Honestly, though, there are too many people in that strict-is-better camp and their influence is felt within software development companies.  If I were to guess at the future of JavaScript, I’d probably have to say that TypeScript and Flow will gain in popularity as larger development teams look to lower the number of bugs in their code.

I don’t know, though.  Maybe it’s time that we just relax and let the cat hang out in the fish bowl.

 

magnetic card readers

Continuing in the series of fun recycling projects for these Dell Vostro 200 computers, I purchased a MagTek Dynamag USB-based swipe card reader for a new project to track visitors in the office’s entrance.

dynamag

Overview

The solution includes an Ubuntu server which only runs a single application to receive the card swipe details, to find the Track 1 data and to then submit this information to a Microsoft IIS—based website. The pages here then offer up an API for the incoming card swipe details and an administrative page for registering new visitors, reviewing the log details and the visitors as seen, to include the ability to export those details to Excel. The data is stored in a Microsoft SQL Server database.

To save cost, I decided to have each visitor just use a magnetic swipe card already in their wallet. In this way, I wouldn’t have to buy a magnetic card encoder, purchase card blanks nor worry about designing or issuing them (or trying to get them back later).

Typical Cost of an Access Control System for Visitors

From this webpage 2016 Average Card Access Cost

“Expect to pay an average of $1,500 to $2,500 per door for a high-quality system for up to 150 people. … It will cost an average of $1,000 to $1,500 for the hardware for the door. It will cost an average of $3 to $5 per keycard. Monthly service fees can range from $10 to $100 per month.”

My total cost for this project was just eight hours’ labor plus the $48.36 for the card reader! This included the database and website coding plus the I.T. work to setup the Ubuntu server and to create the Python script to talk to the USB-based reader, to test everything and to write up the documentation. This isn’t bad, considering the cost of an average system.