Table of Contents
What is programming?
Here we refer to Computer programming as Programming, and it’s a way for us to write commands and code that the computer can understand and execute for us.
More and more of our everyday lives owes a huge part to programming. The phones we use, ATM machines, how computers work, tablets, washing machines and Smart TV’s are a few examples.
With the help of programming you can write commands and instructions for a computer processor to execute to accomplish a wide variety of tasks.
Programming is problemsolving with the help of a computer.
With programming we can solve any logical problem by first understanding the parts that would make up a solution to our problem, and then we can simply code these parts for a computer – to have it help us solve the problem. This makes for easy problemsolving of especially complex problems, but also easier ones.
How does computer programming work?
A programming language is like any type of language, only difference is that here we learn to communicate with our computers. Much like the various languages in the world are spoken by people with often different cultures, various programming languages tend to be used for different tasks.
The languages are built up of different building blocks that all have specific functionality (rules for how a specific action is to be coded in each language). Once you have learned and mastered all of the building blocks you will be able to communicate fluently in your chosen programming language! (Just like you would be able to after having studied glossories and grammar for any other language)
The programming language we are going to focus on with this website is primarily Java, which is a so called “high-level programming language”, which means that the coding language is made easy for a humans to understand by “abstracting concepts that the computer understands” – these languages have to be translated from the human-readable code into computer-understandable 1’s and 0’s that it can understand once the program is to be executed.
For example:
int aNumber = 10;
Might be a representation of:
1110011101011010...
To “translate” our abstracted (human-readable) high-level programming code, we then run our code through a compiler which translates our words and instructions into 1’s and 0’s that a computers processor can understand and then in turn run the program we created using a computers processor and RAM-memory.
The lower the level of the programming language – the closer we come to writing actual 1’s and 0’s as our code for programs (less abstraction).
Why learn programming?
Learning programming will open up a whole new world for you. Once programming is mastered, suddenly everything feels possible. There are a ton of jobs in industries today crying out for programmers and coders!
- Programming will also help you become better at general problemsolving, breaking problems down into smaller more manageable and more easily understandable pieces
- It will help you to work more efficiently and save time by automating otherwise tedious tasks in your life and work
- You will be able to do things faster with the help of a computer
- Build and create things in the virtual world that can even rival other real life creations
- You will get full control over one of the most powerful tools that exist in modern day society – namely the computer
There is an endless stream of possibilities with learning programming, anything and everything from:
- Creating your own games
- Creating your own website
- Blog
- Social media platform
- Working with existing social media platforms
- Collect, analyze and use information that can be found on the web (automatically even)
- Create macros for your computer to automate work in everyday life
- Create servers with information that other people can access via the Internet
- Calculate things quickly
- and much much more!
It’s safe to say the future seems to be moving into a tech-era where this particular skill will be of high value and offer lots of job opportunities. Those job opportunities are usually also quite well-payed as an added bonus.
Introduction to various programming languages
In our modern day society different programming languages have become popular for different tasks. Usually a programming language becomes popular for a specific purpose because it fit’s that purpose very nicely in how it is designed to work and be used.
Java
For example Java programming language is used a lot in Embedded systems such as ATM machines, Washing machines, interactive billboards, car interfaces as well as make up the Android operating system that has become widely popular and used for smartphones the world over and is also the code used for Android applications.
I usually recommend Java as a starter programming language for people that come to me and ask for help to get started with programming. And this is in large part because of my own personal experience with the language of how easy and straight forward I found it to be compared to some other languages I tried when I was starting out my own programming journey.
Java is a very clearcut language where the logic is quite easily followed and errors usually also are easy to identify and correct – thanks to the language’s good documentation of all it’s components and the efficient development environment IDE’s (Integrated Development Environment) such as Eclipse.
Java is also one of our oldest high-level programming languages (ca. 1995), which means that there are a lot of resources and material online that cover most problems and functionality related to Java programming for all kind of scenarios and programming applications.
Resources:
C & C++
C could be said to be the influence for most modern day programming languages that we have today and it was developed in the 1970’s, C++ followed around a decade later ca. 1985 and was meant as an “upgrade” for the C programming language. One major key difference is that C++ offers Object oriented programming while C does not.
Personally I’ve only ever studied C++ Programming language myself (so far :p) out of these two alternatives. And from studying C++ some key differences stood out to me compared to other programming languages such as Java for example.
In C++ you had to manage your own “garbage collection”, which Java manages automatically.
Garbage collection in programming and computer science is the work of clearing the allocation of memory that components use in your program. Automatic garbage collection that Java utilizes can also mean less control of what– and how much memory is available at any given time in your program – compared to if you were to clear it manually by yourself every time you knew a variable never again would be used in your program.
Examples of manual garbage collection was that you created a variable and once that variable had been used for it’s purpose – the variable was deleted to “release” the memory space the variable had allotted in the RAM of the computer running the program.
Another key difference that was noticeable in C++ was that it seemed like you had to adapt your code to suit the operating system that your program was to run on, whilst in Java for example, every program is run inside of a Java Virtual Machine (JVM) – which is a sort of virtual machine environment that can work on most- if not all operating systems, making it easier to develop applications and programs for multiple platforms in Java compared to C++.
This would mean that one program in Java could work on multiple systems with only 1 version of the program, while programs in C++ needed many differently coded versions to be compatible with all the various operating systems you wanted the program to run on!
So C++ might offer more control when it comes to performance optimization but might require extra time developing for multiple platforms.
The manual garbage collection can also become a bit tedious and time consuming after a while. And if you intend for your program to run on multiple platforms, you might need to develop multiple versions – where each version is compatible with a specific platform.
If you know the 2D MMORPG game called Tibia that rivaled Runescape back in the day pre-World of Warcraft-era – this game was developed using C++! The source code for this game could and can still be downloaded and modified to create what is called “Open Tibia” servers that allow people to create and modify and then host their own versions of the game.
The great modern MMORPG World of Warcraft (WoW) was also coded using C++.
Windows operating system was developed using a fair part C language.
For those of you interested, check out this lengthy and thorough comparison and analysis of the differences between C and C++ programming languages.
There are plenty of good resources online to research this more in depth if you’re interested :)
Resources:
- C Programming Language on Wikipedia
- Check out this resource for C Documentation
- C++ Programming Language on Wikipedia
- C++ Documentation
C#
C# is very popular in the gaming and music industry. Unity game development studio seem to have good support for coding your games with the help of C#. C# can also be used in the coding of musical synths as well.
Resources:
PHP & Python
PHP and Python have become well known for back-end web development. Creating complex Content Management Systems (CMS) such as WordPress, E-commerce websites such as WooCommerce, Forums such as phpBB, Guestbooks, Community websites such as Facebook, etc.
Instagram and Spotify were developed with the Django Framework, which in turn is created with Python.
Resources:
JavaScript
JavaScript is used popularily for front-end web development. Such as adding “behaviour” to a website (for example making something happen when you click an image or a specific button on a website).
This includes manipulations of the Document Object Model (DOM – all elements that make up a website) after all of the document nodes for a website has been fully loaded – which allows for some nifty functionality (add, remove, move and change elements on websites, etc.).
JavaScript is part of the World Wide Web Consortium’s (W3C) contributions for Web Development.
I know what you’re thinking, JavaScript sounds a lot like Java, despite this fact, there is little to no relation between the two, they are in fact vastly different. You can read more about it in Douglas Crockfords in-depth look at JavaScript.
There are plenty of resources online to learn about JavaScript from, including another one of my own websites:
webbdev-essentials.net/ (work in progress, on hold while developing this website)
Mozilla Developer Networks (MDN) is famous for having some of the best documentation when it comes to HTML, CSS and JavaScript, it’s definitely one of my personal favorite sites for information in these subjects :)
Resources:
HTML & CSS
HTML and CSS is used for Web Design. Building wireframes of websites with building blocks called elements (HTML) and applying various styling to these elements to make up the desired layout and design of your choice (CSS).
HTML stands for HyperText Markup Language and CSS for Cascading Style Sheets.
In the early days HTML handled the styling of the websites by itself. But since the arrival of CSS, this has been helpfully separated from the actual structure of a website.
Previously one could find <font>
tags telling web browsers what font a specific text should have – compared to nowadays with CSS where you have CSS-code externally (as a separate style file) included to HTML pages, on-page (in the HTML Head-section (<head></head>
) of the HTML document) or inline (inside of the actual HTML-elements) of HTML-elements.
If you’re interested in the history of web design and web development, check out HTML 4.01 which was one of the old and widespread web standards. There was also XHTML which combined HTML + XML and brought over some stricter coding guidelines from XML that was much needed (in my humble opinion) to HTML – because HTML could be a mess at times.
As a practical example that could occur when coding websites: the code was “accepted” by browsers with un-closed HTML-tags which could cause some unexpected behaviour at times.
HTML-tags make up the HTML language and usually create coding blocks of specific types – for example: <p></p>
creates a block for a paragraph of text where the paragraph is typed inbetween the “opening-tag” (<p>
) and “closing-tag” (</p>
).
A modern concept that was quite popular with the release of HTML5 version was the use of “semantic HTML-tags”, which meant that a lot of newly added HTML elements in HTML5 added meaning to website elements that was not possible before when the infamous <div></div>
container was widely used but held little to no information about what type of data or information was contained inside of it.
With HTML5 instead we got <article>
, <aside>
, <nav>
, <section>
and many other semantically meaningful tags – which could also help Search Engines better understand the content of web pages that used this type of coding by getting hints from the tags themselves, instead of the non-descriptive <div></div>
and similar alternative HTML-tags.
Batch & Shell scripting
Batch- and Shell scripting can be used to gain finer-grained control over Windows and Linux operating systems in your computer.
Batch is what the files containing command line code to be executed in Windows operating system environment is called. The word “batch” here comes from the meaning that the code was non-interactive execution. If you ever used Windows Command Line Tool/Command Prompt a.k.a. CMD.exe
you will recognize the commands used for batch scripting.
Shell scripting is the Batch equivalent for Linux operating systems. Shell scripts are in the same way using the commands that can be found for the Terminal in Linux systems.
Both batch- and Shell scripts can also be written as programs and saved as executable files to make the operating system do your bidding for you via file execution instead of manually having to type the commands when you want to do something with the operating system every single time.
Resources:
AHK (AutoHotKey)
AHK can help you build macros that makes everyday work and tasks more efficient and easier by automating them.
And this is just scratching the surface of the possibilities in a world with programming.
Resources:
Syntax
In programming, syntax refers to the rules that specify the correct combined sequence of symbols that can be used to form a correctly structured program using a given programming language. Programmers communicate with computers through the correctly structured syntax, semantics and grammar of a programming language.
Definition quoted from: https://www.techopedia.com/definition/3959/syntax
So Syntax of a programming language is how a specific programming language is to be typed – so that later the compiler can correctly turn the code into a functioning program using that specific programming languages building blocks and how they are to be typed.
Variables and Data Types
In programming languages a common construct is to save data to be used somewhere in your program with a sort of “nametag” to help identify and fetch the data later, these nametags are called variables.
Depending on the programming language, variables can be created differently, in some languages one variable can contain data of any Data Type – whilst in other languages different variables need to be created for different Data Types.
Data Types explained
Data Types defines what type of data a variable can contain – text, numbers, true/false (boolean) values, lists, etc. Specific data types often are limited to a specific capacity for data that it can store.
For example integer variables in Java are coded with 4 bytes (32 bits – each bit is binary so 232 values) of memory space, which makes it able to store values from -9,223,372,036,854,775,808
to 9,223,372,036,854,775,807
.
This means that if your computer program were to use an integer variable with a value of 9,300,000,000,000,000,000
– which exceeds the integer variable capacity, that variable would not be able to properly represent the value you intended to store – which then can lead to various errors and issues in your program either directly or down the line.
Binary representation of floating point decimal numbers can be tricky, which can be seen in programming languages trying to represent certain floating point decimal numbers which can result in a faulty representation – which in turn can lead to errors when calculations should be done with a number represented in such a way.
In Java this is known as a “roundoff-error” and can make it tricky to build bank-like programs and applications using primitive variables that exist in the language and might require specially designed solutions.
Expressions, Statements and Comments
A big part of programming languages are built up using Expressions, Statements and Comments.
Expressions in programming explained
Expressions are used in programming languages to do things like assign a value to a variable, call on the actions embedded within a function/method or a combination of multiple expressions joined by various operators. [p. 914 – Big Java Late Objects]
Statements in programming explained
A Statement can be a simple expression that ends with a semi-colon (;) to mark the completeness of that statement. It can also be a branch (if/switch – also known as conditional statements) or a loop that repeat coded actions for a set interval or condition. [p. 920 – Big Java Late Objects].
Conditional Statements
Conditional statements help us determine what path to take in our program – say for example we want to check if a statement is true – if it is, then we want to do something specific. But if it’s not true, we want to do something entirely different. These types of statements are known as conditional (or IF) statements.
In if-statements you can check if a variable value matches a specific value and act on it, or you can do multiple comparisons combined into one single condition and only if all comparisons matches your condition, the code will be executed.
If-/conditional statements help us guide and determine the path and direction our program should take based on specific conditions that we set. This is one of the most helpful ways to guide logic in our programs.
Loops
In programming languages you can create so called “Loops” that does exactly what it says – it goes round and round until a condition you specify is completed. That condition could either be a counter that should reach a certain number/limit, or a condition that starts out being false and builds up to becoming true during the iterations (repetitions).
For example, we can use counters and say that the counter starts at the value 0, we then want the loop to run for as long as the counter value is lower than 7 (not equal to 7, lower than – since it starts at 0 and counts the 0, this makes for 7 iterations/rounds – count them yourself if you don’t believe me ;p) and then we tell the loop that for each completed iteration/round we wish to increase our counters value by 1, also known as incrementation.
For each iteration/round we also want to do something, in this case we want to print out the counter value what it is for the iteration/round. This will lead to our loop working as below:
#1 iteration/round: counter value = 0
#2 iteration/round: counter value = 1
#3 iteration/round: counter value = 2
...
#7 iteration/round: counter value = 7
You get the idea, then the loop stops once the condition set for the loop is complete and the requirements for looping has been met.
There usually are more ways than this type of loop, to loop through iterations/rounds in programming languages though – all similar, but with specific differences :) This loop demonstrated above was supposed to be a so called “For-loop”. There are also the do-while loop and while loop.
Functions/Methods
Functions and Methods are very similar in a lot of ways but usually differ majorly because methods are so called “member-functions” that are part of “classes” that are used in object oriented programming.
Write reusable code with functions and methods
A function is a way of writing reusable code that can be called upon with a specified function name. Once the function name is called, the program will fetch the function code and execute it in the place where you called the function. This way you don’t have to write the same code twice (optimally). It also allows for cleaner and well-structured code compared to how messy it can get without using functions.
Just imagine needing to do the same thing 50 times in a program, and having to copy-paste that block of code 50 times instead of calling on the function with 1 line of code each time that thing needed to be done. Not to mention the massive amounts of code lines we would amass with 50 copy-paste:s of the same exact code blocks… The more lines of code, the slower the program since it all adds up the coding file size that needs to be loaded for the program to be run.
Now also imagine if you needed to make a change to this block you just copied 50 times, that means you got to do 50 modifications in your code – that might be very extensive and cost you a lot of time – whilst if the code you copied would be contained within a function, you only need to make 1 change for that function, instead of 50 times throughout your code :)
Comments in programming explained
Comments in programming languages are used to document code and to make comments while coding to help remember for the future what specific blocks of code do or why they were created.
Comments are ignored by the compiler when the program runs as long as they are coded correctly. Usually you can create comments that span single lines, multiple lines or can be read with specific software (so called documentation comments which are designed to be written in a specific way that can be read by that specific software – for Java such a software would be JavaDoc).
Anything and everything you put inside of correctly coded comments will be ignored by the compiler when you run your program.
The concept of keeping old code commented out rather than deleted in case its needed in the future
This makes it an excellent option to “comment out code” which is a concept popuarily used for code that is outdated or should be replaced with new code, to keep a record of the old code as backup in case the need arises to switch back to the old code.
Compatibility issues to be aware of when programming
It can be difficult to know if new code will work “compatibility-wise” and with stability when introducing new features into complex large programs with a lot of code dependent on code elsewhere in the program.
An example of this could be a function that contain specific code, if this function were to be deemed outdated – you might try to update this code, but if something else in the program used the old code, and your updated code doesn’t work the same way, then the program might break and it needs to be fixed either by adding backwards compatibility to the update or remove the dependency in the code elsewhere that used the function we updated in order for the program to run correctly again.
Self-documenting code explained
A good coding praxis is to create self-documenting code while coding, which basically means that the naming conventions of variables, functions etc. are so descriptive that someone without prior knowledge of the code will understand right off the bat what is going on and which component does what.
A part of this is also to avoid so called “magical numbers” which is number values put directly into the code without being represented by a descriptive and clear variable in the midst of the code – always declare numbers in descriptive variables to make the code more descriptive, clearer and easier to understand in general is a good praxis to aim to follow.
The difference between scripting- and programming languages explained
“All scripting languages are programming languages but all programming languages are not scripting languages.”
Programming languges need a compiler to create a executable program that can then be run indepdently of other programs, while scripting languages use an interpreter and need to be run within another program.
Scripts are also often coded to run with the help of a specific environment/program whilst a compiled programming language program can run by itself.
If you’re further curious about this take a look at this article explaining the differences between scripting and programming languages more in-depth.
I was excited to uncover this web site. I want to too thank you for ones time for this particularly
wonderful read!! I definitely loved every little bit oof it and
i also haave you saved to fav to look at new stuff on your web site.