In order to understand the similarities and differences in more languages in the quickest possible time, I use Hello World, the most familiar of all, to demonstrate the mysteries of each language.
Please respect original, reprint please indicate source website www.shareditor.com and original link address
Note: The entire tutorial is based on a Linux system (for ease of interpretation, I chose to install the CentOS 7来 demo with VMware virtual machines, other Linux can be), including compilers, dependent library installation procedures, command line, if the use of Windows or Mac system slightly different, CentOS 7 Installation method Baidu, you know.
C language of the source of all things
Description: C language is compiled to execute the language, Linux under the common compiler is gcc,c language source code can be directly compiled into executable program (machine code), said it is the source of all things because other languages are written in C language, such as Java, PHP, Python ...
Source code: HELLO_WORLD.C
#include <stdio.h>int main(int argc, char* argv[]){ printf("hello world\n"); return 0;}
Compile execution:
[root@centos7vm code]# gcc -o hello_world hello_world.c[root@centos7vm code]# ./hello_worldhello world
The most popular Java language
Description: The Java language was once a household name, someone can start to say I will Java, although the trend has been past, but the advantages of Java cross-platform and powerful class library is not to be underestimated, other languages difficult to transcend, Java derived in addition to a lot of peripheral products (such as JSP), A lot of open source systems are based on Java (Hadoop, Hive, HBase, Lucene, etc.), Java and C are compiled to execute the language, the difference is that Java compiled bytecode files run on a layer of Java virtual machine, and virtual machines can be built on various operating systems , so Java has the advantage of cross-platform, a compilation of a number of places to execute
Environment Preparation:
[root@centos7vm code]# yum install java*
Source code: Hello_world.java
class HelloWorld { public static void main(String[] args) { System.out.println("hello world"); }}
Compile execution:
[root@centos7vm code]# javac HelloWorld.java[root@centos7vm code]# java HelloWorldhello world
HTML language in the Internet age
Description: HTML is Hypertext Markup Language, popular is to display the Web page, is an interpretation of the implementation of the language (read a sentence, do not need to compile into other forms), HTML through a label to indicate how the browser display Web page
Source code: hello_world.html
<html> <head> </head> <body> <h1>Hello World!</h1> </body></html>
Open the display with your browser:
Explain the scripting language of execution bash
Summary: Bash is a shell script (also known as Bshell, similar to CSH and Ksh), in fact, similar to Dos in the Bat batch program, a bunch of sequential execution of the command written in a file to execute together, while extending a number of branches, loops, functions and other language features, Often used in server-side development and operations
Source code: hello_world.sh
#!/bin/bashecho "hello world"
Execution effect:
[root@centos7vm code]# sh hello_world.shhello world
A Python language that can be compiled and executed and interpreted
Description: Python's power lies in its nondescript, said it is interpreted to execute, it will be compiled into a file, said it is a scripting language, it has all the properties of object-oriented, now Python open-source class library is very powerful, what functions have, Python has become a big data direction necessary tools
Source code: hello_world.py
#!/usr/bin/pythonprint "hello world"
Execution effect
[root@centos7vm code]# python hello_world.pyhello world
Ps:python can also be executed interactively, like executing python statements in a terminal, as follows:
[Root@centos7vm Code]# Pythonpython2.7.5 (default, Nov 20 2015, 02:00:19) [GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2type "help", "copyright", "credits" or "license" for more information.>>> print " Hello World ' Hello World '
Please respect original, reprint please indicate source website www.shareditor.com and original link address
PHP, the world's best language
Description: There are a lot of dynamic Web backend languages, ASP, ASP, JSP, C #, Python, php......,php can be said to be the most easy to get started language
Environment Preparation:
[root@centos7vm code]# rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm[root@centos7vm code]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm[root@centos7vm code]# yum install php55w.x86_64 php55w-cli.x86_64 php55w-common.x86_64 php55w-gd.x86_64 php55w-ldap.x86_64 php55w-mbstring.x86_64 php55w-mcrypt.x86_64 php55w-mysql.x86_64 php55w-pdo.x86_64
Source code: hello_world.php
<?phpprint("hello world\n")?>
Execution effect:
[root@centos7vm code]# php hello_world.phphello world
PS: In fact, the PHP program is not used this way, but with the HTTP server by receiving HTTP requests, and execute the response of the PHP script, and then return the HTML tag to the user, the implementation of Dynamic Web site, will be explained in detail later
Web page style Language CSS
Description: CSS is an auxiliary language of HTML, used to describe the style of the Web page, HTML does not have CSS can also work (can be customized by the various attributes of the tag and style properties), but CSS can be the style of abstraction, and HTML stripping, so that HTML is purely as a layout
Source:
Hello_world.html
<html> <head> < link rel= "stylesheet" type= "text/css" href= "style.css"/> </head> <body> <h1 >hello world! </h1> </ body></HTML>
Style.css
h1 { color: red}
Open the display with your browser:
Web front-End scripting language JavaScript
Description: JavaScript is a scripting language that can run on the front of a Web page, enabling richer interactions, asynchronous callbacks, multithreading, timers, animations, and more, based on HTML
Source code: hello_world.html
<html> <head> </head> <body> <script type="text/javascript"> document.write("</script> </body></html>
Open the display with your browser:
Summarize
In summary, the selection of several typical language to illustrate the operation process, for different business scenarios to choose the language, each programming language can be used as a change, not recommended to start the system learning, and should use a period of time after the system learning, so as to supplement some unused features.
More advanced content on programming languages can be seen in the principles of compilation, Lex & Yacc
Teach you to be an all-stack engineer (full stack Developer) One-recount summarizes the differences between the eight major categories of programming languages