 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Laszlo
Joined: 14 Feb 2005 Posts: 4078 Location: Pittsburgh
|
Posted: Fri Mar 04, 2005 7:41 pm Post subject: Translator & new syntax |
|
|
I understand, that AHK should maintain backward compatibility. However, its complexity has grown to a level, where I'd like a complete redesign of the syntax, like AutoIt3. Maybe, the simplest solution was a translator from a universal scripting language (maybe BASIC) to AHK. Some of the problems why we constantly have to refer to the Help:
There are three kinds of data:
- variable name
- string (including numbers)
- binary info (%ClipBoardAll%)
Command parameters are in different forms:
- variable name
- variable reference
- expression, like x+1
- literal strings (without quotes, leading spaces ignored)
- processed strings, with variable reference and escape sequences
Syntax and semantics of command parameters depend on preceding subcommands
Hard to remember restrictions (like at single line if statements)
Hard to remember special cases (e.g. appending binary data deletes existing content of the file) |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10480
|
Posted: Fri Mar 04, 2005 9:12 pm Post subject: Re: Translator & new syntax |
|
|
| Laszlo wrote: | | its complexity has grown to a level, where I'd like a complete redesign of the syntax, like AutoIt3. | That might happen someday, but I think the existing syntax has some advantages over that of a programming language. One of them is that simple scripts do not require quotes around strings.
| Quote: | Command parameters are in different forms:
- variable name
- variable reference
- expression, like x+1
- literal strings (without quotes, leading spaces ignored) |
The fourth item goes with the second, leaving only three different types of things. Most users can safely ignore expressions for simple scripts, leaving only two things: input/ouput variables (no percent signs) and normal parameters (literal numbers, strings, or variable references). I don't think this is too bad in terms of complexity, though the presence of input variables is probably something that causes more confusion than it's worth.
| Quote: | | - processed strings, with variable reference and escape sequences | I think all languages have these in one form or another.
| Quote: | | Syntax and semantics of command parameters depend on preceding subcommands | If you mean the fact that commands like Gui and Menu have sub-commands, I think that's largely a style issue. Some people like it and some don't. I like it mostly because it centralizes the documentation.
| Quote: | | Hard to remember restrictions (like at single line if statements) | You can avoid that particular pitfall by always including braces, even around single lines.
If there are others you can think of, please post them because it might help guide the future development of the language, including the possibility of an AutoHotkey v2 someday.
| Quote: | | Hard to remember special cases (e.g. appending binary data deletes existing content of the file) | That was done because the file would be corrupted by a normal append. In other words, it makes no sense not to have the delete be implicit. There will probably be a FileWrite command soon, which would allow the ClipboardAll documentation to refer to it rather than FileAppend.
In general, there's a reason for just about everything in the language, though clearly some things could have been done better if only I knew then what I do now, etc.
Thanks for the feedback. Most people never bother to post anything constructive like this, and I appreciate it. |
|
| Back to top |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4078 Location: Pittsburgh
|
Posted: Fri Mar 04, 2005 11:05 pm Post subject: |
|
|
Don't get me wrong, Chris! I did not mean to criticize AHK. It is a huge, complex, powerful and functioning system, and I love it. The translator from a general programming language will help us, non-programmers, who only write scripts once in a while. I understand that every syntactic or semantic detail has a reason to be that way, but we mortals keep forgetting all the fine points. I spent about 10 hours to re-learn and debug the GUI stuff for my 2-page Deluxe Clipboard script: where do I need a comma, where do I need %, how to specify the number of dropdown rows in a ComboBox, etc. If there had been a more familiar syntax version, less powerful and easier to remember (with a translator), I could have done it in one hour (what shows how powerful AHK became).
If the majority of AHK users are of the geek type, let this wish have the lowest priority. |
|
| Back to top |
|
 |
jonny
Joined: 13 Nov 2004 Posts: 3004 Location: Minnesota
|
Posted: Fri Mar 04, 2005 11:43 pm Post subject: |
|
|
| As I understand it, AutoHotkey is already modeled after BASIC syntax, correct? I wouldn't know, since I've never used it myself, but my friend works with BASIC a lot and he said it looks very similar. So really the dilemma here is not that the syntax is "uncommon," it's simply unfamiliar. Then again, I could be totally off base. I'll think about it some more. |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10480
|
Posted: Sat Mar 05, 2005 9:27 am Post subject: |
|
|
| Laszlo wrote: | | If there had been a more familiar syntax version, less powerful and easier to remember (with a translator), I could have done it in one hour (what shows how powerful AHK became). | I'm not completely following you. Perhaps you can give an example of the easier-to-remember syntax you have in mind, as well as more details about what the translator would do.
| Quote: | | If the majority of AHK users are of the geek type, let this wish have the lowest priority. | I think the majority are casual users who are not programmers (or who are, but want a scripting language that is easier to use and remember than a programming language). In fact, this is the target audience.
| Quote: | | AutoHotkey is already modeled after BASIC syntax, correct | I don't think there's too much Basic flavor to it, but I'm not well familiar with Basic either. The most accurate description is that it's based on AutoIt v2 syntax, which in turn is based on Microsoft's ScriptIt, whose syntax is described here. |
|
| Back to top |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4078 Location: Pittsburgh
|
Posted: Sun Mar 06, 2005 4:04 am Post subject: |
|
|
I've spent a few hours with trying to come up with a simplified uniform syntax for AHK. Every direction I took led to complications, and eventually something similar to an existing language. The simplest was the old IBM scripting language REX (does anyone remember it). Another way led to the MATLAB macro language. You can model the syntax after PEARL or any of the dozens of scripting language commonly in use today. In any case, the simplicity of hot key/hot string definitions will be lost.
The dilemma is: if you want to keep the simple syntax for simple tasks, AHK is good as it is now. If you want to have a general syntax with no exceptions, sub-cases, etc, for AHK projects of thousands of lines of code, then pick an existing general scripting language what you like, and somebody might write a translator from it. But simple tasks will not be that simple any more. |
|
| Back to top |
|
 |
