Author Topic: Object Oriented Languages for the CPC (or any other 8bit micro)!  (Read 5068 times)

0 Members and 1 Guest are viewing this topic.

Offline Ygdrazil

  • Global Moderator
  • 464 Plus
  • *****
  • Posts: 493
  • Country: dk
  • Liked: 48
  • Likes Given: 259
Hi

Does anyone know if there exists a compiler(or interpreter) for the CPC that is able to produce object code based on a Object Oriented Language (like Java, Ruby, C++ etc)

Just curious! Why is OO unknown on the CPC?

/Ygdrazil

Offline fano

  • Supporter
  • 6128 Plus
  • *
  • Posts: 835
  • Country: fr
  • Easter Egg Programmer
    • Easter Egg
  • Liked: 278
  • Likes Given: 614
Just curious! Why is OO unknown on the CPC?
2 ideas : because it is slower and bigger than low level languages and maybe because OO was not so popular in the 80's. (i had another stoopid assertion but i'll keep it for me  :P )
« Last Edit: 19:37, 18 January 10 by fano »
"NOP" is the perfect program : short , fast and (known) bug free

Follow Easter Egg products on Facebook !

Offline mr_lou

  • 6128 Plus
  • ******
  • Posts: 3.147
  • Country: dk
    • index.php?action=treasury
    • 8-bit Memoirs - a Blu-ray diskmag-like eBook about the 8-bit era
  • Liked: 1313
  • Likes Given: 2620
Slower and bigger yea.
The same goes for mobile development even today. To get more speed developers stay away from OO coding.

Offline Ynot.zer0

  • CPC6128
  • ****
  • Posts: 293
  • Country: gb
  • Liked: 23
  • Likes Given: 63
I remember there being a quote from the guy who actually invented the C++ programming language and he stated that it created about an extra 25% resource overhead to write the same thing in C++ than it did in C.

There are Pro's and Con's to both (which have their own debating forums on the web) - with modern day PCs no-one really cares about bloat, they just dump a JRE or .net CLR onto the PC along with a few more GB sticks of RAM into the machine and it'll handle the bloat.

(Do people get taught Pascal, Modula-2, C or ASM anymore? (that's where I started) or does it only start at the Visual Basic / Java / PHP / C# level now? If so, that is a shame....)



Yes, as stated above, having very limited resources on a 464/664/6128 the preferred option for speed was Assembler or C (I remember seeing Pascal aswell, but never used it on the Amstrad).

Interestingly enough, today, I just purchased a book called 'Programming in C on the Amstrad by Ian Sinclair' - I never coded in C on the Amstrad CPC and I fancied running up WinApe this weekend and writing a couple of simple apps - who knows maybe even write a game  :-)

« Last Edit: 10:56, 22 January 10 by ynot.zer0 »

Offline arnoldemu

  • Supporter
  • 6128 Plus
  • *
  • Posts: 5.336
  • Country: gb
    • Unofficial Amstrad WWW Resource
  • Liked: 2275
  • Likes Given: 3478
Hi

Does anyone know if there exists a compiler(or interpreter) for the CPC that is able to produce object code based on a Object Oriented Language (like Java, Ruby, C++ etc)

Just curious! Why is OO unknown on the CPC?

/Ygdrazil
A compiler is a difficult and time consuming thing to write, even more so on a cpc, and I don't think there would be much ram left for the code itself.

I did once consider writing a javavm for the cpc, but in the end decided it was going to take too long, it would take too much ram and be too slow.

The thing about java is that you would need to support most of the libraries to get anything useful, and that alone takes too much.

If I were to use a high level language I would probably use small-c or c and use sdcc or z88dk to write it.
These two generate reasonable sized binaries.

My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

Offline Ynot.zer0

  • CPC6128
  • ****
  • Posts: 293
  • Country: gb
  • Liked: 23
  • Likes Given: 63
anyone know where I can download a HiSoft C .DSK image from?

I'm sure I have it on 3" disc - but being in the middle of moving house, most of my retro tapes/discs are boxed up in storage at the moment.

thanks

tony

Offline Ygdrazil

  • Global Moderator
  • 464 Plus
  • *****
  • Posts: 493
  • Country: dk
  • Liked: 48
  • Likes Given: 259

HiSoft C - download: [http://www.cpcwiki.eu/index.php/HiSoft_C


When talking about C.. I know for sure that HiSoft advertised for a C++ compiler for the PCW!..

C++ is per definition OO..

So anyone knows where the HiSoft C++ can be downloaded from?

http://en.wikipedia.org/wiki/C%2B%2B about C++

/Ygdrazil

Offline TFM

  • Visit the mysteries of the CPC at www.futureos.de
  • Supporter
  • 6128 Plus
  • *
  • Posts: 9.899
  • Country: aq
  • Space Chicken for FutureOS is free!
    • index.php?action=treasury
    • FutureOS - The revolution on CPC!
  • Liked: 1982
  • Likes Given: 4650
If you want to work with OO on the CPC then you can use SymbOS. Like Prodatron told before SOS is totally OO! Everythng is OO there! Great isn't it. So get in contact with him. He already posted some infos about OO and SymbOS here in the forum, but I don't find the page now...
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

Offline Ynot.zer0

  • CPC6128
  • ****
  • Posts: 293
  • Country: gb
  • Liked: 23
  • Likes Given: 63
Does anyone know where the latest copy of SymStudio can be downloaded?

I checked: http://www.cpcwiki.eu/index.php/SymStudio  but the link is broken and all links on www.symbos.de are broken too.

I found http://genesis8.free.fr/frontend/programm/symstud7.zip but that is quite a few versions old.
« Last Edit: 10:45, 21 January 10 by ynot.zer0 »

Offline Octoate

  • CPC6128
  • ****
  • Posts: 290
  • Country: de
    • Octoate.de
  • Liked: 62
  • Likes Given: 326
Hi,
I uploaded Symstudio 0.95 to the CPC Wiki file hosting. You can download it from
http://share.cpcwiki.eu/123585
--

Offline Executioner

  • Supporter
  • 6128 Plus
  • *
  • Posts: 783
  • Country: au
  • WinAPE Developer
    • WinAPE
  • Liked: 392
  • Likes Given: 60
If you want to work with OO on the CPC then you can use SymbOS.

SymbOS itself uses OO constructs for the GUI and other items, but it won't provide you with an OO programming language.

Quote
Like Prodatron told before SOS is totally OO! Everythng is OO there! Great isn't it. So get in contact with him. He already posted some infos about OO and SymbOS here in the forum, but I don't find the page now...

That sort of put's an end to the myth that writing OO code is so much less effiecient than non-OO code doesn't it. I'm certain a version of SymbOS written in C would be much faster ;) or just a pure assembler version with no OO constructs. Just think, SymbOS 25% faster  ::)

Offline Ynot.zer0

  • CPC6128
  • ****
  • Posts: 293
  • Country: gb
  • Liked: 23
  • Likes Given: 63
apologies Executioner, I was referring to using C++ and the 25%, not Assembler.

Sure, if it's written in Assembler with OO techniques it's going to be be awesomely fast and a lot faster than any higher level languages (such as C) and not have the bloat overhead of C++ or Java.



I just checked out the SymStudio and I see what you mean, it does not provide you with an OO programming language - it is still Assembler behind the scenes.  Would that be one of the reasons it did not obtain a greater adoption?

Offline Executioner

  • Supporter
  • 6128 Plus
  • *
  • Posts: 783
  • Country: au
  • WinAPE Developer
    • WinAPE
  • Liked: 392
  • Likes Given: 60
apologies Executioner, I was referring to using C++ and the 25%, not Assembler.

I was just havin' a bit of fun with your (and TFM's) comments, hence the smileys. Still, I think a good C++ compiler and/or JIT may be able to produce code that's nearly as fast and a lot easier to maintain than procedural C code, and you tend to use more efficient data structures simply because they're easy (eg. Hashtable, LinkedList etc).

I actually did some performance tests between Java, Delphi and C once and found Java's String handling was much much faster than C null terminated character arrays. It was faster than Delphi too, but that was mainly because the JVM doesn't do any memory deallocation until a GC.

Offline TFM

  • Visit the mysteries of the CPC at www.futureos.de
  • Supporter
  • 6128 Plus
  • *
  • Posts: 9.899
  • Country: aq
  • Space Chicken for FutureOS is free!
    • index.php?action=treasury
    • FutureOS - The revolution on CPC!
  • Liked: 1982
  • Likes Given: 4650
I was just havin' a bit of fun with your (and TFM's) comments, hence the smileys.

:-)

I have my fun here too ;-) And that's the right way I think. Funny people live longer ;-)

But back to OOP. IMHO it depends which kind of software you want to produce. If a certain OS or application is supposed to run with a variety of hardware-environments or OSes then it really makes sense to user higher languages like C or even use OOP.

However, if you developp an OS or an application for a defined hardware or OS-environment, then the best choice is assembler. And the best choice of data-structures depends on the CPU. This is pure pragmatism. Further the so called spaghetti code is ofter superior to the so called structured programming. People may don't like this (because they want to have a high degree of order in their things), but nevertheless it's true and can be prooven right by everybody who is able to code.
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

Offline AMSDOS

  • Supporter
  • 6128 Plus
  • *
  • Posts: 3.915
  • Country: au
    • index.php?action=treasury
    • Programs for Turbo Pascal 3
  • Liked: 1123
  • Likes Given: 1900
There's some interesting reading about Object Orientated Programming on this Wikipedia page which interestingly enough people were talking about this brand of coding back in the 1950s. Simula 67 is one of the earliest Object Orientated programming languages, though another early one is Smalltalk which became commercially available with Smalltalk-80.

I'm unsure if either of these languages was available for the Amstrad, there is certainly no mention of them on the Wiki - most likely if there was, there maybe some small scaled down version of the language which operates through CP/M.

You would have to remember though that it was the early 70s when Unix came out, and it took a long time before anything the size of a PC would be able to run it, so even some of those PDP made back in the 60s were the size of your fridge, they were pretty powerful too, CP/M is merely a Toy by comparison.  8)
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Offline duncan_bayne

  • CPC464
  • **
  • Posts: 49
  • Country: au
    • Duncan Bayne
  • Liked: 27
  • Likes Given: 3
Just curious! Why is OO unknown on the CPC?

It's not.  Although there are languages with built-in support for some OO principles (like C++  :'( and Java) there's nothing stopping you writing OO code in plain old C.

Check out Object Oriented Programming in ANSI C for a good explanation and some solid examples.

Also, note that adding OO functionality to some languages is remarkably easy.  As Rudolf Winestock put it:

Quote
Imagine adding object orientation to the C and Scheme programming languages. Making Scheme object-oriented is a sophomore homework assignment. On the other hand, adding object orientation to C requires the programming chops of Bjarne Stroustrup.

Offline sigh

  • 6128 Plus
  • ******
  • Posts: 1.283
  • Liked: 576
  • Likes Given: 59
Further the so called spaghetti code is ofter superior to the so called structured programming. People may don't like this (because they want to have a high degree of order in their things), but nevertheless it's true and can be prooven right by everybody who is able to code.

I'm curious about this. What are the benefits of "spaghetti" code in that it is more superior to structured programming? With structured programming, other people can read your code (if you want) more easily if your working in teams and it also may make debugging less painful?

So what are the benefits of spaghetti code? Are the code lines shorter and the programs a little faster?

Offline duncan_bayne

  • CPC464
  • **
  • Posts: 49
  • Country: au
    • Duncan Bayne
  • Liked: 27
  • Likes Given: 3
So what are the benefits of spaghetti code? Are the code lines shorter and the programs a little faster?


Offline arnoldemu

  • Supporter
  • 6128 Plus
  • *
  • Posts: 5.336
  • Country: gb
    • Unofficial Amstrad WWW Resource
  • Liked: 2275
  • Likes Given: 3478
I'm curious about this. What are the benefits of "spaghetti" code in that it is more superior to structured programming?
Spaghetti code can exist anywhere and it's always bad news.

Code *should* be designed well, with documentation in the code AND made as simple as possible.
Make it more complex and it'll break more easily, be harder to debug, and harder to understand.

My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

Offline AMSDOS

  • Supporter
  • 6128 Plus
  • *
  • Posts: 3.915
  • Country: au
    • index.php?action=treasury
    • Programs for Turbo Pascal 3
  • Liked: 1123
  • Likes Given: 1900
Off-Topic:
In the Small-C thread I made a small BASIC program with Look-up Table and some machine code with little demonstration of Rolling the Screen. Originally the demonstration code I had two WHILE...WEND loops, the first is an infinite loop, the second had a displaced offset in the Lookup table so that when I call the routine to move the screen, everything would move to the right place. As soon as I changed that second WHILE...WEND to a FOR...NEXT, the program was noticeably faster because I didn't have to Increment values and instead I was setting the values that FOR...NEXT needed to know.

Of course the problem with FOR...NEXT is you cannot have an infinite Loop like WHILE...WEND, er, well, you can in some sense, though normally the alternative for using WHILE...WEND is to use some sort of conditional GOTO or use GOTO for some sort of Infinite Loop and of course if that's faster than a WHILE...WEND, then it maybe better in some sense, though to have a GOTO like that, it would still be structured cause GOTOs in that sense are Localised.
If a program was a 10-liner, then there maybe some restriction to the amount of GOTOs you'd have in them, though larger programs would allow it to happen.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Offline TFM

  • Visit the mysteries of the CPC at www.futureos.de
  • Supporter
  • 6128 Plus
  • *
  • Posts: 9.899
  • Country: aq
  • Space Chicken for FutureOS is free!
    • index.php?action=treasury
    • FutureOS - The revolution on CPC!
  • Liked: 1982
  • Likes Given: 4650
Spaghetti code can exist anywhere and it's always bad news.

Code *should* be designed well, with documentation in the code AND made as simple as possible.
Make it more complex and it'll break more easily, be harder to debug, and harder to understand.
Should it? For me there is only one Thing that Counts at the end: The Features/properties of the final program. I leave it to others to program structured, as Long as my Approach or program is more quick at the end.
However, we will never agree here. You argue based on a mind model and I argue according to Efficiency and pragmatics.
Your Approach is the best for teaching purposes. Mine for the best programs.  8)
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

Offline robcfg

  • Supporter
  • 6128 Plus
  • *
  • Posts: 2.350
  • Country: se
  • 8-Bit Technomancer
    • index.php?action=treasury
  • Liked: 1046
  • Likes Given: 2535
Hey TFM!


I think your approach work best for small projects or projects held by one person. The moment you have a big project with several people working on it, you better have a clean, structured code.


Also, abusing spaghetti code can lead to not being able to optimize it beyond certain point as it would need a complete rewrite.


Then again, programming styles are quite personal  ;)

Offline PhilZeVibe

  • 464 Plus
  • *****
  • Posts: 471
  • Country: fr
    • CPCBox - CPC emulator in JavaScript
  • Liked: 165
  • Likes Given: 187
Edgar Dijkstra said it best ~50 years ago! :)
https://files.ifi.uzh.ch/rerg/arvo/courses/kvse/uebungen/Dijkstra_Goto.pdf

"GoTo Statement Considered Harmful
For a number of years I have been familiar with the observation that the quality of programmers is a decreasing function of the density of goto statements in the programs they produce.
More recently I discovered why the use of the goto statement has such disastrous effects, and I became convinced that the goto statement should be abolished from all "higher level" programming languages (i.e. everything except, perhaps, plain machine code)."
Atwood's law (2007): "Any application that can be written in JavaScript, will eventually be written in JavaScript."

Offline TFM

  • Visit the mysteries of the CPC at www.futureos.de
  • Supporter
  • 6128 Plus
  • *
  • Posts: 9.899
  • Country: aq
  • Space Chicken for FutureOS is free!
    • index.php?action=treasury
    • FutureOS - The revolution on CPC!
  • Liked: 1982
  • Likes Given: 4650
Hi Rob,
Well, I don't pray spaghetti codes. It's just one means the can make programs better. There are others too.
 
Of course you are right for Projects done by a lot of programmers together. In this case structures just make life more easy. :)
 
However on CPC I prefer to have a better (means more quick) program, instead of having a program which is slower, but has nice looking source code ;-)
For teaching purposes it may be very different again.
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

Offline AMSDOS

  • Supporter
  • 6128 Plus
  • *
  • Posts: 3.915
  • Country: au
    • index.php?action=treasury
    • Programs for Turbo Pascal 3
  • Liked: 1123
  • Likes Given: 1900
Spaghetti Code in Pascal and C
« Reply #24 on: 03:18, 11 July 13 »
I think in Pascal and C those languages make it harder to come up with Spaghetti code unless your intention was to make Spaghetti Code, certainly in a non-Programmers environment like Pascal one would have to setup Procedures everywhere and have Procedure calling Procedure and going backward and forward, using variables to trigger different conditions found in those Procedures, the Pascal languages I've used have GOTOs in them, though unlike a BASIC program a GOTO can only stay within the same routine.  I guess the same would apply for real languages like Fortran C, so to intentionally make a Spaghetti Code program in those languages would involve a lot of setting up. But I think it's fortunate that GOTO isn't limited to Assembly or M/C, because there is argument there that it can be used correctly or help improve an program, I normally just stay away from it wherever possible though.  ;D
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3