Allegro.cc - Online Community

Allegro.cc Forums » Off-Topic Ordeals » guru java programming tips & tricks here!!

This thread is locked; no one can reply to it. rss feed Print
 1   2 
guru java programming tips & tricks here!!
Frank Garrett
Member #1,625
November 2001
avatar

One day i was just surfing the net and
suddenly a killer wave site took me to
a new land called java programming for
guru. So i just looked around and found
Developing Professional Java Applets
web page
Tricks of the Java Programming Gurus
web page
Hacking Java: The Java Professional's Resource Kit
Sorry not avaible
Have fun!!
[ November 11, 2001: Message edited by: Frankie ]

Bob
Free Market Evangelist
September 2000
avatar

Hey, just what I was looking for!
Thanks!

--
- Bob
[ -- All my signature links are 404 -- ]

Peter Hull
Member #1,136
March 2001

Is anyone interested in Java? I was playing recently with JNI and Allegro - using my system you can now write Allegro programs in Java*

Pete

  • Provided those programs only use the function 'putpixel' :) - there's a lot still to do!

Bob
Free Market Evangelist
September 2000
avatar

Do you draw inside a JComponent, or an applet? I can see JComponents as being more useful...
Hmm, Allegro for Java anyone?

--
- Bob
[ -- All my signature links are 404 -- ]

23yrold3yrold
Member #1,134
March 2001
avatar

I've never really bothered caring about Java, since my main interest is making video games, and I've never found C++ lacking in that department. Anyone wanna take this opportunity to sell me on why I should bother learning it?

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

amarillion
Member #940
January 2001
avatar

pro:

The great advantage of java is that it is portable. Not only the code can be compiled on different systems, but also the compiled bytecode can be run on different sytems (Intel, mac, whatever). That is also the reason why java is so popular for web applications: It will work on any system with a java compatible browser.

Also the java language has been designed to be as close to C++ as possible while removing some of the more error-prone stuff like pointers and macros. Also Java is garbage collected, which means you don't need to worry about freeing and deleting stuff.

con:

Java has no templates, no compiler directives, no macros. You don't have the same "freedom" as in C++. How can you survive without pointers?

Goku
Member #686
September 2000
avatar

Pardon my long essayish thing here. Since Chris asked, I figured I could shed some light on his situation by sharing some information about all possibilities. For my Java arguments, I will mainly consider it for its web-page applet abilities. Java's not that great for standalone apps and there's other options if you need portability.

So Java, Flash and ActiveX (as well as a few lesser known methods) are your main choices for making browser applets, so how to choose...

Flash is more point-and-click oriented (IIRC, FlashScript is almost entirely programmable while never touching a keyboard) so unless you really dig deep or get creative, you have less control, and it lacks that sort of brute force feel that programmers tend to like. But that also makes it quite easy to use. Plus, I don't know if Flash players exist for other OSes like BeOS (I'm pretty sure they exist for Linux and Mac though).

ActiveX can be done in C++, Visual Basic and maybe Delphi so the language choice is good. I think it has a speed advantage on Java and Flash but the reason for that isn't a positive one: it's extremely non-portable. ActiveX controls are compiled in native Windows code. Furthermore, the last I knew, you needed a plugin to view ActiveX controls if you use a browser other than Internet Explorer. ActiveX is also the only one of the three that can (in its browser form) access a local hard drive. Obviously that's a mixed blessing.

Java is the most portable (except maybe BeOS again...) and rather robust. But it's also slow (in this case, portable also means interpreted) and occasionally confusing to the C++ vet. It's the only one of the three that can make a standalone application without imbedding it into something else (ActiveX) or bundling a player (Flash).

Since cost is usually an issue: Java's compilers and runtimes are free. ActiveX may be doable without MSVC but I wouldn't want to try, so to use C++, you'll need MSVC. There does exist however a free version of VB that will only compile to ActiveX controls (but will interpret anything else from within the IDE). I also think that Delphi is now free for personal use. Correct me if I'm wrong. Finally, save for really simple things like FlashTyper, Flash will cost several hundred bucks for the full app or from $50-$100 for a watered down third party program that exports to Flash format.

OK, I may be a little biased though I tried not to be. All of them are good technologies if you want to make web applets. It's just a matter of your needs and your funds.

All right, pardon my huge ramblings. I'm done now.

Bob
Free Market Evangelist
September 2000
avatar

pro: No more array out of bound indexing
con:
- No header files, which means that you can't have two classes that refer to each other.
- No multiple inheritence
- Damn slow compiler
- Damn slow JVM
- Only one public class per file
- Files must have the exact same name as the class they contain
- Can't split up classes into multiple files
- No good editors (Forte, VAJ, VJ++ all suck bad - using EditPad right now )
- Poorly documented
- Very poorly documented GUI API
- No delete, which means your object stay in memory until the garbage collector decides to wake up and pick them up, unless it doesn't want to because it's referenced elsewhere in some obscure manner
- **** slow string class
- And some other things I can't think of right now

--
- Bob
[ -- All my signature links are 404 -- ]

Marty Dill
Member #277
April 2000
avatar

"you can't have two classes that refer to each other."

Uh ... are you sure about that? It sure seems to work for me.

Bob
Free Market Evangelist
September 2000
avatar

-- cut file A.java --
public class A {
private B b;
}
-- end file A.java --
-- cut file B.java --
public class B {
private A a;
}
-- end file B.java --
No matter how much you try, you will not be able to compile this.

--
- Bob
[ -- All my signature links are 404 -- ]

Marty Dill
Member #277
April 2000
avatar

Uh ... did I miss something here? It compiles just fine.

Bob
Free Market Evangelist
September 2000
avatar

Then you must be using some super compiler.
Using JDK 1.3.1_01, I get:
code:
G:\school\ce321\scm>javac A.java
A.java:2: cannot resolve symbol
symbol : class B
location: class A
public B b;
^
1 error
G:\school\ce321\scm>javac B.java
B.java:2: cannot resolve symbol
symbol : class A
location: class B
private A a;
^
1 error

--
- Bob
[ -- All my signature links are 404 -- ]

Marty Dill
Member #277
April 2000
avatar

Strange ... I'm using 1.3.0_02 ...
code:E:\>type A.java
public class A {
private B b;
}
E:\>type B.java
public class B {
private A a;
}
E:\>javac A.java
E:\>javac B.java
E:\>

Bob
Free Market Evangelist
September 2000
avatar

This is really strange. I know you can "trick" the compiler by compiling a fake A, then building B, then rebuilding A.
But I'm using a newer version of JDK - it should behave like yours...why oh why is it not working? It could've saved us hours of work trying to build workarounds...

--
- Bob
[ -- All my signature links are 404 -- ]

Matthew Leverton
Supreme Loser
January 1999
avatar

I hate Java - I've had to use it "professionally". Then again, I'm not the best at it, but it is fun to use it to write Java applets.

SPEED Online

I've had to use Java to write business applets to display ridiculous graphs that upper Management wanted... :P

Peter Hull
Member #1,136
March 2001

Bob:
Actually neither - it's a Java application which just kicks open an Allegro window (or fullscreen) in the same way a Windows app does.
You could write applets using MemoryImageSource as a the buffer for a bitmap. You'd have to write a Java system driver, and I'm not sure if you can use JNI with Applets - it would pose a security risk.
Pete

Bradley Bergeron
Member #1,102
March 2001

Quote:

No more array out of bound indexing

ummm...you sure? i've had programs that have crashed becaue of this, is safer than c++(i think) but it still can happen

fox
Member #1,615
November 2001
avatar

Bob: ever tried borlands JBuilder? i was pretty satisfied with it.
documentation from sun worked good for me too...
though i have to admit i never really got into applets much...i was modding a game using JNI(vampire), so maybe all this stuff sucks for applets , don't think so though
fox

Bradley Bergeron
Member #1,102
March 2001

i have taken a couple university courses in java and they always recommended the sun documentation, and i've never had any trouble with it, found it quite useful actually.

Korval
Member #1,538
September 2001
avatar

Quote:

i've had programs that have crashed becaue of this, is safer than c++(i think) but it still can happen

Certainly the language will let you do it, but the VM will kill your app the moment it does. Unlike C/C++, where you can then go stomping through memory at will. The only thing that kills C/C++ apps when they go past the bounds of an array is the OS's memory protection.

DanielH
Member #934
January 2001
avatar

I was pretty pissed off when I found out that all the computer classes at my school switched to java. I didn't know anything about java.
But now after three classes, I like to program in it, but it still is a terrible system. Of course I've only done console programming.
One plus is that it is portable. Well this is true because each os has its own interpreter. Kinda like a basic program.
I use forte, just for the editing, I still compile and run everything in command line. I got too many errors and lock ups otherwise.
Bob, It also compiled with no errors.
There are so many good classes that come with java, that I wish these classes came with C++ also.
You don't have to bother with memory. I've done so much OOP in java, but I have no idea how to do it in C++.
One simple thing is creating an object in java
code:
class Thang
{
private int p;
public Thang(int v)
{
p=v;
}
public int getThang()
{
return p;
}
public static void main(String[] args)
{
Thang t = new Thang(5);
System.out.println(t.getThang());
}
}

So how would I do that in C++? How would I create/free the memory? I've been learning so many good things in these classes, but have no idea how to convert from java to C++.
[ November 13, 2001: Message edited by: DanielH ]

Zaphos
Member #1,468
August 2001

But why would a school teach compsci in java? The AP Compsci Exam is in C++! Furthermore, C++ is more stable (I can see java getting replaced in a couple years, but I doubt that will happen to c++ ... never know, but I doubt it)
Learning Java is just less important, methinks, than C++.
And C++ runs on every os too ... if you compile it in that os ... It isn't like C++ is going to die with any one company ... (like java might?)

DanielH
Member #934
January 2001
avatar

I think they switched because java is easier to use and port to all systems. Oh and its free.

If they taught C++, which one would they teach? Which compiler?

23yrold3yrold
Member #1,134
March 2001
avatar

Whaddaya mean "which C++"? It is standardized.

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

Bob
Free Market Evangelist
September 2000
avatar

Ah, I think I know why it didn't compile my Java files - the classpath was set up wrongly: it didn't look for java/class files in the current directory, but only in the obj directory! Well now it works perfectly! (a bit late though >:( )

--
- Bob
[ -- All my signature links are 404 -- ]

 1   2 


Go to: