Live data from Hacker News

Dart team posts an example of fast code with 22ms for a “Hello world”

twitter.com

11–20 of 33 posts

Re: Dart team posts an example of fast code with 22ms for a “Hello world”

#11
Lots of bashing in this thread, but to clarify a bit:

The Dart VM is roughly based on V8's internals. Running dart alone would be similar to running node, which needs to initialize the VM, parse the code, and run it. This is obviously slower than a pre-compiled binary.

dart2native brings it half-way to native, by doing parsing and initialization, and saving a memory snapshot right before executing the main function. This greatly reduce startup time (and is the same technique that makes Flutter apps start fast), but still not as fast as a binary, since it is loading the snapshots and doing some initialization.

This is usually fast enough, because once the initialization is ran, the following code will run fast. This is a constant initialization loading time, and doesn't represent anything.

Saying 22ms doesn't mean anything, and feels like a misinformed statement.

Dart overall is a pleasant language, and it is somewhat unique that it provides multiple ways to run. You can run with dart, dart2native, dart2js, and I believe there's one for ARM (for Flutter). This allows you to choose the best for your target platform

Re: Dart team posts an example of fast code with 22ms for a “Hello world”

#12

Lots of bashing in this thread, but to clarify a bit: The Dart VM is roughly based on V8's internals. Running dart alone would be similar to running node, which needs to initialize the VM, parse the code, and run it. This is obviously slower than a pre-compiled binary. dart2native brings it half-way to native, by doing parsing and initialization, and saving a memory snapshot right before executing the main function.…

As people pointed out in the thread, in 22ms a game will have rendered a full 3D world with physics and audio multiple times.

22ms is... not fast. Unless you count modern world where "fast" is "anything that runs under 10 seconds".

Re: Dart team posts an example of fast code with 22ms for a “Hello world”

#13

Lots of bashing in this thread, but to clarify a bit: The Dart VM is roughly based on V8's internals. Running dart alone would be similar to running node, which needs to initialize the VM, parse the code, and run it. This is obviously slower than a pre-compiled binary. dart2native brings it half-way to native, by doing parsing and initialization, and saving a memory snapshot right before executing the main function.…

And it looks like compilation times are just abysmal: https://twitter.com/alexyanov/status/1258474918607544322?s=2...

Re: Dart team posts an example of fast code with 22ms for a “Hello world”

#14

Lots of bashing in this thread, but to clarify a bit: The Dart VM is roughly based on V8's internals. Running dart alone would be similar to running node, which needs to initialize the VM, parse the code, and run it. This is obviously slower than a pre-compiled binary. dart2native brings it half-way to native, by doing parsing and initialization, and saving a memory snapshot right before executing the main function.…

As people pointed out in the thread, in 22ms a game will have rendered a full 3D world with physics and audio multiple times. 22ms is... not fast. Unless you count modern world where "fast" is "anything that runs under 10 seconds".

That's an odd contrast (one frame of a game versus loading a language runtime). How long does a game engine take to load?

A reasonable comparison is whether Dart is able to render complex experiences at 60fps (i.e. 16ms / frame) on a low-end phone device, which is the primary use case.

Re: Dart team posts an example of fast code with 22ms for a “Hello world”

#15

Lots of bashing in this thread, but to clarify a bit: The Dart VM is roughly based on V8's internals. Running dart alone would be similar to running node, which needs to initialize the VM, parse the code, and run it. This is obviously slower than a pre-compiled binary. dart2native brings it half-way to native, by doing parsing and initialization, and saving a memory snapshot right before executing the main function.…

As people pointed out in the thread, in 22ms a game will have rendered a full 3D world with physics and audio multiple times. 22ms is... not fast. Unless you count modern world where "fast" is "anything that runs under 10 seconds".

This is like saying a game runs at 0.1fps because it took a couple seconds to load at the start.

This is initial load time. Printing likely account for <1% of the actual time, the rest being initializing the program

Re: Dart team posts an example of fast code with 22ms for a “Hello world”

#16

How it compares with go, node and java?

Here are a few comparisons (13" MBP, YMMV).

  $ ./hyperfine './hello.gonative' --warmup 10
  Benchmark #1: ./hello.gonative
    Time (mean ± σ):       3.3 ms ±   0.9 ms   [User: 1.2 ms, 
      System: 1.2 ms]
    Range (min … max):     2.4 ms …  14.2 ms   455 runs

  $ ./hyperfine './hello.dartnative' --warmup 10
  Benchmark #1: ./hello.dartnative
    Time (mean ± σ):       8.2 ms ±   0.4 ms   [User: 3.9 ms, 
      System: 3.6 ms]
    Range (min … max):     7.5 ms …  10.2 ms   243 runs

  $ hyperfine 'java HelloWorld' --warmup 10
  Benchmark #1: java HelloWorld
    Time (mean ± σ):      90.7 ms ±   1.3 ms   [User: 83.2 ms, 
      System: 23.9 ms]
    Range (min … max):    88.7 ms …  94.2 ms   31 runs

Re: Dart team posts an example of fast code with 22ms for a “Hello world”

#17

Earlier quoted context omitted.

As people pointed out in the thread, in 22ms a game will have rendered a full 3D world with physics and audio multiple times. 22ms is... not fast. Unless you count modern world where "fast" is "anything that runs under 10 seconds".

That's an odd contrast (one frame of a game versus loading a language runtime). How long does a game engine take to load? A reasonable comparison is whether Dart is able to render complex experiences at 60fps (i.e. 16ms / frame) on a low-end phone device, which is the primary use case.

Depends on the game engine. Jonathan Blow has written one for his upcoming Sokoban game and it completely compiles and launches the game from source in about a second and a half. No incremental compilation, no debug mode. That's not just the runtime engine, it's the tooling to make the game, as well. A second and a half, from source files on disk to a running binary showing a 3D viewport on screen.

Think about that.

There is no excuse for how slow software is today. None.

Many parts of Windows 95 were faster in wall clock time in 1995 on the hardware of 1995 than today's Windows 10 is on the hardware of today. Yes, today's software does more, but THAT MUCH more? Are you sure?

The hardware we have is very fast. Software developers have been relying on hardware upgrades for performance improvements for far too long, and now few software developers know how fast things can be, if they just try just a tiny little bit.

Also, OOP teaches developers how to think about software in ways that are exactly opposite to how computers actually do work efficiently. Object oriented programming is just inherently slower because it encourages developers to think of things one at a time. Computers like to do things in batches.

More people need to think about performance, because clock speeds aren't going up like they used to, and we still don't know how to write software that spreads across a lot of cores very well. The free ride that hardware upgrades provided us is quickly coming to an end.

tl:dr; everyone needs to learn about how processor caches work, especially the 24-year old JS devs who think they already know everything.

Re: Dart team posts an example of fast code with 22ms for a “Hello world”

#19
[disclaimer: I work on the Dart team.]

As others have already noted, the intent here is to purely measure the one-time startup cost of the runtime in ahead-of-time compiled code - i.e., the amount of time necessary before we can starting executing any user code - i.e., the print in this case. It's assumed that the time to do the actual print is trivial here.

If you want to compare, you might compare with other garbage collected language/runtimes.

Re: Dart team posts an example of fast code with 22ms for a “Hello world”

#20
post #7

Both process startup and terminal can be very slow depending on OS. I also have a rule, I don't bash novice developers for their lack of knowledge.

Do you really think novice devs work on Dart at Google?

Would that be really so surprising?
Post reply on HN