SlideShare a Scribd company logo
1 of 31
Download to read offline
Doctoral course: 
object technologies 
IMO Group 
Department of computer science 
University of Vigo 
J. Baltasar García Perez-Schofield 
http://webs.uvigo.es/jbgarcia/
Implementation of object-oriented 
languages
Terminology 
➲ Inheritance: 
● By concatenation: the new object (B) is built con-catening 
the object it inherits from (A) with the 
same object (B). 
● By delegation: objects are independent. If an ob-ject 
B inherits from another object A, then when it 
were unable to satisfy a given message (F), it will 
delegate it in its parent (it will send F to A). 
➲ Behaviour: The set of methods of an object 
(in many programming langages, its class). 
➲ State: the values of all attributes in an ob-ject.
Implementation of object-oriented 
programming languages 
➲ There are two main possibilities: 
● Integration of object-oriented extensions in a tra-ditional 
language, such as C or Pascal. 
● Create a completely new language. 
➲ There are two main kinds of object-oriented 
programming languages: 
● Class-based ones. 
● Prototype-based ones.
Class-based languages 
Extending a traditional language 
with object-oriented capabilities.
Implementación de Lenguajes 
Orientados a Objetos 
➲ Discussion about adding object-oriented ca-pabilities 
to the C language. 
➲ In fact, the first tool Bjarne Stroustrup crea-ted 
in order to be able to compile C++ (C 
with classes, at that time), was a simple pre-processor.
Classes 
➲ Classes are moulds that allow object cre-ation. 
class Car { 
int numWheels; 
int color; 
int fuel; 
void startUp(); 
}; 
void Car::startUp() { 
fuel--; 
}
Clases 
➲ The base for a class is a record (struct). 
➲ The only problem is that records can't store 
functions ... 
➲ ... but this can be simulated: 
struct Car { 
int numWheels; 
int color; 
int fuel; 
} 
void Car_startUp(struct Coche &this) { 
this->fuel--; 
}
Métodos 
➲ Methods are C functions, which have a this 
argument, which is nothing else than the ob-ject 
executing that method at a given time. 
➲ This means that this points to the appropri-ate 
struct Coches for each moment. 
➲ Thus, all methods have an extra argument 
apart from the ones that would be declared 
in a method of this “C with classes” pro-gramming 
languages.
Static methods 
➲ The only exception are class methods or 
static (in C++ terminology). They pertain to 
classes, not to objects. This means that this 
method, once translated into a C function, 
will not have the this parameter.
Translation example 
➲ The following program: 
class Car { 
public: 
int numWheels; 
int color; 
int fuel; 
static void findGasStation(); 
void startUp(); 
}; 
//... 
int main(void) { 
Car myCar; 
myCar.color = 1; /* WHITE */ 
myCar.startUp(); 
}
Ejemplo de traducción 
➲ Would be translated as: 
struct Car { 
int numWheels; 
int color; 
} 
void Car_findGasStation() { 
// ... 
} 
void Car_startUp(struct Car &this) { 
// ... 
} 
int main(void) 
{ 
struct Car myCar; 
myCar.color = 1; /* WHITE */ 
Car_startUp( &myCar ); 
}
Compilation 
➲ Note that it is possible to do a strict type-checking 
at compile time, as C++ does, in 
this preprocessor. 
➲ Compile-time type checking is one of the 
strongest points of C++, as it is a way of de-tecting 
errors before the execution of a pro-gram. 
➲ It is very easy to add visibility criteria 
(private, protected).
What is it left for implementation? 
➲ Encapsulation is directly supported by the 
implementation of translation given here. 
➲ Inheritance can be easily added by merging 
structures when one derives from another 
one. This is inheritance by concatenation. 
➲ However, polymorphism is not so simple to 
implement. It is needed an structure as the 
vtable employed in C++.
Class-based languages 
Creation of an object-oriented pro-gramming 
language from zero
Classes and objects 
➲ It will be mandatorily needed to distinguish 
between: 
● behaviour (methods, which will be stored in the 
class, and the description of the attributes), and 
● state (the values of the attributes, which will be 
stored in the object). 
➲ It is possible to dismiss the class information 
at run time, as C++ does, or keep them as 
introspection information. 
➲ If they are mantained at run time, then they 
are known as meta objects.
Clases y objetos 
➲ Supposing the same class example than 
previously: 
● Although it is not necessary, methods can still be 
implemented as functions of the programming 
language that accept an extra argument this. 
● There will be the object, holding the state of the 
object, and the metaobject, i.e., the class, as a 
common resource for all objects, at runtime. 
● The metaobject is consulted in order to resolve 
calls to attributes and methods.
Schematic representation of ob-jects 
in memory 
➲ Metaobjects con-tain 
the shift for 
each attribute and 
pointers to the 
functions what play 
the role of meth-ods. 
➲ Objects just con-tain 
the state.
Schematic representation of ob-jects 
in memory 
➲ Thus, for resolving myCar.color = 2;, 
● firstly the pointer “myCar” is dereferenced. 
● from there, the metaclass is reached (the class 
information) “Car”. 
● The shift for the attribute “color” is found. 
● The pointer “myCar” is shifted as specified by the 
metaclass for “color”. 
➲ Finally, the translation in C language would 
be “*((int *)myCar + 4) = 2;”
Compilation time or execution time 
➲ The previous process can happen at com-pile 
or execution time. 
● At compilation time: - flexible, + strong type-checking. 
These are languages such as C++. 
● In execution: + flexible, - strong type checking. 
These are languages such as SmallTalk, 
Python ... 
➲ It is still posible an intermediate language, 
dynamic as Self, but doing compile time 
checking. This is the case of Kevo.
Prototype-based programming lan-guages 
Creation of a prototype-based pro-gramming 
language
Prototype-based programming lan-guage 
➲ There are no classes, objects are created by 
copying other objects. 
➲ The objects that are copied are called proto-types. 
However, a big difference is that new 
objects can be modified independently from 
their prototypes. 
➲ It's a model very flexible and simple. 
➲ It is able to represent the class-based mod-el.
Implementation 
➲ As objects do not depend of a class, and are 
independent of the prototype it was copied 
from, the structure of the object must contain 
state and behaviour (attributes and meth-ods). 
● Methods and attributes are contained in a set, in 
the same space in memory. 
➲ Inheritance is implemented by delegation, al-though 
special programming languages 
such as Kevo prove that this is not mandat-ory.
Schematic representation of ob-jects 
in memory 
➲ Objects contain 
methods and attrib-utes. 
➲ When a message 
cannot be satisfied, it 
is delegated in its 
parent. 
➲ Inheritance, by del-egation, 
can be flex-ible 
and therefore dy-namic.
Conclusions
Object-oriented programming 
models 
➲ There are two extremes in the spectrum of 
object-oriented programming models. 
● The more restrictive model is the class-based 
one. 
● Strong compile-time tpye-checking. 
● Inheritance by concatenation. 
● The more flexible model is the prototype-based 
one. 
● There are not many compile-time verifications. 
● Inheritance by delegation. 
➲ However, intermediate object-oriented pro-gramming 
models are possible (for example, 
the programming language Kevo).
Implementation 
➲ The characteristics that thus condition the 
implementation of a programming language: 
● Existence of classes. 
● Kind of inheritance. 
➲ However, implementation can be separated 
in many layers. 
● Zero is a virtual machine that implements the pro-totype- 
based model. However, there are com-pilers 
that generate bytecode to be consumed by 
the virtual machine. One of them, J-- does com-pile- 
time type-checking, while the other one 
PROWL, is a pure prototype-based programming 
language.
References 
➲ Bjarne Stroustrup, designer of C++: 
● Personal web page 
● http://www.research.att.com/~bs/ 
● “The C++ programming language” 
● http://www.research.att.com/~bs/3rd.html 
● “Design and evolution of C++” 
● http://www.research.att.com/~bs/dne.html 
● Other publications: 
● http://www.research.att.com/~bs/books.html 
➲ SmallTalk 
● Squeak (current implementation): 
http://www.squeak.org/ 
● SmallTalk documentation: http://www.esug.org/
References 
➲ Self 
● Web page: http://research.sun.com/self/index.html 
● Implementation: 
http://research.sun.com/research/self/papers/elgin-thesis.html 
● Other: 
http://research.sun.com/research/self/papers/papers.html 
➲ Kevo 
● http://burks.brighton.ac.uk/burks/foldoc/44/63.htm 
➲ Python 
● Class-based languages, implemented with prototypes. 
● Web page: http://www.python.org/
References 
➲ Looking for papers: 
● http://www.researchindex.com 
● http://scholar.google.com
Doctoral course: 
object technologies 
IMO Group 
Department of computer science 
University of Vigo 
J. Baltasar García Perez-Schofield 
http://webs.uvigo.es/jbgarcia/

More Related Content

What's hot

Cling the llvm based interpreter
Cling the llvm based interpreterCling the llvm based interpreter
Cling the llvm based interpreterRoberto Nogueira
 
Concurrency reification in the xDSML with MoCCML
Concurrency reification in the xDSML with MoCCMLConcurrency reification in the xDSML with MoCCML
Concurrency reification in the xDSML with MoCCMLBenoit Combemale
 
A Tool-Supported Approach for Omniscient Debugging and Concurrent Execution o...
A Tool-Supported Approach for Omniscient Debugging and Concurrent Execution o...A Tool-Supported Approach for Omniscient Debugging and Concurrent Execution o...
A Tool-Supported Approach for Omniscient Debugging and Concurrent Execution o...Benoit Combemale
 
Dynamic languages for .NET CLR
Dynamic languages for .NET CLRDynamic languages for .NET CLR
Dynamic languages for .NET CLRpy_sunil
 
Introduction to Go for Java Developers
Introduction to Go for Java DevelopersIntroduction to Go for Java Developers
Introduction to Go for Java DevelopersLaszlo Csontos
 
Experimentations, transfer and development during the ANR project GEMOC
Experimentations, transfer and development during the ANR project GEMOCExperimentations, transfer and development during the ANR project GEMOC
Experimentations, transfer and development during the ANR project GEMOCBenoit Combemale
 
Wrap-up of the ANR project GEMOC
Wrap-up of the ANR project GEMOCWrap-up of the ANR project GEMOC
Wrap-up of the ANR project GEMOCBenoit Combemale
 
JavaScript Object Oriented Programming Cheat Sheet
JavaScript Object Oriented Programming Cheat SheetJavaScript Object Oriented Programming Cheat Sheet
JavaScript Object Oriented Programming Cheat SheetHDR1001
 
Reifying the concurrency concern into xDSML specifications
Reifying the concurrency concern into xDSML specificationsReifying the concurrency concern into xDSML specifications
Reifying the concurrency concern into xDSML specificationsBenoit Combemale
 
New c sharp4_features_part_v
New c sharp4_features_part_vNew c sharp4_features_part_v
New c sharp4_features_part_vNico Ludwig
 
Groovy / comparison with java
Groovy / comparison with javaGroovy / comparison with java
Groovy / comparison with javaLiviu Tudor
 
Transformer Seq2Sqe Models: Concepts, Trends & Limitations (DLI)
Transformer Seq2Sqe Models: Concepts, Trends & Limitations (DLI)Transformer Seq2Sqe Models: Concepts, Trends & Limitations (DLI)
Transformer Seq2Sqe Models: Concepts, Trends & Limitations (DLI)Deep Learning Italia
 
STATICMOCK : A Mock Object Framework for Compiled Languages
STATICMOCK : A Mock Object Framework for Compiled Languages STATICMOCK : A Mock Object Framework for Compiled Languages
STATICMOCK : A Mock Object Framework for Compiled Languages ijseajournal
 
Polymorphism 140527082302-phpapp01
Polymorphism 140527082302-phpapp01Polymorphism 140527082302-phpapp01
Polymorphism 140527082302-phpapp01Engr.Tazeen Ahmed
 
Cap'n Proto (C++ Developer Meetup Iasi)
Cap'n Proto (C++ Developer Meetup Iasi)Cap'n Proto (C++ Developer Meetup Iasi)
Cap'n Proto (C++ Developer Meetup Iasi)Ovidiu Farauanu
 
Modern Programming Languages classification Poster
Modern Programming Languages classification PosterModern Programming Languages classification Poster
Modern Programming Languages classification PosterSaulo Aguiar
 
Thomas Wolf "Transfer learning in NLP"
Thomas Wolf "Transfer learning in NLP"Thomas Wolf "Transfer learning in NLP"
Thomas Wolf "Transfer learning in NLP"Fwdays
 

What's hot (20)

Cling the llvm based interpreter
Cling the llvm based interpreterCling the llvm based interpreter
Cling the llvm based interpreter
 
Concurrency reification in the xDSML with MoCCML
Concurrency reification in the xDSML with MoCCMLConcurrency reification in the xDSML with MoCCML
Concurrency reification in the xDSML with MoCCML
 
A Tool-Supported Approach for Omniscient Debugging and Concurrent Execution o...
A Tool-Supported Approach for Omniscient Debugging and Concurrent Execution o...A Tool-Supported Approach for Omniscient Debugging and Concurrent Execution o...
A Tool-Supported Approach for Omniscient Debugging and Concurrent Execution o...
 
Dynamic languages for .NET CLR
Dynamic languages for .NET CLRDynamic languages for .NET CLR
Dynamic languages for .NET CLR
 
Introduction to Go for Java Developers
Introduction to Go for Java DevelopersIntroduction to Go for Java Developers
Introduction to Go for Java Developers
 
Experimentations, transfer and development during the ANR project GEMOC
Experimentations, transfer and development during the ANR project GEMOCExperimentations, transfer and development during the ANR project GEMOC
Experimentations, transfer and development during the ANR project GEMOC
 
ETAPS03 SC.ppt
ETAPS03 SC.pptETAPS03 SC.ppt
ETAPS03 SC.ppt
 
hexMachina WWX 2016
hexMachina WWX 2016hexMachina WWX 2016
hexMachina WWX 2016
 
Wrap-up of the ANR project GEMOC
Wrap-up of the ANR project GEMOCWrap-up of the ANR project GEMOC
Wrap-up of the ANR project GEMOC
 
JavaScript Object Oriented Programming Cheat Sheet
JavaScript Object Oriented Programming Cheat SheetJavaScript Object Oriented Programming Cheat Sheet
JavaScript Object Oriented Programming Cheat Sheet
 
Reifying the concurrency concern into xDSML specifications
Reifying the concurrency concern into xDSML specificationsReifying the concurrency concern into xDSML specifications
Reifying the concurrency concern into xDSML specifications
 
20 intro-to-csharp
20 intro-to-csharp20 intro-to-csharp
20 intro-to-csharp
 
New c sharp4_features_part_v
New c sharp4_features_part_vNew c sharp4_features_part_v
New c sharp4_features_part_v
 
Groovy / comparison with java
Groovy / comparison with javaGroovy / comparison with java
Groovy / comparison with java
 
Transformer Seq2Sqe Models: Concepts, Trends & Limitations (DLI)
Transformer Seq2Sqe Models: Concepts, Trends & Limitations (DLI)Transformer Seq2Sqe Models: Concepts, Trends & Limitations (DLI)
Transformer Seq2Sqe Models: Concepts, Trends & Limitations (DLI)
 
STATICMOCK : A Mock Object Framework for Compiled Languages
STATICMOCK : A Mock Object Framework for Compiled Languages STATICMOCK : A Mock Object Framework for Compiled Languages
STATICMOCK : A Mock Object Framework for Compiled Languages
 
Polymorphism 140527082302-phpapp01
Polymorphism 140527082302-phpapp01Polymorphism 140527082302-phpapp01
Polymorphism 140527082302-phpapp01
 
Cap'n Proto (C++ Developer Meetup Iasi)
Cap'n Proto (C++ Developer Meetup Iasi)Cap'n Proto (C++ Developer Meetup Iasi)
Cap'n Proto (C++ Developer Meetup Iasi)
 
Modern Programming Languages classification Poster
Modern Programming Languages classification PosterModern Programming Languages classification Poster
Modern Programming Languages classification Poster
 
Thomas Wolf "Transfer learning in NLP"
Thomas Wolf "Transfer learning in NLP"Thomas Wolf "Transfer learning in NLP"
Thomas Wolf "Transfer learning in NLP"
 

Similar to Post-graduate course: Object technology: Implementation of object-oriented programming languages.

(4) c sharp introduction_object_orientation_part_i
(4) c sharp introduction_object_orientation_part_i(4) c sharp introduction_object_orientation_part_i
(4) c sharp introduction_object_orientation_part_iNico Ludwig
 
Objective-c for Java Developers
Objective-c for Java DevelopersObjective-c for Java Developers
Objective-c for Java DevelopersMuhammad Abdullah
 
Presentation 1st
Presentation 1stPresentation 1st
Presentation 1stConnex
 
Design patterns in javascript
Design patterns in javascriptDesign patterns in javascript
Design patterns in javascriptAyush Sharma
 
Future Programming Language
Future Programming LanguageFuture Programming Language
Future Programming LanguageYLTO
 
Session 3 - Object oriented programming with Objective-C (part 1)
Session 3 - Object oriented programming with Objective-C (part 1)Session 3 - Object oriented programming with Objective-C (part 1)
Session 3 - Object oriented programming with Objective-C (part 1)Vu Tran Lam
 
A350103
A350103A350103
A350103aijbm
 
Not Your Fathers C - C Application Development In 2016
Not Your Fathers C - C Application Development In 2016Not Your Fathers C - C Application Development In 2016
Not Your Fathers C - C Application Development In 2016maiktoepfer
 
Javascriptinobject orientedway-090512225827-phpapp02
Javascriptinobject orientedway-090512225827-phpapp02Javascriptinobject orientedway-090512225827-phpapp02
Javascriptinobject orientedway-090512225827-phpapp02Sopheak Sem
 
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...NicheTech Com. Solutions Pvt. Ltd.
 
I assignmnt(oops)
I assignmnt(oops)I assignmnt(oops)
I assignmnt(oops)Jay Patel
 
JavaScript in Object-Oriented Way
JavaScript in Object-Oriented WayJavaScript in Object-Oriented Way
JavaScript in Object-Oriented WayChamnap Chhorn
 
Question and answer Programming
Question and answer ProgrammingQuestion and answer Programming
Question and answer ProgrammingInocentshuja Ahmad
 
Object oriented-programming-in-c-sharp
Object oriented-programming-in-c-sharpObject oriented-programming-in-c-sharp
Object oriented-programming-in-c-sharpAbefo
 
OOP lesson1 and Variables.pdf
OOP lesson1 and Variables.pdfOOP lesson1 and Variables.pdf
OOP lesson1 and Variables.pdfHouseMusica
 
Summer Training Project On C++
Summer Training Project On  C++Summer Training Project On  C++
Summer Training Project On C++KAUSHAL KUMAR JHA
 

Similar to Post-graduate course: Object technology: Implementation of object-oriented programming languages. (20)

(4) c sharp introduction_object_orientation_part_i
(4) c sharp introduction_object_orientation_part_i(4) c sharp introduction_object_orientation_part_i
(4) c sharp introduction_object_orientation_part_i
 
Objective-c for Java Developers
Objective-c for Java DevelopersObjective-c for Java Developers
Objective-c for Java Developers
 
Presentation 1st
Presentation 1stPresentation 1st
Presentation 1st
 
Programming paradigms
Programming paradigmsProgramming paradigms
Programming paradigms
 
Design patterns in javascript
Design patterns in javascriptDesign patterns in javascript
Design patterns in javascript
 
Future Programming Language
Future Programming LanguageFuture Programming Language
Future Programming Language
 
Session 3 - Object oriented programming with Objective-C (part 1)
Session 3 - Object oriented programming with Objective-C (part 1)Session 3 - Object oriented programming with Objective-C (part 1)
Session 3 - Object oriented programming with Objective-C (part 1)
 
A350103
A350103A350103
A350103
 
General oop concept
General oop conceptGeneral oop concept
General oop concept
 
Not Your Fathers C - C Application Development In 2016
Not Your Fathers C - C Application Development In 2016Not Your Fathers C - C Application Development In 2016
Not Your Fathers C - C Application Development In 2016
 
Cp3-- A module support tool for C++
Cp3-- A module support tool for C++Cp3-- A module support tool for C++
Cp3-- A module support tool for C++
 
Javascriptinobject orientedway-090512225827-phpapp02
Javascriptinobject orientedway-090512225827-phpapp02Javascriptinobject orientedway-090512225827-phpapp02
Javascriptinobject orientedway-090512225827-phpapp02
 
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
 
I assignmnt(oops)
I assignmnt(oops)I assignmnt(oops)
I assignmnt(oops)
 
advance-dart.pptx
advance-dart.pptxadvance-dart.pptx
advance-dart.pptx
 
JavaScript in Object-Oriented Way
JavaScript in Object-Oriented WayJavaScript in Object-Oriented Way
JavaScript in Object-Oriented Way
 
Question and answer Programming
Question and answer ProgrammingQuestion and answer Programming
Question and answer Programming
 
Object oriented-programming-in-c-sharp
Object oriented-programming-in-c-sharpObject oriented-programming-in-c-sharp
Object oriented-programming-in-c-sharp
 
OOP lesson1 and Variables.pdf
OOP lesson1 and Variables.pdfOOP lesson1 and Variables.pdf
OOP lesson1 and Variables.pdf
 
Summer Training Project On C++
Summer Training Project On  C++Summer Training Project On  C++
Summer Training Project On C++
 

More from Baltasar García Perez-Schofield

Curso de doctorado de Tecnología de Objetos: Sistemas Orientados a objetos y ...
Curso de doctorado de Tecnología de Objetos: Sistemas Orientados a objetos y ...Curso de doctorado de Tecnología de Objetos: Sistemas Orientados a objetos y ...
Curso de doctorado de Tecnología de Objetos: Sistemas Orientados a objetos y ...Baltasar García Perez-Schofield
 
Curso de doctorado Tecnología de Objetos: Implementación de lenguajes orienta...
Curso de doctorado Tecnología de Objetos: Implementación de lenguajes orienta...Curso de doctorado Tecnología de Objetos: Implementación de lenguajes orienta...
Curso de doctorado Tecnología de Objetos: Implementación de lenguajes orienta...Baltasar García Perez-Schofield
 
Learning object-oriented programming trough a visual tool at Cisti 2008
Learning object-oriented programming trough a visual tool at Cisti 2008Learning object-oriented programming trough a visual tool at Cisti 2008
Learning object-oriented programming trough a visual tool at Cisti 2008Baltasar García Perez-Schofield
 
Charla invitada en oviedo: Evolución del soporte de persistencia
Charla invitada en oviedo: Evolución del soporte de persistenciaCharla invitada en oviedo: Evolución del soporte de persistencia
Charla invitada en oviedo: Evolución del soporte de persistenciaBaltasar García Perez-Schofield
 

More from Baltasar García Perez-Schofield (9)

Presentación ESEI para IES Lauro Olmo
Presentación ESEI para IES Lauro OlmoPresentación ESEI para IES Lauro Olmo
Presentación ESEI para IES Lauro Olmo
 
Curso de doctorado de Tecnología de Objetos: Sistemas Orientados a objetos y ...
Curso de doctorado de Tecnología de Objetos: Sistemas Orientados a objetos y ...Curso de doctorado de Tecnología de Objetos: Sistemas Orientados a objetos y ...
Curso de doctorado de Tecnología de Objetos: Sistemas Orientados a objetos y ...
 
Curso de doctorado Tecnología de Objetos: Persistencia.
Curso de doctorado Tecnología de Objetos: Persistencia.Curso de doctorado Tecnología de Objetos: Persistencia.
Curso de doctorado Tecnología de Objetos: Persistencia.
 
Post-graduate course: Object technology: Persistence.
Post-graduate course: Object technology: Persistence.Post-graduate course: Object technology: Persistence.
Post-graduate course: Object technology: Persistence.
 
Curso de doctorado Tecnología de Objetos: Implementación de lenguajes orienta...
Curso de doctorado Tecnología de Objetos: Implementación de lenguajes orienta...Curso de doctorado Tecnología de Objetos: Implementación de lenguajes orienta...
Curso de doctorado Tecnología de Objetos: Implementación de lenguajes orienta...
 
Prototype-based programming with PROWL.
Prototype-based programming with PROWL.Prototype-based programming with PROWL.
Prototype-based programming with PROWL.
 
Prototype-based, object-oriented programming
Prototype-based, object-oriented programmingPrototype-based, object-oriented programming
Prototype-based, object-oriented programming
 
Learning object-oriented programming trough a visual tool at Cisti 2008
Learning object-oriented programming trough a visual tool at Cisti 2008Learning object-oriented programming trough a visual tool at Cisti 2008
Learning object-oriented programming trough a visual tool at Cisti 2008
 
Charla invitada en oviedo: Evolución del soporte de persistencia
Charla invitada en oviedo: Evolución del soporte de persistenciaCharla invitada en oviedo: Evolución del soporte de persistencia
Charla invitada en oviedo: Evolución del soporte de persistencia
 

Recently uploaded

Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 

Recently uploaded (20)

Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 

Post-graduate course: Object technology: Implementation of object-oriented programming languages.

  • 1. Doctoral course: object technologies IMO Group Department of computer science University of Vigo J. Baltasar García Perez-Schofield http://webs.uvigo.es/jbgarcia/
  • 3. Terminology ➲ Inheritance: ● By concatenation: the new object (B) is built con-catening the object it inherits from (A) with the same object (B). ● By delegation: objects are independent. If an ob-ject B inherits from another object A, then when it were unable to satisfy a given message (F), it will delegate it in its parent (it will send F to A). ➲ Behaviour: The set of methods of an object (in many programming langages, its class). ➲ State: the values of all attributes in an ob-ject.
  • 4. Implementation of object-oriented programming languages ➲ There are two main possibilities: ● Integration of object-oriented extensions in a tra-ditional language, such as C or Pascal. ● Create a completely new language. ➲ There are two main kinds of object-oriented programming languages: ● Class-based ones. ● Prototype-based ones.
  • 5. Class-based languages Extending a traditional language with object-oriented capabilities.
  • 6. Implementación de Lenguajes Orientados a Objetos ➲ Discussion about adding object-oriented ca-pabilities to the C language. ➲ In fact, the first tool Bjarne Stroustrup crea-ted in order to be able to compile C++ (C with classes, at that time), was a simple pre-processor.
  • 7. Classes ➲ Classes are moulds that allow object cre-ation. class Car { int numWheels; int color; int fuel; void startUp(); }; void Car::startUp() { fuel--; }
  • 8. Clases ➲ The base for a class is a record (struct). ➲ The only problem is that records can't store functions ... ➲ ... but this can be simulated: struct Car { int numWheels; int color; int fuel; } void Car_startUp(struct Coche &this) { this->fuel--; }
  • 9. Métodos ➲ Methods are C functions, which have a this argument, which is nothing else than the ob-ject executing that method at a given time. ➲ This means that this points to the appropri-ate struct Coches for each moment. ➲ Thus, all methods have an extra argument apart from the ones that would be declared in a method of this “C with classes” pro-gramming languages.
  • 10. Static methods ➲ The only exception are class methods or static (in C++ terminology). They pertain to classes, not to objects. This means that this method, once translated into a C function, will not have the this parameter.
  • 11. Translation example ➲ The following program: class Car { public: int numWheels; int color; int fuel; static void findGasStation(); void startUp(); }; //... int main(void) { Car myCar; myCar.color = 1; /* WHITE */ myCar.startUp(); }
  • 12. Ejemplo de traducción ➲ Would be translated as: struct Car { int numWheels; int color; } void Car_findGasStation() { // ... } void Car_startUp(struct Car &this) { // ... } int main(void) { struct Car myCar; myCar.color = 1; /* WHITE */ Car_startUp( &myCar ); }
  • 13. Compilation ➲ Note that it is possible to do a strict type-checking at compile time, as C++ does, in this preprocessor. ➲ Compile-time type checking is one of the strongest points of C++, as it is a way of de-tecting errors before the execution of a pro-gram. ➲ It is very easy to add visibility criteria (private, protected).
  • 14. What is it left for implementation? ➲ Encapsulation is directly supported by the implementation of translation given here. ➲ Inheritance can be easily added by merging structures when one derives from another one. This is inheritance by concatenation. ➲ However, polymorphism is not so simple to implement. It is needed an structure as the vtable employed in C++.
  • 15. Class-based languages Creation of an object-oriented pro-gramming language from zero
  • 16. Classes and objects ➲ It will be mandatorily needed to distinguish between: ● behaviour (methods, which will be stored in the class, and the description of the attributes), and ● state (the values of the attributes, which will be stored in the object). ➲ It is possible to dismiss the class information at run time, as C++ does, or keep them as introspection information. ➲ If they are mantained at run time, then they are known as meta objects.
  • 17. Clases y objetos ➲ Supposing the same class example than previously: ● Although it is not necessary, methods can still be implemented as functions of the programming language that accept an extra argument this. ● There will be the object, holding the state of the object, and the metaobject, i.e., the class, as a common resource for all objects, at runtime. ● The metaobject is consulted in order to resolve calls to attributes and methods.
  • 18. Schematic representation of ob-jects in memory ➲ Metaobjects con-tain the shift for each attribute and pointers to the functions what play the role of meth-ods. ➲ Objects just con-tain the state.
  • 19. Schematic representation of ob-jects in memory ➲ Thus, for resolving myCar.color = 2;, ● firstly the pointer “myCar” is dereferenced. ● from there, the metaclass is reached (the class information) “Car”. ● The shift for the attribute “color” is found. ● The pointer “myCar” is shifted as specified by the metaclass for “color”. ➲ Finally, the translation in C language would be “*((int *)myCar + 4) = 2;”
  • 20. Compilation time or execution time ➲ The previous process can happen at com-pile or execution time. ● At compilation time: - flexible, + strong type-checking. These are languages such as C++. ● In execution: + flexible, - strong type checking. These are languages such as SmallTalk, Python ... ➲ It is still posible an intermediate language, dynamic as Self, but doing compile time checking. This is the case of Kevo.
  • 21. Prototype-based programming lan-guages Creation of a prototype-based pro-gramming language
  • 22. Prototype-based programming lan-guage ➲ There are no classes, objects are created by copying other objects. ➲ The objects that are copied are called proto-types. However, a big difference is that new objects can be modified independently from their prototypes. ➲ It's a model very flexible and simple. ➲ It is able to represent the class-based mod-el.
  • 23. Implementation ➲ As objects do not depend of a class, and are independent of the prototype it was copied from, the structure of the object must contain state and behaviour (attributes and meth-ods). ● Methods and attributes are contained in a set, in the same space in memory. ➲ Inheritance is implemented by delegation, al-though special programming languages such as Kevo prove that this is not mandat-ory.
  • 24. Schematic representation of ob-jects in memory ➲ Objects contain methods and attrib-utes. ➲ When a message cannot be satisfied, it is delegated in its parent. ➲ Inheritance, by del-egation, can be flex-ible and therefore dy-namic.
  • 26. Object-oriented programming models ➲ There are two extremes in the spectrum of object-oriented programming models. ● The more restrictive model is the class-based one. ● Strong compile-time tpye-checking. ● Inheritance by concatenation. ● The more flexible model is the prototype-based one. ● There are not many compile-time verifications. ● Inheritance by delegation. ➲ However, intermediate object-oriented pro-gramming models are possible (for example, the programming language Kevo).
  • 27. Implementation ➲ The characteristics that thus condition the implementation of a programming language: ● Existence of classes. ● Kind of inheritance. ➲ However, implementation can be separated in many layers. ● Zero is a virtual machine that implements the pro-totype- based model. However, there are com-pilers that generate bytecode to be consumed by the virtual machine. One of them, J-- does com-pile- time type-checking, while the other one PROWL, is a pure prototype-based programming language.
  • 28. References ➲ Bjarne Stroustrup, designer of C++: ● Personal web page ● http://www.research.att.com/~bs/ ● “The C++ programming language” ● http://www.research.att.com/~bs/3rd.html ● “Design and evolution of C++” ● http://www.research.att.com/~bs/dne.html ● Other publications: ● http://www.research.att.com/~bs/books.html ➲ SmallTalk ● Squeak (current implementation): http://www.squeak.org/ ● SmallTalk documentation: http://www.esug.org/
  • 29. References ➲ Self ● Web page: http://research.sun.com/self/index.html ● Implementation: http://research.sun.com/research/self/papers/elgin-thesis.html ● Other: http://research.sun.com/research/self/papers/papers.html ➲ Kevo ● http://burks.brighton.ac.uk/burks/foldoc/44/63.htm ➲ Python ● Class-based languages, implemented with prototypes. ● Web page: http://www.python.org/
  • 30. References ➲ Looking for papers: ● http://www.researchindex.com ● http://scholar.google.com
  • 31. Doctoral course: object technologies IMO Group Department of computer science University of Vigo J. Baltasar García Perez-Schofield http://webs.uvigo.es/jbgarcia/