My first programming language is C++. C++ is a multi-paradigm programming language. One of the paradigms C++ supports is Object Oriented Programming. I want to say I get the general idea and benefits of OOP as is exemplified in C++.
I have recently started creating a project in Android Studio. One of the languages Android Studio supports is Java. Java is a 'pure' object oriented programming language. Pure is in scare quotes due to java supporting primitive data types.
My question is why does Java go full OOP where as C++ doesn't feel the need to go to that extent. C++'s approach seems more 'reasonable' to me. However, I'm sure there are specific reasons why Java does it the way it does. Where everything is an object, everything has to be declared as public, protected, etc. Everything is used loosely.
0..(2^N)-1
, whereN
is the bit size of the pointer. All memory addresses exist for the duration of the program. No new addresses will ever exist, nor can they be made to not exist. Therefor we must come to some consensus about what is at particular addresses. In C/C++ like languages the language defers that consensus to the programmer. Do you want to change how you look at a section of memory, just change the pointer type. No worries. But this makes GC impossible, without the programmer agreeing to play nice. That's a huge loop hole. – Kain0_0 Nov 20 '19 at 22:25int
, and actual objects likeString
. But not for objects likeFile
, these need to do something first. The GC cannot know what that something is in advance so it calls a function called a finaliser. Java provides this via an interface and only objects can implement that – Kain0_0 Nov 20 '19 at 22:46