HNHacker News
TopNewBestAskShowJobs

ahoge

1,026 karma · joined December 11, 2011

submissionscomments
ahoge··on “We have decided not to integrate the Dart VM into Chrome”
For me, it is.

Well, its semi-useless enums suck, but other than that I'm quite happy with it.

ahoge··on “We have decided not to integrate the Dart VM into Chrome”
Dart is natively supported outside browsers. There is the standalone VM, which you can use just like Node.js, and the VM library, which you can embed in native applications.

The VM is crossplatform and it even supports ARM and MIPS.

They are also working on an interpreter which will get around the JIT restrictions on iOS and Windows Phone.

ahoge··on “We have decided not to integrate the Dart VM into Chrome”
> JS is getting nearly every Dart feature with ES6 and ES7

With ES8 or ES9, maybe.

By the way, optional named arguments with default values look atrocious in ES6.

ES6: function foo({a = 1, b = 2} = {}) {…}

Dart: foo({a: 1, b: 2}) {…}

Dart also supports things like factory constructors, named constructors, method cascades, operator overloading, SIMD, arbitrary large integers, mixins, implicit getters/setters, implicit interfaces, enums, 'a' - 2 is a type error, [0][-1] is a range error, metadata annotations, and of course also optional types.

ES7 might include SIMD and operator overloading.

Another key point is that Dart's doc comment syntax is standardized. It also has an official style guide, a formatter, and a package manager.

To me, these things are also very important features.

ahoge··on ECMAScript 6 compatibility table
Maybe it would be a good idea to add a note in the meantime. I was quite confused when the module stuff was gone. I assumed it was moved to ES7, but it didn't show up there either. I finally learned the truth after googling a bit and finding that issue. Would have been nice if the page would have told me that right away.

Is this the only noteworthy ES6 feature which isn't tested?

ahoge··on Four Solutions to the JavaScript Problem
> Is option number 1 "Use JavaScript Carefully" really that hard?

Writing larger applications in a team isn't impossible with JavaScript. It's just needlessly difficult.

Well, even if it's just me, after a few hundred lines of JS, I really start to miss proper tooling.

ES6 did at least add some structure and tooling hooks with classes, modules, default parameters, and named parameters (via destructuring). However, it's nowhere near the kind of tooling you get with TypeScript or Dart.

Optional types are really handy. Just add some types to the signatures of your functions and you get massive tooling benefits (and basic documentation).

ahoge··on Wet Wipes Box Says Flush, New York’s Sewer System Says Don’t
> That's still only $72 a year, man.

You didn't include the regular TP. With a bidet or washlet, you'll need a lot less of that, too.

> $500 on toilet seats?

There are much cheaper options available. As another commenter mentioned, you can get a non-electrical attachment for as little as $30.

For example:

http://www.amazon.com/Luxe-Bidet-Neo-110-Non-Electric/dp/B00...

Edit: Also, you were comparing the price for upgrading two toilets with the wet wipes expenses for a single person.

ahoge··on Wet Wipes Box Says Flush, New York’s Sewer System Says Don’t
Bidets and washlets are the more economical option anyways. Wet wipes aren't cheap. Even if you spend $250+ on a somewhat fancier "warm water cleaning toilet seat", you'll break-even in no time.

That's even true if you use regular toilet paper, because you'll need a lot less of that.

ahoge··on Strengthening JavaScript
What does "turning into Java" even mean? What exactly are you afraid of?

Having actual integers? Threads? Better tooling?

The `class` keyword? It makes the code less verbose.

Optional types? Would you rather write JSDoc comments?

Optional typing actually works amazingly well. You need very few type annotations to get all the tooling benefits. Typically, it's enough to annotate the headers of your function. Type inference takes care of the rest.

ahoge··on Angular 2: Built on TypeScript
Define "get to work".

I mean something like this: https://atom.io/packages/ide-flow

Tool-tips, call-tips, auto-complete, type checking, and so forth. The kind of stuff you get with TypeScript or Dart.

ahoge··on Angular 2: Built on TypeScript
Angular 2 is heavily inspired by AngularDart. Angular 2 has a single codebase for JS and Dart.
ahoge··on Angular 2: Built on TypeScript
Flow doesn't work on Windows yet. Atom seems to be the only editor which supports it. That plugin had its 2nd release just 3 days ago.
ahoge··on Angular 2: Built on TypeScript
If you add gzip compression, it's still smaller than doing the same thing with jQuery. "dart:html" provides an idiomatic DOM API where all list-like things are actually Lists, events are streams, Futures instead of callbacks, and so forth. It's pretty nice to use, but it's also one of the bulkier libraries.

Also note that you could now add a thousand lines of code and the file size wouldn't increase much. You already paid that one-time cost.

You can further improve the size by using a better minifier on top of --minify.

ahoge··on Angular 2: Built on TypeScript
> And the size of helloworld.dart.app.js is 102k

No, it's not.

  dart2js --minify hello.dart -o hello.dart.js
Results in a 5 KB JS file.

This game is 35 KB (procedural graphics included):

http://mbtic.com/games/fuzetsu

ahoge··on Angular 2: Built on TypeScript
Because Dart isn't a viable option for writing libraries or frameworks which are meant to be used from JavaScript.

You can interact with JS libraries, but exposing some API to JS-land is a completely different matter.

There are some vague plans to improve this, but there hasn't been much interest, because if you use Dart anyways, you do of course want to use it as the "host" language. It has the tooling and all that jazz. Of course you'd want to use it for as much as you can.

ahoge··on Sylph: the programming language I want
You didn't answer my questions. I have no doubt that untooled unitypedness can be improved upon.
ahoge··on Sylph: the programming language I want
> Why? Just get the machine to do it.

I meant the writing stage, not the checking stage.

Imagine you don't know which type to pass. So, you'd have to pass something (null or whatever) in order to generate an error which gives you a clue.

That doesn't sound very convenient.

Well, the machine could check which types match that fingerprint, which might work okayish if the list isn't too long, but it won't tell you anything about the writer's intend.

Is a list of doubles, a list of ints, a Float32x4List, or a Float64x2List really the same thing?

What if it's actually meant to be used with something else which also supports the [] operator and whose items support the + operator.

Static analysis might not be able to tell you because it doesn't know all packages in existence. That package might not have been referenced, because that's not required to use a type from that package.

How does the generated documentation look like? It takes one argument "foo" which is something which has a "bar" field and a "baz" method? I'd rather have a concrete type there. "int x". Done.

What if you optimize the function a bit and now the fingerprint doesn't match one or more types anymore. Was this a breaking change?

Your intention didn't change. You always had one particular type in mind.

ahoge··on Sylph: the programming language I want
The inference example is actually a good illustration for why you want to add types to a function's signature.

As the author mentioned, a machine can look at how the arguments are used and make some educated guesses. The big problem is that humans have to do the same.

That's why I like optional types à la Dart. Not only do they help with static analysis, they also act as documentation.

With a good editor, this documentation is right at your fingertips. When you type a function's name, a call-tip will remind you of the expected arguments. If you've added type annotations, the types will be there, too.

ahoge··on ECMAScript 6
> Was it really necessary to add "class" syntactic sugar?

Yes. Now your editor/IDE knows that that thing is supposed to be a class. The doc generator also knows that it's a class. Furthermore, this makes things more compatible since framework A and library B use the same kind of classes.

Finally, it means that you won't have to waste time with evaluating a dozen semi-popular options to handle classes/inheritance.

It does of course also make your code a lot easier to read and it makes it easier for new developers who used some other language with classes before.

> Hopefully ES7 doesn't get the verbose syntax of Java/C#.

I recommend to take a look at TypeScript and Dart. Optional types aren't verbose. You just add some types to the surface area, which, compared to JSDoc, is drastically less verbose. Inside functions, you can generally omit the types.

ahoge··on ECMAScript 6
The behavior of strict mode would have broken existing code. That's why you have to opt-in.

New syntax, on the other hand, can be added without breaking existing code. These new constructs would have been syntax errors beforehand.

ahoge··on XSV – A fast CSV toolkit in Rust
You can't use these control characters in CSV either. The grammar from RFC 4180 excludes the 0x00 to 0x1F range.
ahoge··on XSV – A fast CSV toolkit in Rust
From "3. MIME Type Registration of text/csv":

  Common usage of CSV is US-ASCII, but other character sets defined
  by IANA for the "text" tree may be used in conjunction with the
  "charset" parameter.
Basically, you can specify that it's UTF-8 or whatever via the Content-Type response header. Setting this response header isn't something an encoder could do. A CSV parsing library also shouldn't be responsible for loading the CSV file via HTTP. In most cases, CSV files aren't directly fetched via HTTP anyways.

Anyhow, ASCII is utter nonsense. We aren't living in an ASCII world. Even the Americans don't do that. An ASCII-only format is completely useless.

ahoge··on XSV – A fast CSV toolkit in Rust
RFC 4180 does not specify the character encoding.

This isn't a problem with JSON, XML, ASN.1, Protobufs, or Thrift. Anything other than CSV, really.

ahoge··on XSV – A fast CSV toolkit in Rust
> what's wrong with [CSV]?

The encoding, line endings, and the used separators are random. Encoding/decoding behavior may be locale-dependent. E.g. if you use Excel with a de-DE locale to create a CSV file, Excel with a en-US locale won't open it. The former uses ';' as separators and the latter expects ','.

Since the format is so (seemingly) simple, there are millions of ad hoc implementations out there. Naturally, most of them are horribly broken.

Fun fact: ASCII actually reserved control characters for this stuff. 1F is the "unit separator" and 1E is the "record separator". There is even a "group separator" (1D) and a "file separator" (1C).

http://en.wikipedia.org/wiki/ASCII#ASCII_control_code_chart

ahoge··on The Wake Programming Language
http://en.wikipedia.org/wiki/Type_safety

Aggressive type coercion is not type safety. It does not prevent type errors. It just sweeps them under the rug.

    5 - 'foo'
That's a type error. It's not a convenient shortcut for `NaN`.
ahoge··on Interview with Bob Nystrom
> I got into programming before the web and was mostly self-taught,[...]. My biggest challenge was finding enough information.

I had the same problem. I had one tiny pocket book with less than 150 pages and Turbo C's built-in help system which was basically just trimmed down API docs. A list of header files which lead to a list of functions which lead to a short 1-2 sentence description.

But I still had a lot of fun.

I agree that the first language isn't that important, if you switch to something else shortly thereafter. However, I think it's a bit problematic if you keep using this one language exclusively for a couple of years.

Maybe BASIC wasn't such a bad idea. No one wants to stick with that and it's also rarely used in production. If you start with something like BASIC, you're forced to switch.

ahoge··on Annotated code: Circles bouncing off lines
In case anyone wonders about that reverse-for loop in updateCircles():

Iterating over an array in reverse allows you to remove items in the same iteration (at the very end of the loop). If you delete an item, the items which follow are downshifted by one which means that their indices also change.

However, this isn't a problem if you iterate in reverse, because you already took care of those items in previous iterations. The item you'll handle next will stay where it is.

This also works nice with unordered lists (or "bags").

ahoge··on In search of the perfect JavaScript framework
> intercooler doesn't have an entry point.

It does.

There is an IIFE which is run when the script is loaded. Right before the object is returned to the global "Intercooler" variable, a callback is registered via a jQuery.ready() shorthand.

Practically speaking, this callback is the entry point (theoretically, it's the IIFE itself).

If it wouldn't have an entry point, adding attributes to elements would do nothing.

http://en.wikipedia.org/wiki/Entry_point

"an entry point is where control enters a program or piece of code"

ahoge··on In search of the perfect JavaScript framework
> Well, it's a library, not a framework: you can use it for as much or as little of your app as you like with as little as a single attribute declaration doing something useful for you.

If it has an entry point, it's not a library, it's an application. If said application does basically nothing on its own and you're supposed to extend it, it's a framework.

http://en.wikipedia.org/wiki/Software_framework

Pay close attention to the 4 bullet points in the first section.

> On "use strict", my understanding was that it applies per script

Yes. However, when you merge scripts, there is only one script at the end.

The site you linked to also mentions this problem.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

"This syntax has a trap that has already bitten a major site: it isn't possible to blindly concatenate non-conflicting scripts. [...] It is thus recommended that you enable strict mode on a function-by-function basis [...]"

ahoge··on In search of the perfect JavaScript framework
"No framework"... so here is a framework. Uh hu.

Anyhow, move that "use strict;" line into the IIFE. If it's global, you can't merge that file with other files. Some of the code out there breaks in strict mode. That's why it isn't enabled by default.

ahoge··on I turned caps lock on for a week
The caps lock key is very useful, if you rebind it to something else.

I use it for Enso, which lets you start programs, open files, spellcheck, count words, do math, and things like that.

Using it to swtich between input methods is another good choice.

← PreviousPage 4 of 16Next →