Should I choose v1 or v2? [AutoHotkey Wiki]
versions
Sidebar
Community
Editors Optimized for AutoHotkey
Guides
Hardware
Libraries
Script Showcase
User Pages
Alternatives
CloudAHK Sandbox
Should I choose v1 or v2?
Should I choose v1 or v2?
Original article by Lexikos
Which version should I install?
Install both.
The launcher included with v2 enables the use of v1 and v2 scripts on one system, almost transparently. If a script’s version requirement isn’t explicitly declared with #Requires, the launcher can usually detect the required version based on syntax.
If you install v2 and try to run a v1 script without first installing v1, in many cases the launcher will offer you to automatically install the required version. So if you don’t specifically intend to run v1 scripts, just install v2.
SciTE4AutoHotkey supports both versions out of the box, while VS Code can support both with the installation of appropriate extensions. See Tools for details.
As a beginner, which version should I learn?
v2.
Both versions make it easy to carry out a range of tasks with just a few lines of code. Where they differ most is the syntax - the rules and patterns that you must learn in order to write code that works.
For historical reasons, v1 has two kinds of syntax: legacy syntax and expressions. The legacy syntax gives a false impression of simplicity which sometimes appeals to non-programmers, but actually results in greater complexity and is the root cause of frequent confusion.
v2 uses expressions throughout, and several common causes of confusion have been removed. If you are a beginner and only need to carry out simple tasks, it is still sufficient to learn just a few simple patterns. When you need more, the learning curve is gentler as there is no need to shift to a different syntax.
v2 has more thorough error-detection and reporting. Sometimes this means writing extra code to avoid doing something the program considers invalid, but in return, troubleshooting is much easier and the code you write is more reliable. Stricter error-detection also tends to limit the damage that mistakes can cause.
It is unfortunately true that there are fewer resources available for learning v2 than for v1, but that will change over time. v2 itself has simpler syntax and is easier to learn, so you may find that the relative lack of resources isn’t a problem, if you give it a try.
As a v1 user, why should I switch to v2?
Even if you aren’t a beginner, you may - I dare say you will - benefit from simplification of the syntax and the removal of many common causes of confusion. v2 also includes hundreds of individual improvements, representing over a decade of work.
v1 development will cease; see End of v1. Perhaps you’ve invested a lot of time learning v1 and building your collection of scripts, but sticking with v1 means investing more time in a product that is going nowhere. Someone else could pick up development of v1, but unless that someone is you, don’t count on it.
Note that switching doesn’t mean immediately letting go of v1, or having to convert all of your scripts. You can use both.
As a v1 user, won’t I need to learn an entirely new language to use v2?
It has been said that v2 has a completely different language; that v1 users switching to v2 will need to learn a lot of new syntax or concepts, giving up their existing language skills. This is at best oversimplified and exaggerated.
v2 builds upon the same basic concepts as v1, but centers its syntax around expressions. If you have learned expressions for v1, you are most of the way toward understanding v2 code. The major differences are removal of obsolete syntax and concepts, and more robust error-detection and reporting. New syntax and concepts generally aren’t mandatory learning; and they are there to help you.
As a v1 user, you’ve probably memorized many details, such as the names of commands, the syntax of each parameter and various special rules within the language. It is true that many small details have changed and will require some relearning, but there are also details and pitfalls that you no longer need to account for while writing code.
Why should I take the time to convert my v1 scripts to v2?
In the process of converting code, you may find opportunities for improvement due to new language features or behaviour, or perhaps because your skills have grown since writing the original code. Improvements to error-detection may allow you to find bugs that were previously undetected - I’ll admit to finding such errors while updating my own code.
But maybe you shouldn’t. If converting v1 code doesn’t seem like the best use of your time, or doesn’t make good business sense, you’re free to continue running old scripts with v1, while writing new code in v2 if you so choose. The installer and support scripts for v2 are designed to make this easy.
My recommendation is to start small; write new scripts in v2 and learn a bit before attempting to...