269 points · by syrusakbary · 7y ago · 56 comments
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 supplant JS and this is an exploratory compatibility-breaking step.
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 Typescript is only interesting as a (painful) intermediate solution for large Javascript code bases until there is a serious replacement for Javascript through WebAssembly. I'd never choose Typescript as a language, even stronger, I recently moved away from full-stack web development partly because of it. Back to C++, what a relief..
I've been pretty impressed with static duck-typing and miss it when I'm in Java.
If something gets typed as `any` all bets are off and there are no benefits. So people don't end up running the type checker during development anyway. Which defeats the purpose.
There are small places where it is useful -- some developers on the team had never used a type system before and found that it helped them eliminate errors from their code before they even ran the program.
But overall... agree, Typescript/Flow -- they were great experiments and useful -- but I'd rather see ways for us to adopt better languages. Elm, Purescript, Haskell, F# -- Javascript is great for projects of a certain size... but once you get to a large team and many tens-of-thousands of lines of it... discipline will only get you so far.
Then why allow `any`? Using TS without the compiler and linter configs tuned to your benefit is like trying to use a plane only as a car. No discipline required if you let yourself fly with settings that set you up for long term success later.
Also, Flow is not on the same level as TS. It's a dead project and was never fully baked.
How about memory safety and type inference?
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.
I guess we have been using different platforms, so is the bubble of web development.
Just for your education, Python ML research, is just glue for GPGPU libraries written in C++, NVidia nowadays specifically targets their GPGPU designs to match C++ semantics, Apple, Google and Microsoft use C++ for their drivers, Metal shaders use C++, AAA game industry breathes C++, Fintech uses a mix of Java/.NET and C++, LLVM and GCC, the beloved FOSS compiler stacks are written in C++, AUTOSAR requires C++14, Arduino Sketch is actually C++,…
C++ might have a couple of flaws, not being mainstream is certainly not one of them.
Oh the humanity!
I weep for mankind and for the industry if this is where we have fallen.
Quick question: are you a Javascript programmer?
If this dream will come true, we will have both broken JS development space, and not much better TS developer ecosystem.
The creation of TypeScript is Microsoft's doing its trick called "Extend Embrace Extinguish."
They see that their captive developer community of VB and C# devs is trying to migrating to more sane scripting languages, and they want to cauterise the bleeding with TS.
The moment TS will gain steam, they will very likely add some extensions that will finally break any form of reverse compatibility, and make TS a standalone language. And few years down the line they will put a lid on it too.
And knowing that MS Devs are not far Java devs in their mentality, they will follow wherever their stomach guides them.
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.
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 objects with hidden classes at runtime, does similar thing with vtables ahead of time.
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).
It also makes me wonder how AssemblyScript will fit into the picture. Anyone from Microsoft/TypeScript can shed some light on future plans?
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 repurposed as explicitly targeting WebAssembly in order to become a viable alternative.
And Static TypeScript is part of a set of projects with very different goals.
That being said, it could indeed be turned into something targeting WebAssembly. And unless Microsoft goes that route, it may happen as a fork. Still, I’m not sure of the benefits compared to AssemblyScript. I’d rather see Microsoft contribute to AssemblyScript.
Either way, I hope Microsoft pushes AssemblyScript forward :)
The main use case for STS is https://makecode.com which is a CS EDU platform for physical computing.
One 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
STS has at runtime four kinds of unrelated object types:
1. a dynamic map type has named (string-indexed) properties that can hold values of any type; 2. a function (closure) type; 3. a class type describes instances of a class, which are treated nominally, via an efficient runtime subtype check on each field/method access, as described below; 4. an array (collection) type.
I can not think of what they smoke claiming running a scripting language on an MCU.
Microsoft seem to set its sights on breaking the MCU development after nothing has left to break on the desktop.
From the parent link: https://github.com/microsoft/pxt/