Why not Espruino?

Why not Espruino?

I recently posted about MetalScript, a JavaScript compiler I’m creating to allow people to write firmware in JavaScript. One of the responses I received is that there already exists a solution for running JavaScript on a microcontroller: Espruino. Why am I creating something new? TL;DR: Espruino uses an interpreter, which takes up memory, runs slowly, …

Read More Read More

MetalScript: The Idea

MetalScript: The Idea

People who know me, or have been reading my blog for a while, probably know that I’ve been working on a JavaScript firmware compiler, which I’ve called MetalScript. For the first time ever, I’m going to share a little about it with you, my beloved blog readers. If you’re not interested in the story behind …

Read More Read More

Global To-String
JavaScript Corners - Part 9

Global To-String
JavaScript Corners - Part 9

(This is Part 9 in my series on JavaScript corner cases). Here’s another one. In JavaScript, global variables are properties of the global object. By default, the global object is like any other, and inherits from the Object.prototype  object. Object.prototype comes with a number of its own properties, such as the toString method. So, that means that toString is also …

Read More Read More

JavaScript Corners – Part 9
Node.js With-Statement Bug

JavaScript Corners – Part 9
Node.js With-Statement Bug

What does the following evil code print? var x = ‘before’; var obj = { x }; with (obj) { x = (delete x, ‘after’); } console.log(x); If you’re not sure, don’t worry — neither are current JavaScript engines. Firefox prints “after”, while Edge, IE, and Node.js print “before” (node v7.9.0). I believe that Firefox …

Read More Read More

C++ vs JS
Binary Type Coupling

C++ vs JS
Binary Type Coupling

I was chatting to some of my colleagues at work recently about the potential benefits of a JavaScript compiler vs a C compiler, when targeting an embedded MCU. A concern that came up multiple times regarding different features, is …but you can already do that in C, so how is JS better? This is a …

Read More Read More

JavaScript Corners – Part 7
Calls and With Statements

JavaScript Corners – Part 7
Calls and With Statements

Here’s a quick one. What does the following print? (Assuming not in strict mode) function foo() { console.log(this.name); } const bar = { foo, name: ‘Bar’ }; global.name = ‘Global’; foo(); // Case 1 bar.foo(); // Case 2 with (bar) { foo(); // Case 3 } In non-strict mode, the naked function call foo() gets a this value …

Read More Read More