jonny
Joined: 13 Nov 2004 Posts: 3004 Location: Minnesota
|
Posted: Sun Mar 06, 2005 4:30 am Post subject: |
|
|
I think a different syntax for AutoHotkey is a great idea. Some people, myself included, wouldn't give a darn if funky tricks like hotkey and hotstring defs are lost. Unfortunately, as Laszlo said, the current syntax is already ideal for AHK's mission (due to some incredible top-level design, wink wink). So the solution is to simply... do nothing. For now. The eventual solution could be to keep AHK the way it is now, but also develop a different version (possibly with dll's?) that is syntax-independent, in which the interpreter is separate from the core itself. That way, different wrappers could be written more quickly for different syntax sets.
Of course, we can't possibly place such a load on Chris to do this. If this is ever going to happen, it needs to wait until more developers step in and this community matures more.
Wow, that was a total brainstorm. I might be way off base, as usual. Chris, is that feasible at any level? Note that I'm working with very limited knowledge of how AHK works (having never actually checked out the source). |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10480
|
Posted: Sun Mar 06, 2005 12:57 pm Post subject: |
|
|
| Laszlo wrote: | | I've spent a few hours with trying to come up with a simplified uniform syntax for AHK. ... In any case, the simplicity of hot key/hot string definitions will be lost. | I appreciate your research and your candor. You clearly understand the usership of AutoHotkey: that on average they're not interested in having a programming language to contend with when all they want to do is automate simple chores and maybe create some hotkeys.
| jonny wrote: | ...develop a different version (possibly with dll's?) that is syntax-independent, in which the interpreter is separate from the core itself. That way, different wrappers could be written more quickly for different syntax sets.
...is that feasible at any level? | It's certainly feasible. Although the current demand for such a thing is probably limited to only a select few, it may grow over time.
Certainly a version 2 of AutoHotkey is likely as a long-term goal (probably a year or more away). When planning that project, we could try to have the best of all worlds: simple syntax for hotkeys and hotstrings, while at the same time eliminating many of the legacy syntax rules -- such as input variables and possibly non-expression IF statements -- that cause more confusion than they're worth.
Last edited by Chris on Sun Mar 12, 2006 2:49 pm; edited 1 time in total |
|
| Back to top |
|
 |
AHKnow* Guest
|
Posted: Sun Mar 12, 2006 3:12 am Post subject: |
|
|
One way would be to make suggestions for correcting syntax, but that will always be balanced by backwards compatibility with existing scripts and trying to get more developers to work on a particular issue.
Until people are ready for version 2 of AutoHotkey, would not the immediate solution be to use/improving/creating an AutoHotkey syntax checker? |
|
| Back to top |
|
 |
Titan
Joined: 11 Aug 2004 Posts: 5390 Location: /b/
|
Posted: Sun Mar 12, 2006 10:54 am Post subject: Re: Translator & new syntax |
|
|
| Laszlo wrote: | | I'd like a complete redesign of the syntax, like AutoIt3. | I respectfully disagree with this. If AutoHotkey were to become like Basic I would just switch to VB/C#.
AutoHotkey is far from a real programming language, it appeals to general computer users and experts alike. Microsoft have been trying to attract this kind of audience (see how they advertise their Visual Studio 2005 Express product range) but I doubt that their stuff is as versatile and easy as AutoHotkey.
AutoIt2 and AutoHotkey are very unique and innovative creations. The beauty of it is that virtually anybody could use it. AutoIt3 is basically a different flavour of Basic, it makes sense to just completely move to a freeware Basic language instead. If AutoHotkey goes down this path (which I for one would not like), then I won't be using it anymore as there will be better things in its league. What I do propose however is controlled expansions to provide flexibility for experienced users whilst being easy enough for novice users to understand. _________________
 |
|
| Back to top |
|
 |
AHKnow* Guest
|
Posted: Sun Mar 12, 2006 1:17 pm Post subject: |
|
|
I think Titan brought up a good point.
Why must AutoHotkey become YET ANOTHER CLONE of BASIC/VISUAL BASIC?
I think AutoIt made a mistake by going down the path of becoming a flavor of Basic. AutoHotkey is an easier to use and understand automation scripting language that can do extra. There is no need for AutoHotkey to copy Visual Basic, as there is already more variations of that programming language than you and I could hope to find in a day or more.
AutoHotkey holds a niche as a useful program that almost any computer power user can get into. It also has plenty of features for advanced users, as well as novice users.
I think that the AutoHotkey users and developers should not be afraid to blaze their own trail among scripting and programming languages.
Making things easy, is also difficult too. Just because something is hard or looks like something else does not mean its better. |
|
| Back to top |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4078 Location: Pittsburgh
|
Posted: Sun Mar 12, 2006 3:28 pm Post subject: Re: Translator & new syntax |
|
|
| Titan wrote: | | Laszlo wrote: | | I'd like a complete redesign of the syntax, like AutoIt3. | I respectfully disagree with this. If AutoHotkey were to become like Basic I would just switch to VB/C#. | Have you noticed the date of the post you quote? It was more than a year ago. Since then expressions, functions, dll calls were added to AHK, so the language did change a lot. Also: | Laszlo wrote: | | ...if you want to keep the simple syntax for simple tasks, AHK is good as it is now. If you want to have a general syntax with no exceptions, sub-cases, etc, for AHK projects of thousands of lines of code, then pick an existing general scripting language what you like, and somebody might write a translator from it. But simple tasks will not be that simple any more. |
|
|
| Back to top |
|
 |
wOxxOm
Joined: 09 Feb 2006 Posts: 320
|
Posted: Sun Mar 12, 2006 5:28 pm Post subject: Re: Translator & new syntax |
|
|
AHK is a swiss knife. I love to walk through debris of doc and learn fast that tweaks and strange syntax of non-formalized language. It gives me strong feeling that AHK is a live creature opposed by rigidness of VB. And thank god it is not as fluid as C++ syntax
The only thing I regret for now is that I can't image how to implement calls that require interface-CLSID-guid objects (IShellFolder e.g.)
if I-objects were implemented we could control explorer shell like a pen in our hand. |
|
| Back to top |
|
 |
holomind
Joined: 11 Mar 2006 Posts: 300 Location: Munich, Germany
|
Posted: Sun Mar 12, 2006 6:23 pm Post subject: |
|
|
my 5cents, i do programming a lot and know many different languages (mostly scripting and web-languages). In the beginning the AHK-syntax was a bit odd. and actually i liked it to be "similar" (but not the same) as a basic dialect so i could understand it quickly. i like it that is has a very efficient syntax without quoting etc. (its unfamiliar in the beginning, but i like it). some syntax looks strange like
| Code: |
if varable <>
dosomething
|
as you think after <> something is missing, but it's simply "" without the quotes.
assigning variables is not always intuitiv in the beginning as you dont really know if you get the variable-name or the variable-value...
the
var1 := contentsOfVar2
needs some getting used to but is quite good.
after all this comments i must say that AHK is very efficient and i was able to do one programm in one day which was "impossible" to do before. i even did give visual-studio a try, but its way to bloated ( i hate compilers and the nice API-Calls are only in the Full version , with VS2005-Express you only can do experiments, with AHK you can write amazing scripts and with gui you have real apps. also the size is very nice as you get a full app with 10-200 lines (10kb?) which would be a 10mega-byter in VB-exe or 20-50Mb in JAVA.
AHK has so much potential, so i will try to unclutter my 10 different tray-helpers and rewrite them into one nice big AHK-Script.
also the huge amount of samples in this forum is amazing and helps to learn the language very fast.
dont make AHK too differnt but keep the nice philosophy it has. perhaps there are some rough edges which are confusing for beginners and one could have an alternative syntax with little bit more quotes and brackets ?
on the other hand, i can use familiar basic or c or php-syntax and feel quite "home"
eg.
| Code: |
; looks more like python or basic
if x = y
do something ; comment
vs.
looks more like c, php or java
if (x = y)
{
; comment
do something
}
|
so one can decide to write more like a batch-script , a basic script or c-app. |
|
| Back to top |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4078 Location: Pittsburgh
|
Posted: Sun Mar 12, 2006 7:20 pm Post subject: |
|
|
| ...except you would need "if x = %y%" in your first example, or "if (x = "y")" in the second one, to have the same behavior. I learned this by now, but I had many-many bugs in my scripts related to this. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|