Recent submissions

Comment · 11 years ago
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.

Comment · 11 years ago
Comment · 11 years ago
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.

Comment · 11 years ago
Comment · 11 years ago
Comment · 11 years ago
Comment · 11 years ago
> 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.

Comment · 11 years ago
Comment · 11 years ago
I'm quite happy with VS Code and this Markdown CSS theme:

https://github.com/mahonnaise/vs-code-markdown-theme

The automatic table formatting was pretty cool though (even if it's purely cosmetic).

Comment · 11 years ago
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.

Comment · 11 years ago
Comment · 11 years ago
Comment · 11 years ago
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.
Comment · 11 years ago
The reduce one needs an initial value of 0 for that to work. Then both versions will return 0 if the array is empty.

    array.reduce((a, b) => a + b, 0);
Comment · 11 years ago

    function sum(array) {
      return array.reduce((a, b) => a + b);
    }
With a loop:

    function sum(array) {
      let acc = 0;
      for(let val of array) {
        acc += val;
      }
      return acc;
    }

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton