346 points · by chinchang · 13y ago · 313 comments
At the same time, I can't help but grin that we on the CS side find a way to erase all the gains in performance and efficiency as soon as the EE guys make them.
There has to be come kind of universal constant: the limit, as technology proceeds into the future, of the execution time of "Hello World" is some fixed number. Because as soon as we get better hardware, we invent an even weightier runtime environment to slap on it. ;)
This is a long-noted phenomena. The old saying that summed it up was, "Andy giveth, Bill taketh away." (Referring to Andy Grove of Intel and Bill Gates of Microsoft.)
According to some recent research[2], the three primary factors affecting the adoption of a programming language by developers are, in this order:
1. Libraries available
2. Familiarity
3. Performance
And per the paper, this order of preference is extremely strong. Which means, because of the huge mass of Javascript developers out there, that as soon as a library becomes available to do something in Javascript, Javascript will rapidly become the most popular way to do that thing, regardless of the performance hit.
[1] http://redmonk.com/sogrady/2012/09/12/language-rankings-9-12... [2] http://www.eecs.berkeley.edu/~lmeyerov/projects/socioplt/pap...
> 1. Libraries available
Not just programming languages. Microcontrollers too. You could get much better performance out of a bare AVR, but where are the libraries and modules? Whereas an Arduino comes with a library for anything that moves - of course most people are going to prefer it.
http://blog.safaribooksonline.com/2013/07/16/javascript-powe...
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 comparison, but gives a fair amount of difference in the actual languages. And yes it is on a Lua users site, so may be biased, but on my very light reading didn't seem too bad.
Although I'm one of those Lua "unadopters", for me it's better to simplify stuff to my audience, and I have considered seriously to use JavaScript for my next project instead of Lua.
But one area where Lua is gaining traction is because it is the only high level language that is integrated with Nginx.
Its only real drawback is a lack of libraries/package manager compared to, say, Python/Ruby (respectively). I guess some people might miss built-in support for classes.
http://www.codinghorror.com/blog/2007/07/the-principle-of-le...
That's one way to see it.
Another is that we don't erase them: we put them to use so programming can be more widespread, easier and more ambitious in scope.
(E.g. you cannot practically write a 10.000.000 line program in ASM, whereas you can in C. Or you cannot have everyone be able to write a 200 line high level program that does something complex in C, but you can in Python).
Allowing programming to be more widespread is a noble cause, but there comes a point (and I think it is approaching rapidly) where you layer so much abstration between the machine and the programmer, that they're guaranteed to write poor, or at least slow code. We need to find a middle ground, and I think javascript pulls in the wrong direction to this.
At the same time, I can't help but grin that we on the
CS side find a way to erase all the gains in performance
and efficiency as soon as the EE guys make them.
Here is one way I can think of - add a layer to run a subset of Scheme on this :)For me, the main challenges always were getting the program onto a chip and wiring everthing so that is does not break or shortcut.
Although I agree with you that Arduino C is simple enough for most microcontroller programs and Javascript is a bit overkill.
I like my functions as first class citizens. I like my prototypes and my inheritance model. I like my callbacks and my closures. I like how I can move from client-side, to server-side, to my TV, all with the same language. I like how easy it is for beginners to produce something useful and for seasoned developers to produce something good.
There are many other languages that share such traits but Javascript is one of the few that can be picked up by beginners interested in any field (eg: games, web, apps) and keep surprising you. It is extremely powerful in the hands of those that devote time to learn how things work. Its one of the few languages that you can learn as a beginner and keep with you as you become a better programmer.
I don't think it should be the only language someone knows but it should be a language that everybody knows.
So yes, there are people who like 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 worry about whether my end-user will have to worry about installing 100 dependencies to consume my code/service (2) I can choose how robust my setup is (Closure Compiler) or how sweet (CoffeeScript), and spend time sharing my setup with others who like the language instead of using proverbial sarcasm on topics about languages that I don't want to use.
It very clearly states, 'The golden rule of CoffeeScript is: "It's just JavaScript".'
what?
JavaScript, TypeScript, and Dart have one.
In my day job, we write mostly Coffee - which is little more than a preprocessor to JS, IMHO. It's definitely nice to have, but I don't consider it an independent language unto itself. If you know JS well, it shouldn't take more than a day to get up to speed with CS.
Just because it has first-class functions it does not mean that JavaScript is a "functional" language.
JavaScript does not promote the use of pure functions, referential transparency, and the minimization of state.
JavaScript does not encourage the use of recursion.
JavaScript has an atrociously broken type system, rather than a robust and theoretically sound one.
JavaScript does not offer pattern matching and other functionality offered by modern functional languages.
In fact, it goes out of its way to promote a very imperative, non-functional style of software development, even when efforts are made to try to use it in a functional way.
[1] http://www.anvari.org/fortune/Quotations_-_Random/3041_quote...
With Python, you don't have to worry about the conventions part, since there is one "Pythonic" way to do everything. But at least with JS there are only a few different standard ways to implement, for example, OOP. So once you've gotten used to it, when you read someone's code, you can quickly notice what style they use and contribute your code to match it.
My biggest remaining gripe with Javascript is the lack of a good base set of libraries for container and string manipulation. Sure there are packages (like Underscore) you can use, but it would be nice to have them as a standard part of JS.
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.
My main reason for liking Python isn't that it's compact and manageable (unless by compact, you mean the code one writes), but because I like the elegance of the language.
You're saying you have to stick to strict conventions for JavaScript to be any good? That would imply that it isn't any good to me. I use it, frequently, I just prefer not using it.
1) There are very fast implementations in production, as well as an arms race between some of the world's most powerful titans of software development to outdo each other at js vm performance.
2) It is a thin abstraction over the Reactor Pattern, which is very useful for certain kinds of event-based applications.
3) Very lively and robust package ecosystems in npm (node) and jQuery (web). Virtually all packages are async by default.
It's a shame, would love to see more Smalltalk posts.
Because its the current trendy thing. And chasing that dragon isn't necessarily a bad thing if it gets people in the door. Sure its an evolutionary dumb step in some ways but lowering the barrier to entry means that ideas that might not otherwise come to the space could get a chance to grow. Or if nothing else the trendy attention means more libraries get written, which helps someone else down the road.
There are a lot of blind optimism in that statement, but we all know that the best tech doesn't win. What wins is the good enough-ist tech that also pops enough buzzwords win the to interest of the dude that claims to only care about the best tech.
Plus, Lua isn't controlled by a creepy asshole who thinks the NSA is essential and says stupid shit like "Who's ever heard of government misusing information?"
At the heart of my programming heraldry is C. From there I branched out into C++, Java, Perl, C#, etc.
In effect you are comparing JavaScript to Assembler, since CoffeeScript compiles to JS. I'm certain most people would agree that this is a ridiculous comparison, because as quirky as JavaScript can be it is far easier to work with than assembler. I wish people would stop making that comparison (I've been guilty of it myself, but I've stopped as of late).
In my view, the popularity of JavaScript comes down to two things: Interactivity and instant gratification.
I first played with JavaScript while in college in 1995. It blew my mind that I could just put some code into a text file and load it into Netscape and see stuff happen. No compiling, no linking, just text making the browser do things, and unlike Java it did not require me to upload an applet and hope that my target user had a JRE installed.
Today you have things like Chrome dev tools and JS Fiddle where you can get even more of that.
The velocity of going from idea to web app (site) is a lot nicer for most people.
IMHO JavaScript is the programming equivalent of an LLC. It's quick to start, low capital investment, and doesn't expose you to a lot of risk.
Anyhow...that's my two cents that I had to throw in before more veins in my head popped.
Whatever language it is I'm glad prototyping devices are coming out at a cost that basically makes them an impulse purchase.
If it's possible to write performant, robust code with good tooling in CoffeeScript/Dart/TypeScript/Python/Clojure/etc., then the peculiarities of Javascript become a lot less important.
And since CoffeeScript compiles to JavaScript you can use it anywhere JS runs...
...and that's what makes it a bad language.
That's why there's a book called "JavaScript: The good parts" :)
*hyperbole, please forgive me for being not being completely literal.
Most of the time if one thinks s/he knows javascript, actually s/he knows a higher level abstraction library and DOM built on javascript like Jquery.
I had quite a few non-developers on my team, who knew enough javascript to have a "good enough" idea what was going on with the code, without having to bug me all the time.
Yes, a majority of prof. software engineers who work for internet companies work on the web. But then there's also stuff like embedded, systems, databases (not the ones you hook up to some scripting language to generate html), medical, aerospace, industrial processes, etc.
The software industry is huge and only a small part of it is web related.
> I mean just look at the front page of Hacker News
It's like assuming San Francisco was a model for all other cities on this planet. It's all about your local bubble. For you maybe really it looks like everyone (including your local coffeeshop owner) could win a JS hackathon. But for me I barely know an engineer who's fluent in JavaScript. Everything is C++ here.
- All code automatically reentrant
- Partially data-driven tagged and descriptor-based design
- First commercial implementation of virtual memorySuccessfully-executed abstraction is a wonderful thing, people have been trying to abstract away (but retain performance) of C for decades. I welcome newcomers, maybe someone will get it right
I just replied to someone who was saying "what's the point, a BeagleBone Black is so much more powerful".
(sigh)
I'm aghast that a CS education wouldn't include at least Java, especially considering that a large number of schools switched exclusively to Java at one point.
As to your point to zhemao about learning new things, I said in my original post that I wanted to learn new things, in this case, hardware.
For some, there's no joy in complexity or inspiration in learning. Just wrong or right--generally with "my way" being right. What a shame!
Seems like a lot of that energy would be better spent making an equivalent device that runs <language of preference>. 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.
Once you've got to that level you've got a whole family of related microcontrollers that you can move onto from the same principles. With this javascript device you've got no such thing. You're stuck in a dead end if/when it turns out not to have what you need, as you can't progress to "the next level".
I also see nothing on the site to suggest that C/C++ (at least) couldn't be supported, although I have no clue how much work you would have to do yourself (likely too much).
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.
It uses external memory which takes more power. It uses javascript which could take much more power. And the wifi also might not be low power. So it's not clear yet how low power it is.
var b = require('bonescript');
var state = 0;
b.pinMode("USR3", 'out');
setInterval(function() {
state = state ? 0 : 1;
b.digitalWrite("USR3", state);
}, 100);
vs var tessel = require('tessel')
tessel.led(1).blink()
If they can give human-friendly names to stuff like "USR3" and "P9_40" and "P9_36" out of the box, then I'd say they've added some value.Most modern microcontrollers have anywhere from 3 to 5 possible pin states, and I don't think it's possible to safely wrap these up in a nice, human-friendly function like "blink".
For example, on a lot of ARMs, you have:
In, no pull
In, pulled up
In, pulled down
Out, up
Out, down
and on AVRs, you have
In, no pull
In, pulled up
Out, up
Out, down
You necessarily have to have ugly secondary functions like "pinMode".
Where's the blink getting the timer from? What happens if I update the main PLLs? I'll refrain from making assumptions however until I can see their driver libraries. I'm hopeful, but having played around with the 1830 it's not a simple chip.
I can't say I particularly want the javascript, but if they've got wifi and arduino compatible gpio for ~ $25, then I can find a use for it.
Now this has more or less been discussed to death in the threads above and below, but while I don't necessarily think running JS on a uC is a great idea, I don't see a problem with letting non-hardware-versed folk write low level code. People who know hardware will probably not use it for anything critical, and if it makes someone's life easier without endangering others or utterly diluting the community (knock on wood...) then so be it. There's no reason to be elitist about low level programming.
At this moment my workspace consists of a bit of code for an 8bit microcontroller, a FPGA layout + VHDL, and a mixed signal high speed PCB layout I've been laboring over for the better part of two weeks. Take that, "low level" C! Now I could go off about how superior and/or necessary my low level methods are, but my friend who's working on an ASIC design might say something similar to me. There's always a lower level. As always it's a little bit about preference, and a lot about using the appropriate tool for the job.
I might have a problem if web developers started cramming JS onto arduinos and calling themselves competent hardware engineers, but (and I think most people in the field would agree with me) I suspect the likelihood of that happening is negligible. It becomes apparent very, very quickly when someone is pretending to know how to hardware.
This to me makes me think that there is a space out there for a board that has some equivalent to vagrant/docker but for microcontrollers, where you can just flash the device with a image supporting a language of your choice.
Near as I can tell, there is nothing I read on the product launch page that says that JavaScript is supported at the physical hardware level.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
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.
If you are a veteran programmer it may seem dumb but there are plenty of people who only know JavaScript (& HTML). Some of those people will be utterly blown away that they can control actual, physical "stuff" with those skills.
I doubt that. It has M-series ARM microcontroller, Linux is usually used with A-series ARM CPUs.
180mhz ARM Cortex-M3 LPC1830
32mb SDRAM
I'm amazed that such wimpy hardware can run modern JS satisfactorily.Reminds me of that time Sun made the Java CPU and the JavaStation. A hardware implementation of the JVM. It ran 20 times slower than the Microsoft JVM on an average Windows PC.
Most websites have horrible usability, ranging from "everything in CSS popups!" to "every site uses a different widget toolkit, deficient in new and exciting ways".....
I hope I just don't understand your comment.
IMHO, JS is a laguage designed for APIs, which is good for exploring ideas and protyping. There is always a way to push the performance to another layer, like CSS boosted by GPU.
The lab I am working with explores different ways to code robotic and embedded systems. From MIT's SCRATCH to Erlang we have used them all. One of the area that we have been exploring is of using functional programming languages to program embedded systems. (For example we coded a robosoccer using Erlang).
Being a Javascript enthusiast I always wanted to be able to write small JS programs that I could use to control hardware. Given that JS has good support for Functional programming languages as well, I wanted to try that as well.
There is no doubt that people are expecting too much from Javascript but I do believe this is a very novel attempt that I see a point in supporting. I do not think JS is a language that will find application in say automotive systems but it can certainly be used to program robosoccer in my lab.
To each their own, though.
I know I'm weird, but I really like pointers, because I really like being able to manually setup data structures, and enjoy the power provided by pointers.
Manual memory management isn't horribly fun, but for embedded devices I would rather be in charge of that over the chip having to do it for me. It means that if there's ever a memory overflow, it's my own damn fault, and I have the ability to fix it.
JavaScript is an acceptable scripting language. It's not my favorite, but it works. I just don't think scripting languages should really be used on embedded devices.
There are some very good reasons why C can not be replaced by any other programming language when it comes to safety critical embedded systems. That is what separates men from boys.
This would be so much cooler if I could tap into an REPL remotely and blink out a Morse code on the LEDs :)
PS: I have no idea what makes most of us go "cool!" whenever some form of remote control of a hardware device is presented :)
http://arduino.cc/en/Main/ArduinoYUN
The CPU in particular seems quite underpowered assuming that they're clockspeed comparable, but I'm not familiar enough with the M-series ARM cores to give a proper opinion.
This is really interesting though. It looks like they've got linux and node.js into 32mb RAM, which is seriously impressive. It seemed as if people were trying and failing on Carambola (but that may have been because it didn't use an ARM CPU...)
<selfishPlug> I'm the maintainer of nitrogen (http://github.com/nitrogenjs/service), which is a node.js based project to provide web services and client libraries for devices like this. Check it out if you are interested in devices like this! </selfishPlug>
So, I believe its FP support is through software and could be written to be double or greater precision. If this is true and if JS can only do floats, it would be bad news for many basic mathematical operations running on this chip. But hey, as someone pointed out above:
People don't want performance. They want libraries.
But with no FPU, count me out. I'd rather have my stm32f4. Just sayin'.
By spec, JS only has double-precision floats. However, since that means that 32-bit integers can be exactly represented, V8 optimizes to integer calculations unless actually using floats becomes necessary. I would guess that on this device floating point operations are done in software, but also that they rarely occur in practice.
I'm not sure I like the idea of a high level language, trying to control low level hardware. (seems almost counter intuitive)... however, if you wanted such a thing ... Node seems to be the way to do it... from both an accessibility and speed perspective.
I wasn't sure if I should link this here, but this article really sparked a train of thought that brought me to write this: http://blog.mcdougle.net/?p=54
I just wanted to ask the readers here... anybody notice the sticky tape holding it together in the second picture?
So don't worry, js will not take over...completely.
Oh the possibilities!
maybe its not this one.. but the next computer hardware revolution will born like this.. the same way jobs and wozniak did in the 70´s .. from pure passion
hope my kids create its own gadgets like we did with legos in our days..
long live to the hacker spirit!
The thing people need to learn about Arduino is that it's not important that it's a microcontroller. It's important that it lets you drive and read electrical signals from a PC environment. This lets people do that. Sure, it's like visiting a gated resort in Jamaica on vacation instead of being on your own, but many people like to feel safe and get things done without having to learn too many new skills.
You don't see professional musicians trying to play 10 different instruments on world level. Or olympic athletes competing in 10 disciplines. Or lawyer practising 10 domains. But some programmers like to pretend they have 10 languages in their "linguistic toolbox".