Dart entry (a) Language Overview

Dart grammar learning

Dart language Overview

 

Language features

  • Dart everything is an object, even digital numbers, function function, null also are objects, all objects are inherited from the Object class.

  • Dart dynamically typed languages ​​to try to define a variable type, safer, not shown typed variables in debug mode type would be dynamic (Dynamic).

  • Dart resolve all your code before running, the time constant of the specified type of data and compilation, you can increase the operating speed.

  • The Dart classes and interfaces are unified, ie the interface class, you can inherit a class, you can implement a class (interfaces), naturally contains a good support object-oriented and concurrent programming.

  • Dart provides a top-level functions (such as: main ()).

  • Dart is not public, private, protected these keywords, variable names with "_" at the beginning means that it's lib is private.

  • Uninitialized variable will be given a default value of null.

  • The final value can only be set once. const is a compile-time constant, a constant value can be created by const, var c = const [] ;, where c is a variable, but is assigned a constant value, or it may be set to other values. Instance variables can be final, but could not be const.

  • Programming languages ​​not exist in isolation, Dart, too, he was by the language specification, a virtual machine, class libraries, and tools and other components:

    • SDK: SDK contains the Dart VM, dart2js, Pub, libraries, and tools.
    • Dartium: embedded Dart VM in Chromium, the code can be executed directly dart in your browser.
    • Dart2js: The Dart code into JavaScript tool.
    • Dart Editor: Full-featured Eclipse-based IDE, and includes all of the above tools. Supports code completion, code navigation, quick fixes, refactoring, debugging and other functions.

 

Dart supports JIT (Just In Time, time compilation) and AOT (Ahead of Time, before running the compiler) both compilers mode.

JIT  -time compilation at runtime, use in the development cycle, can be dynamically issued and execute code , the development of high test efficiency, but the speed and execution performance because it will run-time compiler affected.

AOT  That advance compiler can generate binary code to be executed directly, fast, good execution performance, but will need to compile in advance before each execution, the development of low test efficiency.

Flutter used in the development of JIT compilation, you can shorten the product development cycle, such as thermal overload is based on this characteristic . Use of AOT in publishing, has run fast, good execution performance characteristics.

Memory allocation and garbage collection

Dart VM memory allocation strategy, just move the pointer on the heap object is created, memory growth is always linear, eliminating the need for available memory process.

In Dart, the concurrency is achieved through Isolate. Isolate is similar thread but do not share memory, worker independently. Such a mechanism, we can make rapid distribution Dart lock-free.

Dart garbage collection algorithm for multi-generation students . The use of new generation in the recovery of memory "half space" mechanism, triggering garbage collection, Dart sets the current half-space "active" object is copied to the backup control, and then the overall current releases all memory space. Recycling process, Dart only need to operate a small number of "active" objects, a large number of "death" does not refer to the object are ignored, so it is suitable for Flutter recovery mechanisms in the framework of the destruction of a large number of Widget reconstruction of the scene.

Single-threaded

Dart is a single-threaded model , resource competition and state synchronization problem does not exist. This means that, once a function is started, it will perform this function until the end, without being interrupted by other Dart code.

Dart and there is no thread, and only Isolate (quarantine ). Before Isolates do not share memory, just a few run worker in a different process , pass messages to communicate on the event queue (Event Queue) through the event loop (Event Looper).

No separate declarative layout language

  • In Flutter, the direct interface layout defined by Dart encoding.
  • Dart declarative programming layout is easy to read and visualization , making Flutter does not require similar JSX or XML declarative layout language. All use the same layout format also makes it easy Flutter offers advanced tools make the layout easier.
  • Development process does not require visual interface builder, because the thermal overload allows us to immediately see the effect on the phone.

Guess you like

Origin www.cnblogs.com/liyonghua/p/11918741.html