Page 1 of 6

Hate: In love with C

Posted: Sat May 30, 2009 9:18 pm
by rude
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. :ultraglee:

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;
}
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. :ultraglee:

Re: Hate: In love with C

Posted: Sun May 31, 2009 12:08 am
by Sardtok
Focus on LÖVE, not HATE. Heck, it doesn't even have the umlaut seal of quality.
And remember that not all C programmers are 50+ years old.

Re: Hate: In love with C

Posted: Sun May 31, 2009 12:24 am
by Robin
Sardtok wrote:And remember that not all C programmers are 50+ years old.
But many of them are 30+ years old, and most of them have been programming since their birth, haven't they? ;)

Re: Hate: In love with C

Posted: Sun May 31, 2009 2:01 am
by Xcmd
If you're going to gut Lua, then at least go with a better language. C is okay, but why not try strapping in Ruby to do thy bidding?

Re: Hate: In love with C

Posted: Sun May 31, 2009 2:36 am
by osgeld
yea if i had my vote id say ruby too

Re: Hate: In love with C

Posted: Sun May 31, 2009 5:58 am
by appleide
Yes, ruby would definitely be interesting :)

If it was going to be another library for C (albeit comes with a cross platform binary tool), there are other libs I could use instead, like SDL.

Ruby on the other hand... I don't know it yet so it'll interest me alot.

Re: Hate: In love with C

Posted: Sun May 31, 2009 6:12 am
by bartbes
Something that might integrate with LÖVE is if you allow certain parts of the game to be written in C, but not the entire game. (btw, what's wrong with C?)

Re: Hate: In love with C

Posted: Sun May 31, 2009 6:29 am
by appleide
bartbes wrote:Something that might integrate with LÖVE is if you allow certain parts of the game to be written in C, but not the entire game. (btw, what's wrong with C?)
C is boring. :p

Re: Hate: In love with C

Posted: Sun May 31, 2009 8:22 am
by sauer2
C is terrible, so the name fits well. :P
But there already is orx game engine for C.
If you want to choose, what about languages like Vala, Seed7, Objektpascal (Gnu/Freepascal), Oberon, Modula3 ,Scheme, Eiffel ,Erlang..?

Re: Hate: In love with C

Posted: Sun May 31, 2009 10:55 am
by rude
Whoa, whoa. I like C. C is awesome. :brows:

A lot of Ruby fans here, eh? I've never used it or seen any code. Read a bit about it just now and its semantics seems pretty nice, but its syntax will take some getting used to.

Xcmd: "gut Lua"? Blasphemy!
sauer2 wrote: Vala, Seed7, Objektpascal (Gnu/Freepascal), Oberon, Modula3 ,Scheme, Eiffel ,Erlang
Wow. I've never used any of those. Some of them I've never heard of.