關于編程語言的思考(上)Thinking of the Programming Language (Part 1)

問題 Problems

  • 什么是編程語言?有哪些?各自是什么類型?What is programming language? How many programming language we have? How many types?

  • 語言的基本組成要素是什么?What's the core foundations of programming language?

  • 為什么有那么多的編程語言? Why there are so many programming language?

  • 語言之間的相同點和異同點是什么?What are the similarities and differences among those languages?

  • 為什么有時候創造一門新語言能更好的解決問題?Why sometimes creating a new language is a better way to solve problems?

  • 如何實現一門編程語言?How to implement a programming language

  • 我學過哪些編程語言? How many programming languages I have learned?

      - C
      - C++
      - 匯編
      - Java
      - C#
      - HTML/CSS
      - JavaScript
      - Swift
      - Cobol、JCL
      - PHP
      - Objective-C
    

什么是編程語言?What is programming language?

人類語言的一大目的是為了溝通,計算機編程語言也是如此。只是編程語言的溝通對象是人與機器。計算機本身很“笨”,因為它所做的所有事情[ [1] ]都需要命令指揮。而這些命令就是人們使用編程語言來編寫的。

One of the main function of human language is to communicate, so does the computer programming language. But it's a communication between the computers and human beings. The computer is quite "stupid" since it only does the instructions which have been told. Those instructions, written by human beings, are programming languages.

語言類型 What's the type of programming languages?

你可能聽過不少語言的分類標準,比如,從語言的等級來分,有低級語言(匯編)、中級語言(C)和高級語言(C++,java)。從語言的實現角度來分,有編譯型語言(C、C++,Pascal)、解釋型語言(php,lisp)和以上兩者的混合型語言(Java,Python)。從語言類型是否在編譯時確定,也可以分為靜態語言(C++,Java)和動態語言(JavaScript)。或者,我們可以從編程風格來分,有面向對象、函數式和邏輯式。當然一種語言可能屬于其中的幾種類別。

You may have heard different standard of classification.For example, we can divide them from the language level: low level, medium level and high level. We can see from the language Implementation: Interpreted、Compiled、Hybrid Language Implementations. Or we can divide from the style: Imperative/Object-Oriented Programming, Functional Programming, Logic Programming.

舉個例子,如何區分編譯型和解釋型呢?一個程序,要讓計算機執行,必須是計算機所能理解的形式。編譯器可以把用某種編程語言寫成的程序(源語言),轉換成另一種編程語言(目標語言)。解釋器不是通過直接翻譯,而是直接一行一行的解釋執行。
How to distinguish between compiled language and interpreted language? A program must be translate to the form which the computer can execute. The complier does the translation from the source language to target language. While the Interpreter directly execute the operations in the source program.

編譯器 Complier:

編譯器.jpg

解釋器 Interpeter:

解釋器.jpg

wiki分類:

programming language

圖片來源

編譯原理課上,老師推薦學習四門語言,C語言,匯編,腳本語言,Lisp。課后問他為什么沒有面向對象的語言,他說面向對象是一種設計。不過,我自己還是堅持面向對象的語言是必學的。

語言的基本組成要素是什么?What’s the core foundations of programming language?

因為我個人接觸語言的局限性,目前只做了如下的思考,歡迎各位討論,提出自己的見解。
The following thinking is based on my own limit experience with programming language, so please feel free to offer your own opinions and discuss with me.

學習一門語言,會學習其語法,以及其對應的語義。語法定義了程序的組織書寫形式。語義描述程序將如何被執行。

Syntax of a programming language determines the well-formed or grammatically correct programs of the language. Semantics describes how or whether such programs will execute.

  • Syntax is how things look
  • Semantics is how things work (the meaning)

過程 process

  • 表達式 expression

    • 語句 statement
      • 聲明 declare 常量與變量
      • 賦值
    • 判斷 judge
      • if-else
      • switch-case
    • 循環 loop
      • while / do while
      • for
      • if
  • 操作operation : + - * / % :? || && ! >> << 等等

  • 數據類型 data type (the value and the operation)

    • 原始類型 primitive type
      • 數值型 numberic: short,int,float,double,long
      • 字符 string:char,string
      • 空 nil
    • 高級類型 advanced type
      • enumeration
      • dictionary
      • array
      • struct
      • generic
  • 函數 function

    • type-return
    • name

面向對象 object-oriented

  • 類 class
    • attribute
    • function(method)
    • construct-deconstruct
  • 繼承 inherit
    • 單繼承、多繼承
  • 多態
    • 重載
  • 接口 interface
  • 協議 delegate

SCIP:

  • 過程抽象
  • 數據抽象

Reference:

待續......
TBA...


作者「[AzureYu]」
文章聲明:自由轉載-非商用-非衍生-保持署名 | BY-NC-SA


  1. 從本質上來看,計算機能做的事情就是計算,不是嗎?Actually, the computer can do nothing but computation, isn't it? ?

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容