Quality of code is getting lower and lower?

Started by
81 comments, last by Raloth 19 years, 9 months ago
Quote:Original post by capn_midnight
Do you live under a rock? Magnetic levitation trains are much better, more economical and faster than regular trains that use wheels.
and C++ is better than C.

Could you then explain why the newest official C standard is C99 whereas the newest C++ standard is from 1998? Sure C++0x is just around the corner but both languages have commitees activly working on evolving both languages, they both have strong communities and large userbases, C is by no means obsolete it's still evolving.

Someone also mentioned longjmp instead of exceptions a solution that although a bit cumbersome works fine.

Also lets not forget that almost every language outthere has the ability to link and call C code, it's effectivly an universal bridge between languages that aspect alone makes it valueble.
HardDrop - hard link shell extension."Tread softly because you tread on my dreams" - Yeats
Advertisement
Quote:Original post by capn_midnight
Quote:Original post by Raduprv
Quote:Original post by capn_midnight
use exception handling. try again.


How do I use that in C?
why are you using a 30 year old language?


because its a 25 year old, 2 million lines long system written in a 30 year old language maybe ?
Lucas Henekswww.ionforge.com
Quote:Original post by Oluseyi
Quote:Original post by OrcSlayer
do you think it's truth that the quality of the code is getting worst and worst by time?
First of all, things get "worse" (a description of continuing deterioration), not "worst" (which is final, and thus can't keep happening).

Second, your programming skills are negligible, given your lack of comprehension of the value of powerful flow control constructs. Not every loop is condition-controlled; sometimes you intentionally write what would seem to be an infinite loop and use a break or other exit statement to terminate it because that's the most logical, efficient and readable way to code it.

In summary, learn to program before speaking about global code quality. Don't be hasty to assess things you don't fully comprehend. If such features are popular in several languages, then maybe there's a good reason why. Let the evidence suggest the argument rather than finding evidence to support a pre-disposition.

Happy hacking.

first of all, dont laugh about my spelling, english is not my primary language.
second of all, you are right that my programming skills are not great, I'm only 17 years old, and I'm learning to program by myself (and in school, but the level of programming in school is VERY low).
but still I allways try to program right, and not use "Exit looptype" or continue or goto, because I think it's just wrong...
you dont need to be that way... and judge me for everything I say (including my english skills, I do my best)
Quote:Original post by OrcSlayer
second of all, you are right that my programming skills are not great, I'm only 17 years old, and I'm learning to program by myself (and in school, but the level of programming in school is VERY low).
but still I allways try to program right, and not use "Exit looptype" or continue or goto, because I think it's just wrong...
you dont need to be that way... and judge me for everything I say (including my english skills, I do my best)

You are responsible for everything you said, and people will judge you based on what you said. Usually arguments reflect a person's knowledge of a particular subject. You said your programming skill is not great but at the same time you deem break, goto, continue as wrong. If you think you are right, then by all means prove it. Show us the evidence why it's wrong, then let's have a healthy good debate. That's how we debate.

Don't take what Oluseyi said personally, and he did not laugh at your spelling. What we do here is pointing out everybody's mistakes and blunders.
Only bad usage of goto is to create loops with goto _instead_ of do/while,and also goto into loops from outside.
That known rule are frequently misinterpreted as "no goto!" rule,because,as someone pointed out,theoretically,goto are not needed.But even puristic languages by Wirth all have goto. Because it's useful thing and may improve readability.

If you REALLY need to goto upward,do

label1:{
....
somewhere there goto are placed.
....
}//label1^

Just look downward to find to where you are going

I frequently use break and sometimes use goto,but my goto's really rarely points upward in code. So,to find to where flow are going you just need to look down the code. And i never use continue because i think continue is not necessary.
Instead of
for(something){blablabla1...if(a) continue; blablabla2}
i'm usually just using
for(something){blablabla1...if(!a){ blablabla2}}


Goto pointing downward are not a bad thing at all.

Also,i'm remembering one code that was most natural using loops made with goto :

loop1start:
Do Thing 1;
loop2start
Do Thing 2;
if(condition1) goto loop1start;
Do Thing 3
if(condition2) goto loop2start;

Think about it.I have 2 loops that shares same code "Do Thing 2".It was natural for that algorithm.Any other thing used instead of goto would be hideous.Duplicating thing2 are hideous too.

And,exceptions.
Exceptions shouldn't be used to exit loops..Each tool have it's use. Remember that from theoretical point of view exception is a only form of goto! .

In any case,if you code complicated things without using goto and break ,you will end up having a lot of boolean flags instead.It will make your program MUCH less readable.
Example:
bool breakflag=0;do{  .......  .......  do{    .......    .......    If(!(BreakFlag = mat[i,j]==0)){      .......      .......    }  }while((j<i)&&(!BreakFlag));  if(!BreakFlag){    .....    .....  };}while ((i>0)&&(!BreakFlag));versusdo{  .......  .......  do{    .......    .......    If(mat[i,j]==0)goto loopsexit1;    .......    .......  }while(j<i);  .....  .....}while (i>0);loopsexit1:

And imagine that there are four loops and seven reasons to exit and you will see what some programmers have to deal with.How you want to do it without goto? Does it increase quality of code?Or any complicated code are low-quality?

And also,there are non-recursive parsers like ones produced by Lex.
Imagine doing similar things without goto...that would be a hell.
Quote:Original post by OrcSlayer
first of all, dont laugh about my spelling, english is not my primary language.

You don't capitalize the first letter of a sentence in your language?
Quote:Original post by Raduprv
Maybe because I don't WANT to do exception handling?

Programming languages teach you not to want what they can't offer. Learn C++, then go back to using C. You'll feel as suffocated as you would going back to using basic.
Quote:Original post by DigitalDelusion
C is by no means obsolete it's still evolving.

Fortran is also evolving.
Quote:Original post by CoffeeMug
Quote:Original post by OrcSlayer
first of all, dont laugh about my spelling, english is not my primary language.

You don't capitalize the first letter of a sentence in your language?

There is no capital letters in my language...
Quote:Original post by CoffeeMug
Fortran is also evolving.


And heavily used in high performance number crunching applications.
Sometimes it's the right tool for the job, as is goto.
HardDrop - hard link shell extension."Tread softly because you tread on my dreams" - Yeats

This topic is closed to new replies.

Advertisement