Introduction to Programming

Avatar image for decoyoctopusx
DecoyOctopusX

53

Forum Posts

0

Wiki Points

3

Followers

Reviews: 0

User Lists: 1

Edited By DecoyOctopusX

This article will detail some of the basic concepts used in every programming language to build the applications that we all know and love. This is not intended to be a tutorial you follow to learn how to program, it is a starter document for learning some of the important concepts required to get started programming. If you know nothing or next to nothing about programming this article is for you!

Variables in programming are text characters that signify a place in your computer's memory, usually RAM(Random Access Memory). They are allocated to your program by the Operating System (i.e. Windows 10/Ubuntu) or memory controller of a program your code is running on top of. Variables are the basis of all programming because at the end of the day programming is nothing more than telling the computer what data goes into which memory. Though over the years, 1970 onwards, many people and teams have developed tools, other programming languages, and hardware to make this process easier. A graphics processing unit or GPU is one such piece of hardware. Developed specifically to make it easier to get graphics to the screen faster. Below is an example of basic variables in C:

No Caption Provided

Each of these variables takes a bit of information and stores it in memory for the program to use later. Color coded in aqua are the variable types bool for boolean, int for integer, float for floating point number, char for character, and the last one is still defined as a character but the brackets next to the variable name signify that it is a string of characters. The const keyword tells the compiler that this variable is constant and never changes. In programming a constant variable is usually useful for defining sizes of variables, but they can be used for whatever you want so long as it does not change. The compiler will throw an error at you if you try to change it. Not all programming languages use type specifiers for variables for example in Lua you could just write something like this:

No Caption Provided

You may also notice that in that example I have no semicolons after each variable definition. Not all languages require these as well. The reason programming languages have type specifiers is because each type takes up a different size of memory or the memory is read differently. By specifying the type you can be more precise in how you use your memory instead of letting the compiler pick for you and hoping it is correct. This is the primary reason a lot of games are programmed in C++ and C#(C Sharp). Those languages give you a finer degree of memory control so you can use only what you need, and do so fast. This is also a double edge sword, because under these conditions you need to make sure memory is allocated correctly otherwise it can break things in a major way. Usually resulting in the program crashing, or in the worst case the whole computer crashing.

Variables need to be changed for anything to happen though, and we do that through functions also known as methods, procedures, subroutines, and many other names. Today I will call them functions because that is basically all encompassing. Functions take a number of variables as parameters and returns another value to be used later. Below is an example of a function that adds two numbers together:

No Caption Provided

You define functions to modify or create variables or call other functions to achieve your program's goal. There are also predefined system functions in most programming languages that do a lot of the more menial tasks or complicated work for you. Below is are two examples:

No Caption Provided

The first line is a call to XWindows API(Application Programming Interface) which takes the parameters we have defined and does all the complicated work of turning that into a Window on a linux based desktop. The second line is one in programming you will see a lot of. That is the standard C function for outputting text to terminal/console. On Windows based systems that would output something similar to this:

No Caption Provided

Using variables and functions in combination with predefined functions to build an application that the end user can use. Whether it be someone at a bank, one of those rascally gamers, or someone staring at a six second video through your phone application. Programming is an incredible tool, and is quickly becoming an essential skill in modern society. I hope you have found this useful to some degree.

A quick note: I will be doing an article(s) detailing writing a full application. I am just looking for a good tool set to do so that is free and easy to use. Wouldn’t want someone to have to buy something to complete a tutorial. Anyways, have a good day!

Avatar image for rorie
rorie

7887

Forum Posts

1502

Wiki Points

0

Followers

Reviews: 4

User Lists: 3

If I wasn't so busy I'd try to get into some Code Academy during this dark time! It's always been a bit of a blind spot for me.

Avatar image for longevitous
longevitous

329

Forum Posts

2

Wiki Points

0

Followers

Reviews: 0

User Lists: 12

Cool, looking forward to the next part

Avatar image for sweep
sweep

10887

Forum Posts

3660

Wiki Points

0

Followers

Reviews: 4

User Lists: 14

#3 sweep  Moderator

Keep it coming!