3 web programming technologies that offer alternatives to JavaScript

0

JavaScript is one of the most popular programming languages ​​in the world. Not only does it generally feature high on the lists of popular programming languages ​​produced by RedMonk, Stack Overflow, TIOBE, and other organizations, but it also has the largest developer community in the world, at least according to the recent State of the nation of SlashData developers.

For web developers, JavaScript is an essential language, perhaps the essential language, given its compatibility. Other rivals have long since collapsed. For example, Delphi allowed you to create forms-based applications that ran in the browser on Windows, but no one used them. More recently, some developers have chosen Dart as a possible replacement for JavaScript, but it has failed to gain traction with many browser makers.

If you are tired of using JavaScript, you can always explore developing Python or C # apps that run in the browser. On a broader level, do these other popular languages ​​pose a threat to JavaScript “territory”? A handful of web development tools let you explore what other languages ​​can offer.

Brython: Python 3.0 running in your browser

Brython’s goal is to replace JavaScript with Python as the scripting language for browsers. For example, below is the Python source code for “Hello World!” in a browser. Enter your name in the text box, click the button and a pop-up window will appear. Not bad for five lines of code.

from browser import document, alert
from browser.widgets.dialog import InfoDialog

def echo(ev):
    InfoDialog("Hello", f"Hello {document['zone'].value} !")

document["test"].bind("click", echo)

All you need to run this is a short HTML file and your Python placed in a script element. It is very elegant. It also works on smartphones as well as in all modern browsers.



A series of modules have been provided for web related items that are not generally supported by Python e.g. Ajax, Markdown, local storage, timers, web sockets, workers, etc. I tried it with Chrome, which looked good (but it is claimed to perform better with Firefo) x.

The Brython Wiki on GitHub lists a series of apps powered by Brython.

Pyodurus

A programming alternative to Bryton is Pyodid, which compiles Python 3.9 with a scientific stack in WebAssembly (the scientific stack being NumPy, Pandas, SciPy and over 75 packages). It also allows you to install pure Python wheels from PyPi.

This is a fairly new project that only appeared in 2018, and which is a spin-off from an unsupported Iodide project. Like Brython, you run Python programs in a script, but here you have to pass the Python code into a function like this:

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

Despite its novelty, Pyodide is a very impressive programming tool but more difficult to use than Brython. If you want WebAssembly, go for Pyodide, because it’s built on it (WebAssembly can be used to improve Brython’s performance, but it’s more complicated).

Other alternatives to Brython and Pyodid include Skulpt and Transcrypt. I learned Python using CodeSkulptor based on Skulptor, during a distance course at Rice University. Skulpt is very good for learning Python because it is simply executed in the browser. You see an editor window on the left with an execute button below and an exit window on the right; but it’s more of a sandbox for running Python than a way to develop software.

Transcrypt takes a different approach and precompiles Python into JavaScript. It doesn’t use Python between script tags, as that would slow things down. Unlike Brython, it uses JavaScript libraries, not Python. It’s an interesting approach, allowing you to write JavaScript in Python. If you are comfortable with JavaScript and Python, this may work for you.

Don’t forget to take a look at their app gallery.

C # and Blazor

If you prefer to program and run C # in the browser, Blazor is the way to go. Like Pyodide, it also appeared in 2018 and comes in two versions: Server and WebAssembly. It’s also cross-platform, so you can develop Blazor apps on Linux and Mac as well as Windows.

Blazor builds on ASP.NET using Razor syntax which mixes HTML and code in an @code block. For example, this is a web page that increments a counter when you click the button:

@page "/counter"

Counter

Current count: @currentCount

@code { private int currentCount = 0; private void IncrementCount() { currentCount++; } }

In the server version, your C # code runs on the server and communicates with the JavaScript front-end using the SignalR protocol. It is only in the WebAssembly version that your C # (now compiled as a WebAssembly) runs in the browser. You can host it on an Asp.Net server so that the data is extracted from the server.

Conclusion

Each of these programming technologies, including the C # Blazor WebAssembly, use JavaScript behind the scenes in one way or another, if only to load a component. But you don’t need to know JavaScript to use any of them (although with Transcrypt that would probably be useful, as you can look at the JavaScript code that Python code transpiles to).

With the exception of Blazor, I don’t think any of them are exactly mainstream, but Brython, Pyodide, and Transcrypt have potential. As for WebAssembly, because it is compiled code, it has become very popular for running malware, especially crypto mining hidden on the machines of website visitors. Having said that, it’s still only a few years old, so maybe someone will implement some easy-to-develop language that generates WebAssembly.

Are any of these items a threat to JavaScript? Probably not, but if you are looking for other ways of web development then don’t hesitate to give them a try.


Source link

Share.

Leave A Reply