Hacker News new | ask | show | jobs
by Timmmmbob 4386 days ago
You don't have to write in low-level C. You can write in high level C++, which is vastly preferable to javascript! Or hell, why not write in Lua! It's what this apparently transpiles to, and is much nicer.

The only reason javascript became popular is because it was the only option on the web. Why does that mean we would want to use it when we have better options?

2 comments

> You can write in high level C++, which is vastly preferable to javascript!

First, C++ compilers are not available everywhere. Second, C++ compilers do not always implement all corners of the language on embedded systems. Third, C++ is better than Javascript? That's going to take some explanation.

> Or hell, why not write in Lua!

Lua has it's own share of "Wat". 1-based indexing when a non-trivial amount of your stuff needs to interoperate with C is a big one. In addition, Lua is nicely configurable--read, "Every Lua implements a different set of modules."

> The only reason javascript became popular is because it was the only option on the web.

It's popular to hate on Javascript, but Javascript isn't that bad. Go back and take a look at Javascript in the Netscape 2.0 and Netscape 3.0 timeframe. It's a fairly straightforward, minimal language.

Now, all that having been said, this isn't exactly impressive. A 180MHz ARM with 32MB of flash and 32MB of RAM is not a small processor. With that level of power, there are lots of options.

If this were running on an 50MHz M0 with 256K flash and 16K RAM, it would be impressive.

> First, C++ compilers are not available everywhere.

Neither is javascript. If both are available for this micro, then his statement is as valid as yours.

> Second, C++ compilers do not always implement all corners of the language on embedded systems.

I've done a good bit of embedded programming in C and I wouldn't need all of C++ to make life a lot easier.

> Third, C++ is better than Javascript? That's going to take some explanation.

To-may-to/to-mah-to. Whichever way you want to spin it (C++ > javascript or javascript > C++) is going to take some explanation.

> but Javascript isn't that bad

No. But its also not as that great in comparison to how popular it is. Its certainly improved a lot since the early days, but it still has some pretty significant warts. Most languages do, of course, so if this is an issue or not kinda depends on the "third" above.

> Now, all that having been said, this isn't exactly impressive. A 180MHz ARM with 32MB of flash and 32MB of RAM is not a small processor. With that level of power, there are lots of options.

Indeed. I wonder how much overhead this has compared to running C on the same thing. I have nothing to back it up and certainly don't have time to benchmark, but I'm convinced I could write a forth interpreter running on a 60MHz PIC24E that would have competitive performance to this thing. Maybe I wouldn't beat it, but I reckon I could come close enough.

> Neither is javascript. If both are available for this micro, then his statement is as valid as yours.

Hrm, I stand corrected. I thought that at least some of the Javascript implementations were C-only, but it looks like they all require C++.

> I've done a good bit of embedded programming in C and I wouldn't need all of C++ to make life a lot easier.

Templates, exceptions, and memory allocation all interleave and you pretty much can't have one without all of them. And that's a huge amount of overhead on a truly small system (which this is not--my first Linux box wasn't 180MHz with 32MB or RAM). About the only thing you can have standalone is the original "C with classes" subset of C++. And I just don't find that very much more useful over straight C (and certainly not over the latest standard C11)

However, I'm much more interested in Rust on embedded systems than these dynamic languages.

Do they not support templates? I'd be happy with "C with classes, templates and RAII". But point taken regardless.

I completely agree - I'm also much more interested in Rust for low level and embedded programming!

If you want to write C++, just compile it to javascript: http://kripken.github.io/mloc_emscripten_talk/gindex.html#/

Ridiculous?

> Third, C++ is better than Javascript? That's going to take some explanation.

It's statically typed, and the types you have to work with are a lot simpler.

.NETMF will run a C# Interpreter in 256KB of RAM and 1/2 a meg of code space.

Give it a bit more and you can get a full UI up and running with a WPF variant!

I didn't think NETMF was interpreted. That said, the last time I looked at NETMF I was put off by forum arguments over who owned what code samples.
For the same reasons you're writing in English.