I do not, and will not, fully understand the desire to put JavaScript or Python interpreters on a microcontroller.
Forty (40) years ago, children were writing assembly on home computers! No internet to run to for help, back then, but somehow, millions of kids learned how to do it.
Today, with all the resources available, assembly is "scary," and "too hard to teach."
I call BS on this notion. Complete BS.
JavaScript doesn't even really belong where it is on desktops and laptops. The very last place it belongs is on a constrained platform.
I would be willing to bet that assembly wasn’t the first language you learned.
The first programming I did was as a kid when I taught myself basic on an apple II+ after I saw a joystick and a manual sitting next to my dad’s computer. ...it looked a bit like my Atari console and I was curious. (I too eventually wrote assembly - you had to in those days - but it wasn’t the introduction to programming for anyone I knew.)
This led to other things, including the robotics company I started, where we are, as I write this, running JS on an esp32 (among other things), hoping to inspire someone else to discover programming as I did - through play and fun.
To me, JS is kinda like basic was when I was a kid. ...the first step on a path that could surely include assembly, ML, distributed systems, robotics, computer vision, etc.
But what should step 1 be for kids today? I have a 6 year old, and all I know is she’s growing up in a different world than I did. ;-)
The first language I learned was machine code. Just saying. And I was in no way programmer. I was just a scientist trying to get some digestible data from the device used in my experiments. As the time went by I got Assembly, C, Turbo Pascal etc. I knew about basic but have never used it.
I first started programming when I taught myself at 3 years old digital logic. I started with just combinatorial logic (I was 3 after all!) but in one week I graduated to sequential logic.I still remember the spark of pride on father's eyes when I showed him the ALU I just created, he still told me to do better. Several ISA and micro-architecture later and half a dozen of languages created ( I remember fondly Beethoven,it was OO, this was before Simula) I started to get good at it. But then Gerda, my dear _Lehrerin_ had to go back to Germany (something about her father) and I had to start first grade so I set those juvenile games aside. I think they still somehow shaped the gentleman I am today.
Was it really millions? I find that hard to believe. I was a kid at that time and was very into computers. I never truly learned assembly and I'm sure I knew more about it than anybody that I went to high school with.
I was in High School with 300 other kids and there were at least two dozen of us who at the very least toyed with assembly on either the TRS-80, a VIC-20 or an Apple II, and knew enough that we wanted to know more. I grew up in a farming community in Illinois.
I doubt that there were millions in any single country, but over the entire world, I would be very surprised if "millions" is not accurate. (Precision is another discussion)
I was like dexterdog, the only person in my school that could program. I toyed around with assembly and C and made some progress but nothing significant. I know people who went to other schools with a dozen or more kids toying around together, like you, and they made it a lot further during their school years, and this advantage has left them still very far ahead to this day, 30 years later.
People learn much faster and better in groups than as individuals.
I had a number of kids in my school (very few in my grade) who were into programming, but nobody was interested in assembly. This was the late 80s. We had an AP class which was not common at the time and I was able to skip intro comp sci in college because of it. Pascal was the main language.
You're right. We wouldn't want to lower the bar to programming too much. Just imagine if the wrong sorts of people took advantage of the advancing technology and lower barrier of entry to substantially improve their lives! We really should be using assembly for web development so we know that only the truly dedicated and those committed to the craft can participate in this career.
That is not the point I'm trying to make at all. You conjured my talking point out of thin air and then attributed it to me. I should have expected this...
I'm not gatekeeping. I'm saying that we spend a lot of effort to lower the bar to software development when it is already very low. It is certainly already low enough that anyone can become a software developer. I would like to see that effort used for something more productive.
An ESP32 can have 1 or 2 cores, running at 160+MHz. It has built in Wifi and Bluetooth, and usually 500KB and 4MB of Flash that programs can run out of.
IIRC, that compares reasonably well with a 486 or Pentium computer running a single application, especially when you realize it's not running a GUI. A decent amount of software of that era was inteprreted - that's when Javascript and Python first came into existence.
All those were used for tiny of functionality in browsers and did not even remotely approach the performance and functionality of the real desktop applications.
This makes no sense. I do not recall the amount of RAM I had on my 486DX50 but whatever version of office it had at the time ran just fine. JavaScript was not even born by then. But when first ever versions of JavaScript were released their execution speed were molasses comparatively to native applications. I know it first hand as I was developing native and web and in browser applications since 94 even before JavaScript (I used Netscape's server push functionality for that). When Java was released and until it matured to decent enough JIT it was the same slow resource hog (again know it first hand).
I do not quite understand what you're trying to say here. Many are / were not wealthy to buy any computer at all back then. I was born long before 486.
> Forty (40) years ago, children were writing assembly on home computers
Last time I checked, the majority of those kids were using BASIC. Specifically: Commodore BASIC or QBasic (DOS).
And Javascript is the modern version of BASIC: widely supported, well integrated into all modern OSes (phone, tablet, laptop, desktop), and capable of doing all of the graphics that a modern nascent programmer wishes.
BASIC is closer to assembly than JavaScript, both in complexity and that you can't implement a JavaScript anywhere as simply as you can implement BASIC
I wasn't talking about BASIC, I was talking about assembly.
Assembly wasn't that hard on those old things, so why is so much time spent today shoehorning JavaScript into places it shouldn't go? Spend that effort on something useful, or at least something sane.
And I'm talking about BASIC, which spawned a generation of programmers. PIC-BASIC, QBasic, TI-83 BASIC, Commodore BASIC. That's how programmers got their start back in the 80s.
> Assembly wasn't that hard on those old things
Assembly is harder than BASIC, and its harder than Javascript.
You can go to any store and pick out a beginner Javascript book these days. But how many Assembly tutorials or books are there?
Back in the 80s, it was more about Commodore BASIC books being distributed with the Commodore itself: ftp://www.zimmers.net/pub/cbm/c64/manuals/C64_Users_Guide.pdf
Pre-internet, it was books like these that allowed programmers to learn and grow.
I don't get the impression from the linked website, that this is for beginners...
>>> Bring your existing experience with JavaScript, but be prepared to think about performance, code size, and memory use in a different way.
I think the use case is if your application would actually benefit from the Javascript language, either because of what it can do, or to make something readable and maintainable in a way that might be hard with raw assembly.
In a similar vein, I played with CircuitPython for a while, and went back to C for my microcontroller projects. My programs tend to feed data up to a desktop computer, typically into the loving arms of a Python program.
I got into computers almost exactly 40 years ago, and the earliest exposure of most kids to programming was in BASIC. I read a book on the Z80 microprocessor, and felt that I could have at least taken a crack at assembly, but didn't have access to a Z80 machine.
People put interpreters for popular languages into environments hoping to grow the population using that environment. It is an attempt to entice an audience of technically adept people easily, adding value to your environment.
Not sure if sarcasm, but writing assembly is complete shite to be honest, even on bare metal. Simple things suddenly take significant time and you probably create a worse result than modern compilers, even on more arcane platforms. Maybe it is useful for an interrupt routine to put some data in a data buffer.
Maybe interpreters are too much for µC, I think the most painful disadvantage of C is string manipulation and trends show a preference for human readable protocols for serial communication. For prototyping even JS might have use case though.
I would argue that assembly is not so bad if you take the time to learn it. A lot of the "high level" things that people attribute to compiled languages exist in assembly. And I also understand why it seems so unapproachable and why people don't want to learn it.
If the bar for entry into assembly programming in 1980 was so low that a child could do it, why are we thinking that we should lower the bar further today? Spend that effort on something which will actually help someone, rather than putting JavaScript on a microcontroller.
But C has way more "wat" in it than JS, in a sense. In JS when you make a wat you can generally debug it and fix it incredibly easily. In C when you wat, well, good luck.
A linter and Typescript and the fact that the "wat" stuff is actually almost always marginal and not commonly ran into in practice means you actually almost never are spending time on wat-ness at all in TS, where in C, a huge amount of time is spent there.
There's a vast gulf of productivity between TS and C (the former winning). TS is an incredibly smart choice for many things small and large. But yes, if you need a lot of low level hooks and incredible performance, don't use it.
Why not the best of both worlds? There are other compiled languages than C/C++. Many provide neatly the productivity of dynamic languages but with much better control. Rust & Nim both work well. Maybe Zig one day.
Rust is far slower as a developer to write (far more complex and verbose), Nim has orders of magnitude less ecosystem/docs/community (Rust has much less too), and both have far worse debugging tools, REPL, etc.
Valid points, and the REPL in JS/TS is handy. But it's worth pointing out that when/if a project outgrows JS, there are more options than just C/C++. The smaller community/ecosystem doesn't matter nearly as much in embedded, at least for libraries. I've found all the Nim libraries I've needed or wrapped C SDK ones, and the debugger is the standard C one. Rust is similar, and more productive than C for many people once you get familiar with it. Though yes, you've got to be willing to figure out things in both. Overall it's good to see more options.
One reason JS makes sense (in; for example, robotics): For all of JS’ problems, it handles async wonderfully. I can think of plenty of actions in robotics that boil down to “do these 3 things concurrently and then do thing #4 when they all complete” and Promise.all or async/await are helpful constructs to have when designing those instructions. It won’t be as performant, but the developer won’t have to worry about polling or communicating across threads/processes
That’s not a knock against assembly, or to say that the same can’t be done in C with time and skill. But in many cases, compromising performance for developer efficiency is a good call.
If concurrency were so hard that switching away from some decent language to JAVASCRIPT seemed like a good idea, I would agree, but it isn't that hard. Not even close. Threads are a very well understood concept.
Why not just use C++ and not sacrifice any performance at all? You say async so it might not be applicable, but C++ has a standard memory model you can rely on for consistency.
I was one of those kinds, JavaScript and Python are the modern version of the BASICs we had on those computers, that I learned before even bothering with hexdumps, monitors and Z80 code.
Python turned into an abominable hot mess over the years due to lack of direction, and nobody really wants to program in JavaScipt willingly. It's something we have to put up with.
Microcomputers from the 80s booted to a BASIC interpreter REPL. There's no reason why a similar constrained system from the current era couldn't just boot to a JS REPL.
And yes, if you wanted to do anything really significant, you needed to learn assembly. But frankly most did not bother.
Think about kids who are getting into programming through JavaScript because they have access to the dev environment without installing anything. Now those kids can work on building hardware as well using the same programming experience.
Forty (40) years ago, children were writing assembly on home computers! No internet to run to for help, back then, but somehow, millions of kids learned how to do it.
Today, with all the resources available, assembly is "scary," and "too hard to teach."
I call BS on this notion. Complete BS.
JavaScript doesn't even really belong where it is on desktops and laptops. The very last place it belongs is on a constrained platform.