腳本語言與編程語言

本文翻譯自:Scripting Language vs Programming Language

Can anyone explain the difference between Scripting Language and Programming Language please? 任何人都可以解釋腳本語言和編程語言之間的區別嗎?
Also can you state some examples for each. 你也可以爲每個例子說明一些例子。 I have Googled a lot but I always find the best answers from Stack Overflow. 我搜索了很多,但我總是從Stack Overflow中找到最好的答案。


#1樓

參考:https://stackoom.com/question/1AOQz/腳本語言與編程語言


#2樓

Scripting languages are programming languages that don't require an explicit compilation step. 腳本語言是不需要顯式編譯步驟的編程語言。

For example, in the normal case, you have to compile a C program before you can run it. 例如,在正常情況下,您必須先編譯C程序才能運行它。 But in the normal case, you don't have to compile a JavaScript program before you run it. 但在正常情況下,您不必在運行之前編譯JavaScript程序。 So JavaScript is sometimes called a "scripting" language. 所以JavaScript有時被稱爲“腳本”語言。

This line is getting more and more blurry since compilation can be so fast with modern hardware and modern compilation techniques. 由於現代硬件和現代編譯技術的編譯速度非常快,因此這條線變得越來越模糊。 For instance, V8, the JavaScript engine in Google Chrome and used a lot outside of the browser as well, actually compiles the JavaScript code on the fly into machine code, rather than interpreting it. 例如,V8是谷歌Chrome中的JavaScript引擎,並且在瀏覽器之外也經常使用,它實際上將JavaScript代碼動態編譯成機器代碼,而不是解釋它。 (In fact, V8's an optimizing two-phase compiler.) (事實上​​,V8是一個優化的兩階段編譯器。)

Also note that whether a language is a "scripting" language or not can be more about the environment than the language. 還要注意,語言是否是“腳本”語言可能更多地是關於環境而不是語言。 There's no reason you can't write a C interpreter and use it as a scripting language (and people have). 沒有理由你不能編寫C語言解釋器並將其用作腳本語言(人們有)。 There's also no reason you can't compile JavaScript to machine code and store that in an executable file (and people have). 也沒有理由不能將JavaScript編譯成機器代碼並將其存儲在可執行文件中(人們也有)。 The language Ruby is a good example of this: The original implementation was entirely interpreted (a "scripting" language), but there are now multiple compilers for it. Ruby語言是一個很好的例子:原始實現完全被解釋(一種“腳本”語言),但現在有多個編譯器。

Some examples of "scripting" languages (eg, languages that are traditionally used without an explicit compilation step): “腳本”語言的一些示例(例如, 傳統上沒有顯式編譯步驟使用的語言):

  • Lua LUA
  • JavaScript JavaScript的
  • VBScript and VBA VBScript和VBA
  • Perl Perl的

And a small smattering of ones traditionally used with an explicit compilation step: 傳統上使用明確的編譯步驟的一小部分:

  • C C
  • C++ C ++
  • D d
  • Java (but note that Java is compiled to bytecode, which is then interpreted and/or recompiled at runtime) Java (但請注意,Java被編譯爲字節碼,然後在運行時解釋和/或重新編譯)
  • Pascal 帕斯卡爾

...and then you have things like Python that sit in both camps: Python is widely used without a compilation step, but the main implementation (CPython) does that by compiling to bytecode on-the-fly and then running the bytecode in a VM, and it can write that bytecode out to files ( .pyc , .pyo ) for use without recompiling. ...然後你就像Python一樣坐在兩個陣營中:Python在沒有編譯步驟的情況下被廣泛使用,但主要的實現(CPython)通過在運行中編譯爲字節碼然後在一個字節碼中運行字節碼來實現這一點。 VM,它可以將該字節碼寫入文件( .pyc.pyo ),無需重新編譯即可使用。

That's just a very few, if you do some research you can find a lot more. 這只是少數,如果你做一些研究,你可以找到更多。


#3樓

All scripting languages are programming languages. 所有腳本語言都是編程語言。

Languages are not classed as script or not - it entirely depends on the execution environment. 語言不歸類爲腳本 - 它完全取決於執行環境。

If the environment is one that is interpreted, this is commonly referred to as a scripting environment. 如果環境是解釋的環境,則通常將其稱爲腳本環境。


#4樓

Scripting languages are a subset of programming languages. 腳本語言是編程語言的子集。

  1. Scripting languages are not compiled to machine code by the user (python, perl, shell, etc.). 腳本語言不會被用戶編譯爲機器代碼(python,perl,shell等)。 Rather, another program (called the interpreter, runs the program and simulates its behavior) 相反,另一個程序(稱爲解釋器,運行程序並模擬其行爲)
  2. Some programming languages that are not scripting (C, C++, Haskell, and other 'compiled' languages), are compiled to machine code, and is subsequently run. 一些非腳本編程語言(C,C ++,Haskell和其他“編譯”語言)被編譯爲機器代碼,隨後運行。

#5樓

Programming Language : Is compiled to machine code and run on the hardware of the underlying Operating System. 編程語言:編譯爲機器代碼並在底層操作系統的硬件上運行。

Scripting Language : Is unstructure subset of programming language. 腳本語言:編程語言的非結構子集。 It is generally interpreted. 它通常被解釋。 it basically "scripts" other things to do stuff. 它基本上是“腳本”其他事情要做的事情。 The primary focus isn't primarily building your own apps but getting an existing app to act the way you want, eg JavaScript for browsers, TCL etc., 主要關注點不是主要構建您自己的應用程序,而是讓現有的應用程序以您想要的方式運行,例如JavaScript for browsers,TCL等,

*** But there are situation where a programming language is converted to interpreter and vice-verse like use have a C interpreter where you can 'C' Script. ***但是有一種情況是編程語言被轉換爲解釋器,反之亦然,如使用有一個C解釋器,你可以'C'腳本。 Scripts are generally written to control an application behaviour where as Programming Language is use to build applications. 通常編寫腳本來控制應用程序行爲,其中使用編程語言來構建應用程序。 But beware that the demarcation is blurring day - by - day as an example of Python it depends on how one uses the language. 但請注意,分界日常模糊,作爲Python的一個例子,它取決於人們如何使用該語言。


#6樓

The differences are becoming fewer and less important. 差異越來越小,越來越不重要。 Traditionally, scripting languages extend existing programs... I think that's the main definition of "scripting" is that it refers to writing a set of instructions for an existing entity to perform. 傳統上,腳本語言擴展了現有程序......我認爲“腳本”的主要定義是它指的是爲現有實體編寫一組指令來執行。 However, where scripting languages started with proprietary and colloquial syntax, most of the prevalent ones these days owe some relationship to C. 然而,在腳本語言以專有和口語語法開始的地方,現在大多數流行語言都與C語言有一些關係。

I think the "interpreted vs compiled" distinction is really a symptom of extending an existing program (with a built in interpreter), rather than an intrinsic difference. 我認爲“解釋與編譯”的區別實際上是擴展現有程序(使用內置解釋器)的症狀,而不是內在差異。 What programmers and laymen are more concerned about is, "what is the programmer doing?" 程序員和非專業人士更關心的是“程序員在做什麼?” The fact that one program is interpreted and another is compiled means very little in determining the difference in activity by the creator. 一個程序被解釋而另一個程序被編譯的事實意味着很難確定創建者的活動差異。 You don't judge a playwright on whether his plays are more commonly read aloud or performed on stage, do you? 你不會判斷一個劇作家,他的戲劇是在大聲朗讀還是在舞臺上演出,對嗎?

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章