Thread: Best way to program on Linux?

  1. #16
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    This thread seems to be going in the direction of "What compiler and/or IDE should I use for C programming on Linux?", so I am moving it to the Tech Board.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  2. #17
    Registered User
    Join Date
    May 2007
    Posts
    17
    Compiling in console can help you understand what's going on, i agree with that, but what about using a command line text editor? What's the point in using them for programming?

  3. #18
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    I do not know about fte, but I think Vim comes with a GUI version, and either way its unique vi heritage and interface is the point.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  4. #19
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    Quote Originally Posted by zacs7 View Post
    If you asked most Windows programmers how to compile something, they'd probably say Build -> Compile
    This one says "make"

    If I happen to be in Linux I like tend to use KWrite or vi - makefiles with both, using a shell for building & testing.

    but what about using a command line text editor? What's the point in using them for programming?
    after using Windows for a long time, it comes a bit strange to do things in terminal. It's like using DOS command prompt in XP, which i don't like very much and find obsolete.
    obsolete, DOS maybe. A linux bash shell? No. bash is windows command prompt on steriods. Take some time to learn what bash can do. Some problems in Linux can be solved with shell scripts alone, and not require writing a program.

    I used to do all my work with Dev-C++ and it really made things easy for me. While trying to figure out these things, why some people especially like using command line compilers or text editors? Isn't it time consuming and unuseful?
    Not really. Makefiles take 2 minutes at most to write. (And you do it once per project.) From there, you type "make" and make will rebuild only what needs it. (Dev-C++ uses make behind the scenes.) I used to use Dev-C++, but it was a little braindead in some things... I primarily use Textpad, sometimes Notepad++ (or if I'm not at home). vi in Linux does the nicest job of keeping indentation, everything from tabs inside a function to keeping comments running. (And still gives syntax highlighting etc. If I'd ever take a day or two to learn vi proper, I'd probably know what else it could do...)
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  5. #20
    Linux is where it's at movl0x1's Avatar
    Join Date
    May 2007
    Posts
    72
    vim for creating the C source code

    type -> vim hello.c

    vim
    ------
    Code:
    #include <stdio.h>
    
    int main(void)
    {
        puts("Hello Cruel World");
        return 0;
    }
    in vim type :wq



    compile --> gcc hello.c -o hello

    fire up the program --> ./hello

    Hello Cruel World

    vim and gcc --- they get the job done

  6. #21
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    This is going to lead to a text-editor war...

  7. #22
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Quote Originally Posted by grumpy View Post
    As sure as I can be going from memory. My copy of the C89/90 standard is in a box at work, so I don't have access to it at the moment.

    My copy of the C++ standard, which I happen to have handy, states that reaching the enclosing } of main() has the same effect as "return 0;". Annex C of the C++ standard, which lists incompatibilities between C89/90 and C++, makes no mention of anything like this. Not conclusive, I know, but production of the list of incompatibilities for information purposes was a formal requirement during the C++ standardisation process -- and I'm more inclined to believe in the content of an ISO standard over behaviour of any compiler.
    Allowing omitting the return 0 was a new thing in the C++ standard and is not allowed in C89. The reason that it is not listed in the incompatibilities section is that that section only lists things that prevent C code from being compiled as C++ code, not things that prevent the other way round. (That would be pretty stupid. You'd have to list every single new feature in C++.) Given that C programs MUST have the return 0, while C++ programs MAY have it, all C programs are valid C++ in that respect.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  8. #23
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > Allowing omitting the return 0 was a new thing in the C++ standard and is not allowed in C89
    I agree, this was a completely stupid thing to add to the C++ standard.

    C++ went out of it's way to try to eliminate all implicit behaviour inherited from C (a good thing), then starts adding some of it's own (a bad thing). No other int returning function has this behaviour.

    My guess is that it was added as a 'sop' to make all those void main programs easy to change by simply replacing 'void' with 'int' and the program was instantly up to spec. No need to go to the trouble of adding 'return 0;' in the code (oh the pain of a few keystrokes).

    *mutters something about being off-topic*
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can't compile an SDL program under Linux
    By dwks in forum Game Programming
    Replies: 2
    Last Post: 01-16-2006, 08:51 PM
  2. Compiling a C program in Linux
    By hern in forum C Programming
    Replies: 14
    Last Post: 06-28-2004, 08:33 PM
  3. A C++ program in Solaris that cannot be ported to Linux
    By tvenki in forum C++ Programming
    Replies: 2
    Last Post: 06-11-2004, 12:13 PM
  4. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 12:39 PM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM