Access to a subroutine involves additional overhead not present when data is accessed directly. While this is becoming of less concern with the wide availability of fast general-purpose processors it may remain important in coding some real-time computing systems and systems using relatively slow and simple embedded processors. In some languages, like C++, the getter / setter methods are usually inline functions, so that when inlining is performed, the code looks just like direct field accessing.
Liang, Y. Daniel. "9.9 Data Field Encapsulation". Revel for Introduction to Java Programming and Data Structures. https://tinnakorn.cs.rmu.ac.th/Courses/Tutorial/Java.Introduction.to.Java.Programming.and.Data.Structures/OPS/xhtml/ch09_pg0013.xhtml ↩