views:

212

answers:

6

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

+2  A: 

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
Would you care to post sample code in java? Say for the keyboard macros example: http://www.rosettacode.org/wiki/Keyboard_macros
Naveen
+1  A: 

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

chaos
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
+1  A: 

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
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
+4  A: 

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
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
Naveen: While true, the point is this. GUI is not part of the language. GUI is an add-on.
S.Lott
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
@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
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.pythonThe 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
+4  A: 

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
+2  A: 

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