最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How can Google's Dart get better performance? - Stack Overflow

programmeradmin8浏览0评论

I've read the article about Google's uping DASH/DART language, which I found quite interesting.

One thing I stumbled upon is that they say they will remove the inherent performance problems of JavaScript. But what are these performance problems exactly? There aren't any examples in the text. This is all it says:

  • Performance -- Dash is designed with performance characteristics in mind, so that it is possible to create VMs that do not have the performance problems that all EcmaScript VMs must have.

Do you have any ideas about what those inherent performance problems are?

I've read the article about Google's uping DASH/DART language, which I found quite interesting.

One thing I stumbled upon is that they say they will remove the inherent performance problems of JavaScript. But what are these performance problems exactly? There aren't any examples in the text. This is all it says:

  • Performance -- Dash is designed with performance characteristics in mind, so that it is possible to create VMs that do not have the performance problems that all EcmaScript VMs must have.

Do you have any ideas about what those inherent performance problems are?

Share Improve this question edited Apr 27, 2013 at 3:27 Seth Ladd 121k68 gold badges205 silver badges286 bronze badges asked Sep 25, 2011 at 15:16 Sune1987Sune1987 1552 silver badges10 bronze badges 2
  • 1 Benchmarks or it didn't happen. Speculating about performance of something that's unreleased is utter bullshit. – fijal Commented Sep 29, 2011 at 21:55
  • Funny thing is that Dart appeared to be slower than JS. – c69 Commented Oct 10, 2011 at 19:20
Add a ment  | 

3 Answers 3

Reset to default 8

This thread is a must read for anyone interested in dynamic language just in time pilers: http://lambda-the-ultimate/node/3851

The participants of this thread are the creator of luajit, the pypy folks, Mozilla's javascript developers and many more. Pay special attention to Mike Pall's ments (he is the creator of luajit) and his opinions about javascript and python in particular. He says that language design affects performance. He gives importance to simplicity and orthogonality, while avoiding the crazy corner cases that plague javascript, for example.

Many different techiques and approaches are discussed there (tracing jits, method jits, interpreters, etc). Check it out!

Luis

The article is referring to the optimization difficulties that e from extremely dynamic languages such as JavaScript, plus prototypal inheritance.

In languages such as Ruby or JavaScript, the program structure can change at runtime. Classes can get a new method, functions can be eval()'ed into existence, and more. This makes it harder for runtimes to optimize their code, because the structure is never guaranteed to be set.

Prototypal inheritance is harder to optimize than more traditional class-based languages. I suspect this is because there are many years of research and implementation experience for class-based VMs.

Interestingly, V8 (Chrome's JavaScript engine) uses hidden classes as part of its optimization strategy. Of course, JS doesn't have classes, so object layout is more plicated in V8.

Object layout in V8 requires a minimum of 3 words in the header. In contrast, the Dart VM requires just 1 word in the header. The size and structure of a Dart object is known at pile time. This is very useful for VM designers.

Another example: in Dart, there are real lists (aka arrays). You can have a fixed length list, which is easier to optimize than JavaScript's not-really-arrays and always variable lengths.

Read more about piling Dart (and JavaScript) to efficient code with this presentation: http://www.dartlang/slides/2013/04/piling-dart-to-efficient-machine-code.pdf

Another performance dimension is start-up time. As web apps get more plex, the number of lines of code goes up. The design of JavaScript makes it harder to optimize startup, because parsing and loading the code also executes the code. In Dart, the language has been carefully designed to make it quick to parse. Dart does not execute code as it loads and parses the files.

This also means Dart VMs can cache a binary representation of the parsed files (known as a snapshot) for even quicker startup.

One example is tail call elimination (I'm sure some consider it required for high-performance functional programming). A feature request was put in for Google's V8 Javascript VM, but this was the response:

Tail call elimination isn't patible with JavaScript as it is used in the real world.

发布评论

评论列表(0)

  1. 暂无评论