Thread: Contradictory viewpoints, confusing the hell outta me

  1. #16
    Registered User
    Join Date
    Aug 2002
    Posts
    55
    lol, you crazy lot

    John.

  2. #17
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >lol, you crazy lot
    To be successful with computers it is a requirement to be insane. If you aren't insane but technically competent then you can probably fake it, otherwise you'll forever be just a user.

    -Prelude
    My best code is written with the delete key.

  3. #18
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,212
    You think that's bad? I broke into microsoft and grabbed all the code I could.

    BTW all the code at microsoft campus seems to be written in this language

    here's a snippet:
    Code:
    REM BigRedButton.bas
    REM Thsi progrom si f0r wen The Grate Gaits pressed The Big Red Button.
    LET bigredbutton = pressed
    IF bigredbutton = pressed THEN
    MWAHAHA:
    PRINT "Microsoft is your master and you are Microsoft's slave."
    GOTO MWAHAHA
    END IF
    
    REM Hahaha that'll get em

  4. #19
    Visionary Philosopher Sayeh's Avatar
    Join Date
    Aug 2002
    Posts
    212
    Okay, without all the banter and crap, here's the straight skinny on fflush().

    ----

    'fflush()' was originally written for _files_. That's why it has 2 'f' characters in the name: file flush.

    However, C views _everything_ (input or output) as a stream. That is where it's UNIX roots show. In UNIX everything is a stream. It greatly simplies the overhead.

    Today, it is usually okay to use fflush() on any stream, in or out. If you look at the sourcecode behind fflush(), you will see that it is a "safe" function and won't screw anything up. It makes decision about what it can and can't do, based on the IO block associated with your stream (file, keyboard, whatever).

    ----

    Don't take my word for it-- look at the sourcecode in your own compiler's implementation. That will atleast answer the question for your individual situation.
    It is not the spoon that bends, it is you who bends around the spoon.

  5. #20
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Don't take my word for it-- look at the sourcecode in your own compiler's implementation. That will atleast answer the question for your individual situation.
    That is the whole point. It is not standard. It is based on your own compiler's implementation. Period. In other words, I could write a compiler that, when fflush was called on an input stream, would fdisk your hard drive.

    And you know what? It wouldn't be any less ANSI compliant than every other compiler out there.

    Quzah.
    Hope is the first step on the road to disappointment.

  6. #21
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    Originally posted by Hammer
    >>Win98? You should know better than that. Shame on you.
    Yeah well, it costs money to upgrade, and I don't see that I'll get £180 pounds worth of benefit from it
    hehe, I'm using Win98 too.

  7. #22
    Visionary Philosopher Sayeh's Avatar
    Join Date
    Aug 2002
    Posts
    212
    That is the whole point. It is not standard. It is based on your own compiler's implementation
    I don't outright disagree with this somewhat narrow view, but that isn't the point. The point is learning. I think it would be a wise move if everybody on this board takes a look at fflush() and tries to understand what it's doing.

    When a developer starts understanding why things are done the way they are, _real_ understanding starts to come. A rule by itself has no consequence. Understanding _why_ allows you to evaluate the consequence accurately.

    Under the hood, all streams are the same. File, video, usb, serial, to C/C++. That's one of the main reasons C was developed-- to make IO generic to the application.

    To reiterate, just my opinion. I think it's important to understand what's under the hood and WHY it's there, instead of always falling back to some hard and fast "it's non-standard!!!!".
    It is not the spoon that bends, it is you who bends around the spoon.

  8. #23
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    To reiterate, just my opinion. I think it's important to understand what's under the hood and WHY it's there, instead of always falling back to some hard and fast "it's non-standard!!!!".
    A valid opinion, however, I believe it best to write clean code that has the best chance of compiling and working correctly where it may be implemented. To further that a step, if you can make your code 100% ANSI compatible, then do so.

    It it my opinion, that given the choice of using a compiler specific method of doing something, and using a standardized version of doing something, go with the latter.

    On that note, I don't really care why fflush(stdin) doesn't work. I know that in every implementation of it, it is not guarinteed to work the same way, so I don't need to use it.

    Especially when it is so simple to write my own code to do the same thing:

    while(fgetc(stdin)!='\n');

    As for 'looking under the hood', you don't get the source code to all libraries with every compiler, so no, you can't always do so. (MSVC++ anyone?)

    It's just a matter of style. You want to know why everything happens; I don't really care why it happens, I just know that this is the way it is; as such, since there is no reason to do it, I'll avoid it.

    Quzah.
    Hope is the first step on the road to disappointment.

  9. #24
    Visionary Philosopher Sayeh's Avatar
    Join Date
    Aug 2002
    Posts
    212
    It's just a matter of style. You want to know why everything happens; I don't really care why it happens, I just know that this is the way it is; as such, since there is no reason to do it
    That mediocre approach really saddens me. It isn't a difference in style-- that's the pacifist's answer.

    Ignorance is BLISS, while KNOWLEDGE is power. POWER!!! (buhahhahah hahahahah hahahahhh [evil laugh])... Essentially, I can take away just 1 of your development tools and you are dead in the water. You could take _all_ of mine, and I could rebuild them.

    And it is IMHO a crime to push the "oh you don't ever need to know what's under the hood" approach to students.

    Bad Quzah, Bad Quzah, Bad...Bad...Bad...
    It is not the spoon that bends, it is you who bends around the spoon.

  10. #25
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >And it is IMHO a crime to push the "oh you don't ever need to know what's under the hood" approach to students.
    I agree. Learning the implementation aspects is just as important, if not more so than learning the interface. But, you and quzah seem to be on both ends of the argument when the correct answer is in the middle. If you know how things work under the hood but cannot drive properly then your knowledge isn't practical, if you know how to drive properly but have no idea how an automobile works, you're knowledge is incomplete.

    It is important to understand both the inner workings and the correct use of the interface to get the most out of programming. Of course, I recommend learning how to use the interface correctly first and then learning how it works so that I don't have to keep screaming about void main and fflush ( stdin ) not being 'correct' even if they work.

    -Prelude
    My best code is written with the delete key.

  11. #26
    Registered User
    Join Date
    Aug 2002
    Posts
    55
    I'd have to completely agree with this opinion. Whilst I'm not proficient with C/C++ yet, I do have a wide range of programming experience, and I do believe that the more you know, the better off you are.

    I started a long time ago, using programs like Ultradev to throw server-side code together, using 'extensions'. The joy. It's horrible think that the guys at work, depend on it.

    3 years on, and I'm more than comfortable with programming in around 12 different languages, and I no longer use anything like Ultradev (God I hate that program lol).

    A suggestion for anyone trying to learn any language: If you don't know why something happens, find out. I think I've resulted in learning C/C++, because I've always craved knowing how things work, so I've gradually worked back from HTML, CSS, Javascript, VBScript and the like. I started jumping into ASP, PHP and VB, then Perl and a few other lesser-known languages, like Lingo and ActionScript, and now, I'm working on C.

    Being able to research for myself (using newsgroups/books/articles), is just so valuable, and I think it's very difficult to do that, if you truly don't understand what is happening around you.

    The experience I've gained from really playing with these languages, and understanding their core, has also resulted my general knowledge of security, exploitation, and how things work, such as protocols, being increased far beyond what any book could teach you.

    Books are good for getting started, but as soon as you have a question it doesn't answer, you're caught in 2 minds. The doubts that kind of situation create, shouldn't be something to ignore, or be something that catches in the back of your mind, it should be something to research, and learn from. Remove all doubt and you've gained something very valuable.

    Just my two pennies anyway. I'll go back to sleep now lol.

    John.
    Last edited by John.H; 08-21-2002 at 12:57 PM.

  12. #27
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Originally posted by Sayeh


    That mediocre approach really saddens me. It isn't a difference in style-- that's the pacifist's answer.
    You're misreading me. Consider the following:

    void main( )

    Does this "work"? Yes. Is it "correct"? No. Do I know why? Sure, becuase it's non standard and the OS expects an integer. Do I need to disect the machine and look up all the specifications for my operating system to see WHY it is "incorrect"? No. It is incorrect, so I don't use it. I know it has undefined behaviour. Do I need to know EXACTLY what happens to my OS when I return it something it doesn't expect? No. I have no need to examine my OS at that level. It doesn't concern me because for what I do, it is irreleveant what the OS does with an undefined return.

    fflush( stdin );

    This is also undefined, so I don't use it. I know for a fact that this "works correctly" in MSVC++. So by your reasoning, because this specific implementation allows this to "work", I should use it freely? No. That's absurd. The entire point here is that I don't NEED to know why this works in MSVC++. As a matter of fact, I know why it works: Because they implemented it to do what they want it to. It still doesn't change the fact that it is "incorrect" to use it.

    Just because it works fine in some implementations, and not others, doesn't mean I should use it because I happen to "know why" it works or doesn't.

    That's my point. I could care less why it does or doesn't work. I know that it does[n't] work and as such, I know enough to use it appropriately.

    You don't have to know at the machine level what a function is doing. God forbid you ever use Java or C++ where the implementation is hidden.

    The whole concept of OO must bug the hell out of you, since you're so stuck on "knowing why".


    Originally posted by Sayeh
    Essentially, I can take away just 1 of your development tools and you are dead in the water. You could take _all_ of mine, and I could rebuild them.
    Really? You could build yourself a compiler without a compiler? My "development tools" consist of a compiler and nothing more. (Sure, it has an IDE, but I don't need it.) So if I take away your text editor and compiler, you can build yourself one from scratch without having a compiler? I highly doubt it. As a matter of fact, I'd lay money on it. This is just a foolish statement on your part. You assume too much.


    Originally posted by Sayeh

    And it is IMHO a crime to push the "oh you don't ever need to know what's under the hood" approach to students.
    Again, you're oversimplifying. No, you don't need to teach your students what at the hardware level each function does. I do not need to see the source code for printf to be able to use it. I do not need to see the source code for malloc to know what it does and how to use it. Your example of wanting to see the source code for fflush to know what it does is ridiculous.


    Originally posted by Sayeh
    Bad Quzah, Bad Quzah, Bad...Bad...Bad...
    Speaking of foolish statements...

    Quzah.
    Hope is the first step on the road to disappointment.

  13. #28
    aurė entuluva! mithrandir's Avatar
    Join Date
    Aug 2001
    Posts
    1,209
    Personally, I do think that a knowledge of hardware makes you a better programmer, but I don't believe that you must know 100% exactly the in's and out's of a language on a technical level.

    I guess that's because I'm not a computer scientist ( my area of study is in information systems).

    The important thing is that I understand enough to get the job done efficiently, effectivley, and to user requirements. Delaying the implementation of a program simply because you felt that you must use some technique to get 5% extra peformance would not be worth the effort. Everything in development is a tradeoff between time, money, and resources. In the real world, this is the way things work.

  14. #29
    Banned Troll_King's Avatar
    Join Date
    Oct 2001
    Posts
    1,784
    I think it would be great to know how to write our own compilers and operating systems but I don't know of anyone who has gone to too great of length to write those books.

    That time is money in the real world junk reminds me of when I was in kindergarden and we had that arguement about my father is tougher than your father. As an adult I would perfer to do things for myself and make up my own mind. I don't want to be 100% dependent on the vendors and made to believe that I have to purchase everything that they produce because even though I'm learning how to program, for some reason, I can't build systems, I am forced to work on the presentation solutions only? Wow I must be a poor bugger, and I can't think, can't use my brain.

    It should be considered with all of the applications that are out there to make my job easier, just how much of this do I really need? I don't want to make my job needlessly more difficult. Maybe I really should be attempting to build my own OS, compiler, and systems. So long as I can communicate through open standards than it doesn't matter what I'm running as long as it gets the job done.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Living in the 00'S
    By mithrandir in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 01-21-2002, 09:31 AM