OPIA - A full OOP language for z80

A forum where you can announce your awesome project(s).

Moderator: MaxCoderz Staff

Post Reply
Shkaboinka
New Member
Posts: 6
Joined: Mon 08 Feb, 2010 5:21 am

OPIA - A full OOP language for z80

Post by Shkaboinka »

Sorry for linking it in like this, but I already have it typed up how I like it (please paste the link):

http://tinyurl.com/5wrpnaf

I've been designing and redesigning this language off and on for several years, and I expect it to have similar results (or capabilities, at least) as the AXE Parser did. I am not in competition though, because the two languages are quite different in design & usage. For example, OPIA will require code to be written and compiled on your computer and does not just have "what you need" built into the language; but it does provide everything you'd expect from a language like C#/Java/C++, but designed for a small machine.

I am FINALLY very close to being able to code it, but I'd like some feedback and opinions. I'm certain that nobody will understand all the documentation and theory as well as I do (since it's mine), so I'd be more than happy to fill in anything I left vague, or simplify anything I made complex.

I promise this language will add another dimension to z80 programming that was not there before, and will enhance the community if it's given a chance.
Xeda
New Member
Posts: 42
Joined: Sun 06 Feb, 2011 7:08 am

Re: OPIA - A full OOP language for z80

Post by Xeda »

Cool, I am checking it out right now :) I have made a few programming languages in my time, too, so if I can provide feedback, I will (I know the importance). However, I am not that savvy when it comes to programming styles. I know TI-BASIC and Z80 assembly and that is about all my brain wants to understand :/
User avatar
NanoWar
Extreme Poster
Posts: 365
Joined: Fri 17 Dec, 2004 6:39 pm
Location: #$&"%§!
Contact:

Re: OPIA - A full OOP language for z80

Post by NanoWar »

This sounds really interesting. One thing I dont get: How would you do garbage-collecting since this isn't an interpreted language? Just "freeing" allocatable space?

Also, I like C# style of ref and out. Function calls should include them, because ASM probably is one of the most confusing languages out there when it comes to program flow.

I assume you are backing local variables with ASM registers. What happens when you run out of registers? Or do you reserve them for calculation only? A short example usage would be neat to clear things up.

So, actually, to make all this object-oriented, most of the code would run in 768 bytes of RAM and the program only provides the semantic? Whoa compiler noob here. I'd love to understand the basic concept, memory layout etc :) .
Revolution Software
Shkaboinka
New Member
Posts: 6
Joined: Mon 08 Feb, 2010 5:21 am

Re: OPIA - A full OOP language for z80

Post by Shkaboinka »

The official documentation, project hosting, and repository is now at Google Code: http://tinyurl.com/z80opia

There has been much progress and discussion, and it's ready for implementation. Most of this discussion is at Cemetech: http://www.cemetech.net/forum/viewtopic.php?t=4675

@Nanowar:

The language is not interpreted; it is fully compiled. However, the compiler will trace values through the program as it compiles in order to precompute as much as possible. For example, given { a =5; b = a*2; c = a+b; return c*a; }, the compiler will know that b is 10, c is 15, and that the return value is 75. Furthermore, it will also notice that since 5 can be used in place of a, 10 in place of b, and 15 in place of c (and because those variables are not used for anything else), that it can just remove those variables altogether. Thus the compiler would optimize that code to just be { return 75; } ... In turn, it would realize that such a simple function might as well just be replaced by the number 75. ... etc.

I will use ref and out parameters, but you will not have to put them in the call (personal choice).

Local variables are backed by static memory addresses within the program (in assembly, that's a label followed by a ".db" placed where code won't run into it). However, as it is compiling expressions into assembly, it trace which variables (AND their values, as possible) are loaded into which registers, so that it can use those registers instead. Also, it will skip actually assigning values back to static addresses if it can tell that that address will NOT be used before it is given another value (or before the end of the context). This is called "liveness analysis" ("dead" variables can be cut out until they become "alive" again; meaning that they hold a value which will be needed later).

If you'd like to learn more about compilers, view the documentation link I posted, which contains 3 great references. Also, you can talk to me directly (shkaboinka@gmail.com). I've spent the last 7 years dabbling with the topic :)
Shkaboinka
New Member
Posts: 6
Joined: Mon 08 Feb, 2010 5:21 am

Re: OPIA - A full OOP language for z80

Post by Shkaboinka »

OPIA has evolved Quite a bit! There is a TON of activity on my forum at Cemetech, and moderately at Omnimaga (since June/July of 2011). I believe I've settled on an excellent balance for low-level polymorphism (thanks to ideas from Google's Go language). The main project is at Google Code (see the overview). There is a short-link posted there if you want an easy-to-remember link; but the main-link is:

http://code.google.com/p/opia/

