Scala.js tutorial: How to start building single-page web applications

Table of Contents1 - Single-page applications2 - 1. Getting started (dependencies)3 - 2. Create hello3.html4 - 3. Create Hello3.scala5 - 4. Run the code!6 - Summary/Discussion7 - Resources8 - More facades9 - Other tutorials in this series10 - Bonus!11 - Source code

In this final, third part of my three-part introductory series on Scala.js I’ll demonstrate a technique that can help you build single-page web applications with Scala.js. That is, the body of your HTML page will look like this:

    <div id="root"></div>          

    <script type="text/javascript" src="./target/scala-2.12/scala-js-hello-world-jsdeps.js"></script>
    <script type="text/javascript" src="./target/scala-2.12/scala-js-hello-world-fastopt.js"></script>

After that, your entire application will then be written in Scala/Scala.js, which is converted into JavaScript code in the scala-js-hello-world-fastopt.js file.

A Scala.js tutorial: “Hello, world” with an HTML button click

Table of Contents1 - 1. Create a new HTML page2 - 2. Make updates to use jQuery3 - 3. The new Scala code4 - 4. Setting the main class5 - 5. Running this example6 - Discussion7 - Summary

In my first “Hello, world” Scala.js tutorial I showed how to get started with Scala.js, including some necessary setup/configuration work. That tutorial ended by showing how to get the string “Hello, world” displayed in a browser.

In this tutorial I’ll take this a little further and show how to create an HTML button you can click that results in the string “Hello, world” being displayed in a JavaScript alert window. When the button is clicked, the alert window will be displayed by your Scala/Scala.js code.

Getting started with Scala.js (a “Hello, world” example)

This is the first tutorial in a three-part series on getting started with Scala.js. This tutorial will demonstrate the proverbial “Hello, world” introduction. After this “Hello, world” tutorial, the next two tutorials will show some more powerful things you can do with Scala.js.

My vi/vim tutorial goes over 200,000 views

Way back when I lived in this low-income apartment complex in Wasilla, Alaska — technically I had no income at the time, and it’s ridiculously hard to find a place to live in Alaska in the summer — and spent as much time as I could meditating in the mountains, I created a vi/vim editor video tutorial and put it on YouTube. I just noticed that video has now exceeded 200,000 views. It feels a little weird to think that over 200K people have started to learn vi/vim from that video.

A funny thing about making that video is that the walls in that apartment complex were paper-thin. I could hear everything my neighbors did in their apartments (use your imagination and you won’t be wrong), and they could hear me, so I intentionally tried not to talk too loud in the video. I had to edit the video at several points to crop out some of my neighbors yelling at each other.

“Hello, Scala” - A swift introduction to a scalable programming language

I wrote the Scala Cookbook for programmers looking for solutions to common Scala problems, and then wrote Functional Programming, Simplified for programmers looking for a simple way to learn functional programming. A few months ago I decided to finish my Scala trilogy and write a book for programmers who don’t know Scala and want a quick introduction to it. With that, Hello, Scala was born:

Hello, Scala