The Scala.js compiler 1, made by
Sébastien Doeraene 2,
Scala 34 code
and anywhere that Node.js is installed.
Programmers often ask me were Scala.js stands in the bigger picture, when it should be used and if it even makes sense when there is TypeScript; the behemoth who has already taken over the likes of PHP 5 with nearly 20 million weekly downloads 6. TypeScript is proof that strong-typing features of languages like Scala are in high demand, but also a testament to the importance of accessibility and wide distribution - things that Microsoft does particularly well, especially in the recent years, even convincing developers to repatriate back to Windows 7.
🔗Scala.js enables distribution of applications through npm
> npm install -g scalajs-cli-demo > scalajs-cli-demo Hello world from Scala.js! ---- To demonstrate usage of Node.js api, here's some of your environment: ALLUSERSPROFILE = C:\ProgramData ...
This works Windows, macOS and Linux. You, as the user, did not need to download & install Java just to run my app. As the developer, I did not need to figure out how to package my app with Java and then upload binaries for various OSes. This simply means access to a much wider audience, because the tool is now accessible natively through a widely-deployed ecosystem. I have to say, to do this and get it on npm 11 was very straightforward. The sources are available on GitHub 12.
🔗Scala.js benefits fully from the npm ecosystem
My excuse for trying Scala on Node.js was simple: I wanted to synchronise some logs over an HTTP EventSource stream, and at the time in 2017, I could not find a single bug-free EventSource library on the JVM. On the other hand, npm had one just sitting there 13, battle-tested across many browsers, and it was a completely painless experience to use this library. All it then took was to publish my app to npm, install it on my target machine and just run my Scala. It uses the full suite of usual Scala things: unit tests in ScalaTest, Optional types and case classes; available on GitHub 14.
Want to publish a trendy desktop app like VS Code or Slack? Electron 15 is at your disposal with its Electron Packager 16 that gives you native installers for all the major platforms. Want to make video games that run both on the browser and the desktop? The Indigo engine 17, built with Scala.js and Electron, enables you to do exactly that, but with all the huge benefits of pure-functional programming, tried & tested tooling, state machines 18 and zero-cost backend-frontend integrations, as well as TypeScript definition support 19; leveraging Scala and TypeScript to the maximum. Or maybe you just want to control Chrome with Puppeteer 20. Or use the Express framework, or run on IoT and serverless platforms.
🔗Scala computations can run in the frontend and the backend
This use case is close to my heart, as I had worked on multiple trading platforms; you must do many computations and validations, to make sure the user gets the correct prices quotes and invalid states are impossible to represent, especially where currencies, exchange rates, and different parameters for financial instruments are concerned. Because of user experience (as you would rather tell the user immediately that something is invalid), you end up reimplementing that logic on the frontend, and in many projects it is done in a different language. Inconsistency ensues, primarily for the reason of duplicated code running out of sync.
However, one trading platform I worked on did have Scala.js, and it was an absolute pleasure to have the
validation code run on the backend and the frontend at the same time.
The user gets instant feedback about what is possible, and when they press 'Buy', it always
works. No more errors like '
Cannot read property 'y' of undefined' and
scrambling to fix production bugs, that I have faced myself even with TypeScript. To do that, the app
does not even
need to be fully in Scala.js, although it is definitely advantageous.
Computations don't just mean simple sums and state processing; it means orchestrating your application declaratively across the frontend and backend, fusing the two into one cohesive and coherent application through macros, type-level programming 39 and other aspects that are mostly in niche programming languages.
🔗Impact; killer apps
🔗The movement towards end-to-end-encryption
More recently, end-to-end encryption has become a huge deal to users 34. The further we go, the more users demand their data to be processed on their devices, and stored remotely only for synchronisation purposes, rather than relying on remote servers. With the example of Notion, client-side full-text search should be entirely possible to do on the client-side, but this requires a congruent framework that can run on the backend and frontend which is very achievable in the Scala arena.
🔗Full-stack development includes end users
When you hear 'full stack', you hear 'backend', 'frontend', but nothing about the end user. In fact, the end user is the consumer of the the world's most popular programming language, which happens to also be pure-functional: Excel 35. Used in millions of production systems but almost never on the backend; its main difficulty is that it is not particularly scalable - hence why most serious production systems involving Excel have a Visual Basic layer, combined with another C# layer, which then speaks to external systems. Perhaps this is why very recently, Microsoft released Power Fx 36, possibly one of the most important creations for end-user computing following Microsoft Excel. Power Fx is a 'a general-purpose, strong-typed, declarative, and functional programming language.', targeting 'No-Code, Low-Code and Pro-Code' users 37. Simon Peyton Jones, the co-developer of GHC, the Haskell compiler, is working on Lambdas for Excel, at Microsoft, right now.
Unifying the language stack enables future projects where end users develop spreadsheets, the developers integrate them into production systems as simple functions - because in the end, that is what many of our systems do boil down to. Developers can enhance them with property tests, performance tests, and various other possibilities achievable through static analysis. In theory this is possible already but the mismatch between how Excel does things and how any other language does things is currently too great.
Computations run on the client-side, or on the server-side, wherever it is appropriate; Spark and Big Data is at the fingertips of every user out there. In fact, these ideas were already explored in Scala but were very ahead of their time because Scala.js was very young back then. 38
Scala.js— Build robust frontend web applications in Scala with Scala.js www.scala-js.org
- Sébastien Doeraene's personal Website lampwww.epfl.ch/~doeraene/
The Scala Programming Languagescala-lang.org
What is "Scala"? (Scala Algorithms)— A condensed jargon-free explanation of what Scala is in the bigger picture of things www.scala-algorithms.com/WhatIsScala/
Stack Overflow Developer Survey 2020— Nearly 65,000 took this comprehensive, annual survey of people who code. Demographics. Most loved, dreaded and wanted technologies. Salary and careers. insights.stackoverflow.com/survey/2020#technology-programming-scripting-and-markup-languages-professional-developers
- Why I ditched macOS, Linux, and chose Windows for development work — The CRUD blog augustl.com/blog/2019/choosing_windows_over_macos_linux/
Svelte • Cybernetically enhanced web appssvelte.dev
- From first principles: Why I bet on Scala.js www.lihaoyi.com/post/FromfirstprinciplesWhyIbetonScalajs.html
scalajs-cli-demo— POC to see if we can publish ScalaJS apps on npmjs. www.npmjs.com/package/scalajs-cli-demo
ScalaWilliam/scalajs-cli-demo— Scala.js in your NPM as a CLI app. Easy to publish! - ScalaWilliam/scalajs-cli-demo github.com/ScalaWilliam/scalajs-cli-demo
EventSource/eventsource— EventSource client for Node.js and Browser (polyfill) - EventSource/eventsource github.com/EventSource/eventsource
ActionFPS/actionfps-clone-logs— Clone live ActionFPS logs into a file. Contribute to ActionFPS/actionfps-clone-logs development by creating an account on GitHub. github.com/ActionFPS/actionfps-clone-logs
What Is Electron and Why Is It So Polarizing?— As application frameworks go, nothing is quite as loved or dreaded like Electron. Why is that? Find out more in this article. www.kirupa.com/apps/what_is_electron.htm
electron/electron-packager— Customize and package your Electron app with OS-specific bundles (.app, .exe, etc.) via JS or CLI - electron/electron-packager github.com/electron/electron-packager
Indigo · A game engine for programmers.— A game engine for programmers. indigoengine.io
State machine (Scala language concept)— A state machine is the use of `sealed trait` to represent all the possible states (and transitions) of a 'machine' in a hierarchical form. www.scala-algorithms.com/StateMachine/
Tweet by Jos DirksenFinished #puppeteer and #scalajs based image scraper and downloader. Got images I wanted for desktop. Slightly overengineered but fun to do! twitter.com/josdirksen/status/901156838204465152
We Won! How Scala Conquered the Big Data World— In 2012, Dean Wampler claimed that Hadoop, and Big Data in general, needed Functional Programming and an alternative to Java. Today he says that Scala has su... www.youtube.com/watch?v=AHB6aJyhDS (2015-04-01)
- ChristopherDavenport/http4s-scalajsexample — Contribute to ChristopherDavenport/http4s-scalajsexample development by creating an account on GitHub. github.com/ChristopherDavenport/http4s-scalajsexample
sveltejs/svelte— Cybernetically enhanced web apps. Contribute to sveltejs/svelte development by creating an account on GitHub. github.com/sveltejs/svelte
Svelte, why so much hype ?— Since the release of version 3 in April 2019, Svelte has been in the news all the time. But why? What... dev.to/zenika/svelte-why-so-much-hype-2k61
- Rich Harris: Futuristic Web Development — Edit from the future: check out our followup podcast interview on SvelteKit https://share.transistor.fm/s/859bbd95---This was recorded for Svelte Summit 2020... www.youtube.com/watch?v=qSfdtmcZ4d (2020-10-19)
- The Ur Programming Language Family www.impredicative.com/ur/
- Adam Chlipala adam.chlipala.net
- TypeScript, Seeing Past the Hype - Matthew Gerstman at ReactiveConf 2019 — Matthew Gerstman, senior software engineer at Dropbox, recently presented at ReactiveConf 2019 in Prague the lessons learnt by Dropbox after they migrated to TypeScript four years ago. Gerstman described the good, the bad and the ugly parts of TypeScript, and how TypeScript helped Dropbox to tackle programming at scale. www.infoq.com/news/2019/10/typescript-hype-reactiveconf/
Scala Nashorn Interaction— Scala Nashorn Interaction example with Single Abstract Method and JavaBeans. www.scalawilliam.com/scala-nashorn-interaction/
- Learnable Programming worrydream.com/LearnableProgramming/
- Bret Victor The Future of Programming — "The most dangerous thought you can have as a creative person is to think you know what you're doing."Presented at Dropbox's DBX conference on July 9, 2013.A... www.youtube.com/watch?v=8pTEmbeENF (2013-07-31)
Scala ScriptEngine doesn't seem to be working as before in 2.12.1/2.12.0 via SBT.— Scala ScriptEngine doesn't seem to be working as before in 2.12.1/2.12.0 via SBT. - sample.bash gist.github.com/ScalaWilliam/29f09ca77f11209aeaeb92f83e553087
r/Notion - Comment by u/SamLovesNotion on ”🔒 End to End Encryption is MUST!”— 289 votes and 87 comments so far on Reddit www.reddit.com/r/Notion/comments/eqvrz0/end_to_end_encryption_is_must/fexxwr8/
Excel Meets Lambda - Prof. Simon Peyton Jones & Prof. Andy Gordon - The Archimedeans × UCCPS— Prof. Simon Peyton Jones is a computer scientist who specialises in functional programming languages. He is most known for being one of the designers of Hask... www.youtube.com/watch?v=r9kf9an-zP (2021-03-10)
Microsoft Power Fx overview - Power Platform— Overview of the Power Fx language docs.microsoft.com/en-us/power-platform/power-fx/overview
What is Microsoft Power Fx?— Microsoft Power Fx is the low code language for expressing logic across the Microsoft Power Platform. It is the same language that is at the heart of Microsoft Power Apps canvas apps today and is inspired by Microsoft Excel. It enables the full spectrum of development from no code to pro code with no cliffs in between, enabling diverse teams to work together and saving everyone time and money. powerapps.microsoft.com/en-us/blog/what-is-microsoft-power-fx/
- Spores: Distributable Functions in Scala — Spores are "small units of possibly mobile functional behavior". They're a closure-like abstraction meant for use in distributed or concurrent environments. speakerdeck.com/heathermiller/spores-distributable-functions-in-scala (2013-09-19)
- Tuples bring generic programming to Scala 3 www.scala-lang.org/2021/02/26/tuples-bring-generic-programming-to-scala-3.html