[Programming] Talk Hello world!

Hello world! Is the first key to open the programming world, as long as you can run a Hello world !, basically even into the door, because the program is running correctly represents the basic development environment have it all, including an editor, compiler , interpreters, wait for the operating environment, but you also know how the program is up and running, and to complete a simple human-computer interaction - run the program -> returns a result.

Of course, running the program are varied and return the same way also different. For instance, some pop, some black window, and some display the page, and some written in the document, and some on the internet at ...... but the original aim, place the returned results are collectively referred to as the output device. But usually do, I usually display-output device, because some page displayed in the display is immediately displayed content does not need to actually open the output means, and then displayed on the screen. Similarly, where to save the file is the file device, called network equipment network data transmission. Of course, this device does not refer to specific things, but the logic of an abstract concept, is a general term.

We wrote the first PC program (like most microcontrollers like without an output device, no storage, no display, so the emphasis here is PC program), they often are carried out in the black window, this window is black computer one form of input output content on the display in the windows is often called cmd.com (or .exe) program, under linux is a thing called bash, this black window displays only text, but most custom about fonts. Black window itself is a programmable environment, you can directly typing the script at the prompt, then we can write the first "Hello World!" To.

Our windows of the black window type:

echo  Hello World! 

Return result:

Hello World! 

Command line of "Hello World!"

But certainly some people say, that what counted Hello World! , What a Programming. But I think, is one such program, as long as you can write code to manipulate a computer's behavior, can be called programming. Just that nobody uses script code command line to build large applications, but it can serve as a system of subsets, such as controlling start some programs, the system is some of the bulk of what operations are possible to achieve a certain function .

For Windows, cmd script syntax is really against humanity, something the early programmers invention, no change over the decades, weird keywords, French rule, process-oriented design, are very engaged in the brain. So then, Microsoft had a WSH instead of the command line (Linux, you can use python, php, perl and other scripting languages ​​instead of bash).

Makes the first big batch script

Javascript (referred js) is a very popular language widely used on Web applications. So I wrote a js Hello World !. js the Hello World! with cmd as simple, clean and even a bit. Let's create a hello.js file, playing with a text editor, type the following line of code in it:

WScript.Echo("Hello World!");

save. Then double-click the file, you will have the following effects.

WSH

In fact, I write to you are still a lot of people think, this is not really programming. Why is this? Probably because these two examples are not the compilation process. Because I used to write programs, and can not be used directly, but compiled into binary machine to know, what the compiler is written in a programming language, translated into binary code instructions. For example, using C to write a Hello World! . For convenience, the operating system is Linux (Windows below too serious to rely IDE), comes with GCC under Linux, first with the vi editing a file called hello.c. It reads as follows:

#include <stdio.h>

void main(){
printf("Hello World!\n");
}

Save and exit vi, console, enter the command:

gcc main.c

ls

Then you will find that the current multi-file a.out of a directory. Then run:

./a.out

Get the results:

Hello world!

a.out is a binary program. Open a plain text editor is a pile of garbage, only to open the program supports binary editing, only to see a bunch of incomprehensible numbers.

In fact, this type of compiler program development than in front of more than one step to write the script, so in terms of feelings, compiler development is indeed more orthodox, but now the momentum scripting language is more and more fierce, the old-fashioned way of programming sometimes become obstacles to human progress.

不过走极端都不是什么好事情,其实主流的是介于纯脚本和编译之间的虚拟机技术。典型的有java和.net。它们看上去跟古老的编程方式一至,但实际编译出来的东西并不能直接运行在机器上,它们编译出来的是一种供虚拟机认识的代码,然后再解释执行。比如java的.class类,你用文本编辑器打之后,发现里边并完全是乱码。再来段Java版的Hello World!

public class Hello {

    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

上述内容保存到一个叫Hello.java的文件里,然后命令行里运行:

javac Hello.java

得到Hello.class,运行Hello:

java Hello

运行结果请自尝试啊。

这里要注意的是,一般电脑上不会自带java的运行环境,需要到Oracle或OpenJdk的网站下载安装程序并安装,并把程序的Bin目录设置到环境变量PATH下边,这样才可以正常运行java的各种命令。

.Net与java同理。不过,.net是多语言编程环境,通常是用C#。C#的代码结构与java的大同小异。C#程序需要安装.net framework。.net并不要求文件名与类名相同。
C#的Hello World!

using System;
public class program
{
    public static void main()
    {
        Console.WriteLine("Hello,World");
        Console.ReadLine();
    }
} 

附——Hello World!一站式体验。

准备工作

除了批处理程序,其他的或多或少都要安装一些编译和运行的环境。

1, Studio Code install Visual
Visual Studio Code download page: HTTPS: //code.visualstudio.com/
2, install the JDK
the JDK download page: https: //www.oracle.com/technetwork/java/javase/downloads/index. HTML
3, installed Framework .Net
.Net Framework download page: HTTPS: //dotnet.microsoft.com/download/dotnet-framework/net472
4, install mingw
mingw download page: https: //osdn.net/projects/mingw/ Releases /
5, install PHP
PHP download page: HTTPS: //www.php.net/downloads
6, install Python
Python download page https://www.python.org/downloads/release/python-374/

Began to experience

On a computer disk just create a folder
in Open vs code
to create a hello.cs file, as follows

using System;
public class program
{
    public static void Main()
    {
        Console.WriteLine("Hello World!");
    }
} 

Press CTRL + SHIFT + ~, vs code below will pop up a black window.
Black window with a mouse click, and enter:

csc hello.cs

hello.exe

Output content:

PS E:\dev\my\demo> csc hello.cs
Microsoft (R) Visual C# Compiler version 4.7.3190.0
for C# 5
Copyright (C) Microsoft Corporation. All rights reserved.

This compiler is provided as part of the Microsoft (R) .NET Framework, but only supports language versions up to C# 5, which is no longer the latest version. For compilers that support newer versions of the C# programming language, see http://go.microsoft.com/fwlink/?LinkID=533240

PS E:\dev\my\demo> ./hello.exe
Hello World!

PS E:\dev\my\demo>

.net version of Hello World

C language Hello World!

C language Hello World!

Go language Hello World!

Go language Hello World!

Guess you like

Origin www.cnblogs.com/icoolno1/p/11335233.html