HNHacker News
TopNewBestAskShowJobs

ahoge

1,026 karma · joined December 11, 2011

submissionscomments
ahoge··on Dart Is Not the Language You Think It Is
>Who is the audience for Dart?

AS3, C#, Java, and JavaScript developers. That's why they went with C-like syntax. It's familiar to most people.

>But web developers, who are the primary producers of JavaScript, will happily stick with Node.js, CoffeeScript, or plain JavaScript.

I'm writing JavaScript for a few years now. I'm really tired of it. It scales very poorly and there is zero tooling. For example, JSLint is mostly about formatting and conventions, because it got very little information to work with.

Also, if you want to take care of dependencies in JavaScript, you'll need boilerplate code (several flavors exist). If you want to document your code, you'll need lengthy doc comments (several flavors exist).

Finally, with JavaScript you're always discouraged to write extensive libraries, because everything you don't use is dead weight.

With Dart, you don't have any of those problems. It scales, there is proper tooling, you can use `import` and put stuff into packages, basic documentation is already done by adding some type annotations, and unused code is also removed.

Additionally, it's a lot easier to learn than JavaScript, because the language is less quirky.

>Dart does not seem to improve on JavaScript in a compelling way. It adds optional static typing, and as far as I can tell, nothing else.

Classes/inheritance, mixins, implicit getters/setters, implicit interfaces, import, lambda expressions, proper lexical scoping, a lexically scoped `this`, operator overloading, actor-like concurrency (isolates), SIMD, faster startup, better performance, const/final, factory constructors, optional positioned/named arguments... and good tooling.

Seen that "WAT" talk? None of that.

Dart is drastically better than JavaScript.

ahoge··on Dart Is Not the Language You Think It Is
Just like V8, the Dart VM doesn't have an interpreter. The code is directly compiled to (fairly crude) machine code. Later, the hot parts are replaced with better machine code.
ahoge··on Dart Is Not the Language You Think It Is
That shouldn't stop anyone. Dart works fine in every modern browser (and IE9), because you can compile it to JavaScript.

Generating minified Dart code is one line and compiling to minified JS is also just one line. If you do one in your build script, you can also do the other. It's a no-brainer, really.

ahoge··on Dart Is Not the Language You Think It Is
> Optionally typed is extremely strange.

It's like the kind of JSDoc annotations you need for the Closure Compiler.

The difference is that it's baked into the language, which enables a very terse syntax and, since it's standardized, it can be used by all of your tools.

You only need those annotations at the API boundaries (arguments and return values) to get most of the tooling benefits like call-tips, auto-complete, direct & inferred static checks, runtime checks, generated documentation, and things like that.

ahoge··on Dart Is Not the Language You Think It Is
> It's really too bad there isn't an equivalent of play.golang.org for Dart.

There is.

http://try.dartlang.org

Anyhow, the barrier is actually pretty low. The editor zip is about 140MB in size and contains everything you need: the SDK, the editor, and Dartium (Chromium + Dart VM).

ahoge··on A Year of MongoDB
I found this very helpful:

http://www.slideshare.net/jessedee/steal-this-presentation-5...

ahoge··on Distributed Personal Wiki
Bitbucket works fine for this. Its wikis are just markdown/git. You can add stuff offline or you can use the web interface.
ahoge··on Unreal Engine in JavaScript/HTML5 – Citadel demo
It's written in C++.
ahoge··on Unreal Engine in JavaScript/HTML5 – Citadel demo
>[Google has] kind of abbonned JS in favor of Dart

Where did you get that idea? Just look at these graphs:

http://www.dartlang.org/performance/

Apparently, they are still trying to make V8 faster. V8's graph isn't flat and there are also very recent bumps.

>As oppossed to supporting asm.js

Asm.js is about JavaScript the compiler target, not JavaScript itself. Using asm.js means writing code in C/C++ (or something similar), which means it's more comparable to PNaCl than Dart.

ahoge··on JS Objects: Inherited a Mess
> giving people shortcuts

I don't see any problem there. The code is very compact. There are lambda expressions, method cascades, and user defined operators.

Also, structure is baked in. You don't need any of that AMD boilerplate code. Annotations are also baked in. You don't need to write those lengthy doc comments.

Additionally, you can auto-complete everything.

> It makes the APIs look like Java APIs more than they jQuery ones.

With jQuery, you often have those "options" objects which force you to check the documentation even if your editor is somewhat jQuery aware.

With Dart, you can just use named arguments. It's also clearer what the default values are. Of course things are also a lot easier if the machine can tell what you're trying to do.

> more like a C# collection of libraries

Well, that's the whole point. If you put type annotations at the API boundaries, those annotations can be used for documentation (fully cross-referenced), call-tips, auto-completion, type inference, and basic sanity checks.

This gets rid of lots of friction. Even if your own code doesn't include any types, the editor will be able to tell what's going on in many cases.

E.g. it knows that `1 / 3` results in a `double`, which has a `toStringAsFixed` method, which returns a `String`, which has a `length` getter, which returns an `int`.

So, if you accidentally write "lenght", the editor will tell you about your mistake right away. Well, you won't even make that typo in first place, because you'll just auto-complete that word.

Furthermore, if you store the value of `length` in a `var`, the editor will remember that it's actually an `int` and it will then notify you whenever you're doing something weird with it.

All of that works just because the libraries you're using are annotated.

ahoge··on JS Objects: Inherited a Mess
>I think people waste a lot of time giving types to APIs and obscure the intention of the code

What do you mean? Adding types to the surface area (arguments and return types) removes a lot of friction.

I'm using jQuery for a couple of years. I still have to look at its docs almost every day I use it. Today, I had to check if the "selector" argument of "children()" is optional (spoiler: it is).

Also, having the type annotations there makes the intention so much clearer. The name and the type of the argument is usually all you need to figure out what it does.

I really like that about Dart.

ahoge··on Facebook tries Google's WebP image format; users squawk
> The only gain here is facebook's bandwidth costs, at the expense (and inconvenience) of its users.

Users love faster websites. If you make your website faster, people will use it more. If you're selling something, they will buy more if your site is fast.

This has been A/B tested by countless companies like Google, Microsoft, Amazon, Netflix, Shopzilla, and so forth. Front-end performance is amazingly important.

ahoge··on Expunging Google
RSS just isn't very popular. Firefox also removed that RSS icon from the address bar a few months ago. Do you think Mozilla did that because they "oppose the open web"?

No, of course they don't. They got rid of it because virtually no one used it.

ahoge··on JQuery 2.0 Released
Even IE9 is pretty old. It's over 2 years old by now. IE8 is over 4 years old.

IE11 will be released soon. How many versions of IE do you intend to support?

ahoge··on Click on a few dots and our program will guess your age
Why not? Placebos also look like the real thing, don't they?

Anyhow, in cases like this it's always nice to save all the data you can get. The correlation you'd like to demonstrate might not exist at all. However, if there are many parameters, you might be able to find something else.

ahoge··on Click on a few dots and our program will guess your age
It could, for example, be used to demonstrate that people are more willing to reveal some private information if you make them jump through a few hoops to gain this "privilege".
ahoge··on Core libraries stabilize with Dart's new M4 release
Yes, the SIMD optimizations aren't quite there yet. You can already write SIMD code though.
ahoge··on How To Reduce Image Size With WebP Automagically
"Minority browser"? What's that supposed to mean? Anything other than Chrome? Or, if we go back a few years, anything other than IE?

In case you didn't know, there are 3 very important browsers: Chrome, Firefox, and IE. Right now, Firefox got around 20%, IE around 30%, and Chrome around 40%.

There are also a few countries where Firefox is the most popular one. For example, in Germany it currently got around 45%.

>a fringe image format

Was PNG any different? People usually don't randomly start to use some image format if it isn't supported by any browser.

Also, ripping two images out of one file and splicing them together requires very little code. In a high-level language it's maybe 50 lines of code. There are many games which do that. It's very simple and it saves typically around 80%.

ahoge··on How To Reduce Image Size With WebP Automagically
We had lossy RGBA many years ago with JNG (a simple PNG/JPG mashup format), but Mozilla killed the format along with MNG. The reason was that the MNG lib added about 100kB to the installer. They suggested to use Flash instead. (Yes, seriously.)

With JNG those massive parallax websites could be ~1MB instead of ~5MB.

ahoge··on Firefox Nightly Gets New Baseline JIT Compiler
>practically does this really matter?

JavaScript is also a compiler target. Even smaller less heavy applications can benefit from these optimizations.

>up-front costs of JIT

You have to reach some threshold. The code is optimized as-needed.

ahoge··on Blink: A rendering engine for the Chromium project
Haha... yea, you can actually make a x-sinewavemarquee tag if you want.
ahoge··on We are Switching to Dart
You could write the back-end in Dart, too. The Dart VM can do IO out-of-the-box. Just like the Node executable, it can be used to run command line scripts, web servers, or anything else you can think of.

Anyhow, since the front-end only communicates with the back-end via standardized protocols (say, HTTP or WebSockets), it doesn't matter what's used on the server-side. These two parts are completely decoupled.

ahoge··on We are Switching to Dart
> ClojureScript [...] provides all of the same benefits.

That doesn't seem to be the case. Dart provides great tooling and you can also step-debug your code from within the IDE. The workflow with Dartium (Chromium with embedded Dart VM) is pretty neat. The performance of the generated JavaScript is pretty good, too. There are also Dart Web Components which give you custom tags (with shadow DOM) and two-way data-binding.

Finally, Dart, with its "boring" C-like syntax, is familiar to pretty much anyone.

ahoge··on JavaScript is Not Web Assembly
"JS is the crappy ill-suited compiler target everyone is forced to use."

Now, if you say instead that it's low-level ("assembly"), fans of JS feel smug about using it instead of being offended.

However, at the same time you hint that JS is something which shouldn't be written by humans.

ahoge··on Why dart2js produces faster JavaScript code from Dart
Where do those 30% come from?

DeltaBlue:

100 / 320.84 * 512.74 = 159.81 -> +60%

Richards:

100 / 444.00 * 814.09 = 183.35 -> +83%

ahoge··on Why dart2js produces faster JavaScript code from Dart
Dart's biggest selling point is that it's very nice to use and that it's free of nasty surprises.

Have you ever written a somewhat bigger JavaScript application with a few thousands lines of code spread across dozens of files? It's horrible.

With Dart, the experience is similar to Java or C# (just with terser syntax). There are classes/packages, and you can simply import things. In the IDE you get call-tips, auto-complete, and sanity checks (based on type annotations or inferred types). There is very little friction in general.

There is also block scope, a lexically scoped `this`, built-in classes/inheritance, mixins, lambdas, and things like that.

ahoge··on Compiling LLJS to asm.js
This was added to Gecko 20.0, but it isn't part of the specs.

V8 doesn't support it: http://code.google.com/p/v8/issues/detail?id=2455

ahoge··on Asm.js in Firefox Nightly
"Run". Yes, just ~600 times slower. At that speed it probably won't be very useful. You have ~50 msec for an operation which is perceived as instantaneous. If it takes 30 seconds (600 times as long), people will not use it. It simply isn't feasible.

This stuff is only ES3 compatible because it didn't need anything from ES5. A low-level compiler target doesn't need any of these things: http://kangax.github.com/es5-compat-table/

ahoge··on Asm.js in Firefox Nightly
You were able to do the same without asm.js.

Problem is, it's way too large and way too slow. People aren't doing these things because they simply aren't feasible.

If you could compile Python directly into that asm.js subset of JavaScript, things would be okay. However, emulating a whole CPU and running some Python interpreter on top of that won't be okay. Even if you would magically reach 100% of the regular speed, it just would be way too fat.

ahoge··on Asm.js in Firefox Nightly
>the notion that GC somehow can't be implemented is nonsensical

http://asmjs.org/faq.html

"The asm.js model provides a model closer to C/C++ by eliminating dynamic type guards, boxed values, and garbage collection."

Sure, nothing stops you from emulating a complete CPU. Of course you can do anything.

However, how large will that JavaScript file be? Also, will it be fast enough to be usable?

← PreviousPage 13 of 16Next →