Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Array fetish?  (Read 3275 times)
0 Members and 1 Guest are viewing this topic.
Offline Captain-Goatse

Junior Duke




I suck at teh 2D. XBOX IS BIG LOL!111


« Posted 2003-04-04 13:50:38 »

Anyone else here have an array fetish?

I mean I love arrays and I use them everywhere. I use one and two dimensional arrays, sometimes even three, but they are quite ineffective.

I also love recursing through arrays and nothing gives me more pleasure than recursing through two dimensional array.

I even love them so much that I had every single int of one program in an array(not very effective). When programming my game, I try to stay away from this extreme, however I still use them everywhere.

Any other fetishes?
Offline leknor

Junior Duke




ROCK!!!


« Reply #1 - Posted 2003-04-04 14:25:50 »

I really like Lists, Iterators, and Maps. Basiclly the whole Collections stuff rocks my world.
Offline GergisKhan

Junior Duke




"C8 H10 N4 O2"


« Reply #2 - Posted 2003-04-05 03:43:36 »

Has anyone ever really done a good study on why it is bad to use Collections in a game?

I am very bad at profiling, having not really done it in a real-world sense.  If someone tells me how I would go about proving such a thing, I would be happy to actually test this.

Personally, I agree with leknor: I LOVE COLLECTIONS.

HashMap is my b****.

gK

"Go.  Teach them not to mess with us."
          -- Cao Cao, Dynasty Warriors 3
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Herkules

Senior Duke




Friendly fire isn't friendly!


« Reply #3 - Posted 2003-04-05 08:55:30 »

I observerd that as soon as you get used to use HashMaps, you cannot live without anymore.

A former collegue of mine got really HashMap nuts - HashMap(HashMap(HashMap(HashMap)))

not so good in the end....

HARDCODE    --     DRTS/FlyingGuns/JPilot/JXInput  --    skype me: joerg.plewe
Offline mill

Junior Duke




popcorn freak


« Reply #4 - Posted 2003-04-05 15:06:04 »

i tend to mix collections.. hashmaps of lists are sweet

i also love java.awt.geom for collision detection.. yeah i know it's not super fast but it's fast enough. the rendering loop take much more time than all the other stuff (AI, collision detection and all the other stuff)

Offline Captain-Goatse

Junior Duke




I suck at teh 2D. XBOX IS BIG LOL!111


« Reply #5 - Posted 2003-04-05 17:17:10 »

Isn't the AWT rendering/mainloop/slacker/window cleaner/thread pooler/worthlesscpu eater invoked and turned on if you even mention the name AWT 2 meters close to the computer.

Last time I remember, calling some of the AWT components invokes the demon, which basically eats up your resources and it requires magic missile +22 to get it back where it came from?

That is if you are not developing with awt...god I'm tired

Hey there is a demon at my house, eating up my resources, called awt. Dog ate my mouse. dog. shit. cd case and parachute I'mgoin
Offline Harley Rana

Junior Duke




Java games rock!


« Reply #6 - Posted 2003-04-06 01:55:50 »

Hey totally understand people falling in love with Collections, i to have formed a more than intimate bond with HashMap.  
Sometimes i feel dirty when trying to put collections in collections, like ArrayList.add(ArrayList).  Whereas making multilevel int[][][][][] is guilt free.

Being a fellow array lover, im sure you would appreciate their excessive use in this game.
http://www.froggy.com.au/harleyrana/4K-entry.html

Im probally preaching to the converted here, as collection aficionados im sure you know about http://trove4j.sourceforge.net/
Kick arse HashMap implementation, and primitive collections.

To bug you some more with stuff you've already seen, a benchmark comparison. http://www.onjava.com/pub/a/onjava/2002/06/12/trove.html

Tongue  Smiley
Offline shawnkendall

Senior Duke





« Reply #7 - Posted 2003-04-06 15:24:24 »

Protoyping all is good, whatever gets the job done.

In production however,
Arrays, good
Java Collections API, bad

Absolutely, the idea of collections is a Good Thing(tm), but the standard Java implementation is a memory and performance hog/waster.  Profile it anytime with something like OptimizeIT and you will be sick to your stomach.
The amount of under-the-covers "new-ing" is through the roof.  Expect a significant amount of GC time cleaning up Java Collections usage.




Shawn Kendall
Cosmic Interactive, LLC
http://www.facebook.com/BermudaDash
Offline Breakfast

Senior Duke




for great justice!


« Reply #8 - Posted 2003-04-06 19:37:20 »

That trove package looks brilliant- at last ! A guilt free way to use collections!

I have discovered a bit of a thing for classes that have a static member that knows how many of itself exist and can return an appropriate one rather than creating new ones of themselves. I don't recall if there is a name for them but I use them quite a bit, especially for the web-programming stuff.
Offline Harley Rana

Junior Duke




Java games rock!


« Reply #9 - Posted 2003-04-07 03:39:34 »

Hey Shawn, could you explain where the performance problems are in Collections api.  For those of us to cheap to buy a profiler. Smiley

The only direct comparison can be between arrays and ArrayList, which my code is full of.  On array list when you don't use iterators is there much difference between pure arrays?

What are the big performance suckers?

Thanks heaps! Smiley  

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline leknor

Junior Duke




ROCK!!!


« Reply #10 - Posted 2003-04-07 06:13:14 »

Quote
could you explain where the performance problems are in Collections api.
The API is a generic API. It's designed to be acceptable in 95% of the cases. Unfortunatlly with games you spend much of your time in that 5% that isn't "common".

Quote
For those of us to cheap to buy a profiler. Smiley
Take a look at the source. I looked at the 1.4.1_02 source for this post.

Quote
The only direct comparison can be between arrays and ArrayList, which my code is full of.  On array list when you don't use iterators is there much difference between pure arrays?
The ArrayList.get(int) and ArrayList.set(int,Object) are pretty close to direct array access. They do an extra range check so the can throw a more friendly ArrayIndexOutOfBoundsException with a meaningful message. They create no garbage.

Quote
What are the big performance suckers?
Most ppl complain about Iterators but by following the code paths for ArrayList Iterators I found no sources of garbage but the level of abstraction that an Iterator provides does incur some overhead that could be advoided if you didn't need that flexiability.

When people have bad experiences with things, wrongly or rightly, they hold on to those emotions and won't let go of them without much effort. (Go read the Networking section for examples.) I think in most cases you'll be fine but there are always people who live in that 5% zone, wrongly or rightly, and complain loudly without qualifying their complaint such that other people can correctly interpet their complaint.

I'm not trying to start a flame way with the above. It's just my observations. It should be considered "free advice". (You get what you paid for. Smiley)
Offline shawnkendall

Senior Duke





« Reply #11 - Posted 2003-04-07 12:32:37 »

Operation and access performance is fine.  Of course, it often pays to make your own HashMaps and hashing functions for many cases, as well as getting away from having to make Integers (the Integer class) for int ids that you would like to hash. (Trove does this(

I was mostly talking about performance lost due to extra GC activity.

In our tests, just getting back the iterators everytime we want to do access and traversal (as well as other access, for exmaple getting back copyied sets) shows up high on our object creation profiling, because our run-time code is squeaky clean.  

When our own code is clean, and then a outside API shows up high, we start to look elsewhere.

Shawn Kendall
Cosmic Interactive, LLC
http://www.facebook.com/BermudaDash
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (41 views)
2014-10-17 03:59:02

Norakomi (33 views)
2014-10-16 15:22:06

Norakomi (26 views)
2014-10-16 15:20:20

lcass (30 views)
2014-10-15 16:18:58

TehJavaDev (59 views)
2014-10-14 00:39:48

TehJavaDev (60 views)
2014-10-14 00:35:47

TehJavaDev (50 views)
2014-10-14 00:32:37

BurntPizza (66 views)
2014-10-11 23:24:42

BurntPizza (38 views)
2014-10-11 23:10:45

BurntPizza (80 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!