Created
September 16, 2024 21:31
-
-
Save JohnScience/e04da68a7478b6af923679a7647a816a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<style> | |
body, html { | |
margin: 0; | |
padding: 0; | |
height: 100%; | |
background-color: rgb(66, 4, 235); /* Set background color to white */ | |
} | |
marquee { | |
display: block; | |
height: 100vh; /* Full viewport height */ | |
width: 100%; | |
overflow: hidden; | |
font-size: 90vh; /* Set font size to almost full page height */ | |
line-height: 95vh; /* Slightly less than full height */ | |
} | |
</style> | |
</head> | |
<body> | |
<marquee behavior="scroll" direction="left" scrollamount="20"> | |
Rust is a compiled programming language like C and C++. While Rust is not a direct successor to C++, Rust is viewed | |
by many - including me - as the replacement for C++. However, Rust can be used practically in any domain. | |
WebAssembly (also, WASM) is a portable binary-code format for executable programs and components-"libraries". | |
A notable application of WASM is in browsers, where WASM can serve as a compiled alternative to JavaScript. | |
Currently, I'm experimenting with the idea of using Rust and WASM to create a multi-component application that would allow | |
the corporate customers of my employer have a fine-grained programmatic control over the actions of our backend server | |
in case of various events like `candidate_evaluated`. The idea is to allow the customers to write the code that would | |
be executed by the server in response to the events. The code would be written in Python, JavaScript or any WASM-compiled | |
programming language. | |
So far, I've created two components: (1) a TypeScript module for browser that exports a code editor for Python, | |
which is written with Code Mirror, and (2) a WASM-compiled Rust module that embeds a Python interpreter, | |
and exports the functions for the code editor. | |
Right now, I'm working to solve the buffering issue in the WASM-compiled module. | |
Under the hood, Python's `print` function makes `write` calls for every argument, for every implicit space | |
between the arguments, and for the implicit newline character at the end of the call. Without buffering, mapping | |
the standard output stream (aka stdout) to the `console.log` results in a weird output with a new line for every | |
"write" call. To fix that, I'm trying to implement a buffering mechanism in Rust that would buffer the output of | |
the Python interpreter and flush the buffer to the `console.log` at the end of the Python script execution or when | |
reaching a "write" call with a newline character. | |
While working on the problem, I've encountered a couple of sub-problems where I'd benefit from "existential" types | |
in Rust. However, this language feature is not yet implemented in Rust. | |
<!-- | |
https://varkor.github.io/blog/2018/07/03/existential-types-in-rust.html | |
https://github.com/rust-lang/rfcs/blob/master/text/2071-impl-trait-existential-types.md | |
--> | |
More precisely, I'm working on adding "perRun" buffering, which is quite an impactful change to the existing code | |
because it requires introducing a `global WRITE_FN` thread-local static. | |
I'm inactively trying to find out how to throw Python exceptions in Rust code. | |
And I'm struggling with type information erasure in Rust. | |
</marquee> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment