How other people should write their software

Archived bsnes development news, feature requests and bug reports. Forum is now located at http://board.byuu.org/
adventure_of_link
Locksmith of Hyrule
Posts: 3634
Joined: Sun Aug 08, 2004 7:49 am
Location: 255.255.255.255
Contact:

Post by adventure_of_link »

mudlord wrote:Okay, I'll be nice. For Mr Kitty's sake as well. 8)
how about this one:

Image
<Nach> so why don't the two of you get your own room and leave us alone with this stupidity of yours?
NSRT here.
I.S.T.
Zealot
Posts: 1325
Joined: Tue Nov 27, 2007 7:03 am

Post by I.S.T. »

byuu wrote:
Awww, isn't that the pot calling the kettle black? :P
Image
OH MY GOD THAT'S SO CUTE I WANT ONE
Nach
ZSNES Developer
ZSNES Developer
Posts: 3904
Joined: Tue Jul 27, 2004 10:54 pm
Location: Solar powered park bench
Contact:

Post by Nach »

Oooh! Breakfast! :twisted:
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
blargg
Regular
Posts: 327
Joined: Thu Jun 30, 2005 1:54 pm
Location: USA
Contact:

Post by blargg »

Breakfast? That's unsustainable; try this instead: kitten huffing.
mudlord
has wat u liek
Posts: 559
Joined: Tue Sep 11, 2007 2:54 pm
Location: Banland.

Post by mudlord »

Oooh! Breakfast!
Doesn't grinvader eat kittens? :o
Nach
ZSNES Developer
ZSNES Developer
Posts: 3904
Joined: Tue Jul 27, 2004 10:54 pm
Location: Solar powered park bench
Contact:

Post by Nach »

mudlord wrote:
Oooh! Breakfast!
Doesn't grinvader eat kittens? :o
Yes. But someone had to preempt him for once.
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
King Of Chaos
Trooper
Posts: 394
Joined: Mon Feb 20, 2006 3:11 am
Location: Space

Post by King Of Chaos »

Nach wrote:Oooh! Breakfast! :twisted:
Indeed...

Image
[url=http://www.eidolons-inn.net/tiki-index.php?page=Kega]Kega Fusion Supporter[/url] | [url=http://byuu.cinnamonpirate.com/]bsnes Supporter[/url] | [url=http://aamirm.hacking-cult.org/]Regen Supporter[/url]
grinvader
ZSNES Shake Shake Prinny
Posts: 5632
Joined: Wed Jul 28, 2004 4:15 pm
Location: PAL50, dood !

Post by grinvader »

Nach wrote:
mudlord wrote:
Oooh! Breakfast!
Doesn't grinvader eat kittens? :o
Yes. But someone had to preempt him for once.
Those ones looked diseased.

I don't fancy poisoned treats.
皆黙って俺について来い!!

Code: Select all

<jmr> bsnes has the most accurate wiki page but it takes forever to load (or something)
Pantheon: Gideon Zhi | CaitSith2 | Nach | kode54
mudlord
has wat u liek
Posts: 559
Joined: Tue Sep 11, 2007 2:54 pm
Location: Banland.

Post by mudlord »

byuu,

http://mudlord.blogspot.com/2008/08/spe ... arity.html

There's my abbreviated response. I could have expanded a lot more, but I chose not to.

But basically, it shows the gist of what I think about optimization, and what I think of bloat & the relevance of optimization on ultra modern hardware.

Feel free to make a article as a rebuttal. I don't really mind. 8)

EDIT: Fixed spelling and stuffles in blog post.
Last edited by mudlord on Tue Aug 05, 2008 9:56 am, edited 2 times in total.
Deathlike2
ZSNES Developer
ZSNES Developer
Posts: 6747
Joined: Tue Dec 28, 2004 6:47 am

Post by Deathlike2 »

Nach and I had a small discussion regarding this.. it falls to a few things IMO.

When CS/programming is taught, the students are never taught to optimize. This is a huge failure since this problem becomes systemic and there are tons of programs produced that could be significantly faster than what was written for it. I could easily point to games being a culprit, but an even more pratical example is the freaking word processor. When you think about load times, you shouldn't be requires to beef up your computer massively just to get Word running better. It makes absolutely no sense to me. Something like Word should load up as fast as Notepad, but that simply is not the case. Maybe it seems that I'm asking for a lot, but considering that it shouldn't consume insane resources or insane CPU just to write up a document. Is that asking too much? I don't think so.

One other thing.. commenting code nowadays seems to be a lost art, since it's probably not used so people can be mystified at what to do before eventually overhauling the code again...
Continuing [url=http://slickproductions.org/forum/index.php?board=13.0]FF4[/url] Research...
mudlord
has wat u liek
Posts: 559
Joined: Tue Sep 11, 2007 2:54 pm
Location: Banland.

Post by mudlord »

When CS/programming is taught, the students are never taught to optimize. This is a huge failure since this problem becomes systemic and there are tons of programs produced that could be significantly faster than what was written for it. I could easily point to games being a culprit, but an even more pratical example is the freaking word processor. When you think about load times, you shouldn't be requires to beef up your computer massively just to get Word running better. It makes absolutely no sense to me. Something like Word should load up as fast as Notepad, but that simply is not the case. Maybe it seems that I'm asking for a lot, but considering that it shouldn't consume insane resources or insane CPU just to write up a document. Is that asking too much? I don't think so.
I 100% agree. Way too much stuff these days is either bloated, unoptimized, or both. Like Word 2003. Its utterly insane, same with loads other apps I use daily, like Visual Studio 2008. We really don't need the bloat. I just wish the devs just wake up and do something about it.

Note: I am not saying BSNES is either those 3 things (bloated/unoptimized/or both).
tetsuo55
Regular
Posts: 307
Joined: Sat Mar 04, 2006 3:17 pm

Post by tetsuo55 »

I completely agree

We should start a movement to teach the importance of optimization and commenting
mudlord
has wat u liek
Posts: 559
Joined: Tue Sep 11, 2007 2:54 pm
Location: Banland.

Post by mudlord »

We should start a movement to teach the importance of optimization and commenting
Some people would get pissy if that happens. Namely Intel and co that earn money from bloat >.>
I.S.T.
Zealot
Posts: 1325
Joined: Tue Nov 27, 2007 7:03 am

Post by I.S.T. »

Intel makes money off of everything. >.> bloated code, lean code, etc. If it runs faster on their platform/s, they make money off of it.
FitzRoy
Veteran
Posts: 861
Joined: Wed Aug 04, 2004 5:43 pm
Location: Sloop

Post by FitzRoy »

mudlord wrote:byuu,

http://mudlord.blogspot.com/2008/08/spe ... arity.html

There's my abbreviated response. I could have expanded a lot more, but I chose not to.

But basically, it shows the gist of what I think about optimization, and what I think of bloat & the relevance of optimization on ultra modern hardware.

Feel free to make a article as a rebuttal. I don't care.
It seems to me that optimization as a final stage will have a better end result faster than optimizing as you go due to code volatility. Maybe it doesn't matter so much with a word processor, but with an emulator, you're trying to duplicate something you're in a constant struggle to understand. If some optimizations have a chance of being scrapped along the way or are going to hinder the author's ability to troubleshoot newly discovered problems, then why bother?

At the same time, hacks of some parts (PPU) are practically necessary in order to even test games at full speed and improve other parts, or generate interest from people like DMV27 who otherwise may not have contributed fixes if the emulator provided no immediate prospects of enjoyment. There is clearly a mix of philosophies at work here, I have no idea why these types of threads persist. Microsoft's overly aggressive product intervals are bloat magnets. Office is as clear a case as you could want. But I don't consider that to be the reason that bsnes is slow. Sorry if you do.
AamirM wrote:If you do a simple google search, you'll find that nearly on every forum there will be someone who will sugggest bsnes to play games.
And you'll find that nearly every time that happens, the original poster was suffering some major, irresolvable issue in their game. People suggest bsnes because it's easy. Got a problem? Bsnes probably doesn't have it. People know this by now, they don't have to go check equally uncertain alternatives every time someone moans that all their games are glitching out.
mudlord
has wat u liek
Posts: 559
Joined: Tue Sep 11, 2007 2:54 pm
Location: Banland.

Post by mudlord »

t seems to me that optimization as a final stage will have a better end result faster than optimizing as you go due to code volatility. Maybe it doesn't matter so much with a word processor, but with an emulator, you're trying to duplicate something you're in a constant struggle to understand. If some optimizations have a chance of being scrapped along the way or are going to hinder the author's ability to troubleshoot newly discovered problems, then why bother?
I still feel though optimizing while going along instead of it being at the final stage is okay though. Sure its a choice some people make, but whatever works for them.

I have no idea why these types of threads persist.
This one existed purely out of polarities between byuu and I. Honestly, sometimes I wish I wasn't here at this forum, because of all the fights and stuff. As honestly, I hate all the resentment and arguments, as it really gets to me. Sure people will just say "its just the internetz", but to some people, its more than that.
byuu

Post by byuu »

There's my abbreviated response. I could have expanded a lot more, but I chose not to.
Looks good to me, thanks for writing it :)
And you'll find that nearly every time that happens, the original poster was suffering some major, irresolvable issue in their game.
All of the niceties (video filters, special chip support, etc) probably aren't helping the perception that it's not meant to compete / replace other emulators ... but I suppose if it increases the number of people testing games, that's probably a good thing.
It seems to me that optimization as a final stage will have a better end result faster than optimizing as you go due to code volatility.
That's pretty much my entire point. Get it right first, optimize it later. It's just that "right" to me, for this specific program, means perfect, and that's not possible ;)
I still feel though optimizing while going along instead of it being at the final stage is okay though. Sure its a choice some people make, but whatever works for them.
Yes, precisely, a choice. I certainly don't mind if people optimize as they go along.
This one existed purely out of polarities between byuu and I.
The sad part is that I don't really even think we disagree. Like politicians, we just have two ways of saying the same thing.

Yes, I certainly appreciate optimized code and think it has a lot of value. And in 99.9% of cases, I agree with your approach. I also agree that VS2k8 and Word are ungodly slow, and there's not much excuse for that. Especially considering those products cost money. I hate the fact that even the "runs on legacy hardware" major Linux distros consume all available RAM on my 512MB machines, unless I go with Xfce.

I even agree with you for writing general emulators, even accuracy-focused ones. But I want to do something different: a niche of a niche, I want the code to be self-documenting so that other emulators can implement my findings. And they do, see zones' additions to IRQ timing in SNES9x for but one example. Really, that's my #1 goal -- I'm not worried about speed because I'm not aiming for people to play it. It's just that I kind of need people to in order to find bugs and such.

It's a truly exceptional case to the rule is all. If you look at my other software, you'll find it may not be the fastest, but it's quite fast in general. xkas can assemble ~200kb of source in less than 1/10th of a second. Der Langrisser uses all kinds of tricks to increase speed (like a vblank polling routine that checks latch ranges to avoid an extra frame seek if we're already in vblank -- something I've never seen anyone else do), etc. Unlike many fan translations, there's no visible slowdown compared to the original.

But I don't even ask that anyone agrees with my approach here, just that they respect it, as it's what I want to do personally.
Honestly, sometimes I wish I wasn't here at this forum, because of all the fights and stuff.
Not to add insult to injury, but in the interest of fairness -- you were the one who brought this up in the first place :/
I'm sure I've started others though.

I agree though that's it getting old. Let's both try to be nice, even if we disagree -- we can at least respect that the other can do whatever he wants with his project and should be able to do without criticism. And if one of us starts bickering here, we'll have FitzRoy delete all of said posts. Sound good? :)
mudlord
has wat u liek
Posts: 559
Joined: Tue Sep 11, 2007 2:54 pm
Location: Banland.

Post by mudlord »

Looks good to me, thanks for writing it :)
No probs. :) Least I got my main point across in how I approach things.


The sad part is that I don't really even think we disagree. Like politicians, we just have two ways of saying the same thing.
Yes, and then that leads to all the bickering and stuff. Which isn't nice for both of us, considering we do get along. Its only when the contentious issues start that problems get abound. :(
Yes, I certainly appreciate optimized code and think it has a lot of value. And in 99.9% of cases, I agree with your approach. I also agree that VS2k8 and Word are ungodly slow, and there's not much excuse for that. Especially considering those products cost money. I hate the fact that even the "runs on legacy hardware" major Linux distros consume all available RAM on my 512MB machines, unless I go with Xfce.
Exactly. If I was paying for a product, I would expect it to run well, and be optimized for such. And the software devs around that charge for bloated POS'es of software really don't deserve the money.

As for the Linux comment I agree. Fluxbox for me works equally well to Xfce. :P I honestly don't care for looks in GUIs, just functionality. So I really don't see the point in Aero, Compiz Fusion and stuff....


But I want to do something different: a niche of a niche, I want the code to be self-documenting so that other emulators can implement my findings. And they do, see zones' additions to IRQ timing in SNES9x for but one example. Really, that's my #1 goal -- I'm not worried about speed because I'm not aiming for people to play it. It's just that I kind of need people to in order to find bugs and such.
Ah I see...so thats why theres not much commenting in the BSNES source...Still I think code commenting is nothing bad. :P
I agree though that's it getting old. Let's both try to be nice, even if we disagree -- we can at least respect that the other can do whatever he wants with his project and should be able to do without criticism. And if one of us starts bickering here, we'll have FitzRoy delete all of said posts. Sound good? :)
Sound perfect to me. :)
Nightcrawler
Romhacking God
Posts: 922
Joined: Wed Jul 28, 2004 11:27 pm
Contact:

Post by Nightcrawler »

I'm going to play devil's advocate here. You two love to throw around Word and Visual Studio as your examples of unoptimized, bloated programs. However, do you really know this to be true? With all the features in Visual Studio 2008 and Word, do you really think you could create something better? There's just no backing substance to your claims other than the programs are slow in loading. You have no idea why they are slow nor how they could be improved.

I'm not agreeing nor disagreeing with whether or not they are bloated. Just throwing out the fact that these claims seem frivolous to use as supporting evidence of your opinion of poor software design without backing. ;)

P.S. Notepad is slow as hell to open and do anything with large files. That doesn't win any awards for speed in my book either.
[url=http://transcorp.romhacking.net]TransCorp[/url] - Home of the Dual Orb 2, Cho Mahou Tairyku Wozz, and Emerald Dragon SFC/SNES translations.
[url=http://www.romhacking.net]ROMhacking.net[/url] - The central hub of the ROM hacking community.
mudlord
has wat u liek
Posts: 559
Joined: Tue Sep 11, 2007 2:54 pm
Location: Banland.

Post by mudlord »

I'm going to play devil's advocate here. You two love to throw around Word and Visual Studio as your examples of unoptimized, bloated programs. However, do you really know this to be true? With all the features in Visual Studio 2008 and Word, do you really think you could create something better? There's just no backing substance to your claims other than the programs are slow in loading. You have no idea why they are slow nor how they could be improved.
That same logic applies to Windows Vista too.

However, do you really know this to be true?
More often than not, there is criteria for bloated software. Like
* Large harddrive footprint
* Large RAM requirements
* Large CPU requirements

VS2008 takes up all 3, not to mention the MSDN Library, which adds another 2-3GB.

Yes its all subjective, but there are some common attributes of "bloated" software. And MS often calls thier extra bloated things added "features".
diminish

Post by diminish »

As for the Linux comment I agree. Fluxbox for me works equally well to Xfce. :P I honestly don't care for looks in GUIs, just functionality. So I really don't see the point in Aero, Compiz Fusion and stuff....
I see a point in Aero, which I think is very important - as the whole desktop environment is hardware accelerated by the video card and it's done really nice, you DON'T have any visual tearing when moving windows, or which is the most important, scrolling. Combining this with ClearType makes life for my eyes much easier (using TN panel) :). Please show me other systems with such behaviour, so I can stop using Vista.
byuu

Post by byuu »

Ah I see...so thats why theres not much commenting in the BSNES source...Still I think code commenting is nothing bad.

Code: Select all

/*****
 * One PPU dot = 4 CPU clocks
 *
 * PPU dots 323 and 327 are 6 CPU clocks long.
 * This does not apply to NTSC non-interlace scanline 240 on odd fields. This is
 * because the PPU skips one dot to alter the color burst phase of the video signal.
 *
 * Dot 323 range = { 1292, 1294, 1296 }
 * Dot 327 range = { 1310, 1312, 1314 }
 *****/


  //dram refresh occurs once every scanline
  status.dram_refreshed = false;
  if(cpu_version == 2) status.dram_refresh_position = 530 + 8 - dma_counter();

  //hdma triggers once every visible scanline
  status.line_rendered  = false;
  status.hdma_triggered = (status.vcounter <= (ppu.overscan() == false ? 224 : 239)) ? false : true;

  //interlaced even fields have one extra scanline (263+262=525 NTSC, 313+312=625 PAL)
  if(ppu.interlace() == true && ppu.field() == 0) status.field_lines++;

  //H/DMA pending && DMA inactive?
  //.. Run one full CPU cycle
  //.. HDMA pending && HDMA enabled ? DMA sync + HDMA run
  //.. DMA pending && DMA enabled ? DMA sync + DMA run
  //.... HDMA during DMA && HDMA enabled ? DMA sync + HDMA run
  //.. Run one bus CPU cycle
  //.. CPU sync

/*****
 * last_cycle()
 *
 * Used to test for NMI/IRQ, which can trigger on the edge of every opcode.
 * Test one cycle early to simulate two-stage pipeline of x816 CPU.
 *
 * status.irq_delay is used to simulate hardware delay before interrupts can
 * trigger during certain events (immediately after DMA, writes to $4200, etc)
 *****/
  //initial latch values for $213c/$213d
  //[x]0035 : [y]0000 (53.0 -> 212) [lda $2137]
  //[x]0038 : [y]0000 (56.5 -> 226) [nop : lda $2137]
  add_clocks(186);
I do try and comment where I can. Especially where something can be misconstrued as a bug.

But take things like this for instance:

Code: Select all

//DMAEN
void sCPU::mmio_w420b(uint8 data) {
  for(unsigned i = 0; i < 8; i++) {
    channel[i].dma_enabled = data & (1 << i);
  }
  if(data) status.dma_pending = true;
}
Anyone with a brain can tell if(data) means if(any DMA channels are actually active). I suppose I could add comments to that, but really ... it takes half a second to see it. If you can't, maybe you shouldn't be messing around with a SNES emulator :P

One problem is that it's really difficult to explain a lot of the really complex stuff in comments.

For instance, take a look at the recent HDMA findings thread. It would suck to have a 10-paragraph explanation of how DMA sync works alongside ~6 lines of actual code. It would make editing the code hard when it's immersed in an ocean of comments :P

What I really need is to write up real external documentation, and reference that in the code.

"DMA sync code. See /doc/s-cpu/dma.pdf for basic outline."

It would also be nice if there were some sort of universal standard for a "collapsed by default" comment, so you just get a little "?" box or something to hit if you want to see the long dissertation comments.
Deathlike2
ZSNES Developer
ZSNES Developer
Posts: 6747
Joined: Tue Dec 28, 2004 6:47 am

Post by Deathlike2 »

Nightcrawler wrote:I'm going to play devil's advocate here. You two love to throw around Word and Visual Studio as your examples of unoptimized, bloated programs. However, do you really know this to be true? With all the features in Visual Studio 2008 and Word, do you really think you could create something better? There's just no backing substance to your claims other than the programs are slow in loading. You have no idea why they are slow nor how they could be improved.
I didn't throw out VS, but I wonder how much stuff has to be loaded so it's happy.. not that it actually matters when time is spent compiling and debugging, that those minor things can be sped up and be helpful is always welcomed.
I'm not agreeing nor disagreeing with whether or not they are bloated. Just throwing out the fact that these claims seem frivolous to use as supporting evidence of your opinion of poor software design without backing. ;)
I guess it depends more on the primary usage of the app. If you only use 10% of an app's features and that app consumes 1GB, you wonder if you spent that space wisely. If the app is like 2MB but its feature filled, noone tends to notice this extra stuff as bloat.
P.S. Notepad is slow as hell to open and do anything with large files. That doesn't win any awards for speed in my book either.
Oh, I'm very aware of that.. I'm only referring to a simple "open app" case than a "open huge file" case. It's woefully insufficient but then again, you shouldn't expect to use it for that purpose in the first place...
Continuing [url=http://slickproductions.org/forum/index.php?board=13.0]FF4[/url] Research...
Nach
ZSNES Developer
ZSNES Developer
Posts: 3904
Joined: Tue Jul 27, 2004 10:54 pm
Location: Solar powered park bench
Contact:

Post by Nach »

If you want to determine if an app is bloated as defined above, it's easy to see by comparing to the competition. If the competition has a similar feature set but is a 10th the size, loads instantly, and works on slow CPUs, you have an indicator right there.

Most office applications today by the big companies ARE bloatware.
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
deltaphc
New Member
Posts: 9
Joined: Mon Feb 25, 2008 5:21 am

Post by deltaphc »

I'd say the perfect example of an all around well-written app is uTorrent. A nice-looking, fairly feature-filled torrent client; yet, it pops up literally at the snap of a finger, even on a *cold* start. And the standalone .exe is very tiny.

If only more software were written like that.
Locked