Looking Back at the Mighty Function

One of the most basic building blocks of programming is the function. You call some piece of code, passing some parameters and you get back a returned value. If you grew up with any modern programming language you probably don’t even think about it. But, the function was a major innovation. In the guts of your computer there were no functions. There was just a program counter that went forward and you could tell it to jump somewhere else if you really want to (the dreaded goto).

I started programming BASIC at 11 years old. Note, this was not Visual Basic, which is a full-fledged modern programming language. This was unstructured BASIC. For me, a program was this linear set of instructions to the computer that accepted input, did some processing and then printed or drew something on the screen (a TV back then, no monitors). Each line in the code had a line number and a common control structure was “goto “. So, the program was literally a linear set of instructions executed one after the other.

I still remember my awe when I learned about the “GOSUB” command (go subroutine), which lets you execute a block of commands and then return to the line after the call. Amazing, isn’t it? No parameters, of course, and no local variable, just go somewhere and return automatically. This was still a major improvement over the “goto” statement, because with “GOSUB” you could call the same subroutine from different places in your program and it will return to the right place. If you wanted to implement it with “goto” you had to store the return line number in a global variable and “goto” it at the end of the code block. There was also the “DEF FN” pair of keywords that confused me to no end. This is arguably the worst and most inconsistent programming language syntactic structure I ever encountered. It allows you define as expression similar to Python’s Lambda functions. You have to concatenate your function name to the “FN”, so each function has a mandatory “FN” prefix such as:

DEF FNSQUARE(x) = x * x

Now you can call the your function

10 PRINT FNSQUARE(5)

Nasty. Isn’t it?

So, whenever you are frustrated with your programming language or why stack overflow has the best answer buried in third place, remember that it has never been so good and it will only get better.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

The Latest

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS

homes in the real estate industry

Exploring the Latest Tech Trends Impacting the Real Estate Industry

The real estate industry is changing thanks to the newest technological advancements. These new developments — from blockchain and AI to virtual reality and 3D printing — are poised to change how we buy and sell homes. Real estate brokers, buyers, sellers, wholesale real estate professionals, fix and flippers, and beyond may

man on floor with data

DevX Quick Guide to Data Ingestion

One of the biggest trends of the 21st century is the massive surge in internet usage. With major innovations such as smart technology, social media, and online shopping sites, the internet has become an essential part of everyday life for a large portion of the population. Due to this internet