CPCWiki forum

General Category => Programming => Topic started by: Ygdrazil on 17:50, 18 January 10

Title: Object Oriented Languages for the CPC (or any other 8bit micro)!
Post by: Ygdrazil on 17:50, 18 January 10
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
Title: Re: Object Oriented Languages for the CPC (or any other 8bit micro)!
Post by: fano on 18:18, 18 January 10
Quote from: Ygdrazil on 17:50, 18 January 10Just 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 )
Title: Re: Object Oriented Languages for the CPC (or any other 8bit micro)!
Post by: mr_lou on 13:08, 19 January 10
Slower and bigger yea.
The same goes for mobile development even today. To get more speed developers stay away from OO coding.
Title: Re: Object Oriented Languages for the CPC (or any other 8bit micro)!
Post by: Ynot.zer0 on 17:01, 19 January 10
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  :-)

Title: Re: Object Oriented Languages for the CPC (or any other 8bit micro)!
Post by: arnoldemu on 17:07, 19 January 10
Quote from: Ygdrazil on 17:50, 18 January 10
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.

Title: Re: Object Oriented Languages for the CPC (or any other 8bit micro)!
Post by: Ynot.zer0 on 22:04, 19 January 10
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
Title: Re: Object Oriented Languages for the CPC (or any other 8bit micro)!
Post by: Ygdrazil on 22:44, 19 January 10

HiSoft C - download: [http://www.cpcwiki.eu/index.php/HiSoft_C (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 (http://en.wikipedia.org/wiki/C%2B%2B) about C++

/Ygdrazil
Title: Re: Object Oriented Languages for the CPC (or any other 8bit micro)!
Post by: TFM on 22:50, 20 January 10
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...
Title: Re: Object Oriented Languages for the CPC (or any other 8bit micro)!
Post by: Ynot.zer0 on 09:32, 21 January 10
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.
Title: Re: Object Oriented Languages for the CPC (or any other 8bit micro)!
Post by: Octoate on 10:42, 21 January 10
Hi,
I uploaded Symstudio 0.95 to the CPC Wiki file hosting. You can download it from
http://share.cpcwiki.eu/123585 (http://share.cpcwiki.eu/123585)
Title: Re: Object Oriented Languages for the CPC (or any other 8bit micro)!
Post by: Executioner on 07:27, 22 January 10
Quote from: TFM/FS on 22:50, 20 January 10
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.

QuoteLike 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  ::)
Title: Re: Object Oriented Languages for the CPC (or any other 8bit micro)!
Post by: Ynot.zer0 on 10:10, 22 January 10
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?
Title: Re: Object Oriented Languages for the CPC (or any other 8bit micro)!
Post by: Executioner on 12:02, 22 January 10
Quote from: ynot.zer0 on 10:10, 22 January 10
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.
Title: Re: Object Oriented Languages for the CPC (or any other 8bit micro)!
Post by: TFM on 01:34, 31 January 10
Quote from: Executioner on 12:02, 22 January 10
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.
Title: Re: Object Oriented Languages for the CPC (or any other 8bit micro)!
Post by: AMSDOS on 10:29, 06 July 13
There's some interesting reading about Object Orientated Programming on this Wikipedia page (http://en.wikipedia.org/wiki/Object-oriented_programming) 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)
Title: Re: Object Oriented Languages for the CPC (or any other 8bit micro)!
Post by: duncan_bayne on 23:10, 09 July 13
Quote from: Ygdrazil on 17:50, 18 January 10Just 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 (http://www.planetpdf.com/codecuts/pdfs/ooc.pdf) 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 (http://www.winestockwebdesign.com/Essays/Lisp_Curse.html):

QuoteImagine 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.
Title: Re: Object Oriented Languages for the CPC (or any other 8bit micro)!
Post by: sigh on 23:53, 09 July 13
Quote from: TFM/FS on 01:34, 31 January 10
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?
Title: Re: Object Oriented Languages for the CPC (or any other 8bit micro)!
Post by: duncan_bayne on 00:19, 10 July 13
Quote from: sigh on 23:53, 09 July 13So what are the benefits of spaghetti code? Are the code lines shorter and the programs a little faster?

(http://25.media.tumblr.com/89598a218da9fecb96f0a9f9b575c3b1/tumblr_mfp8971y771qclwico1_400.jpg)
Title: Re: Object Oriented Languages for the CPC (or any other 8bit micro)!
Post by: arnoldemu on 09:28, 10 July 13
Quote from: sigh on 23:53, 09 July 13
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.

Title: Re: Object Oriented Languages for the CPC (or any other 8bit micro)!
Post by: AMSDOS on 09:34, 10 July 13
[ot]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.[/ot]
Title: Re: Object Oriented Languages for the CPC (or any other 8bit micro)!
Post by: TFM on 16:05, 10 July 13
Quote from: arnoldemu on 09:28, 10 July 13
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)
Title: Re: Object Oriented Languages for the CPC (or any other 8bit micro)!
Post by: robcfg on 16:13, 10 July 13
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  ;)
Title: Re: Object Oriented Languages for the CPC (or any other 8bit micro)!
Post by: Phi2x on 16:55, 10 July 13
.
Title: Re: Object Oriented Languages for the CPC (or any other 8bit micro)!
Post by: TFM on 20:02, 10 July 13
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.
Title: Spaghetti Code in Pascal and C
Post by: AMSDOS on 01: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
Title: Re: Object Oriented Languages for the CPC (or any other 8bit micro)!
Post by: fano on 06:23, 11 July 13
The real question is what do you mean with to make a program  'better' ? fast ? small ? readable ? easy to update ?
Unstructured programming (spaghetti code) may be needed sometimes to improve speed of a program or to reduce binary size but must stay an exception.It is so difficult sometime to understand your own code after months so if it is not correctly written , it is a nightmare (and for other people it is worst)
To be honnest i love programming itself and programming for the CPC so how is good my code (readable, maintainable, extendable,(auto-)documented) is important and how good is my binary for the CPC (speed,size) is important too but when speed and size are not needed, i (try) give priority to good code (to resume , how you do is important like what you do  ;D )

