4 ms·
If you only have 64kB what's the point of using JS? I get that I'm free not to use it, but I genuinely don't understand why these projects are popular - you nea
by mhh__ 6y ago
If you only have 64kB what's the point of using JS? I get that I'm free not to use it, but I genuinely don't understand why these projects are popular - you nearly always end up using C in the end anyway, especially because embedded nearly always means writing to registers and specific memory addresses.
- keithnz 6y agomostly I think it appeals to non traditional embedded programmers. It has some appeal in that it is easy to send code to devices as "data" ( much the same as the advantages of embedding lua or other scripting languages ). Certainly not something I would choose though (I do IoT systems from the embedded devices -> backend -> web frontend ).
- oddity 6y agoSome people only know JS, or just don't want to learn both embedded and C at the same time. If projects like this can help people get over that initial hurdle, then all the better. Plus, writing constrained environment language implementations is quite fun.
- mhh__ 6y agoI guess so. Directed at anyone asking the question your first paragraph raises: C isn't that bad, give it a try, even if you don't use it your skills and perspective as an engineer will thank you.
- colejohnson66 6y agoPointers are quite a hard concept for a lot of people to wrap their heads around. JavaScript’s lack of them is easier to understand for them.
- jakear 6y agoIn my experience the harder thing is the stack/heap memory model. It’s easy enough to get someone to understand that the variable “points” to another variable like a house address or whatever. But, trying to explain that once a return happens the thing that was pointed to will potentially be gone entirely and you probably wont know immediately, or at least until you call another function, unless you allocated it with malloc, but in that case you need to be sure to call free at some point later, but watch out don’t call free twice, and hey there’s some analysis tools you can use with gdb to help find these types of issues, oh yeah gdb is this debugger it has its own special syntax you’ll want to learn than too, etc etc etc. It’s so much easier to say: oh, you want to make a tree? Just make some leafy nodes and make some branchy ones point to them and you’ll literally never see segfault in your life. The pointers are still there, but the trouble is gone.
- nicoburns 6y agoC's point syntax doesn't help either. It's fine if you just have one pointer. But a few of them nested with some functions in the mix. Oh my. Oh, and basic primitives like arrays and strings in C are far more complex (and easier to get wrong) than pretty much every other language. And it doesn't have a built in map type at all!
- krapp 6y agoIf you can understand how 'this' works in javascript you can almost certainly understand pointers in C.
- andrew_ 6y agoI'm not so sure. I learned pointers via C++ years before I tackled JS. Though I suspect you mean that the comprehension is similarly difficult, the paradigms are quite different. Visualizing and mentally tracking `this` by scope is aided by the structure of JS (even though it can get hairy with `bind`). Pointers requires a different model of thinking, and it's not one that's native to many languages. I originally came up in the mid-90s with VB3 and it was quite a jump to C++.
- Jataman606 6y agoIt seems that it actually cannot be used for such small systems. README states that this compiles to 160kB. But i agree with your point, unless theres some OS on board, using JS is probably too restricting.
- awild 6y agoYou can easily virtualize your device for secure computing this way. I did a seminar on secure IoT computing and that was one of the main selling points of it. Since the vendor only exposes the APIs they want and has full control of them they can open up the platform more.
- fulafel 6y agoSame as the point of high level languages generally, you can express more complex application logic with much less programming effort plus you can focus on your app instead of worrying about manual memory management crashes and security vulnerabilities. Register/memory write primitives can be easily exposed to the HLL. (Yes there are other high level languages besides JS you might use too, eg MicroPython...)
- Existenceblinks 6y agoHigh level language should have worry-free memory management or memory safety built-in. Javascript does not have this characteristic. If we ever have to removeEventListener anywhere, it's worrisome in general.
- deleted 6y ago[deleted]
- schwartzworld 6y agoIt gives people access to embedded without them needing to learn C. This is useful for hobbyists. I'm not against learning new languages, but sometimes you want to use what you are familiar with so that you can think about your project, not learning to write the code. Also re: your last point, most of these languages have library support for common features, and you definitely don't have to think about registers and memory addresses. Look at the kind of projects people make with Arduino, flashing LEDs and servos work just fine in a high level language.
- mhh__ 6y ago> Arduino, flashing LEDs and servos work just fine in a high level language. Arduino is C++, no? I would class C and C++ as being basically in the same tier here
- schwartzworld 6y agoWell, it's c++ but most users interact with high level libraries, so you don't really need to know much c++. But still, there's no reason you can't tell the board to switch a pin on in JavaScript or Lua. You don't necessarily need that level of control for most hobby projects.
- imtringued 6y agoYeah the problem is that you basically write C in Javascript in the end. You'll constantly have to second guess which features aren't supported.