Anyone made some experiments with MSX version of Modula?
Modula should have concurrent programming constructs.
The language doesn't make it slow, I think that's up to the compiler.
I like a language to support my programming (i.e. the way I model the stuff), instead of one that frustrates me and stops my train of thoughts.
Exactly!
and doing this cause unavoided machine code complexity (bloat), that on modern processors is aceptable, but not on a simple 8 bit cpu, that's the point
and if you need polimorphism to support your model, this can be obtained with vtable, hence slow on z80.
So OO is unaceptable on a simple 8 bit cpu. But is not the compiler itself, instead are the language constructs that are slow.
Well... and then, what about Smalltalk??
If people claim that the Z80 can support OO programming (OO programming in assembly), then why wouldn't it be possible to let a high level language compiler use the same kind of constructs?
Assembler is an object oriented language if you want it to be.
I disagree. I can of course, borrow some OO concepts like structures for data encapsulation and pointers for functions for virtual methods but with a rigid control of what are you doing, but OO is a paradigm and not a programming style.
The assembler will never provide you inheritance, abstraction, code re-usability as a true OO provides you. You cannot define classes with abstract methods, private and protected members as an example.
The assembler will never provide you inheritance, abstraction, code re-usability as a true OO provides you. You cannot define classes with abstract methods, private and protected members as an example.
I understand what you mean, but from a "is it possible?" perspective... yes, it is possible.
First of all, since every language is translated into machine code, it is pretty possible to build OO assembly (including inheritance, abstraction and so on). The limitation is within our assemblers, not on assembly itself. Supporting those complex structures without assembler support would kill most benefit of OO, since the code will be barely understandable. Moreover, regular assemblers do not provide adequate checking (not controlling the access to private members, for instance).
As an example of solution, I suggest a carreful reading of "Art of Assembly Language" book (for x86 processors) which comes with a language called "HLA" (which means High Level Assembly) and can be described as an assembler with embeded support to complex data types such as structures and classes.
Of course the plain ASM code generated is awfully ugly and, if done on MSX, it would be slow for the reasons already presented (indirections inside indirections inside indirections...). But... it is possible.
Regards!
DJC
Mmmh, I remember many year ago, my university exam of Programming Languages. We did compile in bytecode a Java program with only paper and pen :-)
As far as remember, the main problem with a OO language is not the CPU power, but memory space to store all runtime objects.
I suggest you to read this book: Inside the Java Virtual Machine http://www.artima.com/insidejvm/blurb.html
objects only take space if they contain (non-static) data of course. Same as the data when using structs. And a tiny bit of administration.
If you would have all the time and knowledge in the world, wouldn't it be possible to make a Z80 targeted compiler that takes an OO language like Java or so, which optimizes that much that you get usable speed?
I understand what you mean, but from a "is it possible?" perspective... yes, it is possible.
Even in C++ you can break OO control and access private members by casting or pointer arithmetics. But this is against OO.
The OO compiler does the dirty job for you, all the overhead to protect your class and provide inheritance. If you have to do it manually, so it's not an OO compiler/assembler. You are just mimicking the C++ output.
Once you did all the dirty job, go to the base class and change it drastically. Now your are screwed you just have to rewrite all your code. Again, this is not what OO offers to you. So you cannot say: I program assembler OO rahter you'd say: i made a code that looks like it was coded in C++, but every time i need to change it i want to die!
objects only take space if they contain (non-static) data of course. Same as the data when using structs. And a tiny bit of administration.
If you would have all the time and knowledge in the world, wouldn't it be possible to make a Z80 targeted compiler that takes an OO language like Java or so, which optimizes that much that you get usable speed?
It is possible but it won't be compatible; there are things in Java which make it the environment we all know and 'love'. Like garbage collection, which would not work well on MSX as it takes up a lot of memory. And a lot of runtime checks for over/underflows would need to be left out simply for the massive overhead they present.
It would be an interesting project to attempt though; I would not take Java but some play language which compiles to C which in turn compiles to Z80. That way you can easily test the concept. OO in C is not very hard: you store you data in a struct which is named after the 'class' you are representing and you create functions like:
CLASSNAME* CLASSNAME_new()
etc
It would be easy to see that you can make a very easy translator from:
class Foo {
int bar;
constructor new(int bar) {
this.bar = bar;
}
void addToBar(int x) {
this.bar +=x ;
}
}
to
typedef struct Foo {
int bar;
}
void* Foo_new(int bar) {
Foo f;
f.bar = bar;
return bar;
}
void Foo_addToBar(void* obj, int bar) {
obj.bar = bar;
}
Something like that; it would be quite easy to do and experiment on an MSX with a C compiler. Right?