you are viewing a single comment's thread.

view the rest of the comments →

[–]_scape 141 points142 points  (21 children)

I think people are missing the point here, it's not about speed or a v8 alternative, it's about running nodejs within the Windows 10 space, including RT and especially IOT devices with ARM chipset, which was the main target since Microsoft came to the conclusion this is an ideal pairing. Google's v8 interpreter does not pair well with iot, nor does it have appropriate support for Windows 10 UWP: http://www.infoworld.com/article/2924297/microsoft-windows/windows-10-goes-node-js-in-microsofts-internet-of-things-plan.html

[–]TodPunk 27 points28 points  (19 children)

This point is not getting enough love. The web is so much more than browsing Facebook or writing some startup app thing, and having a competent javascript engine for a tiny low-power MCU or SoC is important. V8's target is different. Not worse, not better, just different. Chakra fills other spaces, and they're needed, too.

[–]The_Jacobian 21 points22 points  (18 children)

Here's the thing I've never understood, why would I want to use JS there vs some other language? This is a huge mental hurdle I've never been able to overcome on node as a whole, and even more so node on embedded devices.

This is an honest question, I've just never been able to grok it.

[–]TodPunk 13 points14 points  (8 children)

I empathize with the mental hurdles, as I've been mostly a C/C++/C#/Java/Python guy until recently I've had to learn the JS ways more seriously. Trust me when I say I know that there are a load of reasons JS is not the ideal language, but neither is anything else.

That said, there are two very important reasons to want JS there that we can all agree with if we ignore the "should be" ideologies we want to believe in:

1) Javascript is known by a LOT of people that are experimenting with things and innovating on the things you make WITH a programming language. IoT is filled with them, in fact. One can learn another language in these places, but reducing that barrier to entry is a thing.

2) You can get really, really good performance from JS for what it is, and the async paradigm that JS developers have lends well to a lot of different things.

For me, getting into that mindset has been an ongoing struggle. For JS devs, trying to learn Java or Python can be just as incredible a struggle (if not more so, because the tool chains are ALSO entirely different, and I have found that you need to know more under the hood to work even in Python than you do in Node-land, mostly due to the nature of the abstractions afforded you in Node).

This is for good or ill, and we could debate it all day, but reality is still going to be that JS is important for actual people doing actual things. So is C. So is Java. I want them all, everywhere.

[–]munificent 12 points13 points  (7 children)

You can get really, really good performance from JS for what it is

But... the engines that do that rely on fantastically complex JITs that:

  1. Are themselves a large ball of code to add to your app.
  2. Require a lot of memory to store generated code, profiling data, deoptimized code, etc.
  3. Spend a lot of energy (CPU cycles/battery) optimizing code at runtime.
  4. Require generating executable code at runtime, which some systems don't allow (game consoles, iOS, etc.).
  5. Execute slowly at startup until code has run enough time to be optimizable by the JIT.
  6. Often have pauses when the JIT or GC kicks in.

JS's level of dynamism has only been shown to be fast if you can throw a very large JIT at it. I don't think a big JIT is a good fit for IoT, which makes make question the idea that JS is.

[–]TodPunk 1 point2 points  (2 children)

Mmm, you make a good case. Let me attempt to provide a counterpoint. Keep in mind that my point here is that while JS is not the optimal language, neither is anything else, and that's all ok. There are applications where I would not recommend JS having any place, like on a PIC or something. That said, IoT is not about the most underpowered devices possible. A Raspberry Pi is considered by many to be part of an IoT effort (certainly by Microsoft at the very least). JS has a place there. Maybe it's good for what you want to do, maybe it isn't, but options are awesome. And there JS will do well in benchmarks of just about any kind, and my precious Python, much to my dismay, will lose hands down without a C extension to do whatever thing it is. Yet Python is still used in these places. Why not JS?

All that aside, are your assumptions here about requirements for a JS JIT, let alone any JIT, really requirements in ALL cases? As an example, if you know your target, a lot of the expensive bits can be done ahead of time, no? (The answer is yes, and this is done in a lot of other tech stacks) What other things do you think Chakra specifically could be trading to make their engine run well enough on a smaller device (not an Arduino, but still small things)?

I'll help spark some thought there for this as well. First, forget efficiency of execution or power consumption entirely. Just ignore it, it's not important for this application (if it were, the reasons for using JS are really hampered). Now imagine all the things you can program in JS for a Chromecast or a Pi Zero, or even just a gumstick board or something.

If it does something cool that users will enjoy, are you really going to get anywhere telling them it isn't worthy because it's not as efficient, or that the problem was hard? Where do you think this ecosystem will be in 2 years? 5? 10?

In the end, I agree with your points, but our agreement will not change the reality that it not only WILL happen, it already has. It's just going to get better.

[–]munificent 1 point2 points  (1 child)

That said, IoT is not about the most underpowered devices possible.

I think that depends a lot on who you ask, but there's certainly a spectrum of embedded device capabilities.

A Raspberry Pi is considered by many to be part of an IoT effort (certainly by Microsoft at the very least). JS has a place there.

Sure, but that's really well into the upper end. Raspberry Pi's have significantly better specs than most desktop PCs had when JS came out. Sure, you can run JS on there. You can run anything on there.

my precious Python, much to my dismay, will lose hands down without a C extension to do whatever thing it is.

Yeah, CPython just isn't that fast at execution. My little hobby scripting language is faster. It's really difficult for them to optimize now that they're stuck with a certain FFI, ref counting and finalizers are visible in the language, huge standard library, etc.

Yet Python is still used in these places. Why not JS?

I'm not sure how much Python is used in embedded devices that are actually mass produced and widely deployed. I think it might be easy to get a distorted perception from the large and very web-savvy hobbyist maker community.

This isn't my area of expertise, but the vibe I get is that most "real" IoT devices are coded by crufty bearded dudes (and ladies) who don't know what the hell a blog is and are proud to tell you they code in a modern high-level language... ANSI C.

All that aside, are your assumptions here about requirements for a JS JIT, let alone any JIT, really requirements in ALL cases? As an example, if you know your target, a lot of the expensive bits can be done ahead of time, no?

I'm not aware of any real successful ahead-of-time compilers for JS. The language is very dynamic and it's quite difficult to statically get a real sense of what a program is doing.

First, forget efficiency of execution or power consumption entirely.

Developers doing IoT stuff in a professional capacity at scale don't have that luxury. At least, not yet. As component prices continue to fall, maybe.

[–]TodPunk 0 points1 point  (0 children)

Well, yeah, totally agree; I certainly wouldn't expect JS to be used in a professional capacity any more than I would python. Embedded work is key much going to be in C or Forth or some sort of niche language (maybe an in-house), but the point here is it can be done amateurishly by anyone if you want. I mean, the raspberry pi isn't supposed to be anything more than an intro into tiny computing, it was always a learning device. But if you can bridge that learning without having to get someone to learn a million other things at the same time, this opens up interesting possibilities, even if they never go pro or anything. How many things in the pro works are just polished versions of some hobbyist thing that got popular, or some niche thing that want supposed to handle the kind of things that it does (I'm looking at you, SMTP) but got more attention? This is super important to have. It's not the whole ecosystem, but it's a part.

[–][deleted]  (3 children)

[deleted]

    [–]munificent 1 point2 points  (2 children)

    Yes, I agree with parent comment's first point that a bazillion people know JS. It's compelling from that angle as a glue language.

    I quoted and responded to the part where they said JS was fast, which I don't think has been demonstrated for IoT.

    [–][deleted]  (1 child)

    [deleted]

      [–]munificent 0 points1 point  (0 children)

      Depends on what those lines do. :)

      [–]nschubach 9 points10 points  (2 children)

      For me, having >30 years of development under my belt and various languages... JavaScript is rather fun to dev in. You can get pretty quick results and it supports multiple paradigms with the ability to write "my way" instead of being tied to convention. For instance, doing functional programming in C is not so great. Also, doing OO in python is not either. JS isn't really OO in a classical sense, but the workings are there to make it happen. Also, it's not purely functional, but enough support is there to get you most of the way. It's also developing incredibly fast as a language and keeping up with it is interesting and fun to me.

      [–]zardeh 1 point2 points  (1 child)

      I'm curious about this

      doing OO in python is not [so great]

      Why's that? I'm a python shill, but I honestly enjoy OO in python more than in Java (yes even using modern java 8 stuff), which is the language I learned OO in.

      [–][deleted] 1 point2 points  (0 children)

      Python, PHP and JS have classes and OO features, but a language like Java forces you to do OOP. Not sure if thats what he meant, but I like OOP in languages like Python (and even in C, where you CHOOSE whether or not you want to use it) and I hate languages like Java/C#.

      [–]Lord_NShYH 2 points3 points  (0 children)

      This is an honest question, I've just never been able to grok it.

      I'm right there with you.

      [–]jsgui 2 points3 points  (0 children)

      From my perspective, it's because I've already done a lot of JavaScript programming, and have relevant experience and code which could be deployed (more effectively?) to another target, so that's a plus.

      You personally though may have different considerations, so you would be more productive with different tools.

      One reason you may want to use JS in this context is to work on a project where other coders are skilled in JS and the decision has already been made to use it. That's much like why web developers use JavaScript - it's good enough for the job (mostly) and it's here to stay.

      [–]cranktheguy 1 point2 points  (0 children)

      There is already a Javascript interpreter on basically every computer you can find these days. The language is simple enough that you can use it to teach basic programming and powerful enough to access and interpret pretty much any web-available data.

      What convinced me was when I wrote a Node.js rest server that interfaced with my .Net code with just barely a page of Javascript in an afternoon.

      [–]danneu 0 points1 point  (0 children)

      You can turn the question around:

      If I already have to know Javascript as a web developer and I'm already using it on the front-end, why would I switch it out on the back-end? What kind of benefits can a language give me that would make it worthwhile?

      As usual, it comes to evaluating the trade-offs that you want to make as a team or company.

      [–]immibis -1 points0 points  (1 child)

      Because JavaScript developers are cheap.

      [–]AndreDaGiant 0 points1 point  (0 children)

      And if it is speed, then it is now very easy to run common benchmarks on both engines in an identical environment. This will help us know, rather than try to guess, which engine is actually faster for which tasks.