📅 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 data 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
Browser to Try:
- Vivaldi – Chrome-based browser with extensive customization.
- Mozilla Firefox Developer Edition – Firefox with development in mind.
- Opera – Alternate browser different from Chrome-based and Mozilla-based browsers.
- Mozilla Firefox – The standard Firefox. Developer tools are available, but the Developer Edition is worth a try for comparison.
- Chromium – The open-source version of Google Chrome.
- Google Chrome – The proprietary version of the Chromium browser.
Always test your web pages in multiple browsers in order to check that they appear and perform similar in all. One of the disadvantages of web design is that a page might appear perfectly in one browser but display as a complete mess in another despite following web standards.
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)
As useful as an IDE might be, avoid using one for now. Use a plain text editor. By relying completely upon a text editor that provides no help, you must lean upon your knowledge and skills. This helps you learn the language better. By doing this, you will understand what you are learning. This way, you can be skilled programmer regardless of which IDE or text editor you choose to write programs with. If you rely upon an IDE, then you risk becoming dependent upon that particular IDE. Not good.
There are no visual aids when using a text editor. Did you make a mistake? Then, you must analyze your code in detail because incorrect syntax will not be underlined in red the way an IDE would reveal. Is your code not running? Again, double-check your program in a text editor. You have to know what you are doing, and a text editor drills this practice well. An IDE does not.
Memorize keywords. Learn statement syntax. Enter proper whitespace manually so your code is readable. An IDE will do these things for you, but a text editor requires that you pay attention to your code and develop the habits.
One good advantage is color-coding, Definitely use a text editor that highlights statements, keywords, and other syntax using colored text. This is a vital programming convenience, not a hindrance.
One more reason to avoid an IDE: Project dependency. Various IDEs will organize projects using custom project management systems that are incompatible with one another. This makes it tricky to migrate code written in one IDE to another IDE. Plain text files have no such limitation.
Use A Dedicated Directory
Never use a system directory or home directory to test your code. No, no, no!
If something goes wring, you do not want to ruin your operating system installation or delete personal files by accident in the event of program malfunction. When you write a program, it will probably contain bugs.
Create a new directory and name it whatever you like. The directory name code is obvious.
In the next lesson, we will begin with HTML 5 basics.