Friday, April 16, 2021

How to start a career in coding


A couple of days ago, a good friend of mine asked me how to make her kid more interested in programming. I think that parents should focus on giving kids opportunities to try different things instead of pushing them to take a route. Success is guided by motivation, and motivation comes from the inside. The best programmers I know started and continued their careers because they enjoyed the craftmanship of coding. They were attracted to the cryptic look of a screen full of code. They liked the tactile nature of typing code on a keyboard. They were amazed by how a series of words in English mixed with special characters lead the computer to show something on the screen. They quickly grasp the idea of a series of steps typed in a text file and how the computer understands these steps and executes them. They early discovered that the computer is, in the end, a dumb machine that obeys the programmer. None of them told me something like, "I started to program computers because I knew I would have a job in the future." No. The motivation is in the craftsmanship.

Like with many other disciplines, you can try programming and see if you like it. I started when I was about 13 years old. Since it seemed my brothers and I liked computers and we had gotten our first one, my parents bought a series of books on computers for kids. The third book was about programming. The programming language that the book explained was BASIC, a general-purpose language with an easy-to-read syntax. I don't think you need to be a kid or a teenager to start a career in software development. All you need is to experience coding by yourself and be honest with your feelings. If you enjoy the process, you'll get trapped in it and your curiosity will guide you.

So, let me show you how you can try coding by using the BASIC programming language. Unlike in my days of learning how to program, you don't need to install anything (lucky you!). Head to https://www.jdoodle.com/execute-freebasic-online and follow the rest of this article. This won't work if you don't go and open that page, preferably, from a computer (as opposed to a mobile device).

What you see on the website I pointed you to, is a screen divided into several sections. On the top, you have a text editor where you'll be typing your code shortly. At first, you'll find a short program already typed for you. Remove all that. Select the text and hit the delete key on your keyboard. We want to start coding from scratch! Next, you'll see a section to configure things out. I want you to make sure that you turn the "interactive mode" on by clicking on the switch that says Interactive. The switch should be turned to the right. Next, you'll see the area where the result or output of the program is displayed.

A programming language consists of words. Very few words actually, especially when compared to a human language. We are going to use upper-case for those words that are part of the BASIC programming language. For the rest, we'll use lower case. Let's get started! Type the following on the code editor at the top of the page:

PRINT "This is my first program ever!"

Click on the Execute button. You'll see the text "This is my first program ever!" on the output. Try adding another line of code to make the program show the message "I'm coding!" in the output.

PRINT "This is my first program ever!"
PRINT "I'm coding!"

Remember to click on the Execute button every time you want to see the result of your program. You'll see that the output shows the texts in the order in which you typed them in the code editor. Try switching the lines of code:

PRINT "I'm coding!"
PRINT "This is my first program ever!"

Once again, the output shows the messages in the same order as your instructions. The computer executes each line at a time from top to bottom. Let's try an essential concept in programming—variables. A variable is a space where you can store a value like a number, for example. A variable has a name and you are free to use any name as long as you don't use a reserved word like PRINT and others. Define a variable to hold a number by inserting a line of code at the very beginning of the program:

DIM n1 AS INTEGER = 7
PRINT "I'm coding!"
PRINT "This is my first program ever!"

The line you added tells the computer to create a variable with the name n1 and store the value 7 in it. The variable is ready, so you can make the program tell its value:

DIM n1 AS INTEGER = 7
PRINT "I'm coding!"
PRINT "This is my first program ever!"
PRINT n1

When you run (another term for "execute") the program, you'll see the number 7 in the output. Imagine that the variable n1 is the computer's favorite number, so you want the computer say "I like the number 7". You can just use PRINT "I like the number 7" but that's boring. Instead, let's use the value in the variable n1. To do that, you need to add the value at the end of the text "I like the number ". To do that you can use the ampersand character (&):

DIM n1 AS INTEGER = 7
PRINT "I'm coding!"
PRINT "This is my first program ever!"
PRINT "I like the number " & n1

Run the program and see how the computer tells you the number it was programmed to like. Change the value of the n1 variable, and rerun the program. For example:

DIM n1 AS INTEGER = 4
PRINT "I'm coding!"
PRINT "This is my first program ever!"
PRINT "I like the number " & n1

A cool thing about variables is that they can store values you can type when running the program. For example, let's make the program ask you what number you like. For that, you can use the INPUT keyword of the BASIC language. We need three new lines. One for telling the computer that we need another variable (to store your answer), one to ask the question, one to get the input from the keyboard. Add them at the end as follows:

DIM n1 AS INTEGER = 4
PRINT "I'm coding!"
PRINT "This is my first program ever!"
PRINT "I like the number " & n1
DIM n2 AS INTEGER
PRINT "What number do you like?"
INPUT n2

Run the program and answer the question! Type a number and hit ENTER. The instruction INPUT n2 tells the computer to pause the execution of the program until the user (that's you as well since you are the programmer and the user of your own program!) types a number and hits the ENTER key. The value that the user types is stored in the n2 variable. Now you can use the value to show another message to the user:

DIM n1 AS INTEGER = 4
PRINT "I'm coding!"
PRINT "This is my first program ever!"
PRINT "I like the number " & n1
DIM n2 AS INTEGER
PRINT "What number do you like?"
INPUT n2
PRINT "Cool, I also like " & n2

A powerful thing computers can do is compare things and execute code if a condition is fulfilled. For example, let's say you want the program to show a message if the number that the user introduces is greater than 999. You can do that by using the IF and THEN keywords:

DIM n1 AS INTEGER = 4
PRINT "I'm coding!"
PRINT "This is my first program ever!"
PRINT "I like the number " & n1
DIM n2 AS INTEGER
PRINT "What number do you like?"
INPUT n2
PRINT "Cool, I also like " & n2
IF n2 > 999 THEN PRINT "It's a big number!"

The last line checks whether the value stored in the n2 variable is greater than 999 and shows a text in the output if so. Otherwise, the program won't show the message. Run the program and introduce a number like 1000. Try also entering a small number and see the different behavior of the program. You are making your program look smarter and smarter!

I'm going to leave it there for now. Did you enjoy the experience? Was it fun to type code, click the Execute button, and interact with your own program? This is the essence of what a programmer does, and if you had fun and cannot wait to type more code, you are on the route to becoming a programmer! If you found it tedious or hard to understand, it might have been my teaching methodology that doesn't suit your learning style. Try other resources, like videos or books, and reevaluate your experience.

There are many programming languages. It doesn't matter which programming language you want to learn. You can continue your journey with BASIC or jump to a language such as Java, Python, C++, or any other that you find interesting for whatever reason. I recommend you get a book on the language you pick and read it through. Code small programs to understand the concepts or if you have a fun or funny idea, go ahead and code it!

Once you feel comfortable with a programming language, explore the libraries that are available for it. A library is code that someone else has written to fulfill a particular function. A library can include code for making it easier to render graphics or images, store data in files, show input controls like text fields and buttons, run complex financial calculations... The list goes on and on.

At some point, you'll have to learn concepts such as data structures and algorithms. Make sure to study the basics of these two topics as well. Read about software engineering. Learn about unit testing and source code control systems such as Git. But don't worry about these things when you are starting. Bookmark this article and come back as you progress. I really hope you continue your journey and, most importantly, that you enjoy it! If someday you get a job as a coder, let me know! I'd love to hear your story.
Share:

0 comments: