0

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

Naveen
  • 5,910
  • 5
  • 30
  • 38
  • 2
    Do you consider a language's "standard library" to be part of or built in to the language itself? For example, is a `FILE` built in to the C programming language, because it's in the C run-time library? – ChrisW Jun 19 '09 at 21:51
  • Please make this a Community Wiki. There's no programming, and no real answer. – S.Lott Jun 19 '09 at 21:58
  • > There's no programming...
    I posted several programming tasks, with links to code implementing them.
    – Naveen Jun 20 '09 at 05:52
  • @Naveen: The word programming is not the same as posting code samples. There's no code. That makes this a fringe question. Further, there's no proper answer -- it's a discussion topic. Please make this a Community Wiki. – S.Lott Jun 20 '09 at 10:33
  • S.Lott: > programming is not the same as posting code samples. There's no code. ... community wiki < I am not sure I know how to do that, besides editing my own post 5 times... Anyways, I don't have a strong opinion on how this topic is classified... So I may try to make it a "community wiki" – Naveen Jun 20 '09 at 13:49
  • @Naveen: look at the page when you edit the question. There's a "Community Wiki" button. Click it. When there's no code, it's hard to have an "answer" -- without code it's just a discussion -- suitable for community editing of responses. – S.Lott Jun 20 '09 at 19:12

6 Answers6

4

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.

S.Lott
  • 384,516
  • 81
  • 508
  • 779
  • I believe programming will be a basic skill for people in the future. Users will be programmers! You may limit yourself to writing server code, but the users who will want to automate their interaction with your server will use a keyboard, mouse, or window manager. And there will be many more of them than you. – Naveen Jun 20 '09 at 05:35
  • Naveen: While true, the point is this. GUI is not part of the language. GUI is an add-on. – S.Lott Jun 20 '09 at 10:31
  • That's kind of my point. the user interface should be part of the language (if an addon, a tightly knit one)... By the way, keyboards are not graphical, and windows don't have to be graphical (text windows (visible or invisible) apply also). – Naveen Jun 20 '09 at 13:44
  • 1
    @Naveen: You're missing MY point. It isn't needed enough to make it a first class part of the language. The case where it is handy -- while important -- is NOT the only use case for the language. The GUI MUST be optional precisely for things like web applications. – S.Lott Jun 20 '09 at 13:58
  • I would be happy with optional. For most mainstream langauges, it is not even an option, forget a builtin. There are 13,000 registered users of http://www.autohotkey.com/forum compared to about 30,000 on http://www.ruby-forum.com/ and about 15,000 on http://groups.google.com/group/comp.lang.python The need for "First class access to the user interface" is subjective. I am in the process of libifying autohotkey: http://www.autohotkey.net/~tinku99/ahkdll – Naveen Jun 20 '09 at 16:28
4

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.

David Thornley
  • 56,304
  • 9
  • 91
  • 158
2

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.

Jens Schauder
  • 77,657
  • 34
  • 181
  • 348
  • Would you care to post sample code in java? Say for the keyboard macros example: http://www.rosettacode.org/wiki/Keyboard_macros – Naveen Jun 20 '09 at 05:32
2

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.

Jake Petroules
  • 23,472
  • 35
  • 144
  • 225
1

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

chaos
  • 122,029
  • 33
  • 303
  • 309
  • That's a little circular reasoning isn't it? All those tasks used to require a human. I am only suggesting more such tasks that shouldn't require a human. – Naveen Jun 20 '09 at 05:45
1

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 :)

Marc Vitalis
  • 2,129
  • 4
  • 24
  • 36
  • The goal is to have the user interface to a programming language be independent of the platform. The backend is always tied to the platform, right down to c and assembly. There is no reason that tasks involving mouse, keyboard, and window automation are any different than networking. All require platform dependent code on the backend, all could have standardized programming interfaces. – Naveen Jun 20 '09 at 05:42