Reasons to like or hate Java, C# and C++
Archon

I know this resembles this thread but I'd trying to ask in a more pratical and controlled manner.

What would be the benefits of each language compared to each other for:
1) Games
2) Business software
3) Anything else

And other questions?
4) What about in the future (whether any of them will die, be replaced, live forever or improve as it's relevant technology improves (probably only applicable to C# and Java))?
5) The interests of businesses? (ie, will business support C# or Java more?)
6) Whether any deficiencies of one language could be made up by the speed of development or ease of the other? (eg, VB vs those strange languages recently posted)
7) Availability and completeness of APIs?

Simon Parzer

Comparison between C++, C# and Java?

Quote:

1) Games

C++ wins, because the generated code is super fast, and there are tons of nice multimedia libraries for it.
C# is on the way to change that (WinFX, DirectX), but right now I think C++ is still better for games.
And Java, ... well it's too slow.

Quote:

2) Business software

Here's C++ the looser, because it lacks productivity compared to Java and C#. C# is better than Java for business applications because the resulting applications look better, run faster and are more usable.

Quote:

3) Anything else

Nothing of the three. Use a combination of LISP and Python.

Quote:

And other questions?
4) What about in the future (whether any of them will die, be replaced, live forever or improve as it's relevant technology improves (probably only applicable to C# and Java))?

C# gets stronger and better right now, Java will die eventually.

Quote:

5) The interests of businesses? (ie, will business support C# or Java more?)

C#, because it's better and it's by Microsoft. Seriously: Companies that switch from C++ to C# usually gain 50% productivity or so. Don't know about Java though.

Quote:

6) Whether any deficiencies of one language could be made up by the speed of development or ease of the other? (eg, VB vs those strange languages recently posted)

I find C# easier than VB. VB just teaches you bad programming habits.

Quote:

7) Availability and completeness of APIs?

C++ has the most complete API, I would say, because you can get just any library for it. On the other hand you can't compare the C++ STL with a .NET framework class library.
C# and Java both have a very complete and easy to use class library, but when it comes to additional stuff, like, using 3rd party libraries, C++ is the better choice.

Archon
Quote:

C# is on the way to change that (WinFX, DirectX)

But then wouldn't it "lose" by not being portable?

Quote:

And Java, ... well it's too slow.

Isn't it picking up speed as I think Marcello swears by it... Maybe Java would transfer into a JIT software like C# and speed up?

Quote:

C# gets stronger and better right now, Java will die eventually.

It's not that I doubt your words, but do you have evidence or sources?

See, Java would not be my choice of language if it is and will always be too slow for software - but I just thought I had hints that Java was improving and would be a feasible language to do anything with...

I really like C#'s syntax and semantics, but it just lacks the hardware-related libraries (DirectX and OpenGL bindings are supposed to be incomplete at the moment) and .NET 3 is coming out soon and Mono/.GNU are behind - I probably wouldn't consider C# if it wasn't cross platform... At least, not for games.

But I feel 'loyal' to C++ and it has the speed but I find it frustrating sometimes.

A J

i just hate the people that post daft questions.

Indeterminatus

Claiming that "Java is slow" is like saying that "driving is slow". The language has no impact on speed whatsoever, it's the cars, erm, the VM. Not all implementations are utilizing JIT compiling, afaik, like VMs on PDAs and mobile phones, but some already do.

I don't think that any of those languages will die any time soon (say, the next 20 years or so). However, I lack the experience in industry, so I cannot back that up.

Having said that, don't trust any wild assumptions on the topic. A C++ dude most likely will answer in favor of C++, a Java dude in favor of Java, a C# dude in favor of C#, a programmer probably in favor of whichever language allows for the richest set of nifty tricks, and an engineer in favor of whichever technology allows for the most efficient development. Finding a person experienced enough to be able to fairly compare will be difficult, and given that all human beings are subjective in nature, even then the resulting advice would have to be taken with a grain of salt.

To put it in a nutshell: I cannot add positively to the discussion. Ignore my post. Bleh.

Felipe Maia

Java is still a child. C# is a Java clone. Business software already uses both of them, because they have pre-built stuff, because OO programing on them are hundreds of time easier than on C++, because they're easily compilable, hence easy to make little changes, updates.
For games, compiled languages will always be more used, they're faster, and the previous "goodies" aren't much applied here, C++ is enough.

BAF

.Net is by far the best multipurpose library I've ever seen (except for that it's not portable). C# is nice too, and it inherits it. You want a nice sockets API? .Net. You want a native, good-looking, easy to use GUI? .Net. You want X? You can probably find it in .Net.

Marcello

BAF: what does .NET have over Java's standard libraries?

One of the wins Java has over C#/.NET is it's been around a bit longer and there's a huge wealth of libraries (many open source) available already. Plus you have stuff like applets and web start if you're dealing with that...

C# has the advantage of being designed for Windows, so its programs will feel more like native windows programs than Java programs will.

I think with much of game programming going into hardware (IE graphics), the "slowness" of Java or C# is much less of an issue. Most people these days aren't going to be writing games that are cpu-limited, or they're just using the wrong data structures.

Obvious advantages of Java/C# over C++ is ease of development, and for businesses that's a definite win. Also potentially more stable/reliable by design (garbage collection etc). You can have less experienced (and thus cheaper) programmers developing in Java/C# and still get the job done (I'm dumb! @ thedailywtf.com though).

Definitely for web applications C++ is just stupid these days. You need something that can be dynamically compiled/reloaded easily/on the fly.

I will probably try to develop my next game in Java, if only as a self-challenge and to see how reasonable it is (there are a few java game libraries out there, but I haven't really played with them much), but my guess is it's at least feasible now. (Freaking nonstop crashes and system incompatibility with c++/openlayer kinda pissed me off of using C++.)

Marcello

Kitty Cat

Java is resource hungry. If you have a program in Java, and an otherwise-identical program in C-something, the Java version will put more strain on your system. This will always be true until they can get Java programs to run without a JRE. That's where Java loses, in my mind. I also prefer a language that does what I say, instead of what it thinks I mean (eg. implicit safety checks, opt-out garbage collection, etc).

Archon

Would you (ie, any of you) install Mono, .GNU or .NET if someone programmed a freeware game or would you all expect native binaries?

[edit]
... and one of the compatible Java software?

Marcello

No, because I already have it? :D

Marcello

CGamesPlay
Quote:

(except for that it's not portable)

...and...

Quote:

Would you (ie, any of you) install Mono, .GNU or .NET if someone programmed a freeware game or would you all expect native binaries?

So pretty much download this file, extract to its own folder, and double click on ltln.exe (or run mono ltln.exe). If you properly installed the Tao framework (you can get binaries for that at http://www.taoframework.com), you will get a working application. It uses OpenGL through C#, and that particular binary was compiled from Linux. It works in Windows, too, I promise.

Archon

I'm going to go look at Tao too... CGamesPlay is good as persuasion.

I'll be able to test it out and program a small game as a test -- though it won't be using Allegro.

If I remember, I'll give out cookies just before this thread closes itself.

CGamesPlay

The nice thing about all of this is that someone can make a C# wrapper for OpenLayer, and then we will all be one big happy family. I'm still deciding whether or not I want to write the wrapper. I want to, but then again so far I have just taken OpenGL commands straight from OpenLayer's source and it has worked fine :P

In conclusion, how much of Allegro does OpenLayer really encapsulate? If writing a wrapper for OpenLayer would actually involve writing a wrapper for Allegro also, then I'm not interested. But if it's possible to get all of Allegro hidden under OpenLayer, then writing a wrapper would be a breeze (relatively).

Fladimir da Gorf
Quote:

In conclusion, how much of Allegro does OpenLayer really encapsulate?

The AllegroGLDriver class has all of it, and it's not that much after all. You could actually write your own SDLDriver, for example, and use that instead.

I've been thinking about "porting" OpenLayer to Java myself, maybe the C# version would be similiar?

Marcello

PORT IT TO JAVA! :-D

Marcello

CGamesPlay

C# would be remarkably similar. For C libraries, it involves making a single static class with static methods for all the functions. For a C# wrapper, we would actually use classes to wrap the classes, with perhaps a static ol class for holding global constants.

[append]

Oh, does OpenLayer use a DLL or static library? It needs to be a static library if it is to be compatible with "platform invoke", which is the technology used to make these wrappers.

Simon Parzer

I've made bad experiences with mono. I once installed it on my system, including a bunch of applications that use it (Tomboy, Beagle, Banshee, ...). Every three boots or so I encountered 100% CPU usage, which always was one of these mono apps running in some endless loop. (I think it was mono itself, because it happened with every mono application now and then).
I really hope that mono gets better and more complete in the future, but I believe this only starts to happen if Microsoft supports it with some developers (nothing against the mono hackers, but Microsoft devs have more knowledge about their own framework/system).

Felipe Maia
Quote:

PORT IT TO JAVA! :-D

Seconded

CGamesPlay
Quote:

I really hope that mono gets better and more complete in the future, but I believe this only starts to happen if Microsoft supports it with some developers (nothing against the mono hackers, but Microsoft devs have more knowledge about their own framework/system).

Mono is developed by Novell, and Microsoft's framework is simply an API that is open to anyone. The language itself is a published spec also.

What version of Mono were you using? Very recently (within this month, I think: http://www.go-mono.com/archive/1.1.16/) they have pushed a new version, featuring lots of bugfixes.

Fladimir da Gorf
Quote:

PORT IT TO JAVA! :-D
Seconded

OK, I'd like to use it in Java myself, too, as nowadays I like Java a lot more than C++, so... I should just go and do it :) Of course, everything takes some time, even if the conversion won't be too difficult (however, the few template classes, for example, can't be converted as-is)...

Marcello

Will you use jogl?

Marcello

Billybob

These arguments are stupid. We're just comparing crap to more crap. Call me when someone develops a language/library/environment that actually works.

Felipe Maia

Actually William, they both work, not high performance, but work very well. Eclipse is the best IDE I've ever seen, and it's java, and if you have enough memory (more than 512mb ram) it's perfect, better than any microsoft crappy shit

Billybob

Well then you just haven't been coding long enough.

Fladimir da Gorf
Quote:

Will you use jogl?

Sure, I guess that's the easiest approach... and most effective, performance wise.

BAF
Quote:

BAF: what does .NET have over Java's standard libraries?

Honestly, I have no idea. TO be fair, I have never programmed in Java in my life. I just have seen how slow and poopy most Java apps feel and look, so I never gave it a shot.

Quote:

Actually William, they both work, not high performance, but work very well. Eclipse is the best IDE I've ever seen, and it's java, and if you have enough memory (more than 512mb ram) it's perfect, better than any microsoft crappy shit

I don't know what "microsoft crappy shit" you're talking about, but Microsoft actually did something right when they made Visual Studio. It is by FAR the best and most stable IDE I've ever used. It has tons of neat features, a sweet debugger, and it is stable (hasn't randomly crashed on me like other IDEs have).

nonnus29

1) The problem with java and .net for games isn't speed. That's argument is a complete nonstarter. Anyone who thinks it is just ignorant and parroting what others tell them. The problem with .net and java for games is distribution: people can't be arsed to download x jre or .net version x or mono version y. So you lose.

2) .Net wins in business for thin client apps and destktop apps because of ms dominance, but MS dominance isn't garunteed to extend very far into the future.

3) Java wins in server side apps due to the simple fact it was first and there are alot of large business applications coded in it already.

4) None of the above suit my needs for allowing a small group of developers to re-engineer a 35 million LOC application within say, one year.

Man these threads get really old...

edit;

Quote:

Honestly, I have no idea. TO be fair, I have never programmed in Java in my life. I just have seen how slow and poopy most Java apps feel and look, so I never gave it a shot.

So it's save to say you haven't used eclipse or netbeans and your opinion is based on visual studio vs dev-c++? That's some real incite there, wow, thanks for sharing! ::)

Felipe Maia
Quote:

I don't know what "microsoft crappy " you're talking about, but Microsoft actually did something right when they made Visual Studio. It is by FAR
the best and most stable IDE I've ever used. It has tons of neat features, a sweet debugger, and it is stable (hasn't randomly crashed on me like other IDEs have).

I've used MSVC 6 and MSVC 8, and I prefer hundreds of times Eclipse. The only thing Visual Studio has of good in my opinion, it's the compiler, which is hundreds of time better than gcc or whatever...

BAF

I like how you can select a function and be taken to it, the nice code completion (which actually works), and the debugger.

nonnus: Why would I try out a language that has felt slow to me numerous times, when I know other languages which do not present that problem and work fine for me? It's not just an application or two, but most Java apps that are even remotely complex are slower than death. One of the only apps of moderate complexity written in Java that doesnt look like shit or feel slower than death is Azerues, and that is the reason I continue to use it.

Marcello

I'm impressed that you've felt the speed of death. No real issues with Java programs here, but then again, my computer doesn't suck.

Marcello

CGamesPlay

Yeah, this has degenerated into trolling.

BAF

It has nothing to do with the computer when a C/C++ app does the same thing as a Java app, only much quicker. It's not as noticable on my good computers as it was on my old 366mhz box.

Thomas Fjellstrom
Quote:

Yeah, this has degenerated into trolling.

Some Java heads like to post randomly about how java roolz. Even in threads that have nothing to do with java (not that thats the case this time).

Goalie Ca
Quote:

The problem with java and .net for games isn't speed.

I would say that it is a problem for any modern computationally intensive game. Theoretically it can be faster but practically it isn't. I would argue that the "java doesn't take a performance hit" are just java fanboys countering the c++ fanboys using token arguments. :D

C# is clearly not fast enough. Even MS admits so. When you get the DX SDK you can clearly see that managed directx, even without com overhead, has quite a bit of work left to be usable. C# is also a horribly slow for computationally intensive stuff.

Felipe Maia
Quote:

Some Java heads like to post randomly about how java roolz. Even in threads that have nothing to do with java (not that thats the case this time).

You're missing the point here, it was quite the opposite. All programming languages serve their purpose, just use if you like.

Thomas Fjellstrom
Quote:

All programming languages serve their purpose, just use if you like.

I totally agree. some others here however don't. Like the ones that randomly post about how "java roolz" in unrelated threads :)

CGamesPlay
Quote:

C# is clearly not fast enough. Even MS admits so. When you get the DX SDK you can clearly see that managed directx, even without com overhead, has quite a bit of work left to be usable. C# is also a horribly slow for computationally intensive stuff.

Fortunately in my case I am making a fairly simple 2d game, so I don't have a ton of overhead.

Steve++
Quote:

The problem with java and .net for games isn't speed. That's argument is a complete nonstarter. Anyone who thinks it is just ignorant and parroting what others tell them. The problem with .net and java for games is distribution: people can't be arsed to download x jre or .net version x or mono version y. So you lose.

You can embed a JRE within an exe (using JNI) so the users don't have to download anything extra. The only problem is that it bloats the exe.

I said that because it may be of practical use to someone. Partaking of the third C++ vs Java vs C# thread in two weeks is not of practical use to anyone, so I will coughJavarulescough resist coughC++isuglycough the urge.

Billybob
Quote:

The problem with java and .net for games isn't speed.

Making a VM with JIT call a native DLL that has different data types is fun!

nonnus29
Quote:

nonnus: Why would I try out a language that has felt slow to me numerous times, when I know other languages which do not present that problem and work fine for me? It's not just an application or two, but most Java apps that are even remotely complex are slower than death. One of the only apps of moderate complexity written in Java that doesnt look like shit or feel slower than death is Azerues, and that is the reason I continue to use it.

I could care less about your personal opinion of java or .net. My point was that you were commenting on IDE's as an expert when you had no experience with the two most significant ide's out there that happen to be primarily java ide's (eclipse and netbeans):

Quote:

BAF:
Microsoft actually did something right when they made Visual Studio. It is by FAR the best and most stable IDE I've ever used. It has tons of neat features, a sweet debugger, and it is stable (hasn't randomly crashed on me like other IDEs have)

Oh really? That's nice. Now if you had actual experience with other ide's besides vis studio, code blocks, and dev-c++, or whatever else, then your opinion would carry more weight. As it is comments like that are just noise; meaningless.

Quote:

Like the ones that randomly post about how "java roolz" in unrelated threads

I assume that was pointed at me, but I don't see why. I fully qualified my statements as being relative to .net and java because they're both jit'd platforms.

edit;

More innane statements;

Quote:

.Net is by far the best multipurpose library I've ever seen (except for that it's not portable). C# is nice too, and it inherits it. You want a nice sockets API? .Net. You want a native, good-looking, easy to use GUI? .Net. You want X? You can probably find it in .Net.

And you admitted you've never used the alternative. I think this is pure trolling and I'm calling you on it. :-*

BAF
Quote:

I could care less about your personal opinion of java or .net. My point was that you were commenting on IDE's as an expert when you had no experience with the two most significant ide's out there that happen to be primarily java ide's (eclipse and netbeans):

I never claimed I was an expert and what do you know about any experience I may or may not have? I never put down the Java IDEs.

Quote:

Oh really? That's nice. Now if you had actual experience with other ide's besides vis studio, code blocks, and dev-c++, or whatever else, then your opinion would carry more weight. As it is comments like that are just noise; meaningless.

Experience has nothing to do with this. It is my opinion. I said VS was the best IDE I have used. I didn't say Eclipse or Netbeans sucked or that they weren't better than VS.net. I haven't used them, so they aren't included in those that I have used. I said nothing about Java IDEs.

Quote:

And you admitted you've never used the alternative. I think this is pure trolling and I'm calling you on it. :-*

That opinion had no experience or anything to back it up. Feel free to call me on that one. :P

Thomas Fjellstrom
Quote:

I assume that was pointed at me, but I don't see why.

It's perfectly "on topic" in this thread. Albeit some very nice trolling.

Archon
Quote:

but MS dominance isn't garunteed to extend very far into the future.

Sorry nonnus29 but your arguments seem aggressive and don't have much foundations to back it up -- how would Microsoft not continue to survive?

I actually agree with BAF that MSVS (2003) is a very nice IDE as I appear to be more productive with using it rather than KDevelop/Kate/Nedit/Scite and whatever else I've used but it may just be the settings. I have not used 6 (or below) or 2005 much or at all to compare them.

Quote:

No real issues with Java programs here

Even Java applets? I would have to say that I'm impressed with Runescape which was made with Java which is why I put Java up for debate here -- and whether Java would be good for any games.

Quote:

C# is clearly not fast enough.

For a hobby programmer such as us, wouldn't you believe that C# may be in our interests? Instant cross-platformability (except for the underlying DLLs but those may be installed once and forgotten), and that no of us seem to make processor-intensive games except when we've messed up with the code. Perhaps a cleaner language could undo that last point? :D

Marcello

No issues with Java applets either, I've written quite a few. :D

Marcello

axilmar

As a long time user of Visual Studio 6.0, I have to say I have seen many crashes in the last few years that I am using it. I never saw Eclipse crash though (although I do not use it as long as VS). I think the reason is garbage collection: a C++ IDE is a very complex app, and therefore the propability of having a wild/null pointer in C++ is very high. Visual Studio 8.0 crashes a lot less, although I have seen it crashing twice.

Java and .NET are slower for certain tasks because of the way the languages are structured. There is always a trade-off involved: productivity vs performance. C#/Java allows the programmer to think more about algorithms from a higher level point of view than C/C++, because in C/C++ there are lots of gory low-level details to take care of. Productivity is also a function of library complexity, and sometimes with C# and Java you pay the price because many libs are over-engineered.

Simon Parzer
Quote:

I never saw Eclipse crash though (although I do not use it as long as VS).

This is only true if you never run out of memory. We once had to use Eclipse on our school computers (256 Megs of RAM), and it did crash a lot, especially while saving :(. All those annoying windows popups ("There is no memory left", or something like that), always running in virtual memory... awful!
When using Visual Studio at the same computers there is no problem at all.

Felipe Maia
Quote:

This is only true if you never run out of memory. We once had to use Eclipse on our school computers (256 Megs of RAM), and it did crash a lot, especially while saving . All those annoying windows popups ("There is no memory left", or something like that), always running in virtual memory... awful!
When using Visual Studio at the same computers there is no problem at all.

I have 256mb RAM at home, and can use Eclipse very well. Never seen it crash. It might have been due to lack of virtual memory, that maybe was disabled or whatever.
Eclipse is the future's IDE, you can't program a plugin for Visual Studio, can you? Microsoft will try to catch up, but Eclipse is much more advanced at the moment.

CGamesPlay
Quote:

Eclipse is the future's IDE, you can't program a plugin for Visual Studio, can you?

This thread has degenerated to trolling! No side knows anything about the other!

Felipe Maia
Quote:

No side knows anything about the other!

I don't know all, but I do know something :)
swings his troll club

nonnus29

How about everyone post why they like language X and not say anthing bad about other languages?

Reasons I like Java because: I like gc, I like it's huge library that has everything and the kitchen sink, it's suitable for the level of games I am likely to write, and it runs anywhere (mostly).

Reasons I like c#: N/A haven't used it.

Reasons I like c++: I haven't used c++ in a long time and don't imagine I will in the future either. But when I did write c++ I used a java like subset of the language :P

Izual

I like C/C++ because it has everything i need and it has Allegro ;D . So there is no reason for me now to learn any other language, since i have programing as hobby. :) And as IDE i use CodeBlocks with Mingw.

CGamesPlay

I like C# because it has a huge standard library. This is the same reason I like ruby, but C# has a JIT. I haven't used Java extensively.

Dennis

I like C++, because I'm used to it. I'm likely to learn C# and Java in the future for portability and lazyness reasons.(If they do indeed have huge standard libraries for all and everything, that means less coding work for me.)
I'd only use C# and Java for utilities and for work though. For games, I'll stick to C++ and Allegro, because I'm highly unlikely to ever write anything else than simple 2D game(s).

Epsi

I like C++ because Java ran off with my girlfriend :'(
(after killing my dog)

Archon

OK. It looks like my interests in C# game programming are gone -- Tao wouldn't work properly. cry cry

CGamesPlay

Bah, you just gave up too easily :P

The problem he had was that we couldn't get a working libglfw.so on his AMD 64 system.

Archon
Quote:

Bah, you just gave up too easily :P

Really? I thought that my misunderstandings were making you hit your head on the desk in frustration and that you'd want me to quit :o

Quote:

The problem he had was that we couldn't get a working libglfw.so on his AMD 64 system.

Well you should explain to me why GCC wanted me to "-fPIC" a package that was already "-fPIC"ed!

Frankly, if it doesn't work 'out of the box', I wouldn't think that anyone would have the determination to go through that to install Tao just to play a game -- they already complain about installing .NET!

Also note that it wasn't 100% working in .NET either. :-/

Again 'also', SDL.NET wont work for me either - there's something buggered with it and AMD64...

Qué unfortuna!

CGamesPlay
Quote:

I thought that my misunderstandings were making you hit your head on the desk in frustration and that you'd want me to quit

This is what programming is about, and more importantly, what learning is about.

Quote:

Well you should explain to me why GCC wanted me to "-fPIC" a package that was already "-fPIC"ed!

What, you think I know what -fPIC does? :P

Quote:

Frankly, if it doesn't work 'out of the box', I wouldn't think that anyone would have the determination to go through that to install Tao just to play a game -- they already complain about installing .NET!

Right, I intend to distribute x86 binaries...

Quote:

Also note that it wasn't 100% working in .NET either.

You can't really say that, because then you have to say Allegro isn't 100% C, because it compiles to machine code. I mean, what is ".NET"? If it's the CLR, well then this application is using the CLR to do platform invokes on the shared objects.

Archon
Quote:

What, you think I know what -fPIC does? :P

Hmmmmmmmmmmmm.... Yeah. I think you do.

Quote:

You can't really say that, because then you have to say Allegro isn't 100% C, because it compiles to machine code. I mean, what is ".NET"? If it's the CLR, well then this application is using the CLR to do platform invokes on the shared objects.

Meh! I just meant that I tried running some of the examples as is, but they give me errors that made it close down - I was more concerned with getting the Linux side working because it's usually where all the problems come from.

CGamesPlay
Quote:

Yeah. I think you do.

Heh, I appreciate your confidence in me :)

Quote:

I just meant that I tried running some of the examples as is, but they give me errors that made it close down - I was more concerned with getting the Linux side working because it's usually where all the problems come from.

Right, this is where all the problems were. Because of binary compatibility under windows, everything works nicely out-of-the-box. But because under Linux there is less binary compatibility, they can't just distribute the glfw dlls like they do for Windows. And because portage ships libglfw as a static library, we have to do the tie-up ourselves.

If you don't mind, I woul dlike to keep in touch with you as the project matures. Perhaps I can make an ebuild to build libglfw shared, or something.

Archon
Quote:

If you don't mind, I woul dlike to keep in touch with you as the project matures. Perhaps I can make an ebuild to build libglfw shared, or something.

If you want to. The ebuild is just called 'glfw' (you kept saying 'libglfw')

It'd be nice if Allegro.NET was .NET 1.1 because then Mono could run it (at the moment) but if I wanted to, I might have to use SDL.NET to continue (and wait for it to be fixed on Linux)...

No one wants to throw in any more ideas?

CGamesPlay
Quote:

It'd be nice if Allegro.NET was .NET 1.1 because then Mono could run it (at the moment)

Allegro.NET is, no offense to the developer, a very bad library. It renames all of the symbols in allegro, which is just an annoyance. Then, even more annoyingly, it uses a Capital_underscore_lowercase naming scheme (or was it Capital_Underscore_Capital? Both are annoying...).

Quote:

If you want to. The ebuild is just called 'glfw' (you kept saying 'libglfw')

Sorry. I got confused because the library name is libglfw :)

Archon
Quote:

Allegro.NET is, no offense to the developer, a very bad library.

How long does it take to provide a <language> interface to a C library assuming it'll be 'plugged in' the same way?

Steve++

I've just started playing with PHP. Now I know why it has been an overnight success.

I just made a simple online shop that uses PayPal's instant payment notification to run a script on my server that verifies the payment, generates a unique code (md5-style), logs that code in the database with the transaction details, then makes a download url using that code and emails that url to the customer. The download url is a php script with the unique code as a variable's value. The URL expires after a certain time. Although the URL's type is php, the script sends a pdf file with a different name and this is handles gracefully on the client side. This whole system is to sell ebooks. I did all that and a week ago I didn't know any php or anything about PayPal integration. I'm not trying to blow my trumpet; just pointing out how useful PHP is as a language.

PS. If anyone wants me to setup something like this for them, my rates are reasonable. ;D

CGamesPlay
Quote:

How long does it take to provide a <language> interface to a C library assuming it'll be 'plugged in' the same way?

In C# it involves:

[DllImport(Module="alleg42.dll",Symbol="set_gfx_mode")]
public static Int32 set_gfx_mode(Int32 mode, Int32 w, Int32 h, Int32 vw, Int32 vh);

The paramters the the DllImportAttribute aren't right, but they look like that.

Archon

AllegPHP?

Steve++

I'm not sure how fast PHP is though. All I know is that it's good on the server side.

Matthew Leverton
Quote:

In C# it involves: ...

But won't that result in unsafe code? The best way to use Allegro with a language other than C/C++ is to use it in a fashion native to the language.

I've got PHP/Allegro bindings about 50% done, but I have no idea what the speed is because I'm using NX to connect to KDE running on a 500Mhz Via chip... (My guess is that it will be pretty bad.) My first pass is simply a 1:1 mapping with memory managment:

1<?php
2 allegro_init();
3 install_keyboard();
4 set_gfx_mode(GFX_AUTODETECT, 640,480);
5 $screen = get_allegro_var('screen'); // Don't know if there's any way to sync PHP/Allegro vars...
6 $font = get_allegro_var('font');
7 
8 $buffer = create_bitmap(640, 480);
9 
10 textout_ex($buffer, $font, "Hello World", 8,8, makecol(255,255,255), -1);
11 
12 unset($buffer); // or $buffer = NULL; equivelent to: destroy_bitmap($buffer);
13 
14 allegro_exit();
15?>

Obviously certain portions won't be available (eg, Unicode & Config) because PHP has native implementations. Also, other portions are limited (eg, Timers & GUI) because it's impossible to provide an exact replication. For example, Timers might simply be:

<?php
  set_tick_variable($ticker, 60 /* BPS */);

  while ($playing_game)
  {
    while ($ticker)
    {
      $ticker--;
    }
  }
?>

In other words, only a few new timer functions to take care of common tasks would be available.

The only practical uses of PHP/Allegro are probably to 1) test ideas and 2) use the graphics portion to process image data on a web server.

The demo running in PHP:
{"name":"589739","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/4\/6\/466700d36387dec3b0cf5fff78d1be2d.png","w":529,"h":427,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/4\/6\/466700d36387dec3b0cf5fff78d1be2d"}589739

James Stanley

BAF, I know it's a bit late to reply now, but on the first page you said .NET's got everything. It sounds like it's too bloated to me, or does it only compile the bits you use?

CGamesPlay
Quote:

But won't that result in unsafe code? The best way to use Allegro with a language other than C/C++ is to use it in a fashion native to the language.

No, DllImport doesn't require the unsafe keyword/flag. And this is the fashion native to C#. Platform invoke was designed for this purpose.

[append]
James: The bits you don't use are compiled, of course, because they are part of the library. They aren't loaded into memory unless you use them, though. Each subsystem is in its own DLL.

Matthew Leverton
Quote:

No, DllImport doesn't require the unsafe keyword/flag.

But how do you deal with this?:

public myCSharpFunction() 
{
  BITMAP *bmp = create_bitmap(640,480); // (what would this line really look like?)
  // memory leak...
}

Having to explicitly call destroy_bitmap() goes against the philosophy of memory managed languages.

Marcello

If it's anything like Java, you would make it a Java class, with a destructor that frees the underlying memory.

Marcello

CGamesPlay

Yeah, one should really do what Marcello said.

Steve++
ML said:

$screen = get_allegro_var('screen'); // Don't know if there's any way to sync PHP/Allegro vars...

I'm not php expert, but wouldn't you do something like this?

function allegro_init()
{
   global $screen;
   // ...
   $screen = get_allegro_var('screen');
   // ...
}

Matthew Leverton
Quote:

If it's anything like Java, you would make it a Java class, with a destructor that frees the underlying memory.

Yes, but then it's not quite as simple as what was originally shown. ;) Something like that probably works well with a language that is "compiled" like Java or C#, but for PHP it would add more overhead:

1<?php
2class Bitmap
3{
4 private $bmp;
5 public function __construct($w, $h, $cd = NULL)
6 {
7 if ($cd !== NULL)
8 $this->bmp = create_bitmap_ex($cd, $w, $h);
9 else
10 $this->bmp = create_bitmap($w, $h);
11 }
12 
13 public function __destruct($w, $h)
14 {
15 destroy_bitmap($this->bmp);
16 }
17}
18?>

You could take that same approach with PHP, but it's possible to do the same in the binding library and have it compiled to C. (This seems to be a big difference between PHP and Ruby... PHP has a lot of C modules, whereas Ruby modules are mostly written in Ruby.)

Quote:

I'm not php expert, but wouldn't you do something like this?

function allegro_init()
{
   global $screen;
   // ...
   $screen = get_allegro_var('screen');
   // ...
}

allegro_init() is a C module function, not a PHP function. However, I could probably do this:

PHP_FUNCTION(set_gfx_mode)
{
  long card, w, h, v_w = 0, v_h = 0;
  int rv;

  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll|ll", &card, &w, &h, &v_w, &v_h) == FAILURE) RETURN_NULL();

  rv = set_gfx_mode(card, w, h, v_w, v_h);
// set the $GLOBALS['screen'] to screen

  RETURN_LONG(rv);
}

That works fine for 'screen', because it won't change. But I'm not sure if dynamic values like key[] can be mapped to a variable without requiring a poll() function to update it.

Marcello

That looks pretty painful ML, may I ask why you're bothering making a PHP wrapper? The graphics portion is pretty crude to do image manip since it's so simplistic.

Marcello

Matthew Leverton
Quote:

may I ask why you're bothering making a PHP wrapper? The graphics portion is pretty crude to do image manip since it's so simplistic.

Just because I can... The majority of it is just a lot of copy and paste. I could have probably written a PHP script that automatically generated the code for almost every function.

Goalie Ca
Quote:

If it's anything like Java, you would make it a Java class, with a destructor that frees the underlying memory.

C# has what's called an IDispoable interface. A class that implements that interface is to be used to wrap things that manage resources. The problem with java is the opposite of c++. In c++ memory can leak while resources are taken care of automatically in the destructor when the object goes out of scope (assuming you don't use new and delete and use raii properly). In java you have to explicitly release ALL resources. While finalize may "automagically" release it, no one really knows when the GC will collect. It is not deterministic behaviour.

In c# you have the "disposable" concept. Basically they have a Dispose() method which is to be used to release resources. You can also have destructors. A using block in C# is basically a try{ }finally{ } block. The unsafe keyword means that you will manage the memory yourself. It IS needed when dealing with any useful C/C++ dll.

CGamesPlay
Quote:

The unsafe keyword means that you will manage the memory yourself.

Well, mostly true, but this is a very crude definition of the keyword.

Quote:

It IS needed when dealing with any useful C/C++ dll.

It is only needed when you will need to work with pointers.

Goalie Ca
Quote:

Quote:
It IS needed when dealing with any useful C/C++ dll.

It is only needed when you will need to work with pointers

L0l. I'm glad you understand :D

Archon

I managed to get GLFW working for Mono and Windows -- I think that Tao would be ready for use if the problems I told CGamesPlay would be solved...

Now CGames is taking ages to respond to emails!

[edit]
OK. No more problems with GLFW as far as I know... Though I'm still waiting for CGamesPlaysByHimself! >:(

Thread #586387. Printed from Allegro.cc