JavaScript logo

The esteemed Dr. Axel Rauschmayer has written a blog post about a new proposal for JavaScript: Types as Comments. It definitely has got me thinking.

On the one hand, I’m a huge fan of JavaScript evolution over the last decade or so. Arrow functions, const/var, classes, modules – that’s all good stuff that has improved the language.

Typescript logo

Seemingly on the same side of this argument: I’m also a huge fan of Typescript. It changed how I do large-scale frontend development four or so years ago – static typing in a language helps me write clear code, catches a huge number of bugs at compile-time, and the tooling and overall ecosystem around it is top-notch. Kudos to Microsoft on this one.

But I’m not convinced the value of this proposal nets out positive. The proposal itself says that the primary motivation is to inch JavaScript evolution towards eventually supporting static types:

Does JavaScript need static type-checking?

“Given how much effort organizations and teams have put into building type-checkers and adopting them, the answer is yes.”

Why?

Tools

You have to accept that JavaScript is the language of the runtime. We shouldn’t be caring about types at runtime – that’s the job of the toolchain prior to deploying. That’s the way every other language works (feel free to tell me how wrong I am in the comments – I am no language expert!).

Static typing only helps developers, not users.

Think about it this way: what level of performance degradation are you willing to accept for full support of static types? Is it ok for the JavaScript parser and runtime to be 5% slower for every web page or 15% larger in code size? Of course I’m pulling these numbers out of my ass.

When I was first fanboying out on TS, I used to think “gee, wouldn’t it be really cool for browsers to support Typescript natively”. Wouldn’t that be an awesome way to learn and view source, etc. But you know what’s good for that instead? Super-fast and small JavaScript for best performance and if you want to share your developer brilliance, have an optional compile-mode and source maps that point to your awesome Typescript.

Patrick the Star

Another thing I don’t like about the proposal is that, while they are clearly heavily influenced by Typescript, they hedge:

How does this proposal relate to TypeScript?

“This proposal is a balancing act: trying to be as TypeScript compatible as possible while still allowing other type systems”

You are JavaScript – if you are adamant about eventually supporting static types, why not boldly point towards a “north star” of a language that has already proven itself? Is it that you don’t want to admit Typescript won? Is it lingering anti-Microsoft bias?

My opinion: If we are going to add static typing for web apps, we should just use Typescript as a new script type. <script type=”application/x-typescript”> seems a better option to me so that the browser can choose an appropriate parser, etc.

§1296 · March 10, 2022 · JavaScript, Software, Technology, Uncategorized, Web · 2 comments ·


Well, two posts in a year – that’s better than only one! Let’s see, what did I accomplish this year, hack-wise?

  • bitjs, Binary Tools for JavaScript:
    • Added a Zipper to create a zip file in JS from byte arrays (issue #29). No compression, store-only for now.
  • kthoom, a Comic Book Reader:
    • Added a Metadata Viewer (issue #18) and Editor (issue #49) using the aforementioned Zipper.
  • TNO, a turn-based strategy game:
    • Finished rewriting an old, DOS-based game as a web-based game for its 25th anniversary 🙂
  • Carve, a vector graphics editor:
    • Started creating a rudimentary SVG editor in the open. Maybe this was irresponsible of me, given SVG-edit exists and I have lots of history there, but I wanted fresh infrastructure (TypeScript, mainly) and a chance to try and get the architecture right in the beginning..
  • Music playlist service and player
    • Private project where I assembled all my offline music, created a microservice to arrange, list, edit music into playlists stored in the Cloud (Firestore), and accessed via a web music player.

All of these little hack projects are strictly in the service of scratching various itches I have. Any fun projects you worked on this year?

Happy New Year, all!

§1292 · January 1, 2022 · Uncategorized · Comments Off on Hack Scratch 2021 ·


Bugs

I was thinking of setting up a bug tracker for a personal project that might have random users. I’d like to have a way for users to report bugs with as little friction as possible, but with something more than an email or a post on a mailing list. Basically a link I can send a user to. Github? Jira? Something better? Are there any good issue trackers that allow multiple identity systems?

§1268 · January 26, 2021 · Questions, Software, Technology · 2 comments ·


Logo for WebP

How’s everybody doing? My work-from-home setup involves a Macbook Pro, a CalDigit TS3+ dock, two external displays (one in portrait, one in landscape), and a couple other peripherals. Since getting the TS3+, I’ve noticed that OSX screws up the orientation of the external displays ~50% of the time. This inevitably results in me furiously tilting my head sideways while I try to maneuver the mouse pointer onto the Mac Display preferences for that display and fix it before my first meeting of the day starts.

I found a Stack Overflow solution that works for me. I downloaded the free Display Rotation Menu tool from Mage Software and now I can just click and change the orientation from the system menu. Should be part of the OS in these WFH days!

§1229 · December 5, 2020 · Apple, Software, Technology, Tips · Comments Off on Orienting From Home ·


Logo for WebP

Kind of an interesting month for raster image formats on the web! Apple just recently announced that iOS and Safari 14 supports the WebP image format. Yay – in roughly a year, we can use it everywhere on the web without needing to have a fallback solution (like using WASM to turn WebP into PNG/JPEG). Now we just have to wait for the rest of the ecosystem (image editors).

I guess next up is for Apple to get on board with the AVIF format, since Firefox and Chrome announced upcoming AVIF support just two days ago.

§1222 · July 11, 2020 · Chrome, Firefox, Google, Safari, Software, Technology, Web · 1 comment ·