I believe this will have major implications for the WebAssembly ecosystem. It also makes me wonder how AssemblyScript will fit into the picture. Anyone from Microsoft/TypeScript can shed some light on future plans?
Static TypeScript: A Static Compiler for the TypeScript Language
41–50 of 57 posts
Re: Static TypeScript: A Static Compiler for the TypeScript Language
#42One important clarification: So far STS has been built specifically to target microcontrollers/MCUs. Initially it was targeted at the BBC micro:bit [0] for educational purposes and has since grown to support many more targets ([1],[2],[3],[4],[5]). The other dominant languages in this space are MicroPython and the AVR/Arduino language. The advantages of STS are beginner friendliness (makecode is a CS EDU platform), low-memory, small size and performance (relative to MicroPython). It's worth noting that in general STS is NOT faster than running JS in V8.
How does it compare to MicroPython?
- Error reporting: Because STS is statically typed and compiled, most program errors are caught in the editor before the program is loaded on the device. Furthermore, STS comes with a simulator that runs in the browser and so programs can be tested there before they run on hardware. For educational purposes, we found diagnosing issues on hardware to be really hard for students, so we try to catch and present errors as early as possible.
- Performance: [3] is the best example of this. Usually we notice STS is ~10x faster than uPython while having a smaller flash and memory footprint. This makes running a game loop at 30FPS feasible on a 120x160 display (e.g. this [6] $25 device).
How does it compare to AVR/Arduino/C/C++?
- Modern language: STS, like TypeScript, heavily uses type inference, supports advanced types constructs like algebraic types (i.e. sum/union and product/tuples), supports ducktyping, has easy to use lambdas, has a light-weight syntax, and favors event-based programming.
- Teachability: Because of the heavy use of type inference, most beginner programs have no type annotations and it looks just like Javascript. So we essentially teach JS to users after they want to move on from blocks.
- In general STS is not faster or smaller than AVR code!
Happy to answer other questions!
[0] https://makecode.microbit.org
[1] https://makecode.adafruit.com
[2] https://maker.makecode.com
[3] https://arcade.makecode.com
Re: Static TypeScript: A Static Compiler for the TypeScript Language
#43This language is quite striking! TypeScript is a superset of JS but here we're going from the other direction. Make a language that is only the TypeScript extensions to JS, and drop all the JS parts. No Object (!!), no Date, TypedArray, RegExp, almost all the mainstays are gone. It's Java 1.0: static offsets and vtables. This feels like the beginning of TypeScript throwing its weight around. It has the momentum to su…
What's wrong with TypedArray? It provides kickass performance for things like graphics. Any replacement would have to be at least as fast.
Re: Static TypeScript: A Static Compiler for the TypeScript Language
#44This language is quite striking! TypeScript is a superset of JS but here we're going from the other direction. Make a language that is only the TypeScript extensions to JS, and drop all the JS parts. No Object (!!), no Date, TypedArray, RegExp, almost all the mainstays are gone. It's Java 1.0: static offsets and vtables. This feels like the beginning of TypeScript throwing its weight around. It has the momentum to su…
STS was designed and built to target MCUs for educational purposes. It's actually incompatible with pretty much every NPM package out there TypeScript or not, because 99% of those can't fit or run on an MCU.
Re: Static TypeScript: A Static Compiler for the TypeScript Language
#45I believe this will have major implications for the WebAssembly ecosystem. It also makes me wonder how AssemblyScript will fit into the picture. Anyone from Microsoft/TypeScript can shed some light on future plans?
In its current state, Static TypeScript is a toy compared to AssemblyScript. It doesn’t support much of the original TypeScript features, while AssemblyScript is getting pretty close to the original TypeScript. AssemblyScript was also specifically designed to target WebAssembly. For example, it supports 64 bit types and has builtins that directly map to WebAssembly opcodes. Static TypeScript would have to be repurpos…
The main use case for STS is https://makecode.com which is a CS EDU platform for physical computing.
Re: Static TypeScript: A Static Compiler for the TypeScript Language
#46This language is quite striking! TypeScript is a superset of JS but here we're going from the other direction. Make a language that is only the TypeScript extensions to JS, and drop all the JS parts. No Object (!!), no Date, TypedArray, RegExp, almost all the mainstays are gone. It's Java 1.0: static offsets and vtables. This feels like the beginning of TypeScript throwing its weight around. It has the momentum to su…
> Make a language that is only the TypeScript extensions to JS, and drop all the JS parts. So? Is there a reason left then to use Typescript instead of C or C++? I cannot think of one. Especially for education you better use a real language that will stay for more than 10 years at least. Microsoft is doing a great job taking over the Javascript community, and now this.., would love to see their hidden agenda. IMAO Ty…
How about memory safety and type inference?
Re: Static TypeScript: A Static Compiler for the TypeScript Language
#47From the title it would seem it is boiled down to a completely statically-typed language, but it isn't. e.g. type casts are no-ops. Instead, every object access is type-checked at runtime. `any` still exists and for unions and complex types it still performs full lookup by name (instead of RTTI/tagged unions or such). So it's not really a static language, but a cut-down JavaScript runtime that instead of optimizing o…
It's also meant to run on a very constrained microcontrollers (think a few kB of RAM), and compile inside of a client-side webapp (both of which make it hard to use things like AssemblyScript).
Re: Static TypeScript: A Static Compiler for the TypeScript Language
#48Earlier quoted context omitted.
I am not sure where you are going with that. C++ is largely popular and enduring for the same reasons as Java: institutionalization (taught in school).
That's simply not true. I'm not aware of any place where C++ is taught. (And in fact C++ programmers are very hard to find.) C is very common and anybody with even a bit of format education has been exposed to C. Then you get people who know a bit of C and throw in a couple 'class' and a couple 'cout', and call it 'C++' for some reason. Which is wrong, obviously.
It may feels nice preaching that C++ is only whatever subset you may like (and there are a LOT of C++ programmers, or "programmers who write code that happen to be accepted by C++ compilers" if you prefer, that do that - personally i like pre-C++98 subset that was implemented in Borland C++ Builder 1) but in practice when you have to deal with a real world big C++ codebase (especially something you didn't write yourself and didn't start last month) you'll see all the faces of C++ at the same time, either you like it or not.
Re: Static TypeScript: A Static Compiler for the TypeScript Language
#49Given that they're both TypeScript subsets with similar goals, how close is STS to AssemblyScript? And is WebAssembly also a planned or possible compilation target of STS?