This article is going to expand on this past post just a tad. By that I mean I will cover what differentiates higher-level application and programming languages (Python or C) and lower-level programming languages (machine language and assembly language) – nothing too extensive, just more for a clearer understanding of what to know about programming languages work – as this blog’s title suggests. In short, you may or may not have heard about a language’s syntax, or the form in which code is written in an acceptable manner, but you should also be aware and understand its semantics, or the meaning of the code written.
There is more to programming than the syntax or form it is written in, and this includes the semantics of that language – its meaning or logic. A syntax error may prevent a code from being ran but a semantic error may produce undesired results. Wikipedia describes this as, “…syntax of a language describes the possible combinations of symbols that form a syntactically correct program…meaning given to a combination of symbols is handled by semantics…” Further, there are other important bits of information to bear in mind; different data types, variable naming options, reserved keywords, operators, and others.
Just a heads up, this post will cover common aspects among many different programming languages, but it does favor Python. It is intended to teach a more general understanding of programming while using an example language that I am familiar with.
Start with the Basics
The purpose of creating a program is to help solve a problem, or in the sense of gaming to provide entertainment, so to speak. Now the code that is written needs to be stored and referenceable throughout the program in accordance to where the data is in memory. In layman’s terms, as there is technical detail as to how programs are ran in memory and referenced using the memory cells, it is easier to reference the data by way of variables that represent the data they store. An example would be creating names for variables: ‘cu_first_name’, ‘cu_last_name’, ‘cu_age.’ Think of variables as an easy-to-remember memory address location.
You may or may not be able to tell what these variables mean, so to ensure you do, they mean customer first name, customer last name, and customer age. The names of the variables used to store the data alleviate the need to remember cell numbers in memory cell management – that itself is a whole other topic that can be more complicated.
Variable names can store different types of data – data types. Data types classify the data they represent. For instance, someone’s first and last name would more than likely consist of a sequence of alphabetical characters or letters (unless you’re named in a numerical sequence), referred to as a string, whereas their age would be represented by numbers, or integers. These are the two main types of data types, though there are many more; floats, decimals, etc. Regardless the data type, proper variable naming makes for an easier time reading your program sometime later when you come back to review the code you wrote quite some time ago. Or even in the case of other programmers coming back to check source code, properly named variables are fantastic, and even more so are adequate comments in the code and the associated documentation on how to use them.
Further, another very important topic is how related data can be stored other than just by variable names. That may not make sense, but please bear with me. What I mean by this is, it’s simple to create multiple variables, but how do you remember them all? What is an easy way to reference all variables that are similar in nature? How do you correlate names and other information about specific individuals or objects? To be clear, data structures is the term used to describe how to organize data.
Sure, read the code and reference the many variables that it may contain, or create a list that stores the full name of customers and whatever relevant data. For example; ‘cu_full_name’ = ‘cu_first_name’ + ‘cu_last_name’. Then create a list such as Customer1 = [cu_full_name, cu_age]. Or you can, if you have 10 users, ask each user their first and last name, concatenate the two into ‘cu_full_name,’ and then store those full names into a consolidated list named ‘customer_names_list.’
Lists, as in this case, may also be known as arrays, or other terms used in the many different programming languages available today. Typically lists contain information related to each other, though this may not always be the case. You can also store different data types (strings and integers) within these lists.
You might be thinking there has to be a more appropriate way of representing a set of data that is related, and indeed there is – dictionaries (Python data structure) or key/pair values. An example of this would be a dictionary where the key would be the first or full name of a user, and some values could include their age, phone number, address, etc. This is a simple way of organizing related information about a specific object, or person in this case.
To reiterate, the basics to be aware of in any programming language is: how to create variables, how to assign these variables whatever data type they may be (integers or strings), and how to further organize gathered data in a form of a data structure. Easy, right?
Next After the Basics
Programming languages have built-in keywords that are reserved for special purposes, hence their coined term reserved keywords. It’s important to recognize these words as for both a reference of their specific words, but also to recognize some of the special abilities that programming language has.
As the name suggests and the brief section intro alludes to, reserved keywords are words that the respective programming language recognizes to allow special action to be associated with that keyword. In other words, you cannot create a variable named with a reserved keyword. This would cause an error in your code at one point or another, as the keyword triggers a special action by that language. A few common examples: “for,” typically leads to iterating through a particular list or other ‘iterable’ data structure; “if,” which is used to match a specific condition and act accordingly upon that; “break,” this is used to either escape a program’s current loop or to terminate the program.
Other aspects to investigate would be how its operators behave, meaning how to perform arithmetic operations (math), relational operators / comparisons (are two values equal, or are they greater than or less than), and logical operators (combining multiple conditional statements; AND, OR, and NOT).
What Else You Should Know
Once you get conformable with the previous sections, next is learning how to define functions and store data persistently.
One major plus of coding is that once you have it written, you can reuse and modify code according to your needs. You can define a function that performs a specific task that can be called upon through however many programs. For example: you can define your own function that iterates through a data structure and acts upon each element of that data set. Perhaps it’s a list of names of people who’ve attended a seminar and you print a welcome statement to each individual.
Up until now, all mentioned data structures exist only during the run time of that program and are stored in RAM – random access memory. It is important to know that RAM is volatile, which means data isn’t stored there permanently. Hard disks are used for longer-term storage solutions; this is where files, applications, and perhaps even pictures or videos are stored for future access. Once a program terminates or completes, the created variables and data structures are deleted – known as garbage collection. This is important as it ensures the RAM used is returned and made accessible for other programs to utilize.
When you think of persistent storage, files and application, are examples, but so are databases. It is entirely possible to create a script to take in data and act upon it according to your needs, and then feed it into a persistent storage solution. You can write the results of collected data into text files, which is human-readable that can allow for a compilation of reports, or even a database for more identified insight into the data by means of column names and specific values. Regardless your approach, as long as you’re able to get the data you need then the options are there for you.
Personally, I like to break up scripts into sections and write the results into a text file. The program runtime can vary but when it’s done, I am able to review data at my leisure and not have to worry about my RAM usage. It is fairly common to have a rather abundant amount of hard disk storage space in comparison to RAM. I can then read through the file and decide what script to create to act upon that gathered data.
High-Level vs. Low-Level Languages
High-level languages are more human-friendly, in that you have keywords and variables that can be used throughout a program and are easy to follow. You can open and read or write a program in this language that may seem complex if you’re new to coding, but pales in difficulty when comparing to low-level languages. The reserved keywords are a prime example of the easiness of high-level languages.
Low-level languages include languages that the system itself understands. Bearing in mind that computers understand ONLY 0’s and 1’s, high-level languages are compiled, or interpreted, into assembly (assembly language), which is an intermediary that then converts the code into machine language (machine code); 1’s and 0’s. Way back when, programming consisted of coding in these languages, which seemed to be a deterrent in learning how to program due to the level of complexity.
If you’ve never looked into assembly and machine code, I urge you to at least explore it and see the ease of use of high-level languages versus low-level languages. One other note I would like to say, and this is in favor of learning a low-level language, is that the runtime for a program increases for high-level languages. This is due to the fact that the code needs to be run through a lower-level compiler or interpreter and then converted into machine language, versus a program that is already written specifically with 0’s and 1’s or in assembly and doesn’t require this conversion.
Some Personal Insight
I recommend going through this post while investigating a potential programming language you desire to learn. Only with time and experience will you be able to understand a programming language. Set aside a day or a week, go through each section of this post and practice creating variables of varying data types. Then sample a few data structure formats and how to better organize your data for easier use. Afterwards, learn how to store data persistently, start by writing a file, as this may be simpler than learning how to interface that language with a database structure, then learn other methods.
There are some great resources out there for the major programming languages; this includes official documentation for that language, but also StackOverflow, GitHub, and even a simple search for “<programming language> <this is what I want to do>” while substituting the bracketed-text with appropriate values. For a fair guidance and expansion of this post, I came across this web page that seems to cover “what to know about programming languages” with some related content and language-specific examples.
As one who loves to learn anything and everything about computer technologies, I also recommend that you explore some of the top high-level languages in use today, but also explore the low-level languages. You never know, you might like the challenge of low-level versus high-level languages.
There is no right first language to learn, but I will say that as long as you start somewhere, that is better than not starting at all. The best method of learning how to program is following this post’s suggestions on how to work with specific languages in accordance to what your end goal may be. If you want to learn web development, follow this guide and the above-linked web page as you overview web-specific languages. Learn how they work; how to store variables and accept user input, as well as how to display content back to the user. The same applies for system languages, or application languages.
Practice really is the key here. You can read and read however much you want about this topic, but it’s only when you start practicing that you build muscle memory. Use resources readily available online, programming nowadays is not how it used to be when computers were a newer concept.
Lastly, for further reading, check out the references below. Initially I wanted to sort them by their value, but really, that was simply too hard. Each offers some great insight and added value in the overall scheme of understanding programming languages in more detail.
What does it take to create a programming language:
A high-level overview of how code works:
Of course, you have to love Wikipedia:
A great, deeper dive into how the lower-level languages work:
How about another take at covering how languages work from another’s perspective: