“脚本”和“脚本”之间有什么区别? 和“申请”?

发布于 2024-07-05 19:31:41 字数 402 浏览 9 评论 0原文

我指的是 这个答案

...bash 不是用来编写应用程序的,它是用来编写脚本的。 当然,您的应用程序可能有一些内务脚本,但不要编写关键业务逻辑.sh,因为另一种语言可能更适合此类内容。

作为一个工作过多种语言的程序员,这似乎是C、Java和其他编译语言的势利。 我并不是在寻找我的观点的强化或挥手的答案。 相反,我真的想知道所指的技术差异是什么。

(我在日常工作中使用 C,所以我不仅仅是在防御。)

I'm referring to distinctions such as in this answer:

...bash isn't for writing applications it's for, well, scripting. So sure, your application might have some housekeeping scripts but don't go writing critical-business-logic.sh because another language is probably better for stuff like that.

As programmer who's worked in many languages, this seems to be C, Java and other compiled language snobbery. I'm not looking for reenforcement of my opinion or hand-wavy answers. Rather, I genuinely want to know what technical differences are being referred to.

(And I use C in my day job, so I'm not just being defensive.)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(21

╄→承喏 2024-07-12 19:31:41

传统上,程序是编译的,脚本是解释的,但这已经不再重要了。 如果您确实愿意,您可以生成大多数脚本的编译版本,而其他“编译”语言(例如 Java)实际上是解释的(在字节码级别)。

更现代的定义可能是程序旨在由客户(可能是内部客户),因此应该包括文档和支持,而脚本主要供作者使用。

网络是一个有趣的反例。 我们都喜欢用谷歌搜索引擎查找东西。 用于创建它引用的“数据库”的大部分代码仅由其作者和维护者使用。 这可以使它成为一个脚本吗?

Traditionally a program is compiled and a script is interpreted, but that is not really important anymore. You can generate a compiled version of most scripts if you really want to, and other 'compiled' languages like Java are in fact interpreted (at the byte code level.)

A more modern definition might be that a program is intended to be used by a customer (perhaps an internal one) and thus should include documentation and support, while a script is primarily intended for the use of the author.

The web is an interesting counter example. We all enjoy looking things up with the Google search engine. The bulk of the code that goes into creating the 'database' it references is used only by its authors and maintainers. Does that make it a script?

ゃ人海孤独症 2024-07-12 19:31:41

我想说的是,应用程序倾向于交互使用,其中脚本将运行其进程,适合批处理工作。 我认为这不是一个具体的区别。

I would say that an application tends to be used interactively, where a script would run its course, suitable for batch work. I don't think it's a concrete distinction.

骷髅 2024-07-12 19:31:41

通常,它是“脚本”与“程序”。

我同意你的观点,这种区别主要是“编译语言势利”,或者引用拉里·沃尔的话,站在栅栏的另一边,“剧本是演员拥有的,节目是提供给观众的”。

Usually, it is "script" versus "program".

I am with you that this distinction is mostly "compiled language snobbery", or to quote Larry Wall and take the other side of the fence, "a script is what the actors have, a programme is given to the audience".

娇纵 2024-07-12 19:31:41

这是一个有趣的话题,我认为没有很好的指导方针来区分“脚本”和“应用程序”。

让我们看一下维基百科的一些文章来感受一下其中的区别。

脚本(维基百科 -> 脚本语言):

脚本语言,脚本语言或扩展语言,是一种控制软件应用程序的编程语言。 “脚本”通常被视为与“程序”不同,“程序”独立于任何其他应用程序执行。 同时,它们与应用程序的核心代码不同,应用程序的核心代码通常是用不同的语言编写的,并且通过最终用户可以访问,它们使应用程序的行为能够适应用户的需求。

应用(维基百科 -> 应用软件 -> 术语)

在计算机科学中,应用程序是一种旨在帮助人们执行某种类型工作的计算机程序。 因此,应用程序不同于操作系统(运行计算机)、实用程序(执行维护或通用杂务)和编程语言(用于创建计算机程序)。 根据其设计用途,应用程序可以操作文本、数字、图形或这些元素的组合。

阅读上述条目似乎表明,区别在于脚本由另一个软件“托管”,而应用程序则不然。 我认为这是可以争论的,例如 shell 脚本控制 shell 的行为,perl 脚本控制解释器的行为以执行所需的操作。 (我觉得这可能有点牵强,所以我可能不完全同意。)

归根结底,我认为口语上的区别可以通过规模来区分。 的程序。 与应用程序相比,脚本的规模通常较小。

此外,就目的而言,脚本通常执行需要处理的任务,例如,构建为某个软件生成多个发行版本的脚本。 另一方面,应用程序旨在提供更完善且面向最终用户的功能。 例如,记事本或火狐浏览器。

This is an interesting topic, and I don't think there are very good guidelines for the differentiating a "script" and a "application."

Let's take a look at some Wikipedia articles to get a feel of the distinction.

Script (Wikipedia -> Scripting language):

A scripting language, script language or extension language, is a programming language that controls a software application. "Scripts" are often treated as distinct from "programs", which execute independently from any other application. At the same time they are distinct from the core code of the application, which is usually written in a different language, and by being accessible to the end user they enable the behavior of the application to be adapted to the user's needs.

Application (Wikipedia -> Application software -> Terminology)

In computer science, an application is a computer program designed to help people perform a certain type of work. An application thus differs from an operating system (which runs a computer), a utility (which performs maintenance or general-purpose chores), and a programming language (with which computer programs are created). Depending on the work for which it was designed, an application can manipulate text, numbers, graphics, or a combination of these elements.

Reading the above entries seems to suggest that the distinction is that a script is "hosted" by another piece of software, while an application is not. I suppose that can be argued, such as shell scripts controlling the behavior of the shell, and perl scripts controlling the behavior of the interpreter to perform desired operations. (I feel this may be a little bit of a stretch, so I may not completely agree with it.)

When it comes down to it, it is in my opinion that the colloquial distinction can be made in terms of the scale of the program. Scripts are generally smaller in scale when compared to applications.

Also, in terms of the purpose, a script generally performs tasks that needs taken care of, say for example, build scripts that produce multiple release versions for a certain piece of software. On the otherhand, applications are geared toward providing functionality that is more refined and geared toward an end user. For example, Notepad or Firefox.

花开柳相依 2024-07-12 19:31:41

John Ousterhout(TCL 的发明者)在 http://www.tcl.tk 上有一篇很好的文章/doc/scripting.html 他提出了系统编程语言(用于实现构建块,强调正确性、类型安全)与脚本语言(用于组合构建块,强调对不断变化的环境和需求的响应能力)之间的区别,轻松转换文本表示形式)。 如果您采用该分类系统,那么 99% 的程序员所做的工作更适合脚本语言而不是系统编程语言。

John Ousterhout (the inventor of TCL) has a good article at http://www.tcl.tk/doc/scripting.html where he proposes a distinction between system programming languages (for implementing building blocks, emphasis on correctness, type safety) vs scripting languages (for combining building blocks, emphasis on responsiveness to changing environments and requirements, easy conversion in and out of textual representations). If you go with that categorisation system, then 99% of programmers are doing jobs that are more appropriate to scripting languages than to system programming languages.

べ繥欢鉨o。 2024-07-12 19:31:41

脚本往往是一系列启动、运行和终止的命令。 它通常不需要/很少需要人际互动。 应用程序是一个“程序”......它通常需要人类交互,而且往往更大。

A script tends to be a series of commands that starts, runs, and terminates. It often requires no/little human interaction. An application is a "program"... it often requires human interaction, it tends to be larger.

挽梦忆笙歌 2024-07-12 19:31:41

对我来说,脚本意味着对代码的逐行解释。 您可以打开脚本并查看其程序员可读的内容。 应用程序意味着独立编译的可执行文件。

Script to me implies line-by-line interpretation of the code. You can open a script and view its programmer-readable contents. An application implies a stand-alone compiled executable.

柳絮泡泡 2024-07-12 19:31:41

它通常只是一种语义论证,甚至是诋毁某些编程语言的一种方式。 就我而言,“脚本”是一种程序,确切的定义有些模糊并且随上下文而变化。

我可能会使用术语“脚本”来表示主要线性执行的程序,而不是具有大量顺序逻辑或子例程的程序,就像好莱坞的“脚本”是演员执行的线性指令序列一样。 我可能用它来表示用嵌入在较大程序中的语言编写的程序,以驱动该程序。 例如,使用 AppleScript 在旧 Mac 操作系统下自动执行任务,或者驱动一个通过嵌入式 TCL 界面以某种方式暴露自身的程序。

但在所有这些情况下,脚本都是一种程序。

术语“脚本语言”已用于动态解释(有时是编译)语言,通常这些语言具有许多共同特征,例如非常高级的指令、内置哈希和任意长度列表以及其他高级数据结构等。但这些语言能够编写非常大、复杂、模块化、设计良好的程序,因此如果您将“脚本”视为程序以外的东西,那么该术语可能会让您感到困惑。

另请参见它是 Perl 程序还是 Perl 脚本?

It's often just a semantic argument, or even a way of denigrating certain programming languages. As far as I'm concerned, a "script" is a type of program, and the exact definition is somewhat vague and varies with context.

I might use the term "script" to mean a program that primarily executes linearly, rather than with lots of sequential logic or subroutines, much like a "script" in Hollywood is a linear sequence of instructions for an actor to execute. I might use it to mean a program that is written in a language embedded inside a larger program, for the purpose of driving that program. For example, automating tasks under the old Mac OS with AppleScript, or driving a program that exposes itself in some way with an embedded TCL interface.

But in all those cases, a script is a type of program.

The term "scripting language" has been used for dynamically interpreted (sometimes compiled) languages, usually these have a lot of common features such as very high level instructions, built in hashes and arbitrary-length lists and other high level data structures, etc. But those languages are capable of very large, complicated, modular, well-designed programs, so if you think of a "script" as something other than a program, that term might confuse you.

See also Is it a Perl program or a Perl script? in perlfaq1.

东风软 2024-07-12 19:31:41

脚本通常作为脚本引擎内较大应用程序的一部分运行
例如。 JavaScript -> 浏览器
这与传统的静态类型编译语言和动态语言形成对比,在动态语言中,代码旨在形成应用程序的主要部分。

A script generally runs as part of a larger application inside a scripting engine
eg. JavaScript -> Browser
This is in contrast to both traditional static typed compiled languages and to dynamic languages, where the code is intended to form the main part of the application.

情感失落者 2024-07-12 19:31:41

应用程序是针对一组常见问题的脚本的集合。

脚本是用于执行一项相当具体的任务的一段代码。

IMO,差异与所使用的语言无关。 可以使用 bash 编写复杂的应用程序,也可以使用 C++ 编写简单的脚本。

An application is a collection of scripts geared toward a common set of problems.

A script is a bit of code for performing one fairly specific task.

IMO, the difference has nothing whatsoever to do with the language that's used. It's possible to write a complex application with bash, and it's possible to write a simple script with C++.

再浓的妆也掩不了殇 2024-07-12 19:31:41

就我个人而言,我认为这种分离是实际实施过程中的倒退。

据我估计,申请已计划完成。 它有多个目标,有多个可交付成果。 在设计时在编码之前预留了一些应用程序必须满足的任务。

然而,剧本只是像套装一样拼凑在一起,几乎不涉及任何计划。

然而,缺乏适当的计划并不会将你降级为脚本。 有可能,它使您的应用程序成为组织不善、计划不周的脚本的集合。

此外,应用程序可以包含聚合后构成整体的脚本。 但脚本只能引用应用程序。

Personally, I think the separation is a step back from the actual implementation.

In my estimation, an application is planned. It has multiple goals, it has multiple deliverables. There are tasks set aside at design time in advance of coding that the application must meet.

A script however, is just thrown together as suits, and little planning is involved.

Lack of proper planning does not however downgrade you to a script. Possibly, it makes your application a poorly organized collection of poorly planned scripts.

Further more, an application can contain scripts that aggregated comprise the whole. But a script can only reference an application.

書生途 2024-07-12 19:31:41

以perl为例,您可以编写perl脚本或perl应用程序。

脚本意味着单个文件或单个命名空间。 (例如updateFile.pl)。

应用程序是由文件或名称空间/类的集合组成的(例如,带有许多 .pm 模块文件的面向对象设计的 Perl 应用程序)。

Taking perl as an example, you can write perl scripts or perl applications.

A script would imply a single file or a single namespace. (e.g. updateFile.pl).

An application would be something made up of a collection of files or namespaces/classes (e.g. an OO-designed perl application with many .pm module files).

坦然微笑 2024-07-12 19:31:41

应用程序很大,会被人们一遍又一遍地使用,并且可能会出售给客户。

脚本一开始很小,如果幸运的话,会一直很小,很少出售给客户,并且可能会自动运行或被废弃。

An application is big and will be used over and over by people and maybe sold to a customer.

A script starts out small, stays small if you're lucky, is rarely sold to a customer, and might either be run automatically or fall into disuse.

难得心□动 2024-07-12 19:31:41

怎么样:

脚本:

脚本是用某种语言编写的编程语句的文本文件(或文本文件的集合),允许将其中编写的各个语句解释为机器可执行代码直接在每个执行之前并且意图发生这种情况

应用:

应用程序是任何计算机程序,其主要功能涉及向人类参与者提供服务。

因此,从理论上讲,用脚本语言编写的基于脚本的程序可以在执行脚本时更改其文本语句(当然,这样做的风险很大)。 已编译程序的类似情况是翻转内存中的位。

有接受者吗? :)

What about:

Script:

A script is text file (or collection of text files) of programming statements written in a language which allows individual statements written in it to be interpreted to machine executable code directly before each is executed and with the intention of this occurring.

Application:

An application is any computer program whose primary functionality involves providing service to a human Actor.

A script-based program written in a scripting language can therefore, theoretically, have its textual statements altered while the script is being executed (at great risk of , of course). The analogous situation for compiled programs is flipping bits in memory.

Any takers? :)

白鸥掠海 2024-07-12 19:31:41

首先,我想清楚地表明脚本是一个程序。 换句话说,脚本是一组指令。

程序:

要编译的一组指令称为程序。

脚本:

一组将被解释的指令称为脚本。

First of all, I would like to make it crystal clear that a script is a program. In other words, a script is a set of instructions.

Program:

A set of instructions which is going to be compiled is known as a Program.

Script:

A set of instructions which is going to be interpreted is known as a Script.

喜爱皱眉﹌ 2024-07-12 19:31:41

@Jeff的回答很好。 我最喜欢的解释是

许多(大多数?)脚本语言是解释型的,很少有编译型的
语言被认为是脚本语言,但是问题
编译与解释的区别仅与问题有松散的联系
“脚本”与“严肃”语言的区别。

这里的很多问题是“脚本”是一个相当模糊的概念
名称——表示一种便于书写的语言
脚本,而不是编写“成熟的程序”(或
应用程序)。 但是如何区分复杂的脚本和普通的脚本呢?
简单的应用? 这本质上是一个无法回答的问题。
一般来说,脚本是应用于某些组的一系列命令
数据,可能按照用户定义的顺序......但是,人们可以延伸
该描述适用于 Photoshop,这显然是一个主要的
应用。 脚本通常比应用程序小,
一些定义明确的东西并且使用起来“更简单”,并且通常可以
被分解为一系列清晰的子操作,但所有这些
事情是主观的。

