📅 July 13, 2017
Lesson 1 Overview
- Client-side vs. Server-side
- Interpreted vs. Compiled
- Strongly typed vs. Weakly typed
- Full Programming Language
- The Web Browser
- The Text Editor
- What Operating System Should I Use?
- Coding Tips
- Avoid an IDE (For Now)
- Develop In A Dedicated Directory
Client-side vs. Server-side
A client is a program running on a computer, a tablet, a game console, a cell phone, a Raspberry Pi, or whatever other device that might connect over a network.
The server is a program running on a (usually) more expensive, faster computer system or group of computer systems that is capable of handling many, many, many client requests simultaneously.
This concept is referred to as a client-server model. A client makes a request to a server. The server does something with the request, such as process or retrieve data, and then the server sends the result back to the client for display on the user’s device.
At that time, web pages were static. This meant that once you loaded a web page, all content was fixed. Text and graphics did not change (unless you used an animated GIF image). There was no interaction (unless you used a Java applet or Flash control). What you saw was what you were stuck with unless the server altered the content upon the next page refresh.
Session state could be saved between pages using cookies in order to provide some form of “memory” on a web site.
Interpreted vs. Compiled
There are two ways to run a program: interpreted or compiled. A programming language is usually designed with one method or the other. The heavy-weight, strict programming languages, such as C, C++, and Java, must be compiled before execution — the process of running a program.
When you write a computer program, you type lines of code called statements. This is plain text in a language we understand, such as English — just like writing a letter. This plain text version of the program written in our language is called source code. But the computer has no idea how to read our language. A computer only understands 0’s and 1’s. So, we must convert the source code into 0’s and 1’s that the computer can execute.
The method used in this conversion process is either interpreted or compiled. If we convert source code ahead of time into a machine-readable program, called an executable file, for execution, then we are said to have compiled the program. We then execute the compiled code, not the source code. C, C++, and Java require that source code be compiled before running the program. If you make a change to the source code, then you must recompile the program in order to update the changes in the executable before running it again.
An interpreted language takes a different approach that does not require compiling before execution. It will run the program as it reads the source code. A special program called an interpreter steps through the source code and produces the results immediately. There is no separate compile step.
Why use one method over another? There are advantages and disadvantages to both techniques, but the main difference is speed. Compiled programs run faster — much faster — than interpreted programs because a compiled program speaks the machine code language of the processor.
An interpreted language might be more convenient to edit and run, but it always requires an interpreter to perform the same conversion process every time, so it runs slower.
Strongly Typed vs. Weakly Typed
Typing refers to the kind of data type that variables can store. If this sounds strange at this point, that’s okay. We will elaborate upon this subject later. For now, there are two main types: strong and weak.
Let’s use a box to illustrate typing. If we have a box that only holds gold coins and gold coins only, then the box is strongly typed. We cannot put silver coins or copper coins in the box because the box was designed only for gold coins.
However, if we have a box that is weakly typed, then we can store any type of coins. We could start with gold coins, dump them out, and then put silver coins in the same box. The box would be weakly typed.
This will make more sense when we introduce variables.
Both have the word “Java” in them, but they are two different languages.
Why? Blame it upon marketing. At the time when the Internet was gaining popularity around 1994, users were craving more interaction with web pages. When Java was released for mass consumption around 1996, web users were delighted. Java applets could perform a seemingly endless variety of magical tricks, such as changing the mouse cursor into a mouse with a swishing tail, graphical raindrop effects on site banners, messing up the browser’s status bar with international phone numbers, and displaying incredibly annoying banner ads that took at least three minutes to load over a dial-up modem. It was great.
Java become popular quickly.
Very popular. Very quick.
Since Java was the new darling of the programming world at the time, the folks at Netscape were wondering what to call their scripting language in order to gain mass acceptance. Netscape’s offering was based off of an obscure specification called ECMAScript…and that does not sound cool at all. (ECMA stands for European Computer Manufacturers Association.)
Full Programming Language
For everyday use in web browsers, good practice dictates that scripts be kept as small as possible for faster rendering by the browser. Longer programs take more time to execute, and this can stall a web page and make users wait.
Anyone can open the markup and source code of a page and view it. Nothing is protected or encrypted. Every interpreted language is viewable in its original form. This is what makes interpreted languages easy to edit.
A browser must have complete access to all files needed in order to render a page. Whatever a browser can see, end users can see.
- A web browser
- A text editor
The process is easy: Write a script, and then run it in a browser.
The Web Browser
A few browsers:
- Vivaldi – Superb browser with extensive customization and developer tools.
- Mozilla Firefox Developer Edition – Firefox with a focus on developer tools.
- Opera – Good for testing web pages in an alternate browser. Includes developer tools similar to Vivaldi.
- Mozilla Firefox – Includes tools, but Developer Edition seems better. Better for page testing.
- Chromium – Open-source version of Google Chrome. Includes developer tools.
- Google Chrome – The proprietary version of Chromium. Includes developer tools.
During web development, you should always have more than one browser so you can test your page in multiple browsers to make sure that the page is rendered properly in all. Standards support can vary among browsers.
The Text Editor
A text editor is a program that reads and write plain text files. The key is plain text. Only the characters themselves are recording. There is no formatting information included as would be with word processors. Do not use a word processor.
Text editors can range from simple to complex, free to expensive. Try several and focus on the one that works the best for you. For Linux, gedit and xed are two that offer a range of programming-related features, such as code indentation and regular expression manipulations, in addition to color themes that offer pleasing aesthetics.
Mac and Windows have their own offerings. If using Windows, avoid the built-in Notepad. Notepad is too limited, and it does not interpret end of line sequences properly. If you write a script in Linux gedit and then open it in Notepad, Notepad will show the entire script on a single line. For Windows, Notepad++ and ConTEXT are two recommendations.
What Operating System Should I Use?
Avoid an IDE (For Now)
However, avoid an IDE for now. Use a plain text editor. The goal is to understand what you are learning in order to become proficient regardless of the text editor or IDE used.
While an IDE is good for advanced development, a plain text editor is better when learning a programming language because it forces you to think about the language and understand what you are doing. An IDE is comparable to learning how to ride a bicycle using training wheels — it offers too much help at first. You do not want to become dependent upon a specific IDE. What happens if you do not have one available? Can you still write code?
With a text editor, there are no visual aids that show your coding errors. You must pay close attention and analyze your code in detail. Auto-completion features are absent. You must memorize keywords, statements, and syntax and enter them properly or else your code will not run. However, do use a text editor that offers color-coding themes since highlight keywords and statement structure for easier learning.
Another reason to avoid an IDE for now is that many implement custom project directory structures. You cannot easily migrate a coding project from one IDE, such as NetBeans, into another IDE, such as Eclipse, without modification because the IDEs have different directory structures and project organization techniques. With a text editor, you can use the same source in any, and your code will run since you are editing plain text files that are independent of any IDE.
Again, IDEs interfere with learning at first. Only after you can code proficiently with a text editor should you begin using an IDE. Once you know the language well, then advance to an IDE so you can write scripts in less time.
Develop In A Dedicated Directory
Create a dedicated directory in your home and store all code there. Name it something recognizable, such as code, and organize your projects within it. Doing this prevents code litter throughout your system, and it confine all code to a specific directory. When writing code in other languages, such as C or C++, that have access to your local file system, then this strategy helps reduce the risk of your program deleting files. If any files are deleted, then only those in the code directory will be affected (usually).
In the next lesson, we will begin with HTML 5 basics.