How do people start programming C or C++?

I want to start programming in C (and maybe C++ if appropriate). I already know some ALGOL and FORTRAN and APL and BASIC, and do quite alot in Forth, but since the C family of languages is now the mainstream I want some practical ability.

Once upon a time people got started in C by learning it in the QuickC environment under DOS. Since I do alot of hardware-specific DOS programming I have started using the old QuickC V2, and this is going fine.

But to do a little Windows programming too, where is a good place to start? Is there a package that’s good for beginners or people desiring a gentle introduction to Windows? Do they teach C at university these days, and is there a typical starting point?

Yep… I learned C++ at university. It’s pretty much a required class for any major nowadays.

Once you learn C, you should dive into C# if you want quick and easy windows programming.

Alternatively, you could use your Basic knowledge and use VB.NET to create windows programs quick and easy.

And the great thing about .NET is that C# and VB.NET are like hand and glove. Same interface construction tools… only the underlying code is different. But both share many of the same functions and methods etc.

Oops… forgot to really answer your question.

Yes, a class is great. But books are just fine. Even start with online tutorials. Do a couple hello world apps and you’ll be on your way to being a C guru. And you’ll start to appreciate the beautiful language. I worked with Fortran extensively recently for my senior thesis project. I had to to convert a couple of important algorithms into C++. It was a bear. Fortran is plain messy. THOSE DARN SCIENTISTS NEED TO LET GO OF FORTRAN!

ahem ok.

You don’t want to learn C. Leap ahead by learning an OOP, such as Java, Python, or Smalltalk. Delphi is good too. You can port your Delphi programs (with some modifications) to Krylix for Linux.

The only time you want C is doing system programming.

Java will die.

If you want to do Windows programming, why not start with C# or VB.NET? They use the same class library so if you learn one, picking up the other is fairly simple.

Microsoft has an abundance of .NET resources available , everything from compilers to entertainment : http://msdn.microsoft.com/vbtv/default.asp

Another resource is Visual Studio Magazine which you can find at most Barnes & Nobles or similiar type bookstores.

Unless you have a specific reason for wanting to go the C/C++ route, my advice would be to start with .NET

It’s even better than that. They actually both use the same compiler, so even the underlying code is exactly the same. A for loop in VB.Net will compile to the SAME code as a for loop in C#.

Anyway, I second the recommendation of learning an OO language. I’d recommend c++, but Java or C# would also be good ideas. There’s really not a huge difference between the three languages, except that c++ is more of a superset of the other two. No matter which one you choose, however, learning either of the others won’t be a big deal.

It’s not messy. It can’t be more messy than the average C code.

Fortran also happens to be the best language for doing numerical computation, bar none. Just the built-in Complex data type alone makes it the number one choice, not to mention all the highly optimised libraries and functions.

C++ and Java are both useful languages to know. Some people will tell you that you should only learn this one, but truth is that neither one is always appropriate. Learn C++ first, because it forces you to deal with some of the details that Java hides.

I bet that annoys the living hell out of the Performing Arts and Anthropology majors!

Or if programming on Linux, where virtually everything is written in C (there’s wrappers for Perl and Python for many toolkits, but they tend to not be as powerful as C)

UnuMondo

      • C/C++ is good to learn, because you can create/see demonstrated programs written both with and without object use. I tend to think that this is the most enlightening way of demonstrating what object-orienting is.
  • C# is MS-owned, and many of us remember what they did with VisJ++, and with the “new improved MS licensing” we are watching the creeping encroachment of Linux. Anyway-- the language hardly matters, as you won’t really get to choose anyway: different shops will have the languages and software they’re already using, and so you have to learn whatever they use.
    !
    O-O programming is very good to understand though.
    ~

I’ll throw in a vote for Objective-C… piece of cake coming from a Delphi background. Of course, you’ll need a gnu compiler, which limits you to *nix and the Mac…

If you want to be just a “Windows” programmer, there’s nothing wrong with Delphi or Borland C+ Builder.

I’ve been meaning to delve into C# for awhile now. Just one thing I was wondering.

Is there an inline assembler in the package, or would .DLL calls be required if I wanted to use my ASM routines?

Thanks,
David

inline assembly is not my strong point, but according to this:
http://www.codeguru.com/cs_syntax/Unmanage.html
you would be able to keep your routines, but you would have to run them as unmanaged code.

Ahh… thanks!

A .DLL it is!

-David

Borland C++Builder is a great place to start learning. It’s basically the same as Delphi, but with C++ instead of Pascal, and it’s what Visual C++ should have been. (Ever notice how Visual C++ isn’t really “visual” at all?)

You create forms (blank windows) and drop components on them, like buttons, timers, check boxes, charts, etc. Then you select a control, choose an event like OnClick or OnMouseDown, and write C++ code to handle that event. But unlike VB, you can also write your own custom components in C++Builder, and it’s fairly simple to move code from an application into a component so you can reuse it in another application.

And, as has been mentioned, you can compile both Delphi and C++Builder projects on Linux.

One more thing: the next version of Delphi will support .NET, giving you the same cross-platform portability and just-in-time compilation as C# or VB.NET.

If you want to stop playing around and learn C, buy the Bible: The C Programming Language by Kernighan and Ritchie. K&R 2nd Edition is the only book you really need for ANSI C, and it gives important info for dealing with that obscure K&R code you’ll come across in any environment. The C described in K&R is platform-independent and not subject to licensing nonsense. Microsoft can play games with C# or the .NET platform or the execrable joke Basic but it can’t touch C, C++, or Objective-C. Those languages are used by professionals to do real work.

Of course, just reading about a language isn’t going to do it. You must program, and for that you need Linux. Microsoft Windows just can’t cut it: It does not offer memory protection, a feature of all real OSes, and that is necessary in C. A misplaced pointer, or an overflowing buffer, should not crash your OS, and those mistakes (oh yes, you will make memory mistakes) will bring MS-Windows to its knees. Linux has always had memory protection.

Secondly, Linux has inherited all of the UNIX programming tools, and those tools are heavily bent towards the C programmer. gcc, the best compiler on any platform, is actively developed on Linux. It is free of charge and nonsense licensing, and it comes with any Linux distro. emacs, the only programmer’s text editor worth mention, is also a Linux tool. The tools alone are worth the (low) price of admission.

C# will be a bad memory in 10 years, when Bill Gates is panhandling outside a city full of Linux shops. Basic has always been a teaching language, a dumbed-down FORTRAN designed so students can’t hurt themselves. C, however, will still be in active use, and those versed in it will be in active demand.

Take a long look at the state of software today: Everyone but Microsoft is using UNIX, including that former toy company Apple, and the programming language of UNIX is plain C. The main UNIX programming tool is gcc, the GNU Compiler Collection, which evolved directly from the GNU C Compiler. Microsoft, with Palladium, DRM, and other foolishness, is driving away its business users, and it will drive away Joe User once its DRM conflicts with CD burning. Linux has been poised to take over for five years, but only recently has that coincided with so many mistakes on Microsoft’s part.

Learn C. It will serve you no matter where you go.

Beautiful? Sure if your on an 8 bit microprocessor and your only other choice is assembly.

C IS NOT BEAUTIFUL!!! It is fast, portable, well documented and well supported but it is NOT BEAUTIFUL.

Mr2001 wrote:

Custom components have been a part of VB since version 5 and ActiveX.