引用自此处

@Jeff's answer is good. My favorite explanation is

Many (most?) scripting languages are interpreted, and few compiled
languages are considered to be scripting languages, but the question
of compiled vs. interpreted is only loosely connected to the question
of "scripting" vs. "serious" languages.

A lot of the problem here is that "scripting" is a pretty vague
designation -- it means a language that's convenient for writing
scripts in, as opposed to writing "full-blown programs" (or
applications). But how does one distinguish a complex script from a
simple application? That's an essentially unanswerable question.
Generally, a script is a series of commands applied to some set of
data, possibly in a user-defined order... but then, one could stretch
that description to apply to Photoshop, which is clearly a major
application. Scripts are generally smaller than applications, do
some well-defined thing and are "simpler" to use, and typically can
be decomposed into a clear series of sub-operations, but all of these
things are subjective.

Referenced from here.

£烟消云散 2024-07-12 19:31:41

我认为代码是编译的还是解释的根本没有关系。

真正的区别在于代码的核心逻辑:

  • 如果代码产生了系统中其他程序未实现的新功能 - 它就是一个程序。 它甚至可以通过脚本进行操作。

  • 如果代码主要由其他程序的操作操作,并且总结果主要是被操作程序的工作结果 - 它是一个脚本。 从字面上看,是某些程序的操作脚本。

I think that there is no matter at all whether code is compiled or interpreted.

The true difference is in core logic of code:

  • If code makes new functionality that is not implemented in other programs in system - it's a program. It even can be manipulated by a script.

  • If code is MAINLY manipulates by actions of other programs and total result is MAINLY the results of work of manipulated programs - it's a script. Literally a script of actions for some programs.

拥抱我好吗 2024-07-12 19:31:41

许多详细的答案已经通过引文等给出,但我还没有看到简明的总结,所以这是我的尝试:

基于所有先前考虑​​的答案的汇总,人们可以合理地得出以下结论:

  1. 几十年前, “脚本”和“应用程序”是明显不同的东西
  2. 随着时间和技术的进步,脚本和应用程序之间的差异不仅显着减少,而且不同的内容也发生了变化。
  3. 一开始,脚本本质上是程序代码,通过一些迭代(循环)和条件逻辑从上到下运行。 同样的逻辑也被用于新兴的工业机器人领域的 PLC 设备中。 应用程序更加详细和复杂,具有更复杂且通常由数据驱动的决策树。
  4. 应用程序通常资源密集型,而脚本旨在快速执行以促进流程自动化,但会牺牲文档和体系结构。
  5. 应用程序中的架构更多地涉及更多嵌套以及常见的组织和结构范例,例如面向对象编程(OOP)和模型-视图-控制器(MVC)设计更多流行且实用

