HN user

ahoge

1,026 karma
Posts0
Comments463
View on HN
No posts found.

Most of the weight comes from images. The average website (Alexa top 1M) contains over 1.4 MB of image data:

http://httparchive.org/interesting.php

Be sure to pick the most suitable format and to optimize your images. You can also try to serve WebP to browsers which support it. When it replaces JPEG, you save about 30%. With PNG8, it's somewhere between 5 and 50%. And with PNG32, if you substitute it with a lossy WebP, easily 80%.

Scripts come 2nd with ~363 KB. ES6's will thankfully help with that. Creating the structure of your application declaratively enables better tooling. Not only does this make your editor a lot smarter, it also paves the way for tree-shaking.

If you tree-shake your application, only the actually used library features will be included in the shipped bundle.

You can write your Angular 2 application code in ES5, ES6, TypeScript, Dart, or to-JS languages like CoffeeScript.

TypeScript is pretty popular and it does work really well. Writing larger applications in a team is much easier if there is tooling to assist you. With most projects, about 80% of the work is maintenance and tooling does immensely help with that.

Want to bang up a quick solution, as in MVP? Use bare-bones Javascript

Actually, adding the bare minimum of type annotations (fields & function signatures) and type casts (e.g. casting whatever you get from querySelector into the concrete type of element) results in fewer key presses, because you can auto-complete everything and because you get additional machine-assistance like call tips and type checks.

So, you'll be actually faster if you add some types. Type inference does cover quite a lot. In practice, you'll need very few annotations and casts.

This Dart demo, for example, only needed a single type cast to be fully typed:

https://dartpad.dartlang.org/e23e4d137570c652591e

Research found that the number one cause of errors in learning Python was its case-sensitivity

You don't make that kind of error in other case-sensitive languages which offer better tooling.

E.g. you start writing "canv" and auto-complete that to "CanvasElement". You just auto-complete everything. And if you actually do screw something up, you get a squiggly line and a hint.

Simply ignoring all kinds of errors does not make the language easier to use. In JavaScript, for example, there are many cases where semicolons can be omitted. However, they aren't actually optional. There is a list of exceptions. It didn't actually make the language any easier.

Another example are things which should be type errors (`'foo' - 123` and so forth), but you get NaN instead. Or when you go outside some array's bounds you just get undefined instead of an exception. This stuff does not make the language easier to use.

The timing of the beam racing down the screen is used by the more modern guns which were used by the SNES, PlayStation, or the Dreamcast.

So, it's really not much of a "myth". Most light guns worked that way. The zapper is an outlier.

Dart:

  import 'dart:async';
  import 'dart:io';
  main() {
    var file = new File('/sys/class/leds/beaglebone:green:usr0/brightness');
    var state = 0;
    new Timer.periodic(new Duration(seconds: 2), (_) {
      state = 1 - state;
      file.writeAsStringSync('0$state', flush: true);
    });
  }
While it's not the most concise version, it's certainly very readable. Everyone can clearly see that the duration is 2 seconds and that that boolean flag is for flushing, because that's exactly what the code says.

As a NoScript user, I rarely see web fonts and I prefer it this way. The text shows up instantaneously and the font will look great and be perfectly readable.

Most web fonts don't look that nice on Windows. Windows heavily relies on hinting and doing this properly is a lot of hard mind-numbing work.

Most web fonts also aren't that readable. Sure, your wide/thin/square font looks very modern and stuff, but it's not as readable as a Verdana or Arial. When I visit your site, I'm there for the text, not the font.

In case anyone wonders about the `!+[1,]` bit:

In modern browsers, `[1,]` is the same as `[1]`. If you coerce it to number, you get 1. (You get "1" if you toString it.)

In IE8, `[1,]` is the same as creating an array with a length of 2 whose first slot contains 1 and whose second slot was left empty. It's kinda like `[1, undefined]`, but there is no "1" key. If you coerce it to number, you get NaN. (You get "1," if you toString it.)

If you coerce 1 to boolean and negate it, you get false.

If you coerce NaN to boolean and negate it, you get true.

So, basically, it just checks if trailing commas in array literals are handled incorrectly.

As somone who doesn't like to configure and tweak stuff for hours, my favorite Markdown editor is VS Code. You only have to set "editor.wrappingColumn" to zero (viewport wrapping) and you're good to go.

You can use tables, fenced code blocks (there is syntax highlighting too), and images (I use viewBox'd SVGs for my diagrams). And of course there is the usual split view and a live preview on whichever side you prefer. You can also customize the CSS if you want, but the default one looks fine, really.

It does everything I need from a Markdown editor out of the box.

https://code.visualstudio.com/Docs/languages/markdown

(The right sidebar can be toggled with Ctrl+B.)

Firefox's Brotli support is already done. Chrome's isn't.

By the way, new features are generally created this way. They are added to browsers way before they are standardized. You see, convincing the other browser vendors isn't easy. You need very compelling arguments.

Take WebP, for example. It provides massive benefits. Especially if you can use lossy RGBA instead of PNG32 (easily 80% smaller). And yet, Mozilla shows little interest in implementing it.

The keyboard handling seems a bit off. If you hold S and then press C, you'll stop moving backwards even though you're still holding S. I often thought I was running into a wall or some other obstacle while in fact my input was simply being ignored.

Fun game. Works really well. However, after playing 4 or 5 levels with Firefox 40 the sound got really stuttery and it never recovered.

For one, it's written in TypeScript. There is one codebase for ES5/6, TypeScript, and Dart. A big benefit of Angular 2 is the better tooling you get with TypeScript and Dart.

It uses things like classes, decorators, and the <template> tag. It uses a virtual DOM, which is still a fairly new concept. It can run in Web Workers and you can even use it for native applications which do not have a regular DOM.

It really is quite different from anything one could have started back in 2009. Even those odd-looking attribute might have not worked because HTML5, which specified a lot of those things more precisely, was far from being done.

Angular 1.x made pretty good use of the things which were available at the time.