Post by Miguel7 » 11 Sep 2014, 09:21
Hey guys,
This is a question I've had in the back of my mind for awhile now, not specific about any one language but just in general. I've programmed in languages that are object-oriented to the extreme, like Java and C#, and also languages like JavaScript, Python, VBA, and (as I found out yesterday) AutoHotkey; this second group of languages supports OOP but doesn't necessarily require it. And for most of them, a beginner doesn't even know there are any "objects" involved - I wrote VBA macros for two years before I ever heard of OOP. So I guess in this post I'm talking not so much about whether a language is technically OO but more the style or process of writing the code.
As an example, let me use AHK (since that's what everyone here is likely to know
). You can write a script like this:
Code: Select all
^n::
Run Notepad
MsgBox Time to get your code on!
ExitApp
There may be several objects at work here behind the scenes (listening for the hotkey, running Notepad, and the object(s) associated with Notepad itself), but to the guy writing the script it looks more procedural ("If this hotkey is pressed, (1) Run notepad, (2) put up a message box, and (3) stop the script"). Same goes for JavaScript
Code: Select all
function go(){
var txt = document.getElementById("someInputField").value;
alert(txt);
}
Same deal: technically, the script is accessing a DOM object (another subject I didn't know Jack about until I'd been using JavaScript for years
), but in practice it looks like a list of tasks ("when the user presses a button, (1) get the text for to be displayed, and (2) display it in a message/alert box"). Both languages support OO and are actually using it, but this is less apparent than in Java or C#. You get the idea.
So whether we're writing in AHK, JavaScript or whatever, what do you think are the advantages and disadvantages of using OOP vs. another approach? I have my opinions about it, but I thought I'd get other programmers' perspective on the subject.
Hey guys,
This is a question I've had in the back of my mind for awhile now, not specific about any one language but just in general. I've programmed in languages that are object-oriented to the extreme, like Java and C#, and also languages like JavaScript, Python, VBA, and (as I found out yesterday) AutoHotkey; this second group of languages supports OOP but doesn't necessarily require it. And for most of them, a beginner doesn't even know there are any "objects" involved - I wrote VBA macros for two years before I ever heard of OOP. So I guess in this post I'm talking not so much about whether a language is technically OO but more the style or process of writing the code.
As an example, let me use AHK (since that's what everyone here is likely to know :lol:). You can write a script like this:
[code=autohotkey file=Script.ahk]^n::
Run Notepad
MsgBox Time to get your code on!
ExitApp[/code]
There may be several objects at work here behind the scenes (listening for the hotkey, running Notepad, and the object(s) associated with Notepad itself), but to the guy writing the script it looks more procedural ("If this hotkey is pressed, (1) Run notepad, (2) put up a message box, and (3) stop the script"). Same goes for JavaScript
[code=javascript file=Script.js]function go(){
var txt = document.getElementById("someInputField").value;
alert(txt);
}[/code]
Same deal: technically, the script is accessing a DOM object (another subject I didn't know Jack about until I'd been using JavaScript for years :lol:), but in practice it looks like a list of tasks ("when the user presses a button, (1) get the text for to be displayed, and (2) display it in a message/alert box"). Both languages support OO and are actually using it, but this is less apparent than in Java or C#. You get the idea. :)
So whether we're writing in AHK, JavaScript or whatever, what do you think are the advantages and disadvantages of using OOP vs. another approach? I have my opinions about it, but I thought I'd get other programmers' perspective on the subject.