"Easy language. Flying" 10 minutes getting started tutorial

Source: Internet
Author: User
"Easy language. Flying" 10 minutes getting started tutorial

Author: liigo

2007.1.1

Link: http://blog.csdn.net/liigo/archive/2007/01/01/1472077.aspx

Reprint must indicate the source: http://blog.csdn.net/liigo

 

  • 1st minutes: overture
  • 2nd minutes: new acquaintance of "easy language. Flying"
  • 3rd minutes: the first program
  • 4th minutes: the First Class Library
  • 5th minutes: Guess digital games
  • 6th minutes: basic syntax
  • 7th minutes: Object-oriented
  • 8th minutes: Special syntax
  • 9th minutes: Answer time
  • 10th minutes: Close

Dear friend, would you like to spend ten minutes learning a brand new programming language "easy language. Flying?

 

1st minutes: overture

It's only 10 minutes. It's time-consuming. Let's get started right away and don't talk much nonsense (isn't it a nonsense? Haha ).

In fact, you don't need to be so nervous. The average reading speed is 300 words per minute, and 10 minutes is enough to read 3000 words. Besides, I don't plan to write it that long, because I have to leave enough time for my dear readers to think about it.

As a ten-minute introductory tutorial, this article cannot cover all aspects. It can only focus on the content that beginners focus on, care about, or are interested in. The main purpose of this article is to give readers a general understanding and perceptual knowledge of "easy language. Flying" in a short time. If you want to get deeper, more detailed, more authoritative, more organized, more logical (or more abstract, more rigid ?) Please read the "easy language. Flying" White Paper officially provided by the easy language-this book is very well written, and it is much better than me! This article provides a lot of reference to this White Paper.

(In this article, I occasionally refer to "easy language. Flying" as "easy language" or "easy language", which is the same in all .)

 

2nd minutes: new acquaintance of "easy language. Flying"

First, let's take a look at the easy language of Feiyang through a few simple sentences:

  • Fully object-oriented, with a complete concept of classes and interfaces (forget structured programming from now on)
  • It has an automatic garbage collection mechanism (you just need to create an object, instead of releasing it yourself, it's much easier)
  • The source code will be compiled into a local machine code, and the program has a high execution efficiency (of course, it is not as efficient as the C language)
  • The same set of source code can be compiled into executable files under multiple operating systems (Windows/Linux/...). This is a cross-platform mechanism.
  • The source code can be compiled into easy language class libraries for code reuse. The same easy language class library can be used on multiple platforms. In addition, you can use C/C ++ to develop an easy-to-use "local class library ". The development class library is very easy.
  • There is a "system" Class Library (similar to the "core support library" in the original easy language) to provide the core support for the program, is necessary for the program to run, its file size is only 150 kb, small and exquisite.
  • There is a cross-platform graphical user interface (GUI) Class Library Based on wxWidgets, which is not yet mature.
  • At present, all kinds of class libraries are very lacking, but time will improve everything
  • There will be a complete integrated development environment (IDE) including "Visual Interface Design", and most of its code will be compiled in easy language. (For the time being, use a text editor to write a program. Oh, we recommend emedit. It provides better support for Chinese Character syntax highlighting)
  • Feiyang easy language has many special syntaxes, such as "friendly names (similar to Natural Language Programming)", "three-way attention style", "multiple return values", "two-way assignment", and "Attribute Table.

I think it is necessary to emphasize again: "easy language. flying flying "is totally different from the original easy language (1.x-4.x). (If you have to find the same point, they are all easy language Company Products, and the author is Wu Tao ). The former requires a lot of advanced programming concepts and is the trend of future development. The latter has more advantages in programming resources and is a more mature practical product.

 

3rd minutes: the first program
Public class startup class
{
Public static startup ()
{
Console. Output line ("Hello! ");
}
}

Save the preceding code as a hello. EF file. Note that the encoding format must be UNICODE (little endian ).

Compile the command line:

EC hello. ef-ecl_name = "program"-starter_cls = "Startup class"-out_mode = runable -out1_hello.exe

The preceding command line will compile and generate the hello.exe file. to execute this program, make sure that the "system. NCL" file in the system library is in the current directory.

The execution result of hello.exe is displayed on the screen: Hello!

Remember? The first easy language (old version) program Wu Tao taught us is also "Hello !". The "Hello World" that many people like to write is just a faint greeting, like "hello, Motherland !" So affectionate? China will never be short of internationalists, but what we need is nationalism!

(Dear friend, if you only have three minutes, you can go back to work or have a rest now. However, I sincerely invite you to spend seven minutes in your busy schedule to continue reading this article !)

 

4th minutes: the First Class Library

Take the source code file of the "first program" above and compile it as an easy language class library without any changes.

Compile the command line:

ec hello.ef -out_mode=ecl -ecl_name="liigo"

"-Out_mode = ECL" indicates compiling the class library (rather than executable files ), -ecl_name = "liigo" specifies the name of the compiled class library (replace "liigo" with your own name, this is the first easy language class library compiled by you. It is very memorable ).

Execute the preceding command line to compile the class library file "liigo. ECL (if you have replaced "liigo" with "Zhang San", the generated file is "Zhang San. ECL "). ". ECL" is a fixed extension of the easy-language class library, which means "eyuyan class library" (easy-language class library ).

Now you know, writing a class library is as simple as writing a program.

To use the compiled class library, pay attention to two points: 1. "introduce" this class library; 2. Make sure that the Library is located in the directory specified by the system environment variable ecls_paths (or in the current directory ).

 

5th minutes: Guess digital games

The "guess number" game is really very, very classic. Through this small game source code, we can not only learn the basic syntax of easy language flying (definition class, definition class method, definition variable, if, loop, method call ......), We can also fully appreciate the object-oriented programming ideas.

In the next three minutes, our theme is it! 5th minutes, compile it into an executable file (see the following section for the compilation method) and play the game by yourself. In 6th minutes, I will explain the basic grammar of the easy language involved in flying. In 7th minutes, I will explain the object-oriented ideology.

Public class startup class // 1st rows
{
Publish static startup () // 3rd rows
{
Guess number = create a guess number (); // 5th rows
// Guess number = create a fully automated guess number ();
Guess. Guess (); // 7th rows
}
}


Class guess number
{
Private integer inner number = 66; // todo: select a random number // 13th rows

Public guess ()
{
Loop (guess number () = false) // 17th rows
{
}
}

Private logic guess number ()
{
Console. Output line ("Please guess one number in 1 :");

Integer = get number ();
Console. Output (number );

If (number = Inner number) // 28th rows
{
Console. Output line ("guessed it, congratulations !! ");
Returns true;
}

If (number> Number) // 34th rows
Console. Output line ("too big, come again. ");
Otherwise
Console. Output line ("too small, again. ");

Returns false; // 39th rows
}

Use an extended integer to obtain a number ()
{
Return to the console. Enter an integer ();
}

}

Class automatic guess number <base class = guess number> // 49th rows
{
Integer current number = 0;

Use an extended integer to obtain a number ()
{
Current number +; // 55th rows
Returns the current number;
}
}

Compilation Method: Save the above Code as a "guess number. EF" file (note that the encoding format must be UNICODE (little endian), and then execute the following command line:
EC guess number. ef-ecl_name = "program"-starter_cls = "Startup class"-out_mode = runable -outdigit guess number .exe

 

6th minutes: basic syntax

Row 3 defines the class. "Class" and "public" are keywords (note: "public", "extended", "private", and "static" are called attributes in the White Paper, in fact, it is similar to the keyword, which is not clearly distinguished below); "//" is the beginning of the comment until the end of the line (another form of multi-line comment is "/*... */")

Row 3 defines the class member method "Start ()"

Row 3 defines the variable "Guess" of the type "guess number" and creates an object of the type "guess number, assign the created object to the variable "Guess" (that is, the variable "Guess" references this object)

In row 3, the member method "Guess ()" of the "Guess" (strictly speaking, the "variable" refers to the object referenced by the "Guess") is called ()"

Row 3 defines a "private" class member variable with the data type as an integer "inner number" and specifies the initial value as 66.

Row 3, "loop" statement, as long as the condition in parentheses ("guess number ()" returns "false") is true, execute the code in curly braces cyclically (until the conditions in the parentheses are invalid)

In the second row, if the statement is used to determine whether the values of the two variables "Number" and "inner number" are equal, the code in the brackets is executed.

If the value of the variable "Number" is greater than the value of "preset number" in the "if-otherwise" statement. If the value is greater than the value of the variable "Number", 34th rows are executed. Otherwise, 35th rows are executed.

Line 3: "return" Statement, end this method, and return the corresponding value (here "false ")

In row 3, define a class "automatic digit prediction" and specify its "base class" as "digit prediction"

In row 3, the value of the variable "current number" is increased by 1, that is, 1 is added on the basis of the original value.

 

7th minutes: Object-oriented

The real world is composed of all things (objects. In the program, the concept of objects is abstracted to describe and express everything in the real world. This is an object-oriented design concept.

Here we will briefly introduce the concepts of "encapsulation", "inheritance", and "polymorphism" in the object-oriented model.

Let's take a look at the "Guess number" class. Its data member "preset number" is "private", and its method member "guess number ()" is also "private", that is, they are invisible to the outside world, that is, they are strictly restricted and can only be used inside the "Guess number" class. Since it cannot be directly operated by code outside the class, this class maintains relatively independent. The member method of "getting numbers ()" is "extended", that is, it allows external (subclass) conditional use. Only the member method "Guess ()" is "public" and can be used freely on the interface. Through the "private" and "extended" and "public" mechanisms, the class not only hides implementation details, but also discloses operation interfaces. This is the concept of "encapsulation.

Let's look at the fully automated guess number class. It does not define the member method of "Guess ()", but the outside world can call its "Guess ()". Why? This is because the base class of "fully automated guess numbers" is "guess numbers", and "Guess ()" is derived from its base class "guess numbers. The concept of "inheritance" in object-oriented systems is similar to that in real life, children inherit the property of their fathers. Subclass can only inherit "public" and "extended" members of the base class, but not "private" members.

The concept of "polymorphism" is more complex, harder to understand, and harder to explain. In general, the member method to be called is determined dynamically based on the object type (rather than the variable type) (when the program is running, rather than during compilation. Polymorphism usually relies on Member methods based on inheritance and overwrite (subclass defines the member methods in the same declaration form as its parent class 'public or extended member method, the method in the subclass will overwrite the method in the base class ).

The following code provides a detailed explanation:

Guess number = create a guess number ();
// Guess number = create a fully automated guess number ();
Guess. Guess ();

Comments the second line to only execute the first line, and comments the first line to only execute the second line. The program has different running results, the main "secret" is the polymorphism mechanism. In this program, the polymorphism mechanism is mainly reflected in the member method of "getting numbers ()"-it is an "extension" method that can be overwritten, it has also been overwritten (the base class "guess number" defines a "get number ()", and the sub-class "Fully Automatic guess number" also defines a "get number ()", the latter overwrites the former ). The program has two running results, that is, because there are two "getting numbers ()" and which "getting numbers ()" is executed, depends on the actual type of the object (determined at creation and never changed): If the object type is "guess number" (the first line), then "guess number. "Getting a number ()" is called. If the object type is "full automatic number guessing" (second line), "full automatic number guessing. "Get number ()" is called. You may still be wondering that these two classes have only one "Guess ()" method, which is defined in the "Guess ()" of the base class "guess number () "Can I call the" get number () "method in the sub-class" fully automated guess number? Yes, because the subclass "get number ()" overwrites the base class "get number ()". This is the essence of polymorphism and the most difficult to understand.

The object-oriented thinking can not be quickly understood and mastered, and requires meticulous taste and long-term practice. Object-oriented is a science, and many people are learning it all their lives.

 

8th minutes: Special syntax

Friendly name-- Write a program in a natural language format:

If the following friendly names are defined:

Friendly name: Write <A> to the screen = console. Output line ();

The program can be written as follows:

'Write 123 to the screen ';
'Write "easy language" to the screen ';
'Write <x> to the screen '(x = 100.123 );

Triplicate:

You can write "If (0 <x <10)" without having to do anything like C/C ++, Java, C # It must be written as "If (x> 0 & x <10 )". "0 <x <10" is the most common way of writing in mathematics. Naturally, why is it not supported by other programming languages? I think that all programmers learn mathematics before learning programming. At the beginning, this strange "x> 0 & x <10" is inevitable, but the design masters of various programming languages turned a blind eye to this!

Multiple return values:

Define a method with multiple return values:

Text, integer name and age ()
{
Return ("China", 5000 );
}

Call the preceding method to receive multiple return values:

Text name; integer age;
(Name, age) = name and age ();

Bidirectional value assignment operator"<=>" -- Exchange the values of two variables:

Integer A = 1, B = 2;
A <=> B; // after execution, A = 2; B = 1;

If there is no bidirectional assignment operator, it is generally written as "c = A; A = B; B = C;" or "A = a + B; B = A-B; A = A-B; "or" A = a ^ B; B = a ^ B; A = a ^ B; ". How troublesome is it.

 

9th minutes: Answer time

With easy language, why do we need to re-develop "easy language. Flying "?

Easy language (old version) is becoming more mature and stable, and the space for further transformation is very small.

What are the essential improvements of "easy language. Flying" compared with the original easy language?

Fully object-oriented, automatic garbage collection, self-developed class libraries, plain text source code, multi-file engineering, and integration with C/C ++.

There are already many programming languages. Do we still need a brand new programming language?

When assembly language was born, C language was born, C ++ was born, Pascal was born, Java was born, C # was born, there will be the same question, the answer is one: "Yes ". The same is true for "easy language. Flying.

"What is the interaction with C/C ++ language?

You can use C/C ++ or other languages to develop easy-to-use local class libraries, which are equivalent to libraries developed by the language itself. They can be referenced and complementary.

What are the similarities between "easy language. Flying" and Java?

In terms of syntax, there is an automatic garbage collection mechanism; there is a concept of "reference" and there is no "pointer". Cross platforms are supported; they all have their own class libraries; they support Unicode, multithreading, and class reflection; they all have stuff like "class path", "Java Doc", "JNI ......

Why is it so similar to Java?

I have no idea about the syntax. Both of them copy the C language. In other aspects, it is normal and reasonable to move "easy language. Flying" closer to the most advanced programming concepts.

What is different from Java?

Compiled language, directly executes machine code, and has high running efficiency (Java is interpreted and executed by JVM in combination with JIT); the most elaborate Runtime Environment (runtime environment ), the core class library is only 150 kb. It is imported in units of "class library" rather than "package ); the path of the most source code file is not strictly required (Java requires that the source file must be located in a specific subdirectory); it does not limit that a source code file can only write one public class; the class construction method is fixed as "initialization () ", The Destructor is fixed as" clean () "(the Java class constructor name is the same as the class name, no destructor); Class Libraries can not only use" easy language. flying flying "self-developed, can also be developed using other programming languages (such as assembly, C/C ++, Delphi); Exception Handling Mechanism is not supported for the time being; the special syntax mentioned above;

How is the quality and efficiency of the garbage collector (GC?

It has not been tested in practice. According to my personal non-strict test, the garbage collector works normally when 10000 objects are referenced by each other and there are a large number of circular references. The average time for each collection operation is about 20 milliseconds. GC may interrupt program execution during work. The interval between each recycle task is about 6 to 10 seconds, which can be adjusted. The specific garbage collection algorithm is unknown.

How many class libraries are available now?

The sample code in the test version provided by easy language company involves three class libraries: system. NCL, user interface. NCL, and tool. NCL, but the class library interface is not published at the same time. Therefore, we can think that there is no class library currently available. As I personally understand, this release of the beta version mainly aims to test the basic syntax and compiler, rather than the class library.

 

10th minutes: Close

I suddenly realized that the article had been written for a long time. It may have been 20 minutes since you read it? I am sorry for this. But please do not complain, because I spent more than 20 hours in this article!

I hope you will have some gains after reading this article. Thank you for your valuable time.

I would like to pay tribute to Wu Tao, a senior IT engineer from China, and to his easy language development team!

 

References:

Dalian dahave Wu Tao easy language Software Development Company Limited Website: http://dywt.com.cn

Easy language official forum: http://dywt.com.cn/vbs/

"Easy language. Flying" 1.0 test version: http://www.dywt.com.cn/edown/efly/efly.rar,http://dywt.com.cn/vbs/dispbbs.asp? Boardid = 148 & id = 100124 & page = 1

"Easy language. Flying" whitepaper 1.0 online address:

HTML:
Http://liigo.diy.myrice.com/efly/whitebook/index.html
Http://www.21111.cn/efy/index.html
Http://www.21111.eb.cn/efy/index.html
Http://e-soscn.s103.72dns.com/efly%5Fbook/
Http://aneng.go3.icpcn.com/efy/index.html

PDF:
Http://liigo.diy.myrice.com/efly/whitebook/white_book.pdf
Http://www.21111.cn/efy/white_book.pdf
Http://www.21111.eb.cn/efy/white_book.pdf

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.