So I know there are a lot of questions on getters and setters in general, but I couldn't find something exactly like my question.  I was wondering if people change the use of get/set depending on different languages.  I started learning with C++ and was taught to use getters and setters.  This is what I understand:
In C++ (and Java?), a variable can either be public or private, but we cannot have a mix.  For example, I can't have a read-only variable that can still be changed inside the class.  It's either all public (can read and change it), or all private (can't read and can only change inside the class).  Because of this (and possibly other reasons), we use getters and setters.
In MATLAB, I can control the "setaccess" and "getaccess" properties of variables, so that I can make things read-only (can directly access the property, but can't overwrite it).  In this case, I don't feel like I need a getter because I can just do class.property.
Also, in Python it is considered "Pythonic" to not use getters/setters and to only put things into properties if needed.  I don't really understand why its OK to have all public variables in Python, because that's opposite of what I learned when I started with C++.
I'm just curious what other people's thoughts are on this.  Would you use getters and setters for all languages?  Would you only use it for C++/Java and do direct access in MATLAB and Python (which is what I am currently doing)?  Is the second option considered bad?  For my purposes, I am only referring to simple getters and setters (just return/set the value and do not do anything else).
Thanks!
You're right - no need for "simple" getters and setters in modern Matlab OOP; the access modifiers that you mentioned are the "Right Way".
In the new MCOS Matlab classes, the syntax for accessing a class property is the same whether you define custom getter/setters or not. Clients can always access property foo as "obj.foo". If you decide to add the special "get.foo" and "set.foo" methods, they are implicitly called by Matlab when a client accesses that property using the "obj.foo" syntax. So it's not really "direct field access" like public fields in Java or C++. It's like Scala's "Uniform Access" model. (I think.) The "." syntax and declarative access controls you mention keep things simple and lets you transparently add custom logic when you need it, without committing to writing boilerplate code up front. The ubiquity of user-defined getters and setters in Java is partially because the language lacks these features.
In old-style Matlab classes, the inverse is true: all fields are private, so you must write your own getter/setters. The convention I've seen is to write a single method with the same name as the property that gets or sets depending on whether you call it as "foo(obj)" or "foo(obj, NewValue)".
The use of getters and setters for different programming languages