Post subject: C programming
Editor, Reviewer, Experienced player (980)
Joined: 4/17/2004
Posts: 3109
Location: Sweden
So I'm planning to learn some C. I know there are some good C programmers here, so I thought I'd ask for tips. Where can you get a good (free) compiler which works under Windows? And an editor, preferably with indenting and syntax checking? Any general programming tips are also welcome. I've programmed qbasic, pascal, ada and scheme (lisp variant) before if that's any help...
Post subject: Re: C programming
Joined: 4/25/2004
Posts: 498
Truncated wrote:
Where can you get a good (free) compiler which works under Windows? And an editor, preferably with indenting and syntax checking?
The Dev-C++ editor comes with the MinGW compiler system. Good stuff. :)
Former player
Joined: 3/19/2004
Posts: 710
Location: USA
The two most popular editors are Emacs and Vim As for the complier, though devcpp is good compiler-wise, I can't stand its editor, so I use mingw under cygwin, though that's perhaps a bit too complicated. Though if you don't want to install cygwin, I hear you run it under mysys. For a beginner though, devcpp is fine.
Editor, Reviewer, Experienced player (980)
Joined: 4/17/2004
Posts: 3109
Location: Sweden
Thanks for your help. I'm downloading devc now, i'll try it as soon as I get home.
Joined: 8/1/2004
Posts: 143
Location: Colorado
I like JEdit as a text editor/IDE. It's based on java so it can run on any platform (I use it on both Linux and WinXP). Also, if you're doing development on Windows, Cygwin comes in very handy for a lot of unix tools like tail, find, cut, sed, etc etc etc
Active player (333)
Joined: 11/25/2004
Posts: 75
I like to use Cygwin and Vim (links above) for all my programming needs.
Currently working on: SNES Star Fox, Level 3 (100%, published) SNES Star Fox, Level 2 (33%, after Sector X) SNES Star Fox 2, Expert mode (100%, published)
Joined: 3/31/2005
Posts: 148
Location: Colorado
Dev-C++'s editor is OK if you turn off smart tabs. Those piss me off like no other, but otherwise I haven't had a problem with it.
Do not try to bend the spoon, that's impossible. Instead only try to realize the truth. What Truth? There is nospoon. Then you will see it is not the spoon that changes, it is only yourself
Player (36)
Joined: 9/11/2004
Posts: 2631
YtterbiJum wrote:
I like to use Cygwin and Vim (links above) for all my programming needs.
Fixed for me. expandtab shiftwidth=8 Like a little kernel hacker. :) If only a was actually any good.
Build a man a fire, warm him for a day, Set a man on fire, warm him for the rest of his life.
Editor, Reviewer, Experienced player (980)
Joined: 4/17/2004
Posts: 3109
Location: Sweden
>If only a was actually any good. What? But a is good. I like a. :( Vim and Emacs are two editors I will never get along with though. I spent a good 15 minutes trying to just close Vim (never mind actually TYPING something), before I gave up and just killed the sucker. But uh, C programming, right. Today I managed to extract the relevant portions from a QNX-infested mess of C++ code and convert it to a C program which actually works and am so proud I must boast. :D
Player (36)
Joined: 9/11/2004
Posts: 2631
A moves too fast, 192 bpm 16th notes do not belong in any song ever.
Build a man a fire, warm him for a day, Set a man on fire, warm him for the rest of his life.
Banned User
Joined: 3/10/2004
Posts: 7698
Location: Finland
Would C be your first programming language which you would be learning? If your answer is yes, then don't. C is probably one of the worst programming languages to learn as a first language. It teaches you huge amounts of bad habits which are really, really hard to eradicate. If your answer is no, and you are quite fluent with some other language already, I would still not recommend using C. If anything, I would recommend C++, using a book which approaches it from object-oriented programming point of view. Personally I love C++ and I hate C. C is good only for two things: To make very small programs for an embedded system (at least assuming that no C++ compiler exists for that system) and to make an IOCCC entry. For those things C is great. For anything else it's really bad. C++ has tons of quirks too, and there are tons of ways to shoot yourself in the foot. However, once you master it, it can be a wonderful and efficient language. You can't say the same about C. I have used some big libraries made in C which are very well done, one good example of which is the GTK+ library, but due to the limitations in C they are inherently cumbersome to use. If things like "object oriented programming" gives you a negative feeling, then perhaps you should learn more programming and less C until you start liking that concept.
Former player
Joined: 3/30/2004
Posts: 1354
Location: Heather's imagination
....in what ways can C++ be more efficient than C? I'm not really understanding. Easier to use and work with, maybe, better maybe, but more efficient?
someone is out there who will like you. take off your mask so they can find you faster. I support the new Nekketsu Kouha Kunio-kun.
Banned User
Joined: 3/10/2004
Posts: 7698
Location: Finland
I didn't say C++ is more efficient than C (at least not speedwise). I just said that once you master C++, it can be a very efficient language. However, when designing and implementing a (big) program C++ can be a much more efficient language than C. You can achieve more with less code, and you can write code which is much more modular, secure and easy to use, making overall developement more efficient and less error-prone. In a few cases C++ can actually be speedwise more efficient than C too. The GTK+ library is a prime example of this: In this library pointer-cast checking (between GTK+'s widget types) is done at runtime, while with C++ it could be done at compile time. Also many arguments are given as char strings which are parsed and interpreted at runtime, while with C++ it would be easy to make most of those things at compile time. I'm also rather sure that eg. dynamic binding is faster in C++-generated code (using C++'s own tools) than with the GTK+ C code which emulates dynamic binding.
Player (71)
Joined: 8/24/2004
Posts: 2562
Location: Sweden
When I used windows I just LOVED UltraEDIT. The best editor for windows ever created! It handles probably all programming/markup/script languages there are. I used it back in school for everything, C++, java, HTML, even some VB stuff. Too bad I'm not a programmer though. I also wish to learn CPP. :)
Editor, Reviewer, Experienced player (980)
Joined: 4/17/2004
Posts: 3109
Location: Sweden
Warp: I wasn't sure who you were addressing, maybe speaking just in general? In any case I started with QBasic, which I've read is a horrible language to start with (but I can't find the quote at the moment), then Pascal, Visual Basic; then Ada which our uni had selected to be the language that everyone should learn about programming in, then Scheme. And now I'm taking this project course in which the instructors said "So you learned Ada? That's cute. Here's how it works in the real word: C." I can see why you hate it though. There are some things I'm not getting along very well with either. Such as no function nesting. And how cryptic many commands are. And the linking thing and other compiler issues are not really my favourites either. But on the whole it's going well, considering I've never written a line of C before. OOP is okay, and not as scary as it first looks.
Player (21)
Joined: 10/14/2005
Posts: 317
gcc allows function nesting, as one of its many C extensions. C++ can't really do function nesting, except with a sort of hack. I'm sure Warp can explain why function nesting is generally a bad idea though. By the way, I think 4matsy and Highness best answered the editor question subject to the following constraint.
Truncated wrote:
under Windows
Emacs and Vim are likely not the most popular ones in this respect. Oh, and there's this about shooting yourself in the foot. edit: Just wanted to say sorry for continuing the off-topic discussion here. I guess a bit of zealotry is inevitable when it comes to talking about programming languages.
Editor, Reviewer, Experienced player (980)
Joined: 4/17/2004
Posts: 3109
Location: Sweden
>gcc allows function nesting, as one of its many C extensions. Yup, I know, but the portability people will smack you over the fingers for trying that. >under Windows But I'm not under Windows at the moment. And that horrible beast Vim started itself when I subversion commited and forgot to add a comment. I liked your foot page. I did a similar stupid thing as the Unix example just a few days ago, so it's nice to feel less lonely in your stupidity.
Player (87)
Joined: 2/10/2006
Posts: 113
Location: US
I'd just like to say, I totally agree with Warp about C being obsoleted by C++. Really the only reason to learn C nowadays is if you want to work with already-existing C code (which sadly includes FCEU). I personally like to/need to do a lot of low-level coding, so I don't use a lot of C++'s more advanced features, but having objects makes organizing your code 10x easier. Plus, learning OOP from C++ is a good intro before doing a fully OO language like Java. Coming from Lisp, Ada, and QBasic, I guess my warning about C/C++ is that they don't do much bounds-checking for you. I strongly recommend bounds-checking everything in your programs--you will accidentally write past the ends of arrays all the time if you don't. These bugs can be really hard to catch, because C/C++ don't care if you go past the end of an array, as long as you're still writing to your program's allocated memory.
Use the force
Banned User
Joined: 3/10/2004
Posts: 7698
Location: Finland
Luke wrote:
Coming from Lisp, Ada, and QBasic, I guess my warning about C/C++ is that they don't do much bounds-checking for you.
The great thing about C++ is that you can create data structures which are easy to use and have automatic bounds checking or whatever you want. In fact, such data containers already exist in C++, such as for example std::vector() which, if you index it with its at() function it performs bounds checking. (It also offers unchecked indexing if you are worried about performance.) In C you could offer "bounds checking" by writing a separate indexing function, but the problem in C is that nothing forces the programmer to use that function, but instead there's a too high urge to index arrays directly. In C++ it's not only easy to add bounds checking to data containers, it's also very flexible on what should be done if boundaries are crossed. For example, you could implement it so that the data container grows automatically as needed.