POV-Ray : Newsgroups : povray.advanced-users : movie within : Re: movie within Server Time
29 Jul 2024 06:25:10 EDT (-0400)
  Re: movie within  
From: Dan P
Date: 4 Feb 2004 12:03:32
Message: <402125e4@news.povray.org>
"Warp" <war### [at] tagpovrayorg> wrote in message
news:40211675@news.povray.org...
> Dan P <dan### [at] yahoocom> wrote:
> > I believe my 15 years of studying and
> > programming experience will come in quite handy.
>
>   If 15 years of programming experience causes you to make programs with
> the quality of the one you posted at the beginning of this thread, I find
> that quite amazing.
>   No offence, but the program looked like made by someone who has started
> learning programming a month ago.

Oh, no offense taken, Warp. I'm just surprised you gave me a whole month.

> > Warp, I didn't argue with you about your coding styles because I didn't
want
> > to get into a fight over something that is largely a matter of style.
For
> > example, even though I used global variables, it makes it easier to take
> > that program and put it into a class that way -- I wouldn't have to
change
> > all the references in the code so they were no longer in a struct when I
> > encapsulate it.
>
>   What I wonder is why you didn't create a class to start with. The fact
> that the program is small is a lousy excuse to make it horrible, specially
> if you are going to post it in public. If someone learning programming
were
> to study your code and enhance it he may well learn really bad habits and
> get himself into trouble. In fact, by doing this you are learning bad
> habits yourself.

I didn't create a class to start with because it wasn't a C++ program. Do
you mean posting code like that is a bad habit?

> > Putting error handling before putting success handling is
> > very odd and makes the code harder to read (some people have that goal,
> > though), in my opinion, but I respected your style.
>
>   I don't understand how it is easy to read that you open a file and
> handle its failure tens of lines later. The error handling was hard
> to find and it was hard to associate with the line where the file was
> opened.

You must write some pretty hard-to-read code if you can't find the end of
your blocks. Try indenting your code and putting in empty lines to break
parts of the program up. Also, if you have blocks that are that large, it
means that you need to add more methods. Only beginning programmers write
C++ programs like they are in BASIC.

>   When opening a file success means that the program can continue
normally.
> That is, it doesn't have to interrupt its normal flow. Only failure means
> that it needs to stop its normal flow.
>   That is, the code is clear if it does something like this:
>
> - Open the file.
> - Did opening fail? If so, issue an error.
> - Read the file.
>
>   In your case what you are writing is this:
>
> - Open the file.
> - Read the file.
> - Did opening fail? If so, issue an error.
>
>   It makes no sense to keep the success check separated from the opening.

Then why do programs like Java require you to write blocks of code like
this?

try
{
    Do something
}
catch (Exception ex)
{
    Failure
}

Are you saying all these people are wrong? I've never seen a person write
code like you describe in my lengthy career of programming in many different
languages. The difference between you and I is that I'm not saying YOU are
wrong for doing it that way. It's your thang... do whatchoowannado. As long
as you're consistent.

>   Besides, by doing it that way you are needlessly introducing an extra
> level of block nesting. The more nested blocks you have, the harder it
> is to read the code.

If you write blocks as lengthy as you describe, then you're right. Every
single person (without exception) who has read the... well, it's gotta be
more than a million now... lines of code that I've written have all said
that my code is so readable that they consider it "self-documenting".

> > Casting a pointer to
> > (void *) when freeing is actually a common practice and if you widened
your
> > experience with C you'd see a lot of other people use it.
>
>   I have been programming C probably longer than you, and I don't remember
> seeing anyone casting to void* to free memory. There's no need, it doesn't
> make sense, and it's in fact dangerous.
>   Consider this:
>
> int a = 5;
> free((void*)a);
>
>   Kaboom?

Well, duh, Warp; a isn't a pointer. Why would you even do that?

>   The compiler does not issue an error message, not even a warning.
However,
> the program will most probably crash.

However, without it, some compilers will report a warning that you are using
a pointer without cast because the free function prototype includes a
pointer type of void. Given that you use EXIT_SUCCESS for your return
values, I am assuming that you only program on one system, but that is just
an assumption; prove me wrong on that.

>   Granted, in this case it's easy to see what's wrong, but in a much
longer
> program a mistake like that can be pretty hard to find.

By saying something is self-evident does not support your argument. Read the
book "The Art of Deception". That's in chapter 1.

>   If you, however, make "free(a)" the compiler will issue an error
message.
>
>   So I'm sorry, but you are simply wrong.

No, I'm not.

> > I put fflush() in
> > there because I'm in the habit of flushing buffered streams -- habit -- 
let
> > me say that again, -- habit -- and so it was something I typed
> > automatically.
>
>   Not all habits are good.

I agree. However, one does not form habits without experience.

>   Certainly if you use fflush() too much when not needed you are only
making
> a slower program for no reason.

Wait... doesn't it have no effect? You're saying that those clock cycles NOT
IN A LOOP that equate to no more than a few milliseconds is making my
program slow? I've already admitted numerous times that I didn't know that I
didn't need to flush stdout and I've already said why I did; because it is a
buffered stream and I thought, because of that, it did.

> > Returning 0 instead of EXIT_SUCCESS is also standard, and if
> > you learned C when I did from the K&R book, you'd know that too.
>
>   No it isn't.
>   There's nothing in the C standard that says that 0 is the return code
> for success. The return code for success is system-dependant and that's
> why EXIT_SUCCESS should be used instead. That's why EXIT_SUCCESS and
> EXIT_FAILURE exist in the first place.

Go search the net for C programs and look for yourself. I'll wait. Some
people even use exit(0) as well. Since you don't do that, write them e-mails
and tell them they're all wrong. They'll love that.

> > But, you
> > know what, I didn't want to make you look bad because your way of doing
> > things works as well and it is a matter of personal preference.
>
>   You seem to have this odd arrogant attitude. Don't you understand that
> by trying so badly to make yourself sound competent you are only making
> a fool of yourself?

...huh? Again, you're arguing for my side against you.

> > Your coding
> > style is not the /RIGHT/ coding style, it is /YOUR/ coding style, Warp.
If
> > you were argue /RIGHT/ coding style, then according to the fathers of C,
I'm
> > actually closer to it than you.
>
>   Yeah, I'm sure that the "fathers of C" suggest that you use tons of
> global variables, never check the validity of input data, index out of
> boundaries in tables (such as argv[]), read data to static buffers without
> limits and make system-dependant code.

If they were running off a quick example like I did, they probably would do
the same thing because they understand the goal of the program was to
demonstrate a concept.

>   Perhaps you should read the latest C standard and some good programming
> design book.

Same to you.

> > As far as including variables I don't use, like the version, and the
static
> > insecure char buffers, that was there for the same reason I didn't check
the
> > command-line arguments -- I wrote it for personal use to put together an
> > animation quickly for a project I was working on and if I wanted to
refine
> > the code to release to the public on a board like you did, I certainly
would
> > have checked for those parameters.
>
>   But you didn't add the checks, yet you still published the code in
> a public forum. Yeah, sure.

Unlike yourself, I'm not insecure about my code, so I don't worry about
people like you picking it over.

> > I understand that you're a perfectionist
> > about these things, but I'm more goal-driven than yourself, and the goal
was
> > create motion-blur, and the goal of the post was to demonstrate how to
do it
> > with sample code, not impress you. I understand how you might find that
hard
> > to imagine.
>
>   What I find hard to imagine is that someone who allegedly has 15 years
of
> programming experience can make such crappy code and isn't even embarassed
> to post it in a public forum full of programmers.

Well, imagination isn't something everybody is born with.

> > Now, I have too much class to download your targa averager and nitpick
over
> > your coding style and say it is wrong to a group of your peers. That
would
> > be disrespectful and naive. When you get more experience working on
> > projects, you'll understand.
>
>   Now you are being incredibly hypocritical. You explicitly ASKED ME to
> comment on your code. Initially I did not, but then you asked so I did.
> Now you are talking as if I had given you comments you didn't ask and
> weren't interested in.

Yes, I did. And I thank you for your comments. The point is that I could
nitpick about your code in front of your peers as well, pointing out all
kinds of things that are a matter of style and saying you're WRONG, but I
don't because I have too much class and I understand that everybody is
different and I respect those differences.

>   As for my averager program, the code is crappy.

Well, well, well. To use your own argument, that's no excuse to post it on a
public web-site! All those bad coding habits you have -- you're going to
spread those, Warp!

> I wrote it 6 years ago
> and I certainly did not have as much experience as today. If I were to
> write the same program again, it would certainly look completely
different.
>   I could better ask you to look at my newer code, but seeing your real
> programming skills and your state of mind that would be only a waste of
> time and resources since I will not be getting anything constructive.

I see you realize my point now. You're not perfect and you're pre-emptively
defending yourself against my criticism about your code. You're so arrogant
that you think I actually: a. care enough about it to do so, and b. have the
time to bother.

All this and I STILL think you're talented and smart because you made the
effort to demonstrate it instead of spending all your time on boards telling
everybody how stupid they are.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.