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 · 1 comment ·


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 ·


Logo for JSON

To be filed under "shoulda-woulda-coulda" and "no-shit-sherlock" and also "forgot-to-write-about-this-fifteen-years-ago"...

I have had to think about XML for the first time in a few years (for the curious, you can read this EPUB bug I filed). If XML had had an array type for simple values (strings), then instead of representing a list of values like this:

<topLevel>
  <myList>
    <item value="abc" />
    <item value="def" />
    <item value="ghi" />
  </myList>
</topLevel>

It could have been this:

<topLevel myList=["abc", "def", "ghi"] />

Would folks have abandoned XML for JSON so quickly?

§1210 · January 11, 2020 · Software, Technology, Web, XML · 1 comment · Tags: ,


Logo for Feedly

Hey, if you are into Comic Books or Superheroes, I started another blog here. That blog takes the place of this Google+ Collection that I was occasionally posting to, but I decided to own the data this time and start at the beginning... so far I've made it to the debut of Superman... it should be more interesting going forward 🙂

Feedly has some buttons you can add to your blog here, but I wanted one that didn't involve a network fetch unless the user clicked it, so I made one (thank you inline SVG):

<a href='https://feedly.com/i/subscription/feed%2Fhttps%3A%2F%2Fwww.codedread.com%2Fcomicbooks%2Ffeed%2F' target='blank' title='follow us in feedly'>
  <svg xmlns="http://www.w3.org/2000/svg" width="70" height="30" viewbox="0 150 1400 530">
    <rect x="0" y="150" width="1400" height="530" fill="#6CC655" />
    <path fill="#6CC655" d="M111.615 420.945L297.64 234.92l186.025 186.025L297.64 606.97 111.615 420.945z"/>
    <path fill="#FFF" d="M201.837 622.782L64.179 484.193c-16.742-16.742-16.742-53.017 0-68.829l197.187-198.117c15.812-15.812 51.156-15.812 66.969 0L526.45 415.364c16.742 16.742 16.742 53.018 0 68.829L388.792 622.782c-8.371 8.371-21.393 13.952-34.415 13.952H234.392c-12.092 0-24.184-5.581-32.555-13.952zm125.567-53.947c2.791-2.79 2.791-8.371 0-11.161L300.43 530.7c-2.79-2.791-8.37-2.791-11.161 0l-26.974 26.974c-2.79 2.79-2.79 8.371 0 11.161l21.393 20.463h22.323l21.393-20.463zm0-114.405c1.86-1.86 1.86-6.511 0-8.371l-28.834-28.834c-1.859-1.86-6.51-1.86-8.37 0l-83.712 83.711c-2.79 2.791-2.79 9.302 0 12.092l19.533 19.533h22.323l79.06-78.131zm0-113.476c1.86-1.86 2.791-7.441 0-9.301L299.5 303.749c-1.86-1.86-7.44-1.86-10.231 0L148.82 444.198c-1.859 1.86-2.79 7.441-.93 9.301l22.323 21.394h21.393l135.798-133.939z"/>
    <text fill="#FFF" x="600" y="500" font-size="250" font-weight="bold">Follow</text>
  </svg>
</a>

Obviously replace my feed link with yours ... unless you want to send me random subscribers!

§1194 · January 17, 2019 · Comic Books, Entertainment, Software, SVG, Technology, Web · Comments Off on Feedly Your Blog ·


Logo for the ReactiveX / RxJS project

I may have more to say about RxJS some other day, but it's something I've been learning since switching jobs at Google late last year to work on a pretty large Angular app. I found it to be a steep learning curve with RxJS and Observables and functional reactive programming in general, but in this case learning RxJS is exacerbated by a lack of good, comprehensive documentation.

However, I did learn that the RxJS team has put together a pretty comprehensive set of docs for RxJS 6. For whatever the reason, they are located at https://rxjs-dev.firebaseapp.com/.

§1175 · October 26, 2018 · JavaScript, Software, Technology, Web · Comments Off on RxJS ·