Live data from Hacker News

JavaScript right on the hardware

technical.io

131–140 of 320 posts

Re: JavaScript right on the hardware

#131
Hmm, I can see some potential difficulties with making JS work efficiently on that MC. It only has single precision floating point instructions, for one thing, and I can't tell how many cycles those instructions take. I'm guessing they'll just do a variant of JS that uses single precision, but even so, it seems like it would be hard to squeeze any kind of performance out of it.

Re: JavaScript right on the hardware

#132
post #54

Earlier quoted context omitted.

I don't have much problem with programming an embedded device in a high-level language, but why JS specifically? Why not Lua, which just as fast, and is better than javascript in many respects?

Slightly off topic, but is it just me or has Lua gotten a lot of attention on HN in the past weekish? I haven't heard much of Lua before but recently it seems to have come up a lot more. And even more off topic (sorry), what makes Lua better/different than other scripting languages? EDIT: On jacobwcarlson suggestion, I Googled Lua vs Python, and found this Wiki, http://lua-users.org/wiki/LuaVersusPython Not a speed c…

I'll leave the pros/cons of the language itself to others, but two of Lua's most attractive aspects are its size and speed. The interpreter is something like 200k and is built to be embedded into anything. For instance, RPM has a Lua interpreter embedded into it and here's Dino's paper about using it in 'sploits: https://www.usenix.org/legacy/event/woot07/tech/full_papers/... Benchmarks are notoriously unreliable but I encourage you to Google around for Lua v X language. It's _very_ peppy.

Re: JavaScript right on the hardware

#134
post #16

So much negativity in this thread & on HN in general. Not everyone has hardware experience, and this looks great for newcomers.

Totes.

Seems like a lot of that energy would be better spent making an equivalent device that runs . Want it to run coffeescript? go make a product designed around coffeescript. Want it to run Lua? Go make a product designed around Lua. etc.

The market has room for diversity. Just because it's not the diversity you prefer, doesn't make it any less valid.

Re: JavaScript right on the hardware

#135
post #47

Javascript doesn't support integers, so it doesn't seem like a good language for programming low level hardware. What about bit manipulation (XOR, AND, Shifting, etc)? This is critical for a lot of serial data communications and I/O controls.

JS supports integers; it just doesn't have an integer type so you can't always store, operate, etc on them efficiently (though a smart engine can do some of that for you). It has bitwise manipulation operations which treat the Number as a 32 bit int. There are also Typed Arrays which make it easier to work on raw binary data. Though yes, it can occasionally get a little finicky trying to interface a high level dynamic language with lower level stuff.

Anyway, for this I'm sure there will be a lot of libraries that handle that for you and expose a fairly high level api; like the blinking led in the example.

Re: JavaScript right on the hardware

#136
post #26

Earlier quoted context omitted.

CoffeeScript is JS. And to be more honest and judgemental, CoffeeScript is the sweeter-but-poorly-documented Javascript. The reason people are attempting to put javascript everywhere is because they can and because others enjoy it. And those who do enjoy JS, know what parts of JS are to be avoided at all costs. And I actually like it compared to other modern scripting languages for two reasons:(1) I don't have to wor…

> poorly-documented what?

There still isn't any language specification, is there?

JavaScript, TypeScript, and Dart have one.

Re: JavaScript right on the hardware

#137

Earlier quoted context omitted.

Because everyone* knows JavaScript. I'd wager that the vast majority of professional software engineers work on the web, or very close to the web, and JavaScript is the lingua franca of the web. I mean just look at the front page of Hacker News on any given week. It's full of talk of JavaScript and new JavaScript libraries and new things to do in JavaScript. When you think about how many more people this can reach wi…

I may know javascript, but my god I wish I didn't have to.

Many people do enjoy writing JavaScript and view it as just as good as Python and others.

Re: JavaScript right on the hardware

#138
post #50
post #30

Earlier quoted context omitted.

Why? I really would like to understand, because I see JS as a necessary evil, and would rather use something else if given the option.

It's extremely simple - basically everything is a hash. It has full lambda, not just crippled lambda like Python. It's very fast (I think it is the fastest scripting language except for Lua, and getting faster because of the browser wars). It usually doesn't require a lot of boilerplate code. What is not to like? The one thing I worry about is the limited range of integers.

Non-string values are not valid hash keys. Operations that should be type errors fail silently and return nonsense. The prototype system is less powerful than the OO system of basically every other scripting language. The language will never have continuations, so people who want real control flow are stuck using preprocessors to generate callback spaghetti. Encoding a particularly rigid mix of dynamic and lexical scope into the language specification, such that everyone must be exposed to dynamic scoping much of the time, is one of the worst ideas I can imagine.

Re: JavaScript right on the hardware

#139
post #116

Earlier quoted context omitted.

I suspect Arduino (at least the ones I've used, Uno?) are a bit underpowered for higher level managed languages like JavaScript.

Absolutely. On AVRs, `new` and `malloc` work, but just barely. RAII/stack-only programming is basically a necessity. That is simply not possible with languages like Python or Javascript.

JS doesn't necessarily have to run natively for this kind of programming model to work out. Johnny5, the library discussed in the link I provided, rather provides an interface to the Arduino's StandardFirmata API http://firmata.org/wiki/Main_Pager

Re: JavaScript right on the hardware

#140

This is very cool, but I don't see how it can compete with boards like the BeagleBone Black. The BleagleBone Black is $45 for a 1GHz CPU and 512 MB of memory, yet the access to low-level hardware is just as good.

Very, very different things.

The BBB and the Raspberry Pi are designed to be relatively high-power (both computational, and power draw from DC) devices running a true multiuser OS.

This thing is more akin to an Arduino Micro or a Teensy - a low-power controller that could run a very long time on a tiny battery, no OS to speak of, just a single loop of essentially real-time code.

I just made a hardware clock for my PC (7-segment LED display mounted in a CD-ROM bay slot). I used an Arduino Micro to drive the display.

I may build a dedicated media server at home. A RasPi or BBB would be perfect.

I'm thinking to launch a stratospheric balloon. I need something to hold together and drive a GPS sensor, temperature sensor, VGA camera, SD card, and radio transmitter. Total weight and power consumption are severely limited. An Arduino or Teensy would be great.

Do a wall-mount big LCD screen at the office, showing the vital stats of our website in real time, for all to see? A RasPi or BBB.

Or you could go even more bare-metal and do everything with an AVR that costs $1 and a few components that you recover from the last floor sweep, like this:

http://florin.myip.org/blog/how-make-halloween-creepy-blinki...

See the differences? Horses for courses.

Post reply on HN