A Bit Baffling

Talk about anything
User avatar
Era
Posts: 26
Joined: 28 Apr 2018, 22:36

A Bit Baffling

29 Apr 2018, 05:06

I really appreciate AutoHotkey and those who build and maintain it. That said, I'm always sad when "improvements" to computer languages result in their drifting away from clarity and simplicity. New features, fine, but to take one example--object oriented programming. Requires extra steps to set up an object, then specify its properties and methods. OOP has value, but its primary value is clerical: it helps people programming together in groups to keep from stepping on each other's toes. For a language like AHK, superimposing OOP makes to me little sense. AHK is primarily used ad hoc by individual programmers working alone. To what purpose would one need encapsulation, inheritance, or polymorphism?

However, some proposed changes for V2 look good. To my mind, anyone who can't instantly distinguish between assignment of value and comparison should probably avoid programming altogether and find something less mentally challenging. So having a single flavor of = is nice I think.

Anyway, just my 2 cents.
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: A Bit Baffling

29 Apr 2018, 05:41

Era wrote:To what purpose would one need encapsulation, inheritance, or polymorphism?
to keep you from stepping on your own toes
if its a one off script youre writing that youre gonna trash after a couple of runs, sure whatever, make a mess, litter the global namespace, idc
if its something that im gonna reuse, id like to be able to read and comprehend what it is i wrote when i open it again after 3 days, and not have to spend half an hour figuring it out
Requires extra steps to set up an object, then specify its properties and methods.
waste a bit of time now to save yourself a lot more later down the road, it's a no brainer imo
User avatar
Era
Posts: 26
Joined: 28 Apr 2018, 22:36

Re: A Bit Baffling

29 Apr 2018, 08:03

Maybe I'm just lucky, but I don't have trouble reading code if the language itself isn't stupidly, needlessly, encapsulated and inheriting right and left from black box code. So, to me it's a no-brainer to avoid OOP when writing my own programs. I guess people experience reading code at different levels of capability. If you know what I'm saying, Mr. Swagfag.
User avatar
nnnik
Posts: 4500
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: A Bit Baffling

29 Apr 2018, 08:04

Hmm yeah I guess you are not capable of reading OOP then.
Recommends AHK Studio
User avatar
Era
Posts: 26
Joined: 28 Apr 2018, 22:36

Re: A Bit Baffling

29 Apr 2018, 10:19

Good night.
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: A Bit Baffling

29 Apr 2018, 10:21

just using it as an example, this was posted just a while ago: https://autohotkey.com/boards/viewtopic ... 18&t=48182

full disclosure, i hit expand, scrolled past 5 screenfuls of text and instantly my gut wrenched with aversion. i didnt even want to try and read, let alone comprehend the code

the dude is trying to click some buttons in a game, imagine how nice it wouldve been if you had a Button class, which had its coordinates, its corresponding image for imagesearching, its own randomize coordinates and click methods, and all this errorLevel checking fuckery tucked and handled neatly away from sight. U would then have the script read for each Button, do Button.click() and it would be immediately apparent what the script does, and if you needed to know what click() does specifically, you could peek into the class and its definition.

instead you have to go line by line(and no u cant assume and skip over) and cram all of that in your head at once to maybe get the big picture of whats going on with the program
User avatar
nnnik
Posts: 4500
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: A Bit Baffling

29 Apr 2018, 10:24

Well AutoHotkey is mainly for GUI manipulation and lets be honest here - GUI problems are meant for OOP.
Recommends AHK Studio
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: A Bit Baffling

29 Apr 2018, 13:51

- If you're saying that anything done via object classes can be done just as well if not better with custom functions alone, I'm tempted to agree. Suggestions of any *well-argued* exceptions are welcome.
- I'd say that often people write both custom object classes and custom functions in an unnecessarily unclear way. I'd also say that object classes can be written in a way that is as readable as custom functions. However, in practice, I would say that people use object classes where functions would be sufficient or preferable, and that the classes will end up being more unreadable than the functions would have been.
- Personally, for anyone writing a class, I find that OTB instantly makes the class harder to follow, I would use Allman style.
- Since this is in the AHK v2 development forum, I suppose that you are saying that AHK is becoming 'too OOP'. Which bits are becoming 'too OOP' in your view, and what would you propose instead?
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
nnnik
Posts: 4500
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: A Bit Baffling

29 Apr 2018, 14:53

Only very few things make sense as functions.
  1. Functions are for the parts in your script that you are never going to reuse as objects are meant for and superior for reuseability.
  2. Functions are for the parts of your script that access super globally, because if you don't need them everywhere encapsulating them in an object makes more sense.
Recommends AHK Studio
SirRFI
Posts: 404
Joined: 25 Nov 2015, 16:52

Re: A Bit Baffling

29 Apr 2018, 17:09

@Era Nobody forces you do write your own classes and do other typical OOP stuff. Some "functions" are now OOP yes, but that's usually due to their complexity. Other than that, v2 is mostly about removing command syntax/behaviour and literal input, which fix v1 syntax inconsistency and related issues, also as actually having you write less code. If you still don't like it - v1.1 is simultaneously developed, with exceptions that don't fit it anymore.
Use

Code: Select all

[/c] forum tag to share your code.
Click on [b]✔[/b] ([b][i]Accept this answer[/i][/b]) on top-right part of the post if it has answered your question / solved your problem.
lexikos
Posts: 9553
Joined: 30 Sep 2013, 04:07
Contact:

Re: A Bit Baffling

29 Apr 2018, 23:05

I saw Era's post yesterday and anticipated an irrelevant "debate" about the merits of OOP. What baffles me is this: What does this have to do with v2?

Please give an example of a move toward OOP in v2 that you find baffling.

The Gui and Menu APIs are now object-based, and are more consistent, cleaner and easier to use than the old ones, especially with TreeView and ListView controls. I couldn't care less whether or how that relates to "encapsulation, inheritance, or polymorphism".
iseahound
Posts: 1434
Joined: 13 Aug 2016, 21:04
Contact:

Re: A Bit Baffling

30 Apr 2018, 03:05

There is a bit of merit to the "black box" argument. For example, when a user interacts with a GUI, the interaction should be "broadcast" for all other AHK objects to see, where as objects tend to hide their changes. I do think Era's point is very subjective, but from an objective point of view, user interactions with GUI should be similar to PostMessage/SendMessage window messages.
User avatar
nnnik
Posts: 4500
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: A Bit Baffling

30 Apr 2018, 03:09

Could you elaborate which specific objects should be affected by the broadcast?
Also isn't this why we have a listener pattern or is what you mean not covered by that?
Recommends AHK Studio
iseahound
Posts: 1434
Joined: 13 Aug 2016, 21:04
Contact:

Re: A Bit Baffling

30 Apr 2018, 19:28

If I have 64 buttons, then I have 64 different "captures". If I'm writing a chess game, the individual buttons have no meaning, and the state of the board is more important. Buttons don't exist in a vacuum, they interact with the states of other buttons. In an abstract sense, objects hide their changes meaning I have to continually ask the object if one of its values have changed. Compare that with an OnMessage(). Something like a global case/switch would be simple to work with.

With that said, I don't like GUI. I've tried my best to avoid any use of AHK built-in GUI in my code. Whether or not this is implemented doesn't matter to me, I just happen to have a sense of what Era was trying to say before he got trolled.
User avatar
kczx3
Posts: 1640
Joined: 06 Oct 2015, 21:39

Re: A Bit Baffling

30 Apr 2018, 19:47

I don’t think anyone got trolled here...
User avatar
nnnik
Posts: 4500
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: A Bit Baffling

01 May 2018, 00:10

If I have 64 buttons, then I have 64 different "captures". If I'm writing a chess game, the individual buttons have no meaning, and the state of the board is more important. Buttons don't exist in a vacuum, they interact with the states of other buttons. In an abstract sense, objects hide their changes meaning I have to continually ask the object if one of its values have changed.
I wouldn't implement it like that at all. You don't have 64 buttons or 64 captures. Making them buttons is a mistake in itself. I'd rather have one custom board control which relays the events to the correct class by itself internally.
I think you should have a look at the MVC pattern. It's a standard pattern in OOP GUI Programming - it probably fixes what you mentioned before.
With that said, I don't like GUI. I've tried my best to avoid any use of AHK built-in GUI in my code. Whether or not this is implemented doesn't matter to me, I just happen to have a sense of what Era was trying to say before he got trolled.
I think he was just trying to troll one of our members and he got the apropriate response.
Recommends AHK Studio
User avatar
Era
Posts: 26
Joined: 28 Apr 2018, 22:36

Re: A Bit Baffling

04 May 2018, 16:44

jeeswg wrote:- If you're saying that anything done via object classes can be done just as well if not better with custom functions alone, I'm tempted to agree. Suggestions of any *well-argued* exceptions are welcome.
- I'd say that often people write both custom object classes and custom functions in an unnecessarily unclear way. I'd also say that object classes can be written in a way that is as readable as custom functions. However, in practice, I would say that people use object classes where functions would be sufficient or preferable, and that the classes will end up being more unreadable than the functions would have been.
- Personally, for anyone writing a class, I find that OTB instantly makes the class harder to follow, I would use Allman style.
- Since this is in the AHK v2 development forum, I suppose that you are saying that AHK is becoming 'too OOP'. Which bits are becoming 'too OOP' in your view, and what would you propose instead?
I totally agree. And if they do encapsulation, you can't even see the code to know what the h is going on! Inheritance, too, can be a nightmare of trying to figure out the chain of causation.... Leave your scripts readable and visible. Cascade is a stupid technique for scripting AHK...
User avatar
Era
Posts: 26
Joined: 28 Apr 2018, 22:36

Re: A Bit Baffling

04 May 2018, 16:48

nnnik wrote:Only very few things make sense as functions.
  1. Functions are for the parts in your script that you are never going to reuse as objects are meant for and superior for reuseability.
  2. Functions are for the parts of your script that access super globally, because if you don't need them everywhere encapsulating them in an object makes more sense.

Reuseability is a complete myth. How many times have you actually plugged a previous bit of code into new source code? Probably never. This is because context defines the massively unpredictable interactions between input and output. So the hoped-for black box reuse is a complete non-starter.

I've been hearing for three decades about how this and that will allow you to reuse code. Beyond any but the most simplistic, short, code snippet, reuse is more trouble than it's worth.

Crockery.
User avatar
Era
Posts: 26
Joined: 28 Apr 2018, 22:36

Re: A Bit Baffling

04 May 2018, 16:50

kczx3 wrote:I don’t think anyone got trolled here...

I didn't feel trolled, just misunderstood.
User avatar
Era
Posts: 26
Joined: 28 Apr 2018, 22:36

Re: A Bit Baffling

04 May 2018, 16:55

swagfag wrote:just using it as an example, this was posted just a while ago: https://autohotkey.com/boards/viewtopic ... 18&t=48182

full disclosure, i hit expand, scrolled past 5 screenfuls of text and instantly my gut wrenched with aversion. i didnt even want to try and read, let alone comprehend the code

the dude is trying to click some buttons in a game, imagine how nice it wouldve been if you had a Button class, which had its coordinates, its corresponding image for imagesearching, its own randomize coordinates and click methods, and all this errorLevel checking fuckery tucked and handled neatly away from sight. U would then have the script read for each Button, do Button.click() and it would be immediately apparent what the script does, and if you needed to know what click() does specifically, you could peek into the class and its definition.

instead you have to go line by line(and no u cant assume and skip over) and cram all of that in your head at once to maybe get the big picture of whats going on with the program
My dear Mr. ? SwagFag:
Functions can be provided with input/output descriptions via comments...so you don't need to tax your pretty head with reading the code within. I/O comments are quite like OOP in that way, without the messy code hiding and cascade. You can tell people what to put in , and what to expect out. Just like a laxative. Get it?

Return to “Off-topic Discussion”

Who is online

Users browsing this forum: No registered users and 51 guests