AHK is a *bad* language?

Discuss Autohotkey related topics here. Not a place to share code.
Forum rules
Discuss Autohotkey related topics here. Not a place to share code.
User avatar
joedf
Posts: 8940
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: AHK is a *bad* language?

07 Nov 2016, 21:14

That may be true, however many choose AHK precisely because they can write it more freely.
Otherwise, one might as well to stick to python or c-like languages if syntax is too big of an issue. :p
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
guest3456
Posts: 3454
Joined: 09 Oct 2013, 10:31

Re: AHK is a *bad* language?

07 Nov 2016, 21:27

QuadrupleA wrote: Really wish the project would adopt a modern syntax that is consistent and has one clear meaning. Put strings in quotes, make unquoted stuff represent identifiers, require parenthesis for function calls instead of this weird FuncName, Val1, Val2 nonsense, etc.
https://autohotkey.com/v2/

sevenwenty
Posts: 7
Joined: 30 Apr 2016, 10:29

Re: AHK is a *bad* language?

05 Jan 2017, 03:33

QuadrupleA wrote:Just wanted to chime in - as a veteran programmer who writes stuff in Python, C/C++, C#, VB, LISP, assembler, SQL, javascript, etc. I find the AutoHotKey syntax absolutely atrocious. It confuses me to no end. Really wish the project would adopt a modern syntax that is consistent and has one clear meaning. Put strings in quotes, make unquoted stuff represent identifiers, require parenthesis for function calls instead of this weird FuncName, Val1, Val2 nonsense, etc.

Programming is hard, and having a language that's so ambiguous and bizarre just makes it harder for everyone, including the non-programmers all this nonsense was seemingly intended to make it easy for.
I agree 100%. AHK powerful and I use it every single day, but it has the most hideous and inconsistent syntax I've ever seen. I've written dozens of scripts and still find myself having to look up simple things because I keep forgetting about some weird quirk that no sane language would have. It's a huge pain to write, enough where I'm starting to consider switching to AutoIt.
garry
Posts: 3740
Joined: 22 Dec 2013, 12:50

Re: AHK is a *bad* language?

06 Jan 2017, 09:53

I found very easy to use autohotkey without programming knowledge / experience
icuurd12b42
Posts: 202
Joined: 14 Aug 2016, 04:08

Re: AHK is a *bad* language?

26 Aug 2017, 14:53

Hahaha, I google "AutoHotKey is a horrible language" and hit this thread, and since I googled it, it's because I need to rant about this thing for a bit, so necro bump....

Friendly Rant:
The main reason I use it is the core feature, emulating a user on an app is what it does very well with enough experience that they basically and eventually thought of everything you could possibly need to circumvent most every issue trying to control an app...

Programming in AutohotKey is like diving in a pool of s.... slime. You do it because you know at the bottom of the pool there's a pot of gold that is difficult to get to, but much less difficult than trying to find a leprechaun.

But damned the language is gross, yet surprisingly complete yet missing the most ridiculous obvious features here and there. It is horrible to work with, error conducive. Half the time I don't know how it's working... I just spend 3 hours trying to figure out some snippet that Used vSomething here and another snippet that did the other half of what I wanted on the same gui control type... that used gSomething (which I frankly did not notice)... Trying to combine the 2 snippets to make my control do both the things I fished out off the web, I failed... Then I miraculously found one snippet that did the 2 things I needed that worked and I stared at it for an hour scratching my head. It looks exactly like mine!!! But there it was... there is this vSomething that tells the system to do something and this gSomething that adds more features in the add command.... I'm having picard moment

http://1mut.com/wp-content/uploads/2012 ... com-19.jpg

The language is like Basic that had a stroke. I read the topic and seen how people defend it as easy to use/Learn? What have you done with it? A 20 line program? Can you even understand the code some expert wrote (I lift my Hat)
that uses classes and interface with dlls and stuff? They must have gone half insane by now!! Heheh

AHK has 4 saving graces
1) It's core features, tried and true, working always
2) The code available online from dedicated and smart programmers
3) Easy to install
4) Easy to make distributables

It's language and it's help file are its downfall, no denying it.

I wish the best for the product as I have done amazing things I would not be able to in c or javascript without the core functions. I just hope they change the language to javascript, I seen 6 year olds program in javascript. I seriously doubt a 6 year old can make heads or tails of this language.
User avatar
tidbit
Posts: 1272
Joined: 29 Sep 2013, 17:15
Location: USA

Re: AHK is a *bad* language?

26 Aug 2017, 15:39

"It's language and it's help file are its downfall, no denying it. "
its docs, alteast the old stuff (no offense, Lexikos) is quite good. Plenty of examples and detailed info on each parameter. The newer stuff is lacking, but it's getting there, slowly. Overall, I'd say AHK docs are nearly the best I've seen, if not the best.

language itself? to each their own. My very first script was a GUI. I have only ever used one language prior (GML, for gamemaker 5/6) to ahk. People say GUIs are one of the hardest (or atleast confusing) parts of ahk. I basically jumped straight into the deep end and did just fine, mostly on my own too.
Ofcourse I'm probably just an oddball, but same can be said with any language, they all have their quirks (especially JS. imo it's far worse than ahk). Just spend some time learning and trial & error, you'll get the hang of it.
rawr. fear me.
*poke*
Is it December 21, 2012 yet?
icuurd12b42
Posts: 202
Joined: 14 Aug 2016, 04:08

Re: AHK is a *bad* language?

26 Aug 2017, 17:22

The docs are TL;DR you need to read everything cautiously to find every idiosyncrasies of the language and of the functions you use. GM's 5/6'/7/8s Help File (since you mention it) also suffers from large single page help sections which was pretty bad when you wanted to get to the point...

AutoIt and AutoHotKey are the worst scripting languages I ever played with and I used BASIC under dos. I had no idea how bad BASIC was until I started with C. Because in c and c++ and other modern languages the language is structured and not ripe with oddities and function behavior modifiers.

I would rather have 15 versions of the same function than have one that does 15 different things with extra hidden features depending on how you called it... Speaking mainly of the GUI system here

I don't really see how you would think js is the worst thing you ever used lol, it has become such a gem imho...

Not specifically using DOM, the gui system could be simplified so much with similar structure

Code: Select all

panel = gui.addPanel(x,y,w,h,label)
textBox = panel.addTextBox(x,y,w,h,text)
textBox.multiline = true
textBox.font = gui.createFont("Arial Narrow Bold", 12)
textBox.OnClick = mytbClick
textBox2 = gui.addTextBox(x,y,w,h,text)
textBox2.OnClick = mytbClick
...
function mytbClick(event e)
{
    var textBox = e.element
    var mouse_x = e.mouse.x
    var mouse_y = e.mouse.y
    var button = e.mouse.button
}
So simple, so obvious...


>Just spend some time learning and trial & error, you'll get the hang of it.
I've been using it for 2 years on and off. I used it only for specific things, where it shines for what it was built for, so I use it rarely I guess.

Oh, 2 annoyances, the ; as comment yet this is illegal
t := Function();
and no for i loop!
User avatar
joedf
Posts: 8940
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: AHK is a *bad* language?

26 Aug 2017, 19:23

Honestly, when i first tried ahk... it took me a while to get into it.
But now that "im in", I love it. :3
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
User avatar
nnnik
Posts: 4500
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: AHK is a *bad* language?

27 Aug 2017, 15:04

The docs could be a lot worse yes. But I also think that a .CHM file is horribly inadequate for this task
Recommends AHK Studio
User avatar
joedf
Posts: 8940
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: AHK is a *bad* language?

27 Aug 2017, 16:25

What do you suggest instead?
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
icuurd12b42
Posts: 202
Joined: 14 Aug 2016, 04:08

Re: AHK is a *bad* language?

27 Aug 2017, 20:40

There's nothing wrong with chm... Obviously there is no hot link from the editor, because- no editor :), to help find things fast... but at least you have an offline help system to search in. and I know nothing else better suited for the job that has the same features. People hate it because it's ugly, that's basically why ppl bitch about it. It has not changed since window 3.1

Your online help's "Enter Search Term" however is broken... 99% of the time it never returns a result and hangs the browser. You'd be better off starting bing or google or duckduckgo directly
www.duckduckgos.com/search?q=treeview site:https://autohotkey.com/docs
And do it in a new tab pls!!!
User avatar
joedf
Posts: 8940
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: AHK is a *bad* language?

27 Aug 2017, 23:24

The docs' search works perfectly well for me... What is your browser and system?
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
User avatar
nnnik
Posts: 4500
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: AHK is a *bad* language?

28 Aug 2017, 05:09

I think a custom solution would be a lot better for integrating it into editors and for tackling the problem of the insane amount of cross references.
icuurd12b42 I don't think you know of the problem with the docs do I don't think you are able to make any sort of valid judgement here
Recommends AHK Studio
User avatar
joedf
Posts: 8940
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: AHK is a *bad* language?

28 Aug 2017, 08:53

nnnik wrote:I think a custom solution would be a lot better for integrating it into editors and for tackling the problem of the insane amount of cross references.
Ahhh yes... true.
Yeah the current ref-opening methods are whack and occasionally glitchy.
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
icuurd12b42
Posts: 202
Joined: 14 Aug 2016, 04:08

Re: AHK is a *bad* language?

28 Aug 2017, 21:32

>icuurd12b42 I don't think you know of the problem with the docs do I don't think you are able to make any sort of valid judgement here
Ouch that is harsh man. I may not know the problems specific to the content of your help file but I can speak in general about help files as I been doing help files since 1992
>I think a custom solution would be a lot better for integrating it into editors and for tackling the problem of the insane amount of cross references.
What sort of custom solution? If you suggest html on the client I'll slap you :)
>What is your browser and system?
It's chrome... It's more of an issue with the google search backend (cse.google.com) than the browser per se. When it works it's OK, but it stops working often. It's possibly some DNS reference that cannot be resolved...
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: AHK is a *bad* language?

28 Aug 2017, 22:08

icuurd12b42 wrote:yet missing the most ridiculous obvious features here and there
I wondered what you had in mind.
icuurd12b42 wrote:t := Function();
Why is this a problem? I wish Visual Studio could let you miss them out (semicolons), and add them in for you. If I spend more time with Visual Studio I may even try to write a script in AHK to add missing semicolons prior to compile. Trailing semicolons are the one thing I don't like about C++, I'd like to hear the rationale for their usage.
icuurd12b42 wrote:and no for i loop!
I agree. I don't need it that often, but it's good for maths-related tests and plotting points in graphs, and converting scripts from other languages. I mention traditional for loops here:
jeeswg's documentation extension tutorial - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=33596

I also agree about the GUI. AHK v2 is overhauling it though, and I've partially created my own replacement functions, which has helped me to appreciate just how many things Chris got right and the good decisions he made, even though I have my reservations about many things. And ultimately, everything in AHK v1 with GUI, though not always intuitive, usually doesn't require many code lines.

I agree that the chm is fine. Everything you need in one file. Any problems and you can explode the chm into separate htms, which I find handy for doing searches, and checking that I've seen every page of the documentation.

I welcome criticism of AHK, although I think it's pretty good overall, especially if you replace commands with custom functions. You take the syntax of Excel functions in sheet formulae, add in curly braces, control flow statements and directives, and you have something very effective. So many of the standard things you would want to do a lot are well covered, cf. C++ where everything that should take one line takes six lines.

So yeah, I 'concuur' with a lot of the things you're saying.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
icuurd12b42
Posts: 202
Joined: 14 Aug 2016, 04:08

Re: AHK is a *bad* language?

29 Aug 2017, 00:25

jeeswg wrote:
icuurd12b42 wrote:yet missing the most ridiculous obvious features here and there
I wondered what you had in mind.
Ridiculously easy to manually code a GUI but can't run it modal for example (without resorting to winapi mastery... or using functions normally used to control a target process window which is what I did being lazy)...
Ridiculously easy to setup a trieeview or list view, an almost incomprehensible task in c++, yet there is no item extra data available to you. Extra data is the first thing you realise you need dealing with list items..

This, this is anoying
var := TV_GetChild(item_index)
vs
TV_GetText(out_var,item_index)

We have the ability to return strings in functions we make... and many old statements have a function equivalent to the output argument method.... This is an omission, I guess

And I'm still scratching my head about "What if I have 2 treeviews on the gui!!"

as I said, here and there. All and all I understand these feature were likely tacked on with enough thought for this to be moderately useable, more so in many cases than a conventional development platform, but the language is almost there for way better implementation, see my ending statement.
icuurd12b42 wrote:t := Function();
Why is this a problem? I wish Visual Studio could let you miss them out (semicolons), and add them in for you. If I spend more time with Visual Studio I may even try to write a script in AHK to add missing semicolons prior to compile. Trailing semicolons are the one thing I don't like about C++, I'd like to hear the rationale for their usage.
The facepalm about this line of code is that ; is a comment!!! think about it.
this is an error
t:=Function();
t:=Function();This is an error
t:=Function() ;This is OK
The fact that ; is a comment means that ; and everything after it should be ignored. having it err out because of the missing space is annoying. Even if inadvertently typed, it would be a blessing if simply ignored...

>I'd like to hear the rationale for their usage.
the ; indicates the end of a statement because they found out that, especially in the early days of 40 character per line, one would need to spread out the code over multiple lines

so this is allowed

x = 10 +
20 +
15;

and that character was an easy eol indicator...

icuurd12b42 wrote:and no for i loop!
I agree. I don't need it that often, but it's good for maths-related tests and plotting points in graphs, and converting scripts from other languages. I mention traditional for loops here:
jeeswg's documentation extension tutorial - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=33596
Dont get me wrong, the loop features are pretty cool, just that the missing for loop is likely THE WTH moment for most everyone...
I also agree about the GUI. AHK v2 is overhauling it though, and I've partially created my own replacement functions, which has helped me to appreciate just how many things Chris got right and the good decisions he made, even though I have my reservations about many things. And ultimately, everything in AHK v1 with GUI, though not always intuitive, usually doesn't require many code lines.

I agree that the chm is fine. Everything you need in one file. Any problems and you can explode the chm into separate htms, which I find handy for doing searches, and checking that I've seen every page of the documentation.

I welcome criticism of AHK, although I think it's pretty good overall, especially if you replace commands with custom functions. You take the syntax of Excel functions in sheet formulae, add in curly braces, control flow statements and directives, and you have something very effective. So many of the standard things you would want to do a lot are well covered, cf. C++ where everything that should take one line takes six lines.

So yeah, I 'concuur' with a lot of the things you're saying.
I do prefer typing 6 comprehensible lines of code over one line that will make me scratch my head and force me to re-read the help coming back to it 3 months later...

I can always make a script to pass 6 arguments to convert thos 6 calls in a one liner... you cant do the opposite with the GUI system

I been spending the day trying to encapsulate a GUIs in classes... Just to see how far I could go... Here's an example
One example

Code: Select all

;This hybrid mix of global and class is weird, but here's a reminder
; ListProcessDialog is the class name, used to set-up and preform actions
; ListProcessDialog_ is the Window Name
; ListProcessDialog_ControlName is the name convention for the controls that need to receive events
;    vListProcessDialog_ControlName and gListProcessDialog_ControlName and ListProcessDialog_ControlName() for the event handling
;The global Name/Handlers for controls
global ListProcessDialog_ListView :=
global ListProcessDialog_StatusBar :=

;Class ListProcessDialog
;   Creates and show a Process Viewer window
;   Calls the MainUI function to add a new App to it's list on double click and closes
;
Class ListProcessDialog
{
	static Icons :=
    ShowModal()
	{
		;disable the main ui window
		WinSet,Disable, ,HotKeySpeak
		;show myself
		Gui, ListProcessDialog_:Show , w400 h400, Select Program From Running Processes
	}

	;creates the Main GUI Window
	Create()
	{
		;set ListProcessDialog_ as target for setting things up
		Gui, ListProcessDialog_:Default
		;allow resize
		Gui, +resize
		Gui, +AlwaysOnTop
		;Label on top of treeview	
		Gui, Add, Text, section, Running Processes:
		
		;the icons list to use in the treeview
		ListProcessDialog.Icons := IL_Create(10,10,1)
		
		;stub icons
		;from dll or exe
		;Loop 10  ; Load the ImageList with some standard system icons.
		;	IL_Add(ListProcessDialog.Icons, "shell32.dll", A_Index)
		;from ico file
		;IL_Add(ListProcessDialog.Icons, "Graphics\HotKeySpeak.ico", 2) 
		
		;listview
		; Create the ListView with two columns, Name and Size:
		Gui, Add, ListView, x0 y+m r20 w700 vListProcessDialog_ListView gListProcessDialog_ListView, Application|Path
		
		LV_SetImageList(ListProcessDialog.Icons,1)
		
		;Gather a list of all processes path
		WinGet, all, list
		;loop through list
		ImageIndex := 1
		Loop, %all%
		{
			Try
			{
				;get the path
				WinGet, PPath, ProcessPath, % "ahk_id " all%A_Index%
				;get component parts of the path
				SplitPath, PPath , OutFileName, OutDir, OutExtension, OutNameNoExt, OutDrive
				;check if not in listview already
				if(ListProcessDialog.Find(OutNameNoExt) = 0)
				{
					;load the icon from exe
					hicon := LoadPicture(PPath, "Icon1")
					;if not failed loading
					if(hicon <> 0)
					{
						;add icon. reload it in image since the documented HICON method fails
						;IL_Add(ListProcessDialog.Icons, HICON:%hicon%) ;compile fail yet document sais it should work
						IL_Add(ListProcessDialog.Icons, PPath, 1)
						
						;Add the treeview item
						LV_Add("Icon" . ImageIndex, OutNameNoExt, OutDir)
						ImageIndex:=ImageIndex+1
					}
				}
			}
			catch e  ; Handles the first error/exception raised by the block above.
			{
				break
			}
		}
		LV_ModifyCol()  ; Auto-size each column to fit its contents.
		;LV_ModifyCol(2, "Integer")  ; For sorting purposes, indicate that column 2 is an integer.

		
		;Status Bar
		t := "  Double Click on Application to Add..."
		Gui, Add, StatusBar, vListProcessDialog_StatusBar, %t%
		;reset the default
		Gui, 1:Default
	}
	;Finds if entry is in the listview
	Find(entry)
	{
		out := ""
		Loop % LV_GetCount()
		{
			LV_GetText(RetrievedText, A_Index)
			if(RetrievedText = entry)
			{
				return 1
			}
			
		}
		return 0
	}
	;Window Resize event
	OnGuiSize(GuiHwnd, EventInfo, Width, Height)
	{
		; The window has been minimized.  No action needed.
		if EventInfo = 1  
			return
			
		;Set GUI context to ListProcessDialog_
		Gui, ListProcessDialog_:Default
		
		;Move, Expand, shrink the controls to match new size
		
		;Treeview
		GuiControl, Move, ListProcessDialog.ListView, % "H" . (Height - 42) . " W" . (Width)
		
		
		;reset the default
		Gui, 1:Default
		return
	}
	;ListView events
	OnListViewEvents()
	{
		if A_GuiEvent = DoubleClick
		{
			LV_GetText(ExeName, A_EventInfo,1)  ; Get the text from the row's first field.
			LV_GetText(ExePath, A_EventInfo,2)
			MainUI_Add_Process(ExePath . "\" . ExeName . ".exe")
			ListProcessDialog_GuiClose()
			;ToolTip You double-clicked row number %A_EventInfo%. Text: "%RowText%"
		}
		return
	}
	;GUI Close event
	OnGUIClose()
	{
		;Re-enable the MainUI
		WinSet,Enable, ,HotKeySpeak
		;Destruct the process viewer window
		Gui, ListProcessDialog_:Default
		Gui, Destroy  
		;cleanup
		ListProcessDialog_Listview := 0
		ListProcessDialog_StatusBar := 0
		ListProcessDialog.Icons := 0
		Gui, 1:Default
	}
}


;All events dispatched to the class function
ListProcessDialog_GuiSize(GuiHwnd, EventInfo, Width, Height)
{
	return ListProcessDialog.OnGuiSize(GuiHwnd, EventInfo, Width, Height)
}

ListProcessDialog_ListView()
{
	return ListProcessDialog.OnListViewEvents()
}

ListProcessDialog_GuiClose()
{  
	return ListProcessDialog.OnGuiClose()
}
It's not possible to set the event handler to a class function, which is basically the major pain for me...

It's all so close to javascript though, a class seems to be instantiatable and give static access, just like javascript and vb classes. 90% there really

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 22 guests