60

Simula 67 is generally considered the first object-oriented language and predates Smalltalk by a number of years. It also used the this keyword for the same concept, which can be seen in this book chapter extract: class Linker; begin ref(Linker) Next, Sex, Employment; text ID; procedure Add_to_List(LHead); name LHead; ref(Linker) LHead; ...


24

Upcasts always succeed. Downcasts can result in a runtime error, when the object runtime type is not a subtype of the type used in the cast. Since the second is a dangerous operation, most typed programming languages require the programmer to explicitly ask for it. Essentially, the programmer is telling the compiler "trust me, I know better -- this will be ...


16

There are four main approaches, though these only scratch the surface of what is available: via lambdas and records: the idea is to encode objects, classes and methods in terms of more traditional constructs. Benjamin Pierce's work from the mid 90s is representative of this approach. Abadi and Cardelli's object calculi (see Abadi and Cardelli's book A ...


13

So what is the equivalent for object oriented languages? Lambda calculus. I mean, there is Cardelli's object calculus (and a handful of derivatives), but in general, there's nothing fancy about object oriented languages that requires a new approach to computation. It's well known (see TaPL for example) how to extend/encode Records and Mutation (and sub-...


12

The connection between object model core and set theory is described in the following documents: Object Membership: The Core Structure of Object Technology Object Membership – Basic Structure What Is a Metaclass? The documents present the structure of instance and inheritance relations between objects. Such a structure can be considered the highest ...


9

In a procedural language you can't necessarily express restrictions that are required to prove that the caller is using a module in a supported fashion. In the absence of a compiler checkable restriction, you have to write documentation and hope that it is followed, and use unit tests to demonstrate intended uses. Declaring Types is the most obvious ...


8

A bit of history is in order, I think. The era from the mid-1960s to the mid-1970s is known today as the "software crisis". I can't put it better than Dijkstra in his Turing award lecture from 1972: The major cause of the software crisis is that the machines have become several orders of magnitude more powerful! To put it quite bluntly: as long as ...


8

Procedural/functional programming is in no way weaker than OOP, even without going into Turing arguments (my language has Turing power and can do anything another will do), which do not mean much. Actually, object oriented techniques were first experimented in languages that did not have them built-in. In this sense OO programming is only a specific style ...


8

Google brought up a similar question with an answer that I think is very good. I've quoted it below. There's another distinction lurking here that is explained in the Cook essay I linked. Objects are not the only way to implement abstraction. Not everything is an object. Objects implement something which some people call procedural data ...


8

In [1] (authored by one of the co-creators of Simula), there is a suggestion that Simula 67 may have been the first to use this dot notation. Given that Simula is widely credited for being the first OO language, it may be tricky to find an earlier example specifically in an OO context. EDIT: On DiscreteLizard's suggestion in comments, I took a peek at the ...


7

First, if this is exactly the sentence on the exam and not your translation, it's ambiguous. It could mean that OOD is one possible way to create and use ADT, or that creating and using ADTs requires OOD. Furthermore, ADT can mean two things: abstract data type or algebraic data type. The two concepts are completely different but are often confused. An ...


6

None, really. OOP doesn't really solve a problem, strictly speaking; there's nothing you can do with an object-oriented system that you couldn't do with a non object-oriented system- indeed, there's nothing you can do with either that couldn't be done with a Turing machine. It all turns into machine code eventually, and ASM is certainly not object-oriented. ...


6

The key to remember is that there's a sort of dualism between functional sum types, and OOP implementations of a superclass or interface: Sum types require the variants for a type to be specified up front, and for every operation, requires that we specify the operation for each variant. Adding a new operation is easy, adding a variant requires refactoring ...


5

In statically-typed object oriented languages (like Java), you can not create an object of an abstract class. Abstract classes are (usually) not completely defined, so creating such an object wouldn't make any sense. What you can create is a reference to an object instance of an abstract class. A reference is just a pointer to an object, not the object ...


5

Without the last list: merge(<B,D,O>, <C,F,O>, <D,O>) = <B,D,C,F,O> With the last list: merge(<B,D,O>, <C,F,O>, <D,O>, <B,C,D>) = <B> + merge(<D,O>, <C,F,O>, <D,O>, <C,D>) = <B,C> + merge(<D,O>, <F,O>, <D,O>, <D>) = <B,C,D,F,O> ...


4

Do not be too obsessed with it. It is often only buzzwords covering a fuzzy trend (from structured to object oriented) towards better organization of programs, with somewhat different realizations in different languages. It can appear in any programming paradigm, whether imperative or declarative. They are intended to improve readability of programs, good ...


4

They're orthogonal. In declarative programming, you describe what would count as an acceptable solution, without necessarily describing how to find it. For instance, a declarative program might have rules like "if you want to install the package gcc, you must have first installed the binutils and cpp packages" and "if you want to install the binutils ...


4

JavaScript looks perfectly like untyped sigma calculus. It supports first-class citizens, described in paper concepts in terms of prototypes, closures, clone (called split), (dynamic) method override, objects dynamic creation, extension, delegation, subsumption, object fragments and polymorphism (which is understatement in terms of this language). ...


4

Depending on the programming language, some or all objects might have reference semantics. What this means is that when you assign the object to a variable or pass it to a method, it's still the same object, not a copy. This means the object maintains identity independent of the values it holds. For example, in C#, classes have reference semantics, while ...


4

Hm, I don't have the points to comment, but are you sure you mean that? Classes already are a sort of sum type: polymorphism means that a variable declared to refer to something of type "A" could instead refer to an object of any of its subclasses B, C, etc. - so this is like a tagged union. And of course, as you say, objects are also product types, in ...


4

It does not matter how you implement multiple inheritance, the inherent issues coming from that still apply. If $C$ is a class, and $D$ a derived class (subclass), and $d:D$ we can write d.foo() to call a method that can be defined in $D$ (possibly ovverriding $C$'s own method) or the method which is inherited from $C$ (and not overridden). In any case, ...


4

So, things like this are possible, but the usefulness varies depending on your system. First, you can absolutely model object oriented programming in a functional, formal setting. System F-sub is the classic example of this, but Scala Dependent Object Types are another model. Secondly, let's talk about the difference between types and classes, without ...


3

Having written embedded C for a few years managing things like devices, serial ports, and communications packets between the serial ports, network ports, and servers; I found myself, a trained electrical engineer with limited procedural programming experience, concocting my own abstractions from the hardware which ended up manifesting in what I later ...


3

If you look at the ADT proponents, they consider an ADT to be what OOP would call a class (internal, private state; a limited set of operations allowed), but no relation between classes (no inheritance, basically) is considered. The point being instead that the same behaviour can be obtained with different implementations. E.g. a set can be implemented as a ...


3

"Constructor anomaly" is not a bug or anything; it is simply an anomaly on the classification of constructor functions. ie. constructor functions are different from member functions in the following ways. Anomalous classifications: While most member functions require an instance and work on an instance, a constructor does not require an instance, but still ...


3

I recommend you look at BML. It is like JML, but for Java bytecode. It allows you to specify contracts (preconditions, postconditions, data structure invariants) at the bytecode level. I think the tools Umbra, JACK, and the Mobius program verification environment support BML, and the Mobius project is building tools that work with BML. See, e.g., the ...


3

I think the accepted answer covers pretty much the original question, but I would like to supplement it (if I may) slightly by throwing in (quite informally) a few ideas regarding the secondary questions. From an inheritance point of view, nothing prevents the class hierarchy to have several roots. As it has been pointed out by other peoples, C++, as well ...


3

To declare a class (or a function) a friend allows the friend to access private members [the naming in C++ is not my fault!] (data or function) directly. They aren't "inherited" in any meaningful way. Yes, it creates a interdependency, but very different and a lot weaker than inheritance does.


3

Usually downcasting is what you do when the statically known knowledge the compiler has about the type of something is less specific than what you know (or at least hope). In situations like your example, the object was created as an Apple and then that knowledge was thrown away by storing the refernce in a variable of type Fruit. Then you want to use the ...


3

It's a matter of where do you want to draw the line. You can design a language that will detect validity of implicit downcast: public static void main(String args[]) { // An implicit upcast Fruit parent = new Apple(); // An implicit downcast to Apple Apple child = parent; } Now, let's extract a method: public static void main(String ...


Only top voted, non community-wiki answers of a minimum length are eligible