Quote from: AMSDOS on 01:18, 11 July 13But 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
Let's say 'GOTO' could be used when the language you are using doesn't own adapted control structures.The best exemple for me is the locomotive Basic that lacks control structures (procedure, functions, ENDIF , SELECT CASE,ect).Since 15 years, i use a derived Basic (that get a lot of things from C) that owns GOTO but i never have to use it because language owns adapted control structures.
About Assembly , this is a particular example as you can make nicely structured program despite that seems to have jumps everywhere, major part of jumps must be seen like 'ELSE', 'ENDIF', 'CASE' , 'LOOP UNTIL' , 'WEND' and so on of other languages.About OO , modern assembler with powerfull preprocessor can help you to have OO approach in assembly.
Title: Re: Object Oriented Languages for the CPC (or any other 8bit micro)!
Post by: JonB on 12:01, 25 July 13
Quote from: TFM/FS on 16:05, 10 July 13
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)

Deopends how you measure "best". Commercial software (I don't mean games by the way) has a lifecycle after it is delivered, and is frequently the subject of maintenance and upgrades. This activity is usually costly and you don't really want to have some hacked up piece of spaghetti code adding to that cost. I agree in certain circumstances (usually where space or CPU cycles are at a premium) advanced techniques that are far above the capabilities of the mediocre developer are necessary, but in this day and age there is no shortage of resources in most applications. Therefore the common perception is that code quality is better than [whatever you are arguing in favour of].

I think it's wrong to argue that your approach is correct all the time - as in all things, it's horses for courses.
Title: Re: Object Oriented Languages for the CPC (or any other 8bit micro)!
Post by: TFM on 16:02, 25 July 13
Oh well, agree and disagree.  :)  CPC is my hobby, so I have the time to try to bring software as close as much to perfection. If I would do commercial software, sure, then things would be different - starting with a tight time schedule usually.

However, Spaghetti code is usually very much misunderstood. Spaghetti code is hard to read, but more efficient than all that easy-to-read-modular stuff.

It always depends what you want.
Title: Re: Object Oriented Languages for the CPC (or any other 8bit micro)!
Post by: TFM on 16:05, 25 July 13
But - sorry for the off topic - back to topic...

OO programming can be seen in SymbOS (Prodatron explains that somewhere here). Maybe this would provide an easy start into it. I dunno exactly which languages you can use, guess he has some way of using C IIRC.
Powered by SMFPacks Menu Editor Mod