Programming Basics for Duncan IV: Subs and Functions

In programming you’ll find that you want the computer to do the same thing again and again, usually something pretty basic. Early on, programmers decided that they didn’t want to write the same instructions again and again so they developed subroutines and functions.

A subroutine is a snippet of code that you can abstract so it can be used again and again. It can be dead simple like this one that makes the computer beep, twice:

SUB BeepTwice
BEEP
BEEP
END
Continue reading “Programming Basics for Duncan IV: Subs and Functions”

Programming Basics for Duncan part III: If and Loops

Your most basic and common decision-making statement is the if command. It always takes this form:

IF (some test that returns a boolean true/false) THEN (do something)

So you have a test and a something(s) to do if the test resolves to true. This is where we use the comparitors from last chapter:

IF x=5 THEN do something
Continue reading “Programming Basics for Duncan part III: If and Loops”

Programming Basics for Duncan part II: Primitives

It’s fun to call them primitives because it makes you feel smart but what we are talking about are the most basic things in a program.

Values

The most basic thing in a program is a value. It is what it is. It can be a number, 5 if my favourite, a letter like K or k or perhaps a decimal like 0.7. Or maybe a boolean value like 1 or 0. It is only one thing. It is a single answer to a question. It is not a word, those a strings, which are a list of values.

Continue reading “Programming Basics for Duncan part II: Primitives”

Programming Basics for Duncan Part I: Hello World

The classic first program on any platform is to output the string “Hello World”. Hang on, string? Yes, it’s a string of characters: H-e-l-l-o-space-W-o-r-l-d. Technically, it’s an array but you don’t need to know about that now.

Continue reading “Programming Basics for Duncan Part I: Hello World”

News Flash! Hosting Update

This blog started I don’t know when on some cheap GoDaddy hosting back in the ADSL days. They sent me a bill for $50 for another years’ hosting and I thought that was just too much, backed up the site and let it fall offline.

Much later, for a lark, I took a surplus Eee from my employer, put it on Ubuntu and stuck it in the server room. It worked! It worked surprisingly well, Nginx running on Linux is no joke. But all good things come to an end and the poor bastard died.

At work we had a legacy account at HostGator (a ‘baby’ package) where the main site used to live. It’s very cheap, $50 a year, ha ha, so it’s been less bother to keep it than move the few sites that were still there. It’s ‘unlimited’ storage so there would be no trouble keeping this site, sachidan.com and bartripping.com there.

The only trouble is that HostGator is complete bullshit. The site is so horrifically underpowered that any image uploaded to WordPress larger than 1MB, or even smaller, would cause the instance to crumble under its heavy load. The little Eee that the site used to be on was Concorde by comparison.

Well, enough of this nonsense, but I don’t like paying $3/month for hosting. It turns out that one of our new company websites is going to be on WordPress so I’ve been marshalling a couple of our DigitalOcean droplets into serving WordPress and since the dev server isn’t too busy anyway… The site has a new home. Regular readers (hi Dad) will notice a swift increase in performance and I won’t have to turn my photos into postage stamps to get them served.

DigitalOcean does have an out-of-the-box WordPress instance that’s actually pretty good but it runs on Apache and I’m completely over Apache. Hey, it’s a good webserver and WordPress is the killer app for Apache on PHP but, even though I find nginx server blocks occasionally infuriating, if I never have to edit an .htaccess file again I will die a happy man.

So sorry it’s been quiet lately, for years, but it’s been no fun on crap hosting, even though this site is all about crap hosting. Sooner or later I’ll buy a Raspberry Pi to host on, but until then you’ll all have to get by with cloud.