I don't want to pull discussion from one site to another, but to spark discussion here (if it wills), you might search for OPIA at omnimaga or cemetech to see what's been discussed (it would be a LOT to post here)

EDIT: Obviously I had already posted something similar before ... but it's still quite evolved since then, so take a look :)
chickendude
Extreme Poster
Posts: 340
Joined: Fri 07 Jul, 2006 2:39 pm

Re: OPIA - A full OOP language for z80

Post by chickendude »

Have you started the actual coding? It'd be interesting to see the resulting ASM code of a few simple programs.
Shkaboinka
New Member
Posts: 6
Joined: Mon 08 Feb, 2010 5:21 am

Re: OPIA - A full OOP language for z80

Post by Shkaboinka »

It's interesting to notice that I've come across most of you in other forums already :)

...Nevertheless, MaxCoderz deserves an update on OPIA. Here is a refresh on what the language is/does (and I will include a link to the current language overview, which has changes a LOT):

OPIA is a C-like language (functions, variables, expressions, constructs, etc.) which brings all the power of polymorphism seen in OOP languages like Java/C# to the z80 -- but in simpler terms which expose function-pointers and method-pointers more directly, but cleanly (structs implement interfaces automatically just by having the correct methods -- thus new polymorphic behavior can be added to something without any changes to the base code or to its underlying structure!).

OPIA is very focused on low-level representation: Variables, arrays, structs, and functions are designed to match raw/native representations so that they can be tied DIRECTLY into any underlying system (e.g. use OS values as variables or call system routines as functions without extra overhead -- it's 1-to-1). Everything is designed to be stored/coded "as it would be" in assembly. OPIA has the capability to be for z80 what C is for larger systems.

OPIA will use Data-flow analysis and Liveness-Analysis, etc., to trace values through the code and precompute/optimize it as much as possible -- So go ahead and use a loop to initialize that array, and the compiler will convert it an embedded value. In addition, you can use the $ operator to REQUIRE this (and cause the compiler to take more liberties) and, for example, tell the compiler to interpret a function and embed the result as a value.

The compiler will be in Java (already started) as a command-line interface. However, it will also be modularized as a java API so that other tools can be made for the language which use the compiler to build/analyze code (Tokens, Abstract syntax trees, Optimization, Compilation, etc.) -- This means things like Notepad++, or new tools like a visual (rather than textual) code editor.

Rather than providing "everything you need" in one package, OPIA only provides core features and must be compiled on your computer. However, unlike those all-in-one packages (which are amazing, btw), OPIA can be expanded and integrated for anything and everything z80. I will be writing the core compiler (which is viewable at google code), but everyone else will have the chance to expand the language via includes/libraries/etc.

There's been a ton of discussion already, but if anything picks up here, I will try to post some summaries of past discussion -- the language design is being made concrete before I get too deep into making the compiler. Discussion will continue in forums, but official documentation of what the language "IS" so far can always be found at:

http://tinyurl.com/z80opia
Shkaboinka
New Member
Posts: 6
Joined: Mon 08 Feb, 2010 5:21 am

Re: OPIA - A full OOP language for z80

Post by Shkaboinka »

THE TIME HAS COME! (the walrus said) ... I have reviewed all comments, topics, posts, etc. all the way back until before I switched the language to a "Go-ish" layout, and I finally feel that OPIA is fully (syntactically and semantically) defined and decided (or at least, as much as it can be before it is coded) -- which I wanted to do before I did anything huge with the compiler.

My plans (when time permits between school, work, moving, and my soon to be first-child) are as follows:

(1) lay out a careful plan for the compiler pipeline/design. This has already been 90% grasped in my head alone (after having poured over compiler books and articles and mental experiments "for fun"), but I have recently re-read most of the chapters in Modern Compiler Implementation In Java (it's the BEST!), and been charting out a careful comparison of my design versus what everyone else swears by -- and it turns out that I am not deviating terribly much. Expect an analysis and layout of the plan from me in the future (I have it mostly set).

(2) Update the Language Overview as much as I see fit (I don't want to be too picky with it, but I do want to make sure that every aspect is well documented so nothing falls through the cracks).

(3) Jump into the coding. I will keep everyone updated as that progresses. The exciting thing is that I will release it in modules, so that you can see everything up to the tokenizing & preprocessing (this is it's current state, though I may rework that a bit to be SLIGHTLY more modular), parsing/tree-building, etc. Every aspect of the pipeline will be explained, as in (1).

Anyone is welcome to ask questions about anything they think is lacking or confusing, and I am still open to considering some changes/additions; but I don't foresee anything that would change the language enough to put of coding it now.

Side note: as for interpreted aspects, the default will be to precompute as much as possible without unraveling loops or recursive calls (unless the contents clearly have no runtime side-effects), and that the $ operator will be "deep"/recursive, causing a thing (and ALL of it's contents, except for references to externally defined entities) to be fully precomputed.
Post Reply