2014-03-25

Coder in Training

I got my first computer back in the early 1980s. It was a (Tandy Radio Shack) TRS-80 MC-10. It was about the size of a modern netbook folded up, and was basically just a keyboard on a box. You used a television as your monitor, and a cassette tape player for data storage. If you wanted it to do something, you had to type in the BASIC program manually every time, or save it to the tape. You didn't want a very long tape, since every program would be like a song. and you would have to let it play until it found what you were looking for.

The MC-10 came with 4 KB of RAM, upgradable to 20 KB by means of a 16 KB module. To give you some perspective, my current computer has 6 GB of RAM. That means that I now have about 300,000 times more memory than back then. Surprisingly, however, 20 KB was plenty to hold and execute any programs I used at the time, and this little computer forced you to at least type in computer code, even if you did not understand it all at the time. You were exposed to it, and could figure out how it worked, if you wanted to.

My next computer was a (TRS-80 Color Computer) CoCo II with 64 KB of RAM, followed up soon after by a CoCo III with 128 KB of RAM that I upgraded to 512. That was a huge amount, and it could run graphical games, and the Microware's Unix-like OS-9 operating system. That made for a powerful multi-tasking computer, that you could really do a lot with. With a 5.25" floppy drive, and cartridge slots, you didn't have to get your hands dirty with coding, unless you really had the interest.

Even with these computers, I didn't spend a lot of time programming, so I was very basic in BASIC. When I was in university I did one computer course which included an introduction to Fortran, but I don't know what use that is these days. Being down in the underbelly of a language was being replaced by (forth generation programming languages) 4GLs.

I have an uncle who wrote programs in Progress for some large companies, and he wanted me to give him a hand, so I started learning that. My situation changed around 1994, however, and I ended up moving away before making much progress with Progress.

After moving, there came an opportunity to learn another 4GL, Clarion. I liked this one. It was easy to make a polished looking final product for the client, without knowing too much about what was happening in the guts of the language. Again, however, things changed, and Clarion fell by the wayside.

While all this was going on, something called the World Wide Web (WWW or just Web) was taking off on the Internet. I'd been using the net since the early 1990s via dial-up using modems. Things were mostly text-based back then with Pine for email, and services like Gopher and Archie. Even on the early Web, the Lynx browser was text only. You had to download an image to view it. Once Netscape Navigator came along, and things got a lot more colourful, putting my own website online became of interest.

There were many free services popping up for people to establish their own presence on the Web. All you had to do was learn a simple scripting language call (hyper-text markup language) HTML. It let you embed images, and make words linkable to other places with a simple click of the mouse. So, by the end of 1994, I had put together a page using Notepad, and hosted it on Geocities, where is lived for many years.

Everyone wanted a website, so I was able to make a little money now and then by writing some simple HTML pages for clients. Eventually, I needed to add more features, so I started using (PHP: Hypertext Preprocessor) PHP as well. I wasn't exceptional at either, but back then it was enough to keep people happy. Eventually, websites got fancier and more complex, and I got left behind.

Jumping back to around 1992 or 1993, I started hearing about this thing called Linux. It was a free, open-source operating system. A couple years later I got my hands on a copy of Debian on a bunch of 3.5`floppy discs, but couldn't get it to work on my hardware, so it was put aside for a while. Somewhere I got a copy of  Linspire, which I was able to get that running, and thus began my life as a GNU/Linux user.

The reason for talking about GNU/Linux, is because it is free, and most of the software for it is free. That is in both contexts of price, and your ability to modify it. After using things that people give you, eventually you think that perhaps you should give something back. And to do that, I need to get into programming more seriously. These days that means learning something like Python, C++, or Java.

After doing a little research, I decided to go with Python. A couple of us were going to build a bot for a Linux IRC channel we were on. The project went nowhere, and neither did my learning Python. Sometimes there is a lot more chat in a group than there is action.

Moving up to 2013, there are a bunch of formulas for evaluating different aspects of sailboats. I actually had a really nice PHP page made up for doing all the calculations. After I took my personal web server down, I transferred them all to a nifty LibreOffice spreadsheet. That was fine for me, but I wanted my friends to have access again like they did on the website. Another project for Python.

This time around I discovered that there are (Integrated Development Environments) IDEs. For Python you can use the likes of Eclipse, IDLE, and Eric. And wanting a graphical program that ran in windows, I found out about tkinter. I had the first formula, Speed=1.34x√LWL, working in the console, but broke it in the GUI. Trying to figure out what went wrong hurt my head, and I was halted again..


Then along came Coding 101 on the TWiT network. Their unconventional training method was to get people introduced to writing programs, and methodologies, not a complete A to Z lesson to show everything about a language. The problem was that they were starting with C# using the Visual Studio Express for Desktop. So, I was going to be starting with yet another language.

As an additional C# resource, I started watching the more complete, step-by-step instruction videos from Channel 9, and their C# Fundamentals: Development for Absolute Beginners series. This one really got me programming. Here is my first C# program code to do the same thing I was working on in Python.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HullSpeedConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            // Call to console for the waterline length of the boat in feet from the user.
            Console.WriteLine("What is the waterline length of your vessel in decimal feet (eg. 27.36)?");
            // Assign Length WaterLine Input (lwlIn) to String for input from console.
            string lwlIn;
            // Assign length waterline (lwl) and calculated maximum speed in knots to Double
            double lwl, speed;
            // Obtain the value submitted by the user from the console.
            lwlIn = Console.ReadLine();
            // Test that a usable number was provided and
            // Convert the waterline length string to a double for use in the sqrt function.
            bool testIn = double.TryParse(lwlIn, out lwl);
            if (testIn == false)
            {
                // Add a blank line.
                Console.WriteLine();
                // Print a warning to console.
                Console.WriteLine("That was not a valid number. Hit [Enter] to close window.");
                // Keep window open until [Enter] is hit.
                Console.ReadLine();
            }
            else
            {
                // Calculate the maximum speed of the boat rounded to 2 decimal places.
                speed = Math.Round(1.34 * Math.Sqrt(lwl), 2);
                // Add a blank line.
                Console.WriteLine();
                // Display the output from the formula to the user in console.
                Console.WriteLine("Your boat has a calculated maximum speed of " + speed + " knots.");
                // Add a blank line.
                Console.WriteLine();
                // Write instructions to console.
                Console.WriteLine("Hit [Enter] to close window.");
                // Keep window open until [Enter] is hit.
                Console.ReadLine();
            }
        }
    }
}

And that brings us up to today. Maybe I will make more progress this time around. It has only been 30 odd years.

No comments:

Post a Comment