Language Syntax
Before we are talking about the language,we can just see its syntax.It is very sample of you, if you are a developer,even a non developer could know it.so let us talk about the syntax,every programming language has its own syntax,as well as the Dart language. See below:
- variable and operators
this is very common and basic ,so you must know how to use - classes
classes are beginning after object-oriented language ,such as c++,java. as the project language ,it must has the classes. - function
when develop language is created by scientists,it always support the function’s calls. - expression and programming constructs
If we use some operations in a function,we also need some expression to concise our working.as well as the constructs - decision making and loop constructs
the key words areif
andfor
,even through you know a little about developing language,you may know these words. - comments
It is very common function that is almost in every programming language. - libraries and packages
If you want to use the codes of the other people or some functions that had been created by you before.you cloud use the libraries or packages to concise your code and manage your mind. - typedefs
In every language,there are some many types,you can use them ,if it was not defined ,you need to define it by you self. - data structures
data structures are very import,it can manage some complex data,you don’t need to know much about algorithms.Just use it if you like it.
Hello world!
every one know that a developer begins with a “hello world” example,as this,I am not the exception.
void main(){
print("hello world")
}
if you configure your dart environment right, you can run it within your .dart file,or just run in the online environment DartPard it will print
hello world
Command line
if you like command line ,you may want to use the command lines,but here,I do not want to take it ,for I just want to learn the language syntax at this time. So sorry about that.If you want to use it ,just run dart -h
,you can see the base command about it.
Checked Mode
when you run a dart file in dart, there are two modes ,the one is production mode ,the other is the debug mode or test mode ,If you want to use the debug mode, just run file as this dart -c xxx.dart
,at this mode ,if you have some error or warning ,the Dart VM will prints some detail messages in the terminal.
Identifiers
as the java ,it support:
- number
- characters
- special of
_
,$
, - can not begin with digits,
- case-sensitive
Keywords
compare with java , there are some special keywords,
1 | 2 | 3 | 4 | 5 |
---|---|---|---|---|
as | deferred | assert | operator | async / async* |
part | dynamic | get | typedefs | var |
set | export | external | in | with |
is | yield / yield* | const | factory | library |
sync / sync* |
other keywords is same as the java, such as if
true
Little things
dart can ignore the spaces,tabs and newlines ,but you should end it with ;
,so a single line can contain so many statements ,but you must need to separate them by semicolon ;
if you want to comment some code you just need to use //
for single line and /* */
for multi lines.
dart language is object-oriented language ,the using of an object is very similar with java. So,if you have used java before, you would learn the dart language very quickly.
The Special
As we can see, dart is similar with java ,but there are some differences:
- files
in java ,you must define a java file with only one class or interface ,but in dart you can define a function ,class,or some variables in it,you can call them easy . it is a programming language ,but have some script feature. - old vs modern
java is a old language that used in so many projects ,but have a fixed structure and call them not easy. dart have some modern language feature and have some ways for easy using. - future
In the last year,google have publish their project called flutter,which use the dart language as the base developing language,just for one year ,there are 34k stars on the project in the github. you can see the potential of dart,just do it and go with me,you will find a new land again.