为什么没有更多的编程语言具有窗口管理器的内置接口?

发布于 2024-07-25 20:28:05 字数 546 浏览 6 评论 0原文

编程是计算机上自动化任务的核心。
据推测,这些任务通常由人类手动完成。
人类通过键盘、鼠标以及与控制台或窗口管理器的交互来使用计算机。
但是很少有语言内置函数来为这些基本计算对象提供接口。

一个值得注意的例外是 autohotkey,它是 Windows 上的一种开源语言,提供允许执行以下简单任务的内置函数:
* 获取像素信息
* 获取鼠标位置
* 键盘宏
* 模拟按键
* 模拟鼠标点击
* 窗口管理
请参阅 rosettacode 上的示例。

Linux 上曾有过各种尝试,其中许多都在没有解释的情况下被停止。 一种是不活动的 tcl 库:android. 搜索 google 代码 for android, lang:tcl

Programming is at the heart about automating tasks on a computer.
Presumably those tasks would normally be done manually by a human.
Humans use the computer through the keyboard, mouse, and interaction with the console or the window manager.
But very few languages have built in functions that provide an interface to these basic computing objects.

A notable exception is autohotkey, an open source language on windows, providing builtin functions that allow the following simple tasks:
* Get Pixel Information
* Get mouse position
* Keyboard macros
* Simulate key strokes
* Simulate mouse click
* Window management
See examples on rosettacode.

There have been various attempts on linux, many of which were stopped without explanation.
One is the inactive tcl library: android. Search google code for android, lang:tcl

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

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

发布评论

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

评论(6

笔芯 2024-08-01 20:28:06

我怀疑这个前提是否正确。 Java 可以做到所有这些,除了“窗口管理”,因为我不知道这是什么意思。

如果你不能用 c# 做到这一点,我会感到惊讶。

如果有很多语言不能做到这一点,我猜是因为如果不将语言与操作系统联系起来就很难做到这一点。

I doubt the premise is true. Java can do all that, except maybe "window management" since I do not know what is meant by this.

I'd be surprised if you can't do it with c#.

If there are many languages that can't do this, I'd guess it is because it is difficult to do it without tying the language to the operating system.

是伱的 2024-08-01 20:28:06

首先,我认为您是在问为什么编程语言的标准库没有与窗口管理器的内置接口。 该语言本身及其库是截然不同的。

一大原因是便携性。 如果一种编程语言的库中有太多特定的函数,那么将其移植到其他系统就会变得更加困难。 例如,I/O、数学函数、字符串、各种数据结构和相关算法都是通用的,几乎可以在任何计算机上运行。

但是诸如窗口管理器、GUI 等之类的东西,它们更加特定于某些平台,这就是为什么它们不包含在标准库中的原因。 这就是 C/C++ 如此可移植的原因。

First of all, I think you're asking why the programming languages' standard libraries don't have built-in interfaces to the window manager. The language itself and its libraries are quite distinct.

One big reason is portability. If there's too many specific functions in a programming language's libraries, it will be harder to port it to other systems. For example, I/O, math functions, strings, various data structures and related algorithms, are all generic and can be made to work on virtually any computer.

But things like the window manager, GUI, etc., they are much more specific to certain platforms which is why they are not included in the standard libraries. This is what makes C/C++ so portable.

泪冰清 2024-08-01 20:28:06

在没有任何人机界面设备交互的情况下由计算机执行的任务数量远远超过由人类直接执行的任务。

Tasks performed by computers without any human interface device interaction outnumber those directly actuated by a human by an enormous factor.

眼泪也成诗 2024-08-01 20:28:06

编程语言尝试(或至少目前正在尝试)独立于平台。 .net 中的示例,您必须引用一些 Win32 api 来执行上面指定的一些操作。 将其内置于核心编程语言模型中,.net 将与操作系统变得过于耦合,因此,创建其 Mono 对应物将过于乏味。

关于击键、宏和一些东西,我现在做的最简单的方法是真正的 vbscript 或在 powershell 中:)

Programming languages tries (or at least is currently trying) to be independent with the platform. Example in .net, you have to reference some Win32 api to do some of the stuffs you specified above. Getting it built-in the core programming language model, .net will become too coupled with the OS, thus, creating its Mono counterpart will be too tedious.

Regarding keystrokes, macros and some stuffs, the simplest way I'm doing it right now is true vbscript or in powershell :)

风吹雨成花 2024-08-01 20:28:05

我编写网络服务器代码。 没有人与代码交互。 它只是 Apache 的许多复杂插件。

“人类通过键盘、鼠标以及与控制台或窗口管理器的交互来使用计算机。”

在我的例子中,这是完全错误的。 “用户”通过 HTTP 发送请求。 没有键盘,没有鼠标,没有控制台,没有窗口管理器。

用户可能正在使用某种奇特的 GUI,但这对我或我的软件来说并不重要。 我看到的只是 HTTP GET 和 POST 请求。 纯文本。

“但是很少有语言内置了为这些基本计算对象提供接口的函数。”

正确的。 我没有使用键盘、鼠标、控制台或窗口管理器。

I write web server code. No human being interacts with the code. It's simply a lot of complex plug-ins to Apache.

"Humans use the computer through the keyboard, mouse, and interaction with the console or the window manager. "

This is completely false in my case. The "user" sends requests through HTTP. No keyboard, no mouse, no console, no window manager.

The user may be using some kind of fancy GUI, but it doesn't matter to me or my software. All I see are HTTP GET and POST requests. Pure text.

"But very few languages have built in functions that provide an interface to these basic computing objects."

Correct. I have no use for keyboard, mouse, console or window manager.

若沐 2024-08-01 20:28:05

所有个人计算平台都有可以执行此操作的库。

问题是这需要标准化所有系统上的用户交互。 Java 尝试过这一点,但没有取得很大成功。 还有其他库或多或少地取得了成功,Qt 可能是迄今为止最有前途的一个。

当然可以为单一平台编写一种包含所有 UI 基础知识的语言。 也可以使用 GUI 和库来伪造它。 然而,我们有充分的理由想要一种可以在任何主要平台上使用的语言,无论是否有 GUI。

All personal computing platforms have libraries that will do this.

The problem is that that would require standardizing user interactions over all systems. Java tried this, without a great deal of success. There have been other libraries with more or less success, Qt probably being the most promising one to date.

It's certainly possible to write a language for a single platform that will include all the UI fundamentals. It's also possible to fake it with a GUI and a library. However, there's good reason to want a language that is usable on any major platform, whether or not there's a GUI.

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