Alternatives to JavaScript

Daniel Kioko
TheCodr
Published in
2 min readSep 7, 2021

Ever thought about replacing JavaScript? There are alternatives that will allow you to run your functions on a browser.

JavaScript is one of the most popular programming languages in the world. It is an essential language for web developers, and its compatibility with other languages makes it a good fit for most developers. Delphi was once known to be JavaScript’s rival but it failed to gain widespread adoption.

Brython

Brython is designed to replace Javascript as a web scripting language. As such, it is a Python 3 implementation adapted to the HTML5 environment, also known as DOM objects and events.

All it takes to run this is a short HTML file, and your Python placed inside a script element. This is very elegant. It also runs on smartphones as well as in all modern browsers.

All you need to do to run the code is a short HTML file along with your Python code placed inside a script element.

def echo(ev):
InfoDialog("Greetings", f"Hey {document['zone'].value} !")
document["title"].bind("click", echo)

Brython has a number of modules provided for web-related functionality that is not supported in Python such as markdown, local storage, Ajax, timers, workers, and web sockets.

Pyodide

Pyodide brings the Python 3.9 runtime to the browser through WebAssembly. It also comes with the Python scientific stack, that is: NumPy, Pandas, Matplotlib, SciPy, and scikit-learn.

Similar to Brython, you can run Python programs inside a script but the syntax used to pass the Python code into a function is slightly different:

pyodide.runPython(`
import sys
sys.version
`);

Pyodide would be the best option to go with if you want to build with WebAssembly.

Blazor

Blazor is part of the ASP.NET framework that lets you build interactive web interfaces using C# instead of JavaScript. Blazor apps are composed of reusable web UI components implemented using C#, HTML, and CSS. Both client and server code is written in C#, allowing you to share code and libraries.

It’s also cross-platform, that means you can develop Blazor applications on Mac, Windows and Linux.

Here’s a sample of code in Blazer:

Current number: @currentPageNumber@code {
private int currentPageNumber = 1;
private void NextPage()
{
currentPageNumber++;
}
}

Something to note is that all these alternatives still have implemented JavaScript functions behind the scenes for them to work properly.

You’re not required to know JavaScript to use any of them but it would be great to know so you can better understand what’s happening in the backend.

I hope you enjoyed reading this! Follow TheCodr for more.

--

--