因此,简而言之,根据我自己和其他人的经验,我想说,今天被认为是应用程序(应用程序)与脚本的区别在于,后者——虽然是结构化的——是显着的比前者少。 此外,脚本通常更加迟钝,因为它们基本上是作为程序员的工具而编写的,而应用程序通常是为主要由程序员使用/使用/体验而编写的。非程序员(即大多数人)。

Many detailed answers have been given with citations and such, but I've not seen a concise summary, so this is my attempt to contribute:

Based on the aggregate of all the previous answers considered, one could reasonably conclude the following:

  1. Decades ago, a "script" and an "app" were significantly different things
  2. As time and technology has progressed, not only has the differences between scripts and apps diminished significantly, but what is different has changed also.
  3. In the beginning, scripts were essentially procecedural code that ran top-to-bottom with some iteration (loops) and conditional logic. The same kind of logic was used in the fledgeling field of industrial robotics in PLC devices. An application is more detailed and complex with more complex and often data-driven decision trees.
  4. Applications often are more resource intensive, whereas scripts are meant to execute quickly to facilitate process automation, at the expense of documentation and architecture.
  5. Architecture in applications is much more involved with more nesting and common organizational and structural pardigms such as Object Oriented Programming (OOP) and Model-View-Controller (MVC) design are more prevalent and practical

So, then in a nutshell, based on the experience of myself and others, I'd say the difference today in what is considered an app(lication) vs a script is that the latter -- while structured -- is significantly less so than the former. Also, scripts are often more obtuse because they are written by and large as tools for programmers, whereas applications are usually written to be consumed/used/experienced by primarily non-programmers (i.e., most of the population).

那一片橙海, 2024-07-12 19:31:41

实际上,脚本(或脚本语言)和应用程序之间的区别在于,脚本不需要将其编译为机器语言。您使用解释器运行脚本的源代码。应用程序将源代码编译为机器代码,以便您可以将其作为独立的应用程序运行。

Actually the difference between a script ( or a scripting language) and an application is that a script don't require it to be compiled into machine language.. You run the source of the script with an interpreter.. A application compiles the source into machine code so that you can run it as a stand alone application.

想挽留 2024-07-12 19:31:41

我想说脚本通常是一组以纯文本编写的命令或指令,它们由托管应用程序执行(浏览器、命令解释器或 shell,...) 。

这并不意味着它不强大或者在实际执行时没有以某种方式编译。 但脚本本身无法执行任何操作,它只是纯文本。
从本质上讲,它可以只是一个片段,需要组合起来构建一个程序或应用程序,但是扩展和完全开发的脚本或脚本集在由主机执行时可以被视为程序或应用程序,就像一堆源文件一样编译后即可成为应用程序。

I would say a script is usually a set of commands or instructions written in plain text that are executed by a hosting application (browser, command interpreter or shell,...).

It does not mean it's not powerfull or not compiled in some way when it's actually executed. But a script cannot do anything by itself, it's just plain text.
By nature it can be a fragment only, needing to be combined to build a program or an application, but extended and fully developed scripts or set of scripts can be considered programs or applications when executed by the host, just like a bunch of source files can become an application once compiled.

浅暮の光 2024-07-12 19:31:41

脚本语言没有标准库或平台(或者没有太多标准库或平台)。 它体积小、重量轻,旨在嵌入到更大的应用程序中。 Bash 和 Javascript 是脚本语言的绝佳示例,因为它们的功能完全依赖于其他程序。

使用此定义,脚本是设计用于驱动更大的应用程序(套件)的代码。 Javascript 可能会调用 Firefox 打开窗口或操作 DOM。 Bash 脚本执行现有程序或其他脚本,并通过管道将它们连接在一起。


您还会问为什么不使用脚本语言,那么:

是否有用于脚本语言的单元测试工具? 对于完全缺失的“真实”应用程序来说,这似乎是一个非常重要的工具。 而且很少有任何真正的脚本语言库绑定。

大多数时候,脚本可以被替换为真正的轻量级语言,例如 Python 或 Ruby。

A scripting language doesn't have a standard library or platform (or not much of one). It's small and light, designed to be embedded into a larger application. Bash and Javascript are great examples of scripting languages because they rely absolutely on other programs for their functionality.

Using this definition, a script is code designed to drive a larger application (suite). A Javascript might call on Firefox to open windows or manipulate the DOM. A Bash script executes existing programs or other scripts and connects them together with pipes.


You also ask why not scripting languages, so:

Are there even any unit-testing tools for scripting languages? That seems a very important tool for "real" applications that is completely missing. And there's rarely any real library bindings for scripting languages.

Most of the times, scripts could be replaced with a real, light language like Python or Ruby anyway.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文