My Background in Coding

Where I started with coding.

Cover Image

When I was 10, my sister was learning QBASIC at high school. As most younger siblings do, I harassed my sister to entertain me almost constantly. Eventually, my sister got annoyed with me and handed me some floppy disks with games on them so I would leave her alone. These games were written in QBASIC and the files were not compiled, so I had to open the IDE (or the equivalent of) to play them. After I quickly got bored with the rather simple games, I started to mess around with the QBASIC code to see what would happen if I changed things around.

From this, I taught myself how to make my own programs; these were usually quizzes that I asked everyone in my family to complete and usually were some form of Harry Potter trivia (I was seriously obsessed). My sister was also learning HTML at school and those floppy disks contained some of the websites she'd built. They were your typical 90s web design fare with animated GIFs, marquee and blink tags, and clashing colour schemes. As with the QBASIC programs, I opened these webpages up (with some guidance from my sister) in Notepad and started moving things about to figure out what was going on. This was late 1990s, early 2000s and we had the internet but my mum ran a business so I was only allowed two hours a week on the internet in one hour blocks so I didn't tie up the phone line for too long. I used those one hour blocks of time on the internet to download and print tutorials on HTML. It was funny in a way, on 56K internet I could only find and print maybe two or three tutorials in the time I had… it's kind of crazy to think we've got internet over 1,000 times faster in our pockets at all times. I spent a lot of time learning the ins and outs of HTML, I got free web space online and hosted my Harry Potter fan site (I told you I was obsessed). It wasn't until I was about 14 that I was introduced to CSS and PHP. I took to CSS pretty well, spending hours moving divs by two pixels to get my layouts just right and then having to start over because Internet Explorer 6 implemented it completely differently and it looked like crap. I don't miss those days, but I'm not that keen on the generic framework-y mess that web design has become in recent years where most sites look like the same rehashed Bootstrap template. PHP was kind of a different kettle of fish though. I had a friend that helped me make my website a little easier to update with PHP include(). That was about the extent to which I learnt PHP and I used and reused the PHP include method across multiple recodes of what was then a help site for a virtual pet site I played (think Neopets but less commercialised). Sometime around when I was 15 or 16, when I was dabbling in a lot of Linux, I consecutively tried to pick up lots of different languages.

I tried C#, C++ and Perl all within the space of about a year. I never really got far with them because I'd hit a wall in understanding and had no one to help me. I hit the same wall every time… somewhere after loops and arrays, where the difficulty just seemed to ramp up insanely in whatever book or online tutorial I was following. C++ was one of the worst for this, I had a For Dummies book that went straight from arrays to pointers, without so much as an introduction. So I kind of just bumbled along with my HTML and CSS throughout most of my teenage years, trying different programming languages and never getting very far with them before getting overwhelmed and giving up. I didn't realise until around early 2016 was that I was missing something pretty vital to learning to program. It was pointed out to me by someone far more experienced in programming; I didn't understand the logic of what I was doing. This was evident in the types of bugs that manifested themselves in my code and my lack of understanding when the reasons for the bugs were explained. That experienced friend suggested that I would get some benefit out of purchasing a discrete mathematics book and working through it. So that's what I did. I bought a book called Discrete Mathematics for Computing by Peter Grossman and read through the first chapter. The end of the first chapter offered exercises like the following:

Modify the below algorithm so that the output also includes the position in the list where the smallest number occurs.

Find the smallest number in a list of numbers. The smallest number can be
found by looking at each number in turn, keeping track at each step of the
smallest number so far.
    1. Input the number of values n
    2. Input the list of numbers x1, x2, ..., xn
    3. min <- x1
    4. For i = 2 to n do
       4.1. If xi < min then
         4.1.1. min <- xi
    5. Output min
    

The book dictated that these lessons be completed in pseudocode similar to the way in which the question is posed. I decided that the more valuable way to approach these questions would be to code them in an actual programming language. At the time, I was learning JavaScript and I've included my JavaScript solution below but I quickly found that people online had *opinions* about JavaScript and it was extremely difficult to get assistance with certain things in the vanilla language. Some of my questions were answered with "Why aren't you using JQuery?" and the answer is "Because I'm a beginner."

var n; do{ n = Number(prompt("Insert the number of values")); } while(!Number.isInteger(n)); //Continue to prompt if is not an integer var x = []; var min; var loc = 1; for(i=0; i<n; i++){="" count="" till="" n="" for="" numbers="" do{="" x[i]="prompt("Insert" the="" numbers");="" }="" while(isnan(x[i]));="" min="x[0];" set="" minimum="" to="" first="" number="" for(i="1;" i<n;="" if(x[i]="" <="" min){="" check="" if="" anything="" is="" smaller="" than="" number,="" then="" it="" and="" note="" location.="" loc="i;" document.getelementbyid("output").innerhtml="The smallest number entered is: " +="" "="" which="" was="" value="" entered.";="" ```="" learning="" javascript="" a="" wasn't="" actually="" bad="" experience,="" certainly="" exposed="" me="" more="" of="" document="" object="" model="" (dom)="" controls="" i="" had="" previously="" used.="" anyway,="" framework="" centricity="" put="" off="" decided="" learn="" php="" instead.="" should="" probably="" that="" going="" back="" non-web="" language="" never="" really="" something="" considered="" seriously.="" i've="" got="" pretty="" solid="" base="" in="" web="" so="" wanted="" build="" on="" that.="" besides,="" most="" projects="" want(ed)="" code="" were="" best="" suited="" be="" applications.="" did="" all="" lesson="" 1="" exercises="" some="" months="" before="" picked="" up="" php,="" redid="" exercises.="" ```php="" <?php="" this="" utilises="" strict="" typing,="" introduced="" php7.="" if(isset($_post['submit'])){="" $numberlist="ForceArrayType($_POST['numberlist']," float);="" above="" calls="" helper="" function="" included="" another="" file.="" basically="" just="" casts="" type,="" otherwise="" returns="" an="" error.="" $i="0;" $x="0;" echo="" '<br="">
You entered:
'; foreach($numberlist as $eachinput){ $x++; if($x > 10){ break; } if(!is_numeric($eachinput)){ $i++; //Counts any non-numeric values for avg calc correction continue; } if(!isset($min) || $eachinput < $min){ $min = $eachinput; $minloc = $x; } echo $eachinput . '
'; if(!isset($max) || $eachinput > $max){ $max = $eachinput; $maxloc = $x; } } $count = count($numberlist) - $i; echo "
The smallest number is $min which was located in box number $minloc"; echo "
The largest number is $max which was located in box number $maxloc"; $avg = array_sum($numberlist) / $count; echo '
The total sum of the numbers is ' . array_sum($numberlist); echo "
The average is $avg"; } ?>

I expanded on this one a little over the initial exercise, adding a sum and an average of the list of numbers entered. I am glad to have finally found a method that seems to work for me and a place to find exercises to do as practice seems to be the most important part for learning and in particular, being able to add features and then troubleshoot those features. Here are a few other resources for PHP exercises I found during my search for things to code: Exercism PHP Exercises, PHPExercises.com