Hate: In love with C
Posted: Sat May 30, 2009 9:18 pm
Ever since I discovered tcc, I've been toying with the idea of making a LÖVE-like thing going with pure C instead of Lua. Let's tentatively call it Hate. No umlaut.
Tiny C Compiler can be embedded into other C programs and compile and run code dynamically. It should be pretty easy hook up PhysicsFS so that tcc can read the source from that archive. We could use .hate files with main.c and other source code along with all resources. From what I understand, tcc compiles really fast, so I don't think loading time is a problem except for really huge projects.
To run a .hate file, you would obviously need Hate installed. Hate would come with a standard set of libraries very similar to the way LÖVE does. The Hate tool would be capable of compiling a .hate into a stand-alone binary for the current platform. People will not need Hate installed to run the resulting binary.
There could also be a webpage where you submit your .hate file, and builds for all platforms appeared after a time, submitted by volunteers (semi-automatically by the hate binary?).
I'm feeling a little conflicted by this "idea", because it is perhaps not substantially different from a normal C library. A hypothetical libhate would certainly be compilable and usable in other C compilers too (not that it would be a bad thing). On the other hand, LÖVE isn't substantially different from a normal Lua library either. Also, Lua is one of the most newbie friendly languages out there ... C isn't. I'm having a hard time imagining C programmers accepting anything except the way they've done things for the last 30 years.
Ok, I'll stop now, while it's still under the threshold of tl;dr. I realize that I haven't really asked any questions in this post, I'm just checking if someone finds this interesting. Hopefully I can supress my urge to find out whether I can pull it off or not so I can focus on LÖVE.
Tiny C Compiler can be embedded into other C programs and compile and run code dynamically. It should be pretty easy hook up PhysicsFS so that tcc can read the source from that archive. We could use .hate files with main.c and other source code along with all resources. From what I understand, tcc compiles really fast, so I don't think loading time is a problem except for really huge projects.
To run a .hate file, you would obviously need Hate installed. Hate would come with a standard set of libraries very similar to the way LÖVE does. The Hate tool would be capable of compiling a .hate into a stand-alone binary for the current platform. People will not need Hate installed to run the resulting binary.
There could also be a webpage where you submit your .hate file, and builds for all platforms appeared after a time, submitted by volunteers (semi-automatically by the hate binary?).
Code: Select all
/**
* Imaginary Hate code. Yes I realize this is just mimicing SDL.
* This example is 2D only, but I do not rule out 3D support as
* a possibility.
**/
#include <hate>
int main(int argc, char ** argv)
{
static hate_Event e;
hate_Image * image;
hate_init(argc, argv);
hate_setdisplay(800, 600, 0);
// Load.
image = hate_newimage("hello.png");
while(1)
{
while(hate_pollevent(&e))
{
switch(e.type)
{
case HATE_QUIT:
hate_quit();
return 0;
}
}
hate_clear(); // Clear screen.
hate_drawimage(image, 0, 0); // Draw the image.
hate_present(); // Presents on screen.
}
return 0;
}
Ok, I'll stop now, while it's still under the threshold of tl;dr. I realize that I haven't really asked any questions in this post, I'm just checking if someone finds this interesting. Hopefully I can supress my urge to find out whether I can pull it off or not so I can focus on LÖVE.