How do people start programming C or C++?

I was surprised to find that I am now a 2-million plus line programmer in C/C++.

I disagree strongly that C is useful only for “system programming”. But regardless of who is correct, I think it is irrelevant.

Learning C++ will teach you most of “true” C in the process, or at least most of it that matters in most programming tasks.

Borland C++ Builder and Delphi are neat and can get you up to speed fast, but many large companies still want to see MFC experience, not Delphi. MFC is less easy to use than Delphi, but equally as powerful, and there is a wealth of information, code samples, and free help available on the web. It’s extra effort, but worth it in the end, IMO.

I think the answer must be tempered by whether the goal is to learn programming for fun, or for work, or both. If it is for fun, then perhaps a local university or community college has a night class as an introduction to C++/MFC. If it’s for a job you already have, then on-the-job learning is probably best for that, although it may limit you in the future by confining your flexibility.

Here’s an idea - make sure you keep a notebook, either electronically or otherwise, of samples of your own code and free code of how to do key functions. It will greatly speed up your progress if you can say “OK…now, I need to read a JPG file and determine the length and width of the image…how do I do that? Oh yeah - I did that once here, let me C&P it…”

What I do in my freeware applications along these lines as well is develop a large class of common functions used in science and math, and some GUI programming and even IO functions. This base class I just copy into every new project I work on, and thus I start with a powerful toolkit available which I know works. So I never have to start from scratch anymore.

Hmm. Perhaps you should tell that to the college boards, who are planning on replacing C++ with java on their AP exams in a couple of years.

I’ve been programming in C/C++ for 15 years, and Java for 2 years. I would recommend Java for a learning tool.

The problem with C++ under the windows environment is that the learning curve is very steep. MFC is not trivial to learn, even for people with solid C++ skills. Trying to learn both at the same time would be very tough.

Plus, C++ forces you to do a lot of ‘plumbing’ that is irrelevant to learning the concepts of the language itself, and that will slow you down.

Borland has a free version of JBuilder that you can download from their web site (at least they used to). JBuilder is probably the best Java development environment around. Writing your first ‘hello world’ app in Java is a lot easier than writing in in C++ in Windows. The language is just a lot cleaner than C++. No IDL, no MFC, no having to learn a zillion intriciate compiler and linker switches, etc.

Hey Napier,

What are you trying to do? Start a holy war?

Deciding which language to learn is one of those classic problems. You really can’t pick a language until you know what you are going to do, and, of course, you don’t know what you are going to do until you understand the capabililties of a language.

From your post, I notice that you have some programming skills, and that you want to do ‘a little Windows programming.’

Based on that little information, I’d suggest Perl for Windows, or more specifically ActivePerl.

What tools do you have access to? It might be worth it to sign up for a semester course at the local junior college just to get student prices on development software. And hopefully, not to sound too square, you can visit your local library and browse programming books.

If you do want to do Java, Sun has online tutorials and free development tools that allow you to make applicatons and web applications.

Anyway Napier, don’t get too close to any one tool or platform as over the last 10 years I’ve gone from programming C on a Mac using Symantic’s Think C to C++ on a Mac with Metrowerks to Unix Perl to C++ using Visual C and Window’s MFC to National Instruments LabVIEW.

If you could explain more about what you are trying to do, I could give you a more detailed route…

Good Luck!
-SandWriter

BensonG - “Java Will Die”
What? I have trouble believing that. What makes you think that will happen.

Folks, this is great. Loads of useful info.

I hear several people say that, if I want to learn C and maybe do a little Windows programming, Delphi is a neat and easy place to start (one says easiest), as is Borland C++ Builder (mentioned the most). Also lotsa votes for Visual Basic (but that wouldn’t fit my goal of C). And Java (which maybe would, and maybe would be easiest).

I have an idea of what C# is, and also what Visual Basic is. But what does .NET mean? Is it the Window interface component, as opposed to the C language component, of C# and VB? Or what? Define .NET for me please.

“Microsoft can play games with C# and .NET…” - crap, what does this mean, if I buy their damn developer tools I can’t do what I want with the programs I write?

Linux enthusiasts - I hear you. Maybe I’ll drop hints for RedHat for Christmas, just to fool with. I think UNIX is great, having administered BSD and SVR4 and SunOS systems in years past. But I live in a corporate world surrounded by Windows PCs, and I want to be able to give simple specialized tools to my customers and coworkers (we’re not primarily programmers but we’re technical people and programming is to some degree an important tool for us and especially me). The whole point is that everybody uses Windows because everybody uses Windows, and I’d rather get the U.S. Army angry at me than Microsoft because at least the Army usually fights fair. I admit defeat! If Gates promised to retire if every US citizen gave him $100 a year, I’d gladly do it, but it ain’t gonna happen soon! So Linux is by my definition not a solution to my problems, unless I am missing something big.

What am I trying to do? My goal is to be closer to the mainstream, because as a programmer exclusively in Forth these days, I don’t actually know anybody that speaks my language. I write hardware-specific programs now that control important processes and machines, and I also occasionally write little utilities that let people solve obscure problems specific to my industrial business. I want the option to choose a programming language that at least some of my coworkers understand.

I’ve written a few utilities now in C that run under DOS. It’s certainly not as clever as Forth, and it’s a good deal higher level, but it’s straightforward enough, it does a better job than ALGOL and FORTRAN and BASIC at encouraging modularity, and it is pleasantly simple. What with the heavy emphasis on libraries and other means of sharing modular tools, it seems good for team efforts - which I guess should always have looked like the future of computing, if folks had thought about it.

[HIJACK]What’s the correct pronunciation of C++?[/HIJACK]

Aw, shoot - I just looked at Borland’s info on C++ Builder V6, and it says the system requirements include several versions of Windows but not NT. Does this mean I can’t use it on my NT desktop work computer? How stupid is this? Does it explain why, when I got an unused C++ Builder V5 and wrote the first hello world example per their beginning instructions, the result would not run but only produced a flurry of complaints about DLLs?

So would I need to get another, non-NT computer to use Borland C++?

And, wherever I used it, could I write programs that other people could use whether they had NT or another Windows?

levdrakon C++ is pronounced as “C plus plus,” and while I’m talking about pronunciation, C# is pronounced as “C sharp.”

Yeah, it’s “C plus plus”, but I always thought it should have been called “Increment C”.

If you are working in C++, and you have the money, I think the best development environment is none other than Microsoft’s Visual Studio. IMO, it’s the best development environment around.

If one of your goals is to learn solid software development skills, i would advise against Visual Basic. While you can put together interface applications very quickly, the language itself promotes poor coding skills, and requires program design that is fairly non-standard.

Hey Napier,

It seems that you would be going pretty far to help your co-workers understand. I’m not familiar with Forth, but I’m sure it has branching, iteration, and i/o operations.

I’m curious what your co-workers don’t understand in Forth that they will understand in C.

Back to the OP, I learned C on my own with Herbert Schlidt’s “Teach Yourself C” book and Symantic’s Think C compilier for Mac OS 6.X

The book is still available on amazon, can’t say much about the compilier.

A quick search on CNET shows there is a “Bloodshed Dev-C++ 4.0” Development Environment that you can download and run on NT, free to try, $20 to register. I haven’t used it, but the ratings indicate it works, 91% thumbs up out of 1000+ users.

Don’t let the C++ throw you, you can use it to program in C. <holy war> Cause everyone knows that at the heart of every member function is good ol’ C!</holy war>

Good Luck,
-Sandwriter

SandWriter said:
>It seems that you would be going pretty far to help your co-workers understand.
– Yes, I would say this is a big effort on my part to make my projects more udnerstandable to my coworkers.

>I’m not familiar with Forth, but I’m sure it has branching, iteration, and i/o operations.
– It does, but it’s pretty different, at least from my limited experience. I think of ALGOL and FORTRAN and BASIC as all being pretty similar, and C is on somewhat a different branch but not very much so. But Forth is more distant. No statements, sometimes no variables, normally no algebraic expressions. If you get curious visit www.forth.org.

>I’m curious what your co-workers don’t understand in Forth that they will understand in C.
– My guess is that if somebody inherited one of my Forth-operated systems, and it stopped, they are liklier to give it up or start over in another language than learn Forth. But I really don’t know. Maybe it’s not the big deal I imagine…

If I’m not mistaken, Forth is a stack-based language, meaning that while it does follow the imperative paradigm, you don’t have variables or arithmetic/relational/logical operators. A program to compute 3*4 + 2 in a generic stack-based language might look something like this:

push 3
push 4
multiply
push 2
add

It has a certain elegance, but I wouldn’t want to write anything complex in it.

Napier: What I mean is that MS can do just that: They can change the next version of their API or their development environment or anything else without any kind of external input, and if they change the wrong thing you are up shit creek with a severe paddle deficiency.

That’s just on the software end. On the licensing end, they can decide that they have exclusive rights to all code developed on their software (which you, after all, merely license from them). Perhaps nothing that extreme, but, legally, all your base are belong to them as long as you’re using their stuff. Nobody, AFAIK, has ever successfully challenged a EULA. This isn’t something you want to deal with if you intend to sell that code as your own, even if the judge tells them to eat their own balls.

Neither of these concerns are relevant in the Open-Source world. If the FSF (Free Software Foundation, legal/political/economic side of the GNU’s Not UNIX Project) decides to do something with gcc that bites, people can, and will, stick with an older, pre-bite version and develop that fork of the software tree. The FSF cannot stop them, according to the GPL (General Public License, the GNU Project’s main license). Nothing like that has ever happened (well, close, which is why there is a difference between Emacs and XEmacs, but that case was even more complex…) and it probably won’t, because the FSF relies on a lot of external input to develop its software. In fact, most Open-Source software projects are developed by communities, with inner circles, outer circles, and hangers-on, as opposed to the corporate development teams. Look at the Perl community for a good example: There’s a General Policymaker (Larry Wall, who invented the language and still holds a lot of clout), a Holder of the Pumpkin (the guy who leads the current development effort for the next version), and a bunch of hackers who work, at various levels, in the actual development effort.

On the licensing end, the GPL saves your ass. The GPL ensures that nobody can restrict the free flow and usage of software. People can sell it (hence Red Hat), but nobody can restrict it. No one can tell you that you cannot use gcc to develop another compiler, or that you can only use gcc to develop encryption software if you create a key escrow system. The GPL is a renunciation of rights: Developers who release code under the GPL renounce their rights to restrict its modification, proliferation, usage, and resale. They retain their right to own the code, in that they must always be credited and always be able to sell it themselves.

Furthermore, code released under the GPL is not public domain. GPL’d code is owned by the author, and it cannot be copyrighted or patented by anyone else. That makes it impossible for someone to use copyright or patent law against us. All of our important code is GPL’d and owned by the FSF, so nobody can steal it from us.

GPL: Anyone can use it, nobody can abuse it.

I get it now, from what ultrafilter wrote, Forth is more of an Assembly level language. Based on that information I have a clearer idea of what is going on. First off, let me assure you that learning C will not pose any great challange. You might have some problems with dereferenced pointers, but who doesn’t (ha ha).

From the assembly perspective, C is a higher level language that hides the mechanics/drudgery of assembly programming. However, there are trade offs. Executable size will be larger than the Forth version, and the speed may be slower as well. However, the win will be as you expect, code that is easier to maintain.

I predict there will be a period of transition where you will plan to do something in C, but get stuck and do it in Forth to get it done. Fortunately C allows you to do inline assembly in the code. If you get to a point where you need speed, you can use syntax to direct the compilier/linker to read the lines as assembly.

Depending on the linker/compilier, you might be able to treat the Forth executable as a module, so you can get your work done, then slowly convert each Forth module to C.

If your work wants you to do this as your job, hit them up for a decent compilier/linker/dev environment.

You will cruise through the “Teach Yourself C” book in no time, you will be learning C names for the Forth concepts. If you get stuck on a C concept, e-mail me and I’ll help you out as best I can.
-Sandwriter

p.s. not to be too mean, but I think it’s pretty funny, the way you spelled understandable. :slight_smile:

Learning C is more than just learning C: Most of the common languages now have syntax strongly reminiscent of C, so gaining a strong foothold in C will give you a big headstart on nearly any other language you’re going to come across as a sometime-programmer. As a C geek, I can usually learn a langauge by reading example code and looking up unfamiliar syntax or keywords. I won’t gain proficiency that way, but I’ll be able to write working code pretty fast.

I would recommend two books for the budding C programmer:
[ol]
[li]K&R (The C Programming Language – Brian W. Kernighan and Dennis M. Ritchie)[/li][li]Practical C Programming – Steve Oualline[/li][/ol]Those two books are both pedagogical guides to C: They are aimed at teaching someone how to program in the language, as opposed to simply being reference manuals for the language. (A C reference manual would be a small pamphlet, more if they included the standard libraries.) But they take different tacks: K&R is very self-guided, giving broad overviews with full programs as examples, then listing a few moderately difficult exercises at the end of each section. Practical C Programming, OTOH, is a more relaxed tour of the language, readable and informative, intended for someone willing to devote a few hours each day to reading and hacking.

Oualline is different from K&R in another way: As much as discussing the language, it discusses programming: Good commenting practice and bad, formatting tips, designing file formats, and good ways of approaching code you didn’t write, among other topics not covered in K&R. Reading Oualline is a good way to become a good programmer in any language, and a lot of his basic ideas transfer well beyond just C.

K&R, however, is a Bible. A Bible is a book that has all knowledge about a specific topic, and K&R has all of the information about C. K&R 1st Edition defined a de-facto standard C in the days before a standard C. To this day, K&R C (as that old code is called) is still floating around, still supported by most (all? damn near, anyway) compilers. K&R 2nd Edition covers ANSI C, the standard C defined by a standards issue. Helpfully, K&R lists an abbreviated version of the ANSI documentation, noting the differences between ANSI and K&R. The main text teaches ANSI C, and that’s what you should write. (Creating any new K&R C, except to use an ancient compiler in a state of emergency, is a Punishable Offense.)

There are a lot of books out there to teach you C (and some Dopers could do a fair job of it, too :)), but the two books I listed (K&R and Oualline) will help you comprehend the language.

s/standards issue/standards bureau/

Sorry.

Not quite. Check out the Forth SIG site for more info

:confused:

I am aware that some languages look a bit like C, particularly C++ (and C# :rolleyes:) but also Java.

Basic, Fortran and Ada certainly do not look anything like C, and neither is Perl, just to name a few common languages.

There are very many common languages which don’t look a thing like C. Ruby, Clos, Delphi, and Cobol come to mind right off the top of my head. Prolog, Scheme, and Lisp, too, but you wouldn’t expect those to look much like C anyway.