Book Image

Hands-on JavaScript for Python Developers

By : Sonyl Nagale
Book Image

Hands-on JavaScript for Python Developers

By: Sonyl Nagale

Overview of this book

Knowledge of Python is a great foundation for learning other languages. This book will help you advance in your software engineering career by leveraging your Python programming skills to learn JavaScript and apply its unique features not only for frontend web development but also for streamlining work on the backend. Starting with the basics of JavaScript, you’ll cover its syntax, its use in the browser, and its frameworks and libraries. From working with user interactions and ingesting data from APIs through to creating APIs with Node.js, this book will help you get up and running with JavaScript using hands-on exercises, code snippets, and detailed descriptions of JavaScript implementation and benefits. To understand the use of JavaScript in the backend, you’ll explore Node.js and discover how it communicates with databases. As you advance, you’ll get to grips with creating your own RESTful APIs and connecting the frontend and backend for holistic full-stack development knowledge. By the end of this Python JavaScript book, you’ll have the knowledge you need to write full-fledged web applications from start to finish. You’ll have also gained hands-on experience of working through several projects, which will help you advance in your career as a JavaScript developer.
Table of Contents (26 chapters)
Section 1 - What is JavaScript? What is it not?
Section 2 - Using JavaScript on the Front-End
Section 3 - The Back-End: Node.js vs. Python
Section 4 - Communicating with Databases

Early web browsers and a 10-day prototype

So, why JavaScript? Obviously, the web needed more than just static data to be useful, so, in 1995, Brendan Eich at Netscape Communications came along. Originally, the idea wasn't to create a whole new language but rather to incorporate Scheme into Netscape. That idea was superseded by the work Sun Microsystems did with Java. It was decided that this language that Eich was creating would be somewhat Java-like, and not Scheme at all. The genesis of the idea came from Marc Andreessen, the founder of Netscape Communications. He felt there needed to be a language to combine HTML with a "glue language" that helped with images, plugins, and—yes—interactivity.

Eich created a prototype of JavaScript (originally called Mocha, and then LiveScript) in 10 days. It's hard to believe that a 10-day prototype has become such a crucial part of the web, but those are the facts as history records them. Once Netscape developed a production-ready version, JavaScript shipped with Netscape Navigator in 1995. Shortly after JavaScript was released, Microsoft created its own version of JavaScript, called (unceremoniously) JScript. JScript shipped with Microsoft's Internet Explorer 3.0 in 1996.

Now, there were two technologies competing for the same space. JScript was reverse-engineered from Netscape's JavaScript, but since the two flavors of the language had their own quirks, the browser wars began, leading sites to often have a label "Best viewed in Netscape Navigator" or "Best viewed in Internet Explorer", due to the technological complexities involved in supporting both technologies on one site. A portent of things to come, the differences in the early versions only increased. Some websites would work flawlessly in one browser and break horrifically in the other—not to mention the complications caused by other competitors to both Netscape's and Microsoft's browsers! Early developers also found the differences between the two technologies only fueled the arms race. If you experienced such degradation of performance (or, even worse, you were working with JavaScript in the early days, like me), you definitely felt the pain of the competing versions. Each company, as well as other third parties, raced to create the next best JavaScript release. At its core, JavaScript has to be interpreted client-side, and the differences between the browsers led to bedlam. Something had to be done, and Netscape had a solution, though it wouldn't be perfect.

We'll learn about this solution in the next section.