Category Archives: languages

Perl as a 2nd language: Modules

This is part 2 of a series on Perl, intended for experienced software developers.

Re-learning Perl has not been easy. Continue reading

Advertisements

Perl as a second language: Step 1

Why 2nd languages? With hello world, and readme.pl

I want to help other people kickstart new programming languages. As an experienced developer, you already what a loop is, or any other common feature: you just want to make it work. The goal of my “second language” posts is to provide that level of help. Continue reading

Your Next Language

I have been re-learning Perl, for a maintenance project at work. If you don’t have a specific task like that, have more fun while learning, with something like a “joke” program that uses the Fibonacci series to display a list of all the characters Lady Gaga has played in her videos. Or the names of Rebecca Black’s songs. Or maybe something interesting instead.

Obvious

Good place to start. Lady Black deserves the best: Continue reading

Shell: ‘seq’ generates a range of numbers

I don’t use this often, but I keep forgetting it – probably because I don’t use it often.

$ seq 146 151
146
147
148
149
150
151

Too long is too bad

Long is good. Too long is too bad.

Steve McConnell tells us in Code Complete, that long variable names are good. I think it’s in the section on “Self-documenting code”.

In object oriented languages, you have the object name, the name of a possible sub-object, and the name of a particular field or item in the object, which all add up to a descriptive long name, but split into different parts.

Example: mypack.special-effect.color = chartreuse

However, I have been working in Gnu Make lately. Gnu Make recommends that you only use numbers, letters, and underscores in Make, as other characters may be used for other special purposes now or in the future. Now, in Gnu Make, you don’t have real objects. You do have “constructed variables”. By using recipes with wildcards in them, and constructing variable names with pattern substitution, you can get some of the same effect as objects. However, the variable names look kinda ugly.

Example: testset_special_effect_color = chartreuse

Its easy in make to get a few lines like the following. The intent here is to make a copy of one pseudo-object that will only be used when code coverage is in effect:

# Initial special effect setup
regression_mypack_special_effect_targets = \
  testset_chartreuse \
  testset_bland \
  testset_monochrome
  
regression_mypack_special_exec = mypack_special_exec
  
# copy for code coverage
regression_mypack_special_effect_ccov_targets = \
  $(testset_mypack_special_back_targets:%=%_ccov)
  
regression_mypack_special_back_color_iterations := 4

My problem was that I copied the variable name wrong. In line 8, I wanted to make a copy of the list of targets, with the names modified to be the ccov version of the targets. The difference is nearly invisible in the middle of the long variable name.

Verbose, clear variable names are an important part of self documenting code. Monotonous names with only underscore separators make that hard. Yet another reason to avoid “make” for complex projects.

Fun OGRE meeting!

There was a lot of activity at the OGRE meeting tonight, including knowledgeable questions and answers, and a great video setup in a meeting room at Jaded Pixel Technologies (Shopify).

John Duff demonstrated the Devise authentication framework with Facebook.

Jonathan Sutherland was persuaded to show off his Rails-based real estate agents’ web site.

Dwayne recorded much more detail than I have in a post to the OGRE mail list, including code links.

Test driven design in Bash

To test your bash scripts, or to use Bash to test other scripts, you need a way to create tests quickly and easily. I created a library to support testing in bash. I have used this library to test Bash, Python, and Perl scripts.

An updated version of the source code is available on GitHub.

Continue reading