4 ms·
"Make Real Things with Browser Technologies" How is that better or so different than making real things in C ? What problem would it solve? I get that js got
by jokoon 11y ago
"Make Real Things with Browser Technologies"
How is that better or so different than making real things in C ? What problem would it solve?
I get that js got very popular thanks to browsers, but does that mean we should use js for everything?
Seems like mozilla is just trying to salvage firefoxOS.
- Already__Taken 11y agoI've developed a few things on my Espruino Pico[1] board, some Raspberry pi and also so arduino things. Just toys really. One of the nice this I've found with the Pico is because of the JS vm, when I don't do anything in the code all the power in the chip goes to sleep state, and just wakes up for me as I've got scheduled. Yes Arduino has sleeps but i've also go to go learn that as another thing, yes the Pi can be configured so but that's even more tinkering. JS seems like a really great "Just get it done" sort of phase to work in. After that you'd no doubt make a better job of the project with a myriad of other technologies. 1: http://www.espruino.com/Pico http://www.espruino.com/Pico
- swiley 11y agoC does that too unless you sit in a tight loop polling something all the time.
- mwambua 11y agoMost embedded applications consist of a tight loop of constant polling. People slow things down by using delays... But if you use the wrong sort of delay (read: the most popular one https://www.arduino.cc/en/Reference/Delay https://www.arduino.cc/en/Reference/Delay), you'll end up executing nops instead of powering down the processor
- benten10 11y agoWhat would then be the right way to sleep? I've always wanted to do something like 'sleep until event <X> and do absolutely nothing till them', but end up using the delay every time.
- Fradow 11y agoFrom what I searched, it's dependant on your microcontroller, so there is no generic way to do this (since different Arduinos have different microcontrollers). For a very low power project I had, I basically found a lib that did deep sleep correctly for my microcontroller (an ATTiny), then you sleep for a significative period of time each time (for example, 500ms), and check if the event happened when sleep ends. That results in a consumption under 10uA. It is obviously very dependant of what you want to do, some applications can't afford to check only every X ms. And be careful too, you need to put everything possible behind your microcontroller, to be able to disable things during sleep (otherwise, you are just powering the rest of your circuit for nothing).
- mwambua 11y agoUnfortunately there's no easy answer to the correct solution. One method is to setup interrupt service routines and put the mcu to sleep the rest of the time. There are a couple libraries that provide convenient interfaces to AVR's sleep lib e.g http://playground.arduino.cc/Code/Enerlib http://playground.arduino.cc/Code/Enerlib The basic idea is that it is possible to put the chip into lower-power mode... but you need a way to wake it up after that. That could be an interrupt, watchdog timer... etc Another thing to note is that for most applications the mcu's power consumption will be negligible with respect to the peripherals', so the average person shouldn't care much.
- pjc50 11y agoMost microcontrollers let you configure a timer that runs while the processor is in sleep, then triggers an interrupt to wake you up. In this style of coding you end up with main() { configure_interrupts(); while(1) { do_irq_bottom_halves(); sleep(); // "wfi" in ARM } }
- HeyLaughingBoy 11y agoAs others said, it depends. I have one application where the CPU literally does nothing other than process switch actions (it turns a double click into a single click), so it goes into deep sleep and pressing a pushbutton is the only thing that wakes it up.
- espadrine 11y agoIndeed, JS being event-driven probably makes it a better fit for such devices. Most devices don't need to be realtime, so the GC pauses likely don't cause much harm. Speed isn't an issue most of the time either. As Dart is similar, it is also trying to lodge itself in that niche: http://dart-lang.github.io/fletch/ http://dart-lang.github.io/fletch/.
- petra 11y agoThe Mbed, which is the Arduino' "professional" brother, does support event driven sleep using callbacks: https://developer.mbed.org/blog/entry/Using-the-new-mbed-power-management-API/ https://developer.mbed.org/blog/entry/Using-the-new-mbed-pow... Since this is a part of the new mbed-2.0 os , i think there are already 5 micro controllers that support it.
- scotu 11y agonot that I like javascript that much, nor I know how meaningful are the result you can get with js in iot-firefoxOS, but js is absolutely more approachable than C so there's that problem that can be solved (lowering the barriers to access hacking on some iot device).
- JustSomeNobody 11y ago> ... but does that mean we should use js for everything? Yes. Jeff Atwood said it should be and so his legion of followers must make it so.
- lovelearning 11y agoNo compiling and linking required. Web and front end devs who are already familiar with JS can program IoT applications.
- moonchrome 11y ago>No compiling and linking required. Seriously ? The only build/library ecosystem that I hate more than C++ is javascript/node - it has all the same problems (a bunch of competing and incompatible standards/tools/patterns that do the same thing) but lower quality because of so much noise from low barriers to entry (hey at least you need to get C++ to compile on one compiler - that's something).
- lovelearning 11y agoIn the context of IoT applications, the typical application is either a dashboard web page or a HTTP web service - hosted on the device in both cases - serving sensor information to whoever requests it. Both cases are easily implemented using Javascript on Firefox OS [1]. In contrast, a C(++) application would let you read the GPIO states. But all the HTTP stuff still needs to be implemented. What's a good way to do that? I know C(++), Python and Java. I might select one of these. Can I use Node.js and interface with the C(C++) code? I don't really know. I think such questions inhibit devs who have not done any/much backend programming from getting into the IoT field at all. Firefox OS solves that problem by exposing low level system interfaces via client-side JS. As for the larger topic of javascript vs C(++) ecosystem, I can't say much because I'm not that familiar with server side javascript. [1]: https://hacks.mozilla.org/2015/02/embedding-an-http-web-server-in-firefox-os/ https://hacks.mozilla.org/2015/02/embedding-an-http-web-serv...
- rasz_pl 11y agothe question is should they?
- lovelearning 11y agoIt's a matter of personal interest and hobbies for me. Most of us have them, don't we? I'm not a good front end dev, but I still do some designing of UIs and websites. I'm not an electronics engineer, but I still build electronics circuits as a hobby. I'm not an artist, but I still use gimp and blender. It's just democratization of technologies. More, the merrier!
- vikeri 11y agoI agree, one issue with js on embedded is that while it is fun and easy to prototype compared to C, if it is intended to be mass produced the variable cost for each unit will be a lot higher due to js needing more powerful->more expensive microcontrollers. If you would substitute C for something in embedded I personally would go for Elixir/Erlang or something that would actually provide some great advantages over C in terms of abstractions and VM:s.
- ycosynot 11y agoWhat's interesting is it's compatible with Web rendering probably at a relative cheap price, and it runs an OS which has WebRTC and stuff, so it can be used as a cheap terminal but which is still able to render internet modernly, and connect through WebRTC to any browser. So it could be used as a server and rendering unit in a network of cheaper C-only integrated circuits which connect to it, I think. Personally, I'm not an expert, but I'm intrigued. We're biased by the monstrosity of the thing, but I like the idea, and surely it serves its function.