Preface
I wrote a few articles two days ago to talk about Dart
back-end development, such as:
"Dart develops the server, am I having a fever? 》
"Continue to have a fever, try the asynchronous operation of the Dart language, and increase the efficiency by 500%"
"Continue to have a fever, talk about the concurrent processing of the Dart language, can you challenge Go? 》
If you have not seen it before, you can take a look first.
Today, let's talk about Dart
, which is static compilation. It is estimated that php
and python
directly admit defeat, java
and go
sidelines?
Advance notice, the content is slightly dry, please bring your own mineral water.
What compilation methods are supported by the Dart language
The current mainstream development languages generally support either JIT
mode, or AOT
mode, or both.
Take care of Xiaobai, explain the nouns a little bit
JIT
is Just-In-Time
, real-time compilation, abbreviated as interpretation type, in short, after the code is run, compile the code while running the code, the advantage is easy to develop and debug, the disadvantage is that the execution efficiency is not good
AOT
is Ahead-Of-Time
, pre-compiled, referred to as compiled type. Simply put, the code is compiled before the code runs. The advantage is that the execution efficiency is higher, but the development and debugging are not friendly.
The mainstream back-end language, from the actual use of
php
and python
are both interpreted. In actual development, the code is written very well, but there are always complaints about low performance
java
and go
are compiled . I always get complained about the compilation once, and the fight is not over yet. I am talking about
java
Faced with this situation, witty students saw it, that developed when using JIT
mode of operation when using AOT
mode does not like it, but also to facilitate development and debugging, execution efficiency is high?
Not bad, you are quite wise, young man, you are right, and Dart
did the same.
How to compile programs written by Dart
After you use Dart
write the application program, you can use the dart compile
command to compile into the final file
For example, use the following command to directly compile into a exe
file
dart compile exe bin/main.dart
You will get the main.exe
file, which can win
platform, but it cannot be linux
under 060e7210c0da3e
Can it be compiled into a file that is common to all platforms? Of course.
Execute the following command
dart compile kernel bin/main.dart
You will get the main.dill
file, which is a binary file that can be used on all platforms and all CPU
architectures.
Classmates who are familiar with go
looked blank, copy me?
Of course, you can also execute the following command to compile it into a aot
file
dart compile aot-snapshot bin/main.dart
It has a win
aot
file compiled on the 060e7210c0db0b platform cannot be used under linux
.
Similarly, linux
under 060e7210c0db34 cannot be used under win
.
Of course, its best part is the best performance, so it is also the most recommended.
Is there anything else I need to add?
some.
In Dart
, there is a special reminder about the compiled page
https://dart.dev/tools/dart-compile
It is this page, which has such a description, please be sure to pay attention:
The exe and aot-snapshot subcommands have some known limitations:
...
No support for dart:mirrors and dart:developer
...
It means that there are some limitations in the two modes of exe
and aot
Does not support dart:mirrors
reflection
Does not support dart:developer
developer tools
Some students may write basic additions, deletions, and corrections every day. I guess they don't know the use of reflection.
In fact, it uses very large, including java
field SpringBoot
framework, PHP
field of Laravel
frame, when in actual operation, we need to use to reflex function, to obtain property information to run the classes, methods, information, in order to complete some automated deal with.
However, Dart
disables reflection, which brings great inconvenience to framework writing.
Of course, the reason given by Dart
reflection. One is that this library is not stable yet, and the other is that it can improve performance.
Hmm, I believe it.
to sum up
Dart
is still mainstream. It fully considers ease of use and performance, and has no PHP
. Unlike 060e7210c0de88, which is criticized in this regard, it paves the way for back-end development.
In addition to the other two features improved at the beginning of the article, asynchronous and
concurrent, so I recommend using
Dart
in the company.
The students have to say, good Java
why not, Dart
but also than Java
more suitable for the development of back-end?
This question will be discussed later.
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。