Mad Idea

All topics about ZGameEditor goes here.

Moderator: Moderators

Post Reply
kattle87
Posts: 402
Joined: Wed Sep 26, 2007 9:06 am
Location: Italy

Mad Idea

Post by kattle87 »

Sorry but I have been away for a while...

There is an idea that has been in my head for a whole day long.
I started thinking about this: what if ZGE created C++ source code (or something like that that can be compiled with something small and portable, like maybe even FreePascal) and compiled the binary instead of interpreting everything? We would really give a cut to a lot of problems...
I think this would be great...

EG: if compiled in C/C++, one could place ZExpressions directly in source code. If a particular function is found, than the right headers are added to the code, so only needed functions are in the executable. (Plus, we get Arrays, Functions and so on for free :P)

How much work could it take??? Months, more?

What is your opinion about that?
In the fall of 1972 President Nixon announced that the rate of increase of inflation was decreasing. This was the first time a sitting president used the third derivative to advance his case for reelection.
-=Hugo Rossi=-
User avatar
VilleK
Site Admin
Posts: 2277
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

It is a good idea.

Benefits:
- full power and performance
- no need to invent a new language or compiler

However there are also some drawbacks:

- every ZGE user needs to install a compiler on their computer. No more a simple unzip-to-install installation of the ZGE-environment.
- the installed compiler also needs to be able to compile cross-platform which usually means having lots of extra files and configuration
- it will take longer to generate the zge applications, and previews inside zdesigner won't be possible
- pascal/c++ are powerful but also difficult. It is easy for users to cause crash-bugs and memory leaks. With a scripting language you can protect against those problems.

I do want to be able to use an existing compiler instead of writing one myself. The dotnet C# compiler can be called in-memory without the need for generating files on disk, so this could be used within zdesigner even for previews. What would be needed is a runtime engine in zge for executing compiled dotnet bytecode.
kattle87
Posts: 402
Joined: Wed Sep 26, 2007 9:06 am
Location: Italy

Post by kattle87 »

Correct me, but C# needs dotnet, right? so no "single file" again... Or the executable can be made self-sufficient? what would be the dimension of the file?

BTW: I'm looking for small C++ compilers, some are as little as 3 MB but do need some extra libraries I think. FreePascal is 20 MB download, don't know how much for installed vers
In the fall of 1972 President Nixon announced that the rate of increase of inflation was decreasing. This was the first time a sitting president used the third derivative to advance his case for reelection.
-=Hugo Rossi=-
User avatar
VilleK
Site Admin
Posts: 2277
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Many (most?) users already have dotnet on their computers. Microsoft wants it to be there so you almost have to actively choose not to have it to avoid it. But yes it would be a dependency that ZGE currently does not have. The generated exe-files would still be self-contained without external dependencies and need not be larger than today, so still 64kb.

Small C++ compilers that can be redistributed are interesting, post links here if you find any.
User avatar
Kjell
Posts: 1883
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hi guys,

My primary reason for working with & on ZGE is the real-time preview. This saves heaps of time compared to libraries that need to be compiled every time you want view any changes. As Ville mentioned, the only sane way of pulling this off is through interpretation.

+ Slightly off-topic, but since Arrays where mentioned again :arrow: I've been using a temporarily? solution for this in the form of three components. Even though the created Arrays cannot be accessed directly from ZExpressions ( yet ) .. which would be nicer, it does the job for now.

K
Attachments
Array.gif
Array.gif (6.28 KiB) Viewed 8909 times
User avatar
VilleK
Site Admin
Posts: 2277
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Looks interesting Kjell. I guess this is a possibility for 2d-arrays of numeric values. With some hacking in the zexpression-parser the arrays can be used from expressions. Send me the source if you want to, or you could start a new array-thread and attach it there.
kattle87
Posts: 402
Joined: Wed Sep 26, 2007 9:06 am
Location: Italy

Post by kattle87 »

idea should be: pass the address of array incremented of the index to the parser, right? I wanted to give it a try but it was quite difficult and I did not try playing with the ZGame "virtual machine" :/ Plus I have had some serious problems with my graphic video card recently and my PC needed mantainance...


BTW: the tiny C++ compiler is the one from http://www.digitalmars.com/
In the fall of 1972 President Nixon announced that the rate of increase of inflation was decreasing. This was the first time a sitting president used the third derivative to advance his case for reelection.
-=Hugo Rossi=-
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

you have my love,.

Post by jph_wacheski »

interesting discusion,. more power is always apealing! however I do agree that the realtime previewing is a danm fine thing.
The actual implementing of any of this is way outside of my interests (makin' games!) so I leave these things to those who are interested,. and quite able,. of course I will adopt the things you guys come up with that allow me to easily access more power and features,. godspeed and good luck!
iterationGAMES.com
User avatar
VilleK
Site Admin
Posts: 2277
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

kattle87 wrote:idea should be: pass the address of array incremented of the index to the parser, right?
Yes a new component for the zge expression runtime, something like a LoadArrayPtr. The array itself is a property on the component, the indices are popped of the stack. It then calculates the actual adress (array + indices), and push onto stack. This address can then be used for assign or load value. That's the idea anyway, I haven't checked the source to see if I remember correctly.

Digitalmars makes interesting products. I've been looking at the D compiler a couple of times, it is quite impressive.
Post Reply