Optimized coding (Development MSX Fora)MSX Resource Center MSXdev 2008 - MSX1 development bonanza!           
            
English Nederlands Español Português Russian         
 Nieuws
   Voorpagina
  Nieuws archief
  Nieuws onderwerpen

 Informatie
   MSX Fora
  Artikelen
  Recensies
  Beursverslagen
  Fotoreportages
  Beurzen en meetings
  Enquêtes
  Links
  Zoek

 Software
   Downloads
  Webshop

 MRC
   Wie we zijn
  Kom bij ons team
  Doneren
  Policies
  Contact met het MRC
  Link naar Ons
  Statistieken

 Zoek
 
  

  

 Login
 

Gebruikersnaam

Wachtwoord




Ben je nog niet lid? Klik hier en word MSX vriend!


 Statistieken
 

Er zijn 48 gasten en 1 MSX vriend online

Je bent een anonieme bezoeker.
 

MSX Fora


MSX Fora

Development - Optimized coding

Ga naar pagina ( 1 | 2 | 3 Volgende pagina )
Schrijver

Optimized coding

snout

msx legend
Berichten: 4991
Geplaatst: 16 Januari 2003, 12:42   
In the TeddyWareZ thread the topic changed to the lazyness of most current coders and the major difference with highly optimized, direct control MSX coders.



Indeed, especially with Java, there appears to be a general attitude 'don't mind if you don't know how it works or what it does, just as long as you can use it to get the results you need'. Imho that's a bad thing. So .. eeh.. read the thread on TeddyWareZ and start replying here
ro
msx guru
Berichten: 2329
Geplaatst: 16 Januari 2003, 14:29   
I think the general idea is:



Real coding is a lost art.



It's just like cooking in a way: making something out of nothing.

If I don't know the exact ingredients, and how they taste like, and I would just mix them together to get SOMETHING eatable, it would not mean it is really tasty.

So what? food is to keep you alive, right? Well, this is food. now, eat it! (and stay alive)



I might be alive, alright, but would I be happy? (will I ever, by the way)



This is how I see coding isues these days; again, lotsa spaghetti!



come to think of it: Isn't this a real BUGGY time, these days?

I mean, every applic you see, isn't bug free as opposed to old MSX warez, which were testing again and again. And, because code was in general okay, debugging was not a big issue. And, thankfully, a product that was released was, most of the time, bug free.



Nowadays, it is like normal to have mucho buggaloos in softs....

what's up with that? I tell you, not enough real knowledge. Coders don't EXACTLY know what they are doing anymore... or atleast I get that feeling over and over again.

But hell, I could be wrong...



AAAAAAAAAAAAAAAAAARRRRRRRRRRRRRRRRRRRRRGGGGGGGGGGGGGGGHHHHH

having said that, later.


msxhans
msx user
Berichten: 35
Geplaatst: 16 Januari 2003, 20:49   
> Real coding is a lost art





Coding is indeed the art of writing programs (thats the title of a book by Dijkstra, a famous dutch computer science professor). And a good artist is not only creative, also he or she is well trained and experienced in using his tools. So a good coder is also a professional and carefully chooses the best tools and learnes how to uses them.



Not only is writing programs an art, it is also a profession. Often it is not a modern profession, it often looks like the middle ages with guilds and secrets. Ambachtelijk is the dutch word.



Already in the seventies it was noted that many programmers did not produce good programs and took a lot of time to produce anything. The worst conclusion was that in the total lifecycle of a software product the coding part is only a small part in the total. Maintaining (which means not only debugging the bad programming but also trying to make the program do things it was not really fir or designed for takes 75% of the total time/money.

It was called the software crisis in 1972. And it still is with us!



In the seventies and eighties of the previous century structured programming and design were developed as tools to fight the crisis.

Simple rules as: do only one thing in a procedure, produce readable code, limit size of source to 1 A4 per function, use good tools that help checking (like Pascal that require variable declaration and check type misuse etc and an operating system that prohibits a program to do stupid things like overwriting memory it is not supposed to) are still valuable.



The best test of programming is peer program reviews: let other programmers read the code. If they understand what the code is trying to do and dont see obvious errors it has a chance of being maintainable! And in those years Edsgar Dijkstra wrote the article about GOTO considered harmfull, fight spagghetti code! He also said programmers have a mental injury after writing Basic programs



In the ninetees object oriented programming was added and had its merits like data isolation and reusable code, alas the lessons learned by structured programming were often forgotten.

GUI programming styles which are event driven are the most difficult programs to write.

In a lineair program you know where it starts and where it ends, in a gui program you invite the user to click anywhere and start code. Combined with bad memory management support in C for example (horror: an application programmer who manages memory) leaves to programs with lots of duplicated/similar code and neither initialized or unknown variables. No wonder we have crashing windows systems!



I do not mind programs that take up memory and disk. I do mind programs that have a bad design and bad coding and are build with tools that are not helping the programmers to produce usefull programs with some resilience. Therefore i consider C a dangerous tool. Assembler is even worse, all quality is left to the programmer, a poor human who makes errors and is not perfect.

Quality is defined offically (OSI standard) as doing what the user expects of it. And that means showing the promised functionality with acceptable performance, being resilient , being able to let the user make obvious errors and help him use the program. Good is good enough.



For programmers it often means optimizing beyond necessity, have functions the user does not want, as small as possible, being excellent. So a programmer is never finished if he is not forced to by time, managers, money etc.



Programming computers like MSX is not different than programming in general. What makes it a challenge is speed, not much memory, not many good tools and not an operating system that helps (it is even worse: not too well documented for programmers, so many errors in for example MSX DOS 2.2 programs.

So a MSX programmer needs to know his tool, the MSX, better than programmers for systems with less limitations.

Does that make programmers for MSX any better? Not in general, i have seen many sources written by MSX programmers in assembler (you can see them too at funet or my site) and many are not easy to read, spaghetti coded and not maintainable. Even the author will find it difficult to understand several weeks later. Commenting, explaining use of data, structured programming, it is rare.



Oh, and what about testing? Testing can only proof that the number of errors left in a program is acceptable ....




wolf_

msx legend
Berichten: 4713
Geplaatst: 16 Januari 2003, 21:11   
about the basic stuff:



The old linenumber basic, with the goto stuff, and primitive structure things should die

It's the way to make messy programs.



it doesn't mean however that the idea of basic is wrong, imo.



to me, 'basic' means



- very natural reading, almost pure english

- a good set of internal gfx/sound stuff (so no crap with include files) and a lot of handy services like stringmanagemt (compared to c++ where strings are an array of chars rather

- a simple editor.. no bilion seperate windows on the screen all showing something that scares the shit out of me..



(((IMO: c(++) was meant for tita-wizzards with long beards and light-emitting eyes. )))


msxhans
msx user
Berichten: 35
Geplaatst: 16 Januari 2003, 21:46   
Indeed, linenumbered based Basic as in the MSX lacks the element of structured programs: blocks (a block is a group of statements that is acting together as one statement: pascal uses begin ..end, C uses {}). So you get GOTO's. A modern Basic does have blocks.



And i agree on this too: I prefer code that reads like natural english, letting code be read as a story. I will not go as fas as calling good code being poetry, but well layed out code has beauty.
GuyveR800
msx guru
Berichten: 3048
Geplaatst: 16 Januari 2003, 22:18   
Programming like that is for wusses. REAL programmers use assembly code and write code they themselves cannot understand anymore after 2 months. If it's fast and bugfree it doesn't need maintaining. If it needs new functionality it needs rewriting anyhow, because building something new on something old is never seamless. Look at building houses, if you build a new wing later you'll always get cracks between the sections eventually.



With the proper tools even superduper fast machine code can read like english (even though english itself is a speech impediment), and even more so than most other programming languages.



And indeed, coding is a very creative art. And art can't be designed, it must evolve. It's like a sculptor who starts with a block of stone and hacks away everything he/she doesn't want there. A coder starts with nothing and hacks away until it does something he/she wants.



Code reuse and libraries are a possiblity in any language, but when applied to games will often lead to boring shite. (Look at the 3D engines that can only produce the same over and over again)



And in the defense of MSX-DOS2, it's heaven to program with! It's very well documented and takes away a lot of hassle. It's better than any other DOS I've ever seen.
wolf_

msx legend
Berichten: 4713
Geplaatst: 16 Januari 2003, 22:42   
Quote:

REAL programmers use assembly code and write code they themselves cannot understand anymore after 2 months.





...talking about spagetti



well, if that means that ALL projects are done within 2 months, who am I to argue



But since some applications have shown to take longer to develop, I assume those coders use hacky undocumented code and need to rewrite everything from scratch, everytime..


GuyveR800
msx guru
Berichten: 3048
Geplaatst: 16 Januari 2003, 23:30   
Oh no, I'm not talking about spaghetti. I don't like that any more than the next guy!

I'm talking more about things like:



ld a,b ; calc pattern offset with flip

ld c,[iy+2] ; store pattern

srl c

rlca

ccf

rl c

rlca

add a,ChgdSprites >> 8

ld b,a ; bc points to Changed Tiles Table



When I had to rewrite this piece of sprite renderer code from GEM to Z380, I was like "wtf is this?!". Even though it's commented it's still a mystery, but it's damn fast
Arjan
msx addict
Berichten: 466
Geplaatst: 16 Januari 2003, 23:35   
There certainly are some cool reactions here!



It's a good thing we don't have to code everything in assembly anymore. It's just not very economical. Programs in asm costs too much time to write, too much time to debug and too much time to maintain. Time is money, so use the best tools for the job. With vb.net, is very easy to create GUI's, way easier than doing the same in C++ (let alone asm ). I was simply amazed by how fast I could code function applications in vb.net, it took way less time than doing similar stuff in C++. Even when you don't know everything about vb.net...



With the increase in CPU speed, low level languages aren't really needed anymore. The CPU is idle for most of the time anyway, and who cares if a program responds in 0.002 seconds instead of 0.0019 seconds (Guyver )? I just don't care. If you really need speed in a specific part of your program, use a lower-level language to do stuff. Assembly isn't really a neccesity anymore, a good compiler can generate faster machine code than most mere humans.



On the MSX, I only use assembly, because I need to get everything as fast as possible since the z80 isn't that powerfull. On GBA, some companies do everything in assembly but I think that's just nonsense. There are only specific parts I'd do in assembly, like a sound engine, maybe a tile engine but definately not everything. On PC, I wouldn't even touch assembly. Or maybe, only for the sake of knowing x86 assembly...



Is code art? I don't know... A good program starts with a good design, might be even more important than the actual coding. Having a good design makes the actual coding a lot easier, dividing work over multiple people gets easier. Also, adding functionality to a program that hasn't been designed is much more difficult than adding new stuff to a program that has been properly designed.



When actually implementing something, not only you need to know how to code, but also how to layout your code. You'll have to create programs that can be easily read. Don't cram 10 expressions in one line, even though it might look 1337. Name your functions and variables properly, insert as much comments as possible / needed. Actually, you can comment _everything_ if you know to do it... hmm this is getting a little offtic...



Oh yeah code reuse is heaven! Even 3D engines can be reused. RenderWare is a good example.



About programmers knowing less details... That's probably true, but does it really matter? Does someone who codes the GUI for a windows application have to know how to draw everything himself if windows wouldn't offer that functionality? Well, I wouldn't. Knowing how to program is more important. A good programmer can code everything, but that doesn't mean he has to code _everything_!



Sloppy code...Bombaman is full of it Actually, the code of the last few years is much better than the code I had in the beginning. Too bad a lot of courses offered spend too little time on quality code. Actually, I haven't had a single comment on my coding-style during my study. Of course, I could spaghetti code a bit when I start my study, but..none of my fellow students got any comments on their style either. Might be just my school, but I fear not... I even think the quality of the courses offered is getting lower and lower. Some cool courses that were obligated some time ago, aren't obligated anymore. Some of them are very useful I think, like a course about Algorithms and Datastructres. Needless to say, I will attend to these courses


Arjan
msx addict
Berichten: 466
Geplaatst: 16 Januari 2003, 23:55   
Quote:



ld a,b ; calc pattern offset with flip

ld c,[iy+2] ; store pattern

srl c

rlca

ccf

rl c

rlca

add a,ChgdSprites >> 8

ld b,a ; bc points to Changed Tiles Table



When I had to rewrite this piece of sprite renderer code from GEM to Z380, I was like "wtf is this?!". Even though it's commented it's still a mystery, but it's damn fast



It's commented, but not commented well enough. Putting the calculation needed above this piece of code would help a lot. Also, what's stored at [iy+2]? I'm sure I would forget that after a few months. (forget some of this if we're missing a part of the big picture...)
GuyveR800
msx guru
Berichten: 3048
Geplaatst: 17 Januari 2003, 00:05   
I'm not talking about a PC with a multiple GHz CPU... Most programs these days run on embedded systems or mobile devices that have a CPU with limited horsepower.

And in fact so many applications are written with 'speed doesn't matter' that your

PC must be more than 10 times as fast as it should!

Mobile devices are already running ARM chips of several hundred MHz's.. That is more performance than anything could possibly need. But for a large part thanks to microsoft, they still feel sluggish.

Bah... Don't get me started
DarQ
msx professional
Berichten: 836
Geplaatst: 17 Januari 2003, 00:18   
haha, microS. You've got yourself started already ?!
ro
msx guru
Berichten: 2329
Geplaatst: 17 Januari 2003, 08:15   
the thing about 'having enough CPU power' is what bothers me.



"In order to get this new piece of hot software up and running smoothly, you NEED to upgrade to the new standard"



That's just pure bull, man! Do I HAVE TO buy a new CPU every f*!!ng year?

(put down your greedy hard earned dollars and buy! buy, you sucker!)



A long time ago, I had this incredible machine with 'limited' horsepower in the size of 3.54 MHz (or s'mthing). I had this machine for YEARS (a decade or so) and was very satisfied with it too. After a while there was a new type of this machine which offered 7.18 MHz (was it?).

It was cool, nothing more than that. I, and others, got very good results on the *old* machine as well as on this new one.



Now, these days, it's all about matching the CPU to your code. Not the other way.

If this machine is not fast enought (anymore), just buy a new one, and let the whole world do the same. (again, put down your dollars and BUY!)

This attitude is what I was talking about earlier.



It's gotta fucking stop! If a person was to write decent, fast and logic code, CPU power should not be that a big issue. But, like mentioned above, coders tend to accomodate to the 'comfort' of having CPU power. So, why not use sloppy code with the same result, eh!



.. it's not that I am mad about coding abbilities as much as sloppyness.



reminds me of these lines:



----

Something has to change. Un-deniable dilemma. Boredom's not a burden anyone should bear.

Constant over stimu-lation numbs me and I wouldn't have it any other way.

It's not enough! I need more! Nothing seems to satisfy.

I don't want it! I just need it! To feel, to breathe, to know I'm alive.

----



It's where the man sings about having too much of anything these days. Over-stimulation. I need more!!

No one should get bored anymore, there's always TV, PC, GAMES, RADIO etc.

But still it's not enough!



(in case you were wondering: it's a phrase of 'stinkfist' by Tool)



ro.
Arjan
msx addict
Berichten: 466
Geplaatst: 17 Januari 2003, 08:57   
Hmm I don't think the programmers are the problem... There are actually very strict deadlines, set up by the management/boss. At my work (internship), I also have deadlines. If we run out of time, my boss says 'just make it work, we will optimize/fix it later'. Of course, later==never, so I my code will remain unoptimized...
ro
msx guru
Berichten: 2329
Geplaatst: 17 Januari 2003, 09:11   
oh, but I wasn't only shouting at coders, I was more yelling at the business in general.

you are 50% right here.



Why is it that your boss thinks you can do it in, say, 2 weeks. While it should really take 3 weeks. Some one probable tolded him or, even worse, your boss is a coder himself.

We've gotta see at the root of this problem, still I think coders have a lot to do with it.



I always plan more time to get thinx done than it actually would take me to accomplish certain tasks. I just play save. And, to be honest, I do deliver good and finished stuff.

or else I would not bother.



but uh, weren't we talking about the code, and coders. They've gotta make a stand!
 
Ga naar pagina ( 1 | 2 | 3 Volgende pagina )
 







(c) 1994 - 2008 Stichting MSX Resource Center. MSX is een trademark van MSX Licensing Corporation.