16

I'm want to learn a desktop programming language, preferably C, C++ or C#. I'm a PHP/HTML/CSS programmer and I would like to get into desktop applications. I need something pretty powerful and I would like to be able to create applications with Windows GUI's.

What would the Stack Overflow community recommend? Is there any knowledge I should have before diving into these languages?

Sam Becker
  • 19,231
  • 14
  • 60
  • 80
  • Sorry for being a bit offtopic but I would suggest a special which-language-to-learn tag to classify such questions easily and help people find different languages for different purposes faster. – Muxecoid Feb 09 '09 at 11:07
  • @Marc - thanks. Now someone needs to put this tag on 148 more questions. :) – Muxecoid Feb 09 '09 at 11:37
  • @Muxecoid I've done it for some of them. I stop every time SO starts asking me whether I'm a human. It's quite a useful tag though it may overlap a bit with "programming-languages". – Daniel Daranas Feb 09 '09 at 14:10
  • 1
    I love C but I can't believe all these people suggested it as the language to bridge the gap between your experience with web applications and developing Windows apps. This isn't 1990. The days of hWnd and the Windows SDK are over. – Robert S. Feb 09 '09 at 22:03

26 Answers26

74

edit:

A web programmer wants to create Windows applications and you recommend C?

What's wrong with you people?!

/edit

Obviously C#.

C# will be easier to get into and will let you build Windows applications using WinForms or WPF and all the new Microsoft toys in .NET. If you know your way around PHP, you should already be familiar with the syntax, object oriented concepts, exception handling, etc.

I suggest you don't complicate your life with C and definitely not with C++ if all you want is to create Windows GUIs. They do provide a good educational experience and they are useful for more advanced things (cross platform development using other toolkits for instance) but at the price of a steeper learning curve and reduced productivity.

Also, if you are a web developer, C# is the only language among the 3 options that you can (realistically, heh) use for the web. ASP.NET is not a bad framework and might be worth investigating too.

Tiberiu Ana
  • 3,663
  • 1
  • 24
  • 25
  • 4
    He didn't say easier to get into, he specified powerful, so the question is much more open than just the path of least pain. – Cruachan Feb 09 '09 at 12:03
  • He said he needed "something pretty powerful" and that sounds to me rather meaningless in the context of the question. – Tiberiu Ana Feb 09 '09 at 12:16
  • 8
    Like the edit ;-p – Marc Gravell Feb 09 '09 at 13:11
  • me too - I wish I'd thought about big fonts on mine :) – annakata Feb 09 '09 at 13:27
  • Well it depends what he means by pretty powerful I guess (can do stuff vs minimal lines of code to do stuff) but I still think *what* he wants to write, and the existing code base that can be accessed to support that, trumps actual language issues. – Cruachan Feb 09 '09 at 16:58
  • if he wants to go forward, C is a must. if just want to fool around and write some windows-only code, and not learn new ways of thinking, use whatever is easier. – Javier Feb 09 '09 at 19:06
  • @Javier, C is great, but it's a HUGE barrier of entry for anyone who wants to write Windows applications. Plenty of folks never learned C and "go forward" every day. – Robert S. Feb 09 '09 at 22:04
  • i agree with your answer. but why do you say "...and definitely not with C++..." ? sounds like C++ is worse than C for this task... – Johannes Schaub - litb Feb 09 '09 at 22:09
  • @litb: Well, I was thinking that C++ does quite a bit more on top of C, so it takes extra dedication to get into it from scratch. But true, plain C is not much of an option for doing Windows GUIs. – Tiberiu Ana Feb 10 '09 at 08:49
  • 1
    +1 Love the big letters and the sentiment. It's astonishing enough that C/C++ continued as long as it did for writing GUIs, and that's no reason to inflict that experience on anyone now. – Daniel Earwicker Mar 05 '09 at 19:41
16

Take a brief look at C first, to the level of writing a few tutorial programs. C is small, well defined and the definite language definition (Kernighan & Ritchie - The C Programming Language) is only a couple of hundred pages long. Although getting your head around pointers and recursion can be a challenge the language itself is sufficiently small that it's possible to know the language completely. One of the pleasures of writing C is it's not too hard to reach the level where one can just code without having to continually refer to documentation to see how to use little know feature x or library function y. Think of learning C as putting the foundations in.

However to actually write useful applications you'll want to use C++ or C#. Which depends on what you wish to write. C# will probably score in most business-orientated cases because of garbage collection and general ease of use, but C++ would score for high performance, low level, or game domains. There's also vast amounts of C++ library code available which can be leveraged relatively easily (and pure C code too which is easily adapted). If your aim is to write something with a particular problem in mind then the availability of such could most likely offset the higher overhead C++ has in just getting things done.

By way of example on this I did a filtered search on 'image' on Sourceforge and returned the following project count

C# : 139
C++: 569

And even with something purposely more business-orientated C++ still scores higher - 'finance'

C# : 12
C++: 32

With anything mathematical or technical the score is heavily weighted against C# - 'fractal'

C# : 4
C++: 44
C : 24 <-- (C++ explicitly excluded)

This is a pretty crude analysis of course, but for example if my aim was to write a desktop fractal generator program then I'd pick C++ over C# as the extra effort involved in handling the UI in C++ would be easily offset by the plethora of example code available in C++. OTOH if I was writing a business application where there was no great advantage to having example code and lots of UI to handle then I'd go for C#.

Afterthought edit: Another reason for at least familiarising yourself with C first is that there's also Objective-C as the main development environment on the Mac and iPhone. Objective-C is C with a very thin wrapper and only really a first cousin to C++, so if you envisage that you might ever be in the position where you want to port code to or develop directly on the Mac then I think you'd find it less confusing if you at least have some feel for how C++ (or C#) builds on C rather than having to 'step sideways' across the tree.

Cruachan
  • 15,733
  • 5
  • 59
  • 112
16

"I need something pretty powerful and I would like to be able to create apps with Windows GUI's."

For rich windows GUIs, I'd be tempted to look at the "xaml" variants: WPF (full desktop) and Silverlight (like flash) - this will give you the latest tools etc, and a lot of styling power.

For this, C# would be the primary choice. Managed C++ is an option, but it's more work.

G S
  • 35,511
  • 22
  • 84
  • 118
Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900
  • Managed C++ is improved a lot and it is C++/CLI now. Using WPF with it won't be a big work, IMO. – Navaneeth K N Feb 09 '09 at 11:42
  • 3
    I wouldn't recommend Managed C++ to a noob in a million years, far too many layers will generate absolute confusion if you don't know what you're looking at (e.g. .net, stl, managed v's unmanaged, and classic c are all available to get tangled up in, far better to simply go with C# IMHO) – Binary Worrier Feb 09 '09 at 12:29
7

C# vs the others really solve quite different things but given your web background and it's rapid development approach, I'd definitely go with C#

annakata
  • 74,572
  • 17
  • 113
  • 180
  • So its pretty much an exchange of rapid development for a low level. – Sam Becker Feb 09 '09 at 11:04
  • yep - and in my experience, if you're writing a desktop app you just don't need to be that low level. My view is that C++ et al are serious tools for creating really high-performance apps, but the cost is slow-dev. – annakata Feb 09 '09 at 11:14
  • +1 - If you are trying to learn computer programming or architecture, then it makes sense to learn C or C++. For all but a few standard applications and *especially* for web apps, C# is the way to go. Marc's advice regarding WPF/Silverlight is good too. – Mark Brittingham Feb 09 '09 at 11:37
7

My suggestion is to learn C++. C# is good, but it will prevent you from writing portable code. If you learn C++, you got many choices. In windows you can use Windows Forms application or WPF with .NET framework. MFC is another good choice. QT is the other choice which works on multiple platforms. So by learning one language, you can write code for multiple platforms and you got a variety of GUI tookits. After learning C++, learning C# would be trivial.

All the best

Navaneeth K N
  • 15,295
  • 38
  • 126
  • 184
6

C# is the highest-level language of these, which means that it's the easiest one to accomplish what you want.

Windows GUIs can be surely made with C++ and even with C, but it's harder.

Joonas Pulakka
  • 36,252
  • 29
  • 106
  • 169
6

definitely first go to the basics: learn C.

then go to your real goal. if you want any chance of going multiplatform C# is discarded. you'd want to go with C++ and Qt, or wxWindows.

Javier
  • 60,510
  • 8
  • 78
  • 126
3

In my opinion you should starting studiying C, to have a base knowledge about aspects like memory, file accessing. C is a low level languaje, this means that you will have more control over the way you access to operating system, but to create windows application you'll have to code a lot of lines of code. For this reason, after doing few things with C, i should start with C# with Visual Studio 2008. .Net Framework comes with a huge number of classes that makes your life easier.

Hope it helps. Kind Regards. Josema.

Josema
  • 4,638
  • 6
  • 22
  • 15
3

C/C++ both allow low level programming. That means that everything is possible, but even simple things can be hard. If that's what you mean when you say that you want something powerful, you should probably start with C++. It at least gives you some decent GUI libraries (gtk+ with gtkmm or qt), whereas GUI programming with C is a pain.

If, on the other hand, you want to develop applications quickly (and that's what you mean by powerful), then C# is probably the way to go.

drby
  • 2,619
  • 25
  • 26
2

I woudl recomend C#. It's not as powerfull as the other two, but for your needs I belive C# will be least painfull. C and C++ are low-level languages, so I think they will be a lot of work for GUI and stuff.

martiert
  • 1,636
  • 2
  • 18
  • 23
2

Save the C. To those people that advise learning C, please give arguments for that. I claim that it has absolutely no benefit to learn C rather than C++. I, unlike them, have arguments to back this claim up.

In a nutshell: C is already a subset of C++ for all intents and purposes, but it's far from the most interesting subset. It only offers a very limited insight into new proramming paradigsm. C++, on the other hand, defines a few very interesting new paradigms which, furthermore, are a generalization of all that C has to offer (i.e. iterators which are a generalization of pointers).

To reiterate: if the choice is between C and C++, choose C++.

Community
  • 1
  • 1
Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214
  • I'm voting for C# myself, but this is a really nicely written argument – annakata Feb 09 '09 at 11:05
  • 1
    Totally agree. Why "taint" a fresh mind the procedural programming paradigm if he can dive right into the "real" stuff without learning bad habits somewhere else. Also, there's always enough rope to hang yourself no matter what language you use ;) – Tigraine Feb 09 '09 at 11:17
  • Tigraine: notice that I nowhere said anything against procedural programming. – Konrad Rudolph Feb 09 '09 at 11:48
  • 2
    But if you never intend to learn C++ and you just want to branch out C is faster to pick up and you will feel like you have learned something faster. C can be grokked in a few weeks to a few months. C++ takes years to truly grok. – jmucchiello Oct 02 '09 at 17:50
  • @Matt: thank you for your interesting and completely valid remark. Honestly though, care to give a *real* reason for the downvote? – Konrad Rudolph Nov 18 '10 at 09:54
  • I would but I'm apparently a troll. You can read many of my remarks on other questions if you wish to be Enlightened. :) – Matt Joiner Nov 18 '10 at 14:12
  • @Matt: to be honest, yes, your comment seems to be written in troll – at least it’s not any language I understand, or indeed recognize. – Konrad Rudolph Nov 18 '10 at 14:51
  • @Konrad Rudolph: When replying, it's a good idea to first read the latest correspondence by the other party. "I would but I'm apparently a troll. You can read many of my remarks on other questions if you wish to be Enlightened. :)" – Matt Joiner Nov 19 '10 at 16:31
  • @Matt: so in other words, you’re first replying with some nonsense text and when pressed you’re telling me to do the dirty work for you because you’re too lazy to write a concise answer. Sorry, but that’s just rude. I’m not hunting through all your answers for some rationale of the downvote, you know … – Konrad Rudolph Nov 20 '10 at 13:04
  • @Konrad Rudolph: You make a point. http://stackoverflow.com/questions/598552/should-i-learn-c-before-learning-c – Matt Joiner Nov 20 '10 at 14:21
  • @Matt: fair enough. I still disagree but the link is interesting nonetheless because I also disagree with Brian: I have never learned C and while I think that I could pick it up fairly easily, I wouldn’t call that step a no-brainer. C uses some very different techniques to realize OOP and separation of concerns (Pimpl) for instance. I wouldn’t claim knowing C just because I grok C++. In fact, this is an added reason why I would learn C++ first, C later: learning C entails learning about things which are entirely irrelevant in C++ and just distract from the goal (*if* that goal is learning C++) – Konrad Rudolph Nov 21 '10 at 09:34
2

Although I agree that C is "useful" to know it is certainly no longer essential for the majority of programmers. For me these days it's main function is that it has given me an understanding of how the underlying hardware affects program performance and behavior but that's the end of it. I haven't used it in development work for the last 9 years.

In regards to getting to grips with object-oriented development I feel that both C# and C++ will give you a firm foundation but C++ is far more flexible (and harder to use correctly) while C# is more consistent and way to go if you're going to get into .NET development. I would therefore recommend learning C# and one of the "new" .NET-presentation technologies like Windows Presentation Foundation or Silverlight. Alternatively, learn Windows Forms first but it's a bit lacking in presentation.

The only case where I would recommend C is if you are going into fairly low-level stuff like device drivers, embedded controllers or similar but in most of those cases you could still use C++.

Hans Løken
  • 407
  • 1
  • 6
  • 15
2

Again, another vote for C# and against C. Sure C is interesting from a technical point of view and will teach you all the details, but the truth is, you don't need to know all the details to make an application. If your goal is to make something work, which it sounds like it is, it's C# hands down. C# is the highest level of the three, which means less time fighting the language, more time making stuff work.

It sounds to me like most people are recommending you learn C so that you can eventually make better C# programs. Why wait, go straight for C# and learn it. I do think C++ is an absolutely excellent language and one day you should learn it, but there's no reason why you can't make a quality C# language if you've never learnt C or C++ - many people do that every day!

Ray Hidayat
  • 16,055
  • 4
  • 37
  • 43
2

Having come up through the languages, first C on Unix, then C++ with MFC and then C# (starting with 1.0) I think that going back in time to earlier incarnations of the language is a bit like learning Latin. Oh, probably just stolen something from Paul Graham there but I would agree with it.

C is very good if you have to have a minimal object code size, very good for embedded stuff where it's one step up on the assembly language. I'm thinking of things like a Microchip PIC etc where you may only have 1K word of program space.

C++ is very good if you can have the larger object size but still need to be able to hammer the metal directly - so things like device drivers, network stacks, etc etc. The kind of glue program that sits under everything.

An OS could end up in either of these - or more likely a mix of the two depending upon the programmer, the age of the code, what it needs to interface with, the depth of the snow outside (just one more run and then I'll write that method!)

C# is really good at the higher level business focussed user layer applications. They could be web based, client based, a mix of the two - it doesn't really matter. The nice thing about the .net family is that you have a rich library, for this layer that is important, and it is being heavily developed to be richer all the time.

As computers become more powerful the cost of the developer outweighs the cost of the processor or memory.

Go with C#, ignore C and C++. By the time you are happy with C# you won't have any need to program in a lower level language for the speed increase.

Alan Mullett
  • 1,106
  • 13
  • 26
1

It doesn't really matter what kind of language you start with but if I were you I would do:

Start with the basics in C (It will probably be hard to understand) Move to C++ And at last C#

RvdK
  • 19,580
  • 4
  • 64
  • 107
1

I'd suggest you start with C#, but quickly progress to C++ as once you have learnt how to code generally, you should return to your roots. I'm currently studying electronics because I'm going back even further. The more you know about how and why, the better you can know about how best to get where you need to go. I think a C# programmer that doesn't know any lower level language is going to write rather sub-optimal code, but a low level programmer learning C# is going to be overly cautious of all the managed stuff. So, whatever you choose, you should consider doing both in the long run.

Richard Fabian
  • 697
  • 1
  • 5
  • 18
1

I would go for C#.

I've done my time (lots of it) with the other 2 and find C# 'cleaner'. You also get a rich library of all kinds of functions included in .Net. I assume that you're not interested in developing for other non-Windows platforms which might have been an argument for going for C or C++. I also assume that you don't need the squeeze the last drop of performance out of the system where C might have given you a slight advantage.

To those who say you ought to learn C in order to understand how programming really works I would say that you ought to learn assembler in order to understand how C works. I did and it does help but is it really worth the pain? To be a programmer you have to switch on your brain. Think about what you are doing and understand your tools!

My vote: C#

paul
  • 13,312
  • 23
  • 81
  • 144
1

Learn C#.

Is good to begin with the basics, but better than begin with C I would begin with the basics of C#. This will give you a solid foundation with the fine points of C# basics and after you could move to more advanced topics.

For example you can take a look to Charles Petzold ".NET Book Zero" here.

DaniCE
  • 2,412
  • 1
  • 19
  • 27
1

I recommend::

First get into C. spend some time get use to it(but not too much)

Then get into C#. that's the way you can deal with GUI things more easyily. IDE like VisualStudio can help you a lot dealing with GUI.

If you wanna be a real good programmer of C/C++/C#, then it might be not the good way but I think you are not interested in being a Guru or something like that :)

Sungwon Jeong
  • 1,267
  • 2
  • 15
  • 28
  • 3
    Do C, but leave before it makes you hard. Do C#, but leave before it makes you soft. And ALWAYS wear sunscreen! :-) – Peter Morris Feb 09 '09 at 12:35
1

There are a lot more jobs developing windows apps in C# than C or C++. Learn C#.

Rob K
  • 8,757
  • 2
  • 32
  • 36
1

C# is a good place to start. You can get it for free and you can do some fun graphics using XNA studio (also free).

I would only learn C++ if you have a specific reason to.

If you are doing Windows programming I would recommend that you do the first few chapters of one of Petzold's Programming Windows books. It will give you a basic understanding of C and of how Windows works at the bare metal level. You don't really need to learn C. Charles Petzold holds your hand and gets you up and running in a basic C Windows program.

bruceatk
  • 5,118
  • 2
  • 26
  • 36
1

Learn C#...if you want to develop desktop apps.

0

Without C/C++/C# experience start with C. Edit: Ok, start directly with C# or C++ don't lose time. You cannot seriously code Windows desktop applications with C anymore, it's just to painful.

Then move to Object oriented languages to get something more powerfull.

If you wan't to stay far from windows plateform, C# is not the better option, or check out the Mono plateform.

IMO, C# is far more advanced than C and C++, you will build big application faster. WPF librarues will give you nice UI without windows style (but only on windows systems...)

thinkbeforecoding
  • 6,668
  • 1
  • 29
  • 31
0

With proper set of libraries memory in standard C++ can become as easy as managed (smart pointers). Some C++ widget libraries are as easy to use as C#.NET. However it will probably perform worse than C# due to several abstraction layers. And with C++ you need to learn non-standard libraries. With .NET most of the components that you need are standard.

C is ancient and does not have STL. It demands you to be smart, but I doubt the advantages of it.

Muxecoid
  • 1,193
  • 1
  • 9
  • 22
0

I need something pretty powerful and I would like to be able to create apps with Windows GUI's.

Well C is pretty powerful so that would would handle that criteria but something like C# and WPF would make life so ,uch easier if you're aiming to GUI apps.

Graeme Bradbury
  • 3,693
  • 22
  • 29
0

Are you planning to make gui based applications for windows? Depending on what, I recommend VB. However, given your choices, I would pick C#.

Daniel
  • 374
  • 2
  • 5