ahoge
Joined 15 years ago
Joined 15 years ago
The problem is highlighted by the images in this article:
http://jandemooij.nl/blog/2015/11/27/math-random-and-32-bit-...
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.
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:
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.
https://github.com/mahonnaise/vs-code-markdown-theme
The automatic table formatting was pretty cool though (even if it's purely cosmetic).
So, it's really not much of a "myth". Most light guns worked that way. The zapper is an outlier.
AltGr is still broken. The problem has been known for almost 2 years and there are about a hundred duplicates.
https://github.com/atom/atom-keymap/issues/35
If you aren't using an US keyboard layout, this might be a problem.
'x: $x, y: $y'
is a lot easier to type than: 'x: ' + x + ', y: ' + y
I actually had to triple check that line. Concatenation is very error-prone. I often mess it up.String interpolation is a fairly popular feature nowadays:
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. array.reduce((a, b) => a + b, 0); 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;
}
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.