1. Introduction
At this age and time that we live in, coding is simply invaluable. It has the power to uplift your career, your future prospects, and even your intellectual capacity. Computation is driving one of the largest capital expansions in history, and there has never been a better time to learn coding than now.
Why Learn Coding?
My first serious interaction with coding was at college. We had to take a course on a programming language called C Sharp. I failed the course the first time I had to take it and barely passed it the second time when I had to take it again. With that defeat in mind, I stayed away from coding for the longest time. I considered it to be a talent that I simply didnt possess. Later, I went on to change my career from engineering to visual effects as I wanted to work in a field that had more room for creative expression. But working in visual effects, I came to realize that the entire operation is actually enabled by the power of computation. From the software that is used to the pipeline management that facilitates the production Coding is everywhere. It allows studios to deliver mind-blowing effects for movies that make hundreds of millions of dollars in the box office.
Upon realizing the power of coding in my field, I decided to embark on a journey to learn more about it. I ended up teaching myself Python, a programming language that is widely used in visual effects. And doing so has been immensely gratifying. Not only has it allowed me to become more accomplished in my work in visual effects and create award-winning effects, but it has also empowered me to transition to an even more rewarding career in software development.
Coding vs. Programming
You must be hearing the terms coding and programming in similar contexts and might be wondering what the difference between them is. In the past few years, coding has become the term of choice to make programming more approachable to the general population. Basically the premise is that you could be coding and still be contributing to the digital economy without actually doing programming.
Let me give you an example of that: you could be using web languages such as HTML and CSS , which are not programming languages. So when coding in those languages you are not really programming but styling or structuring websites (more on their usage in the next section). But you could also be coding in JavaScript, which is an actual programming language. Programming languages allow you to make a computer do things. Every time you are programming something, you are also coding. But when you are coding, you might not be programming. Coding is a more general term that is used for describing all cases where you are communicating intent to the computer .
Basically you can think of programming as a subset of coding. But if truth be told, these two terms are used almost interchangeably nowadays. The main purpose of this book is to teach you how to program. We will be coding for programming purposes by using the programming language JavaScript.
On HTML and CSS
Looking at my path for learning programming, I find some of the efforts to teach coding to beginners to be a bit lacking. One of the primary problems in the area is using HTML and CSS as introductory languages.
The problem with these languages is that they are not even programming languages! HTML is a markup language that is used to define the structure of a document in a way that a web browser would understand. For example, HTML teaches you how to write text for a browser so that the browser would know what parts of it is a document header vs. a paragraph, etc
Likewise, CSS is not a programming language either. It is a styling language that allows us to style HTML documents to have them look aesthetically pleasing and ideally make them more user friendly than before. Furthermore, even though CSS can be used to create incredibly good looking results, it is usually very unintuitive to work with and can be hard to reason about even for a programmer. Learning CSS, you are not only not learning programming, you are very likely engaging in an activity that might not be fun as a beginner if styling websites is not your sole intention.
This push to teach coding using these languages is understandable. After all, given the large dominance of web applications and their immense profitability in certain cases, people found themselves wanting to build their own projects for the Web. And if you are to build a website, you need to use these languages to a certain degree . But having these languages as a starting point could create a misconception about what coding is. Coding can be an immensely rewarding and engaging activity when you are building programs or applications as the domain of possibilities is substantially bigger. As discussed previously, we need to be using programming languages to build programs so the apparent question is: What makes a language a programming language?
You can always check Wikipedia for a semi-formal definition. But to me, for a language to be considered a programming language, it needs to have certain control structures available to it that would allow us to express some basic operations. Even this definition probably makes little sense to a beginner. What is meant is that there are structures in programming languages that allow the computer to perform logical operations. Some of the examples of such structures, which we will see more about later, are the following: conditionals that allow the program to output different results based on given conditions and variables that store values or loops that allow a program to repeat operations for a desired amount of time. Dont worry if none of this makes any sense right now; the purpose of this book is for us to learn about all these fundamental programming concepts .
Almost all programming languages have these kinds of basic structures that enable us to construct immensely more complicated applications. Think of English, or any other language you might know. You have verbs, nouns, and adjectives. And using these building blocks, people can say the simplest things or go on to write amazing novels. And these are the building blocks that are missing from HTML and CSS that make people miss out on what could be achieved when using programming languages.
In this book we will learn all these basic structures that would allow us to communicate our intent to the computer using the programming language JavaScript.
Why Learn JavaScript?
There are many programming languages out there. This book will be teaching you how to code, by using the immensely popular programming language JavaScript.
JavaScript is one of the most widely used programming languages out there as it is built into every web browser. Due to this, almost all the web pages and applications out there use JavaScript to some degree. In recent years JavaScript started to be used not only to program user interaction in web pages but also server side - back-end - applications, Internet of Things (IOT) devices or mobile apps for platforms such as Android or iPhone. Even though it has its roots in web development, JavaScript knowledge is now applicable to a vast number of other domains.
Given the popularity and ubiquity of JavaScript, it is really easy to find resources and information about it if you are to ever get stuck. It has a big, vibrant community behind it. In the popular Q&A website, StackOverflow, there are more than a million questions that are related to JavaScript. If you end up coding in this language and get stuck in a problem, the chances are that someone else also had the same problem, posted a question on this website, and got an answer that you can learn from.