here to stay, and if you follow certain forums it looks like it’s spread absolutely everywhere
and absorbed every other language, but at the same time it just seems so damned indescribably icky.
It was a toy language that went nuclear. With just the bare minimum of features to be practical: several basic data types (Boolean, Number, String, Undefined,
Null, Object), basic flow control structures (if, case, for, do, while), but with fancy new features (at the time of its making) already built-in in the first standard: exceptions and
prototype-based inheritance, it was twisted, hacked and bolted upon enough in the almost two decades since its introduction to become actually usable, and finally, necessary.
Because of its very dynamic nature it has become one of the top reasons for the development of modern optimizing compilers and JITs. In a curious twist of fate, and
out of dire need, web browsers have become the drivers for large innovations and huge software engineering efforts to make this clumsy little language as good
as its more serious cousins. It has become routine to see developer teams
each other records fairly regularly - and this is perfectly fine.
What I think crosses the line into monstrosity is efforts which basically annotate the language with special syntax or objects which ordinarily would not normally
be used in practical programming to signal certain things to the interpreter or JIT. Consider asm.js. Have you every really looked at it?
novice programmers (especially at the time in mid 1990-ies) so they don’t have to trouble their precious minds about what really goes on under the hood, but
worth its salt needs to keep in mind that the practical implementation of the Number type in all current
engines is that of a double-precision floating point number, with all the devious problems it may bring.
the required operation and convert them back into the floating point representation. All this can be done without loss of precision if the numbers fit into a
32-bit integer (because all the values of a 32-bit integer can be unambiguously presented with a 64-bit double precision floating point type), but is reasonably slow.
The point of asm.js is to JIT-compile as much of the code in as low-level way possible, and this means the compiler needs to be sure that the programmer meant
that certain variables and certain operations be strictly integer-only. If this is done properly, certain variables will only ever exist in the resulting compiled
code as integer variables. In practice, it means the compiler recognizes special syntax which would otherwise be unnecessary or unused, like this:
Basically, the result of this operation, by definition, cannot be anything other than an integer value, even if every part of it - x, y and 0 - are actually
floating point numbers. This knowledge is used to simply compile this into low-level integer CPU instructions.
into when the code indicates it is compliant. Asm.js promises it will provide compatible entry points into such compiled code to whatever the wider external
from the Internet).
It makes me wonder — why???. Any code that requires asm.js to achieve decent performance will be horrifically slow when interpreted or even
JIT-compiled with generic compilers. Why not have a separate language which is sufficiently high-performance to allow serious compilation to machine code,
How Rust would help
#1: Rust is a "safe by default" language. It allows C-style low-level shenanigans but such code must be specially marked.
Obviously, for the web, this language feature would be completely disabled.
#2: Rust in integrated with the web. Unlike the vast majority of languages, Rust actually provides for directly
referencing required libraries for a project directly from on-line repositories. This means we can have
fairly large projects with tons of dependencies which don’t have to be distributed with the main code. There is still space for improvement, especially with regards
to depending on specific version of an external library.
#3: Rust compiles to C-level efficient machine code. It was never meant to be interpreted. It has low-level CPU-friendly data types. It can call into
and allowed shaders to be written in a more natural language for them.
#4: The licensing is friendly. Rust is MIT-licensed. It can be included wherever, even in
Of course, memory safety in itself is not enough - some sandboxing of the standard library will also be needed.
Asm.js is not the only elephant in the room. Things like SIMD.js try to shoe-horn advanced features
into a language which simply wasn’t designed to handle them. Compare this to Rust where such constructs could be handled with
templates and macros.
There are comments.