3

I am relatively new to programming and want to be able to make native C++ programs for Linux and Windows.

I am just wondering as a beginner should I first of all learn low level languages such as C and assembly in vim or should I just straight out start in an IDE with C++?

Josh Taylor
  • 81
  • 2
  • 12

7 Answers7

10

If you want to learn C++, learn C++. Learning C or assembly language first is not only a waste of time, but usually teaches relatively poor habits that you need to work at un-learning before you use C++ well.

That's not to say that knowing C or assembly language makes it impossible to use C++ well -- but each requires decidedly different mind-sets, so it creates extra work.

FreeAsInBeer
  • 12,937
  • 5
  • 50
  • 82
Jerry Coffin
  • 476,176
  • 80
  • 629
  • 1,111
5

If your ultimate goal is to learn C++, it is not a prerequisite that you learn C first. You can, but you don't have to.

The bottom line is, do what you feel most comfortable doing.

John Dibling
  • 99,718
  • 31
  • 186
  • 324
  • 4
    In fact, many members of the SO C++ community recommend that you avoid C like the plague if you want to learn modern C++ (as opposed to a bastardized version of C++ called "C/C++"). – In silico Jun 08 '12 at 18:59
  • 1
    I have no problem with that recommendation for someone learning the language, but I would point out that ultimately you'll need to learn at least some of C in order to become expert at C++. – John Dibling Jun 08 '12 at 19:00
  • 1
    And I agree, but this is a beginner we're talking about here. :-) – In silico Jun 08 '12 at 19:01
  • 1
    @JohnDibling: Some of what you learn to become an expert in C++ will also be true of C -- but unless you also want to know C, there's no particular need for you to care about which parts apply to C, which don't at all, and which almost do, but are subtly different. – Jerry Coffin Jun 08 '12 at 19:01
  • @JerryCoffin: I am reminded of [this](http://stackoverflow.com/questions/4329777/is-long-guaranteed-to-be-at-least-32-bits). You cannot really know the answer to the question in the linked post without knowing some bits of the C specification. – John Dibling Jun 08 '12 at 19:03
  • @JohnDibling: Yes, but "knowing some bits of the C specification" isn't even close to synonymous with "knowing C." – Jerry Coffin Jun 08 '12 at 19:19
  • @JerryCoffin: I suppose you're right. Fair point. (Although, I *did* say "some of C") – John Dibling Jun 08 '12 at 19:20
3

C++ is not (really) a high-level programming language. You're still manually managing your memory and getting undefined environment-specific behavior whenever you make a minor programming mistake. Besides that, C++ is a very unfriendly language for new programmers because it is both overly complex and (in my opinion) horribly designed.

I recommend starting with an actual high-level language like Java, Python or C# in combination with a fancy IDE. Starting with C is also an option if you want to concentrate more on low-level aspects rather than general programming techniques and paradigms.

Also you don't have to learn vim if you want to start programming, a simple editor such as gedit or Notepad++ will also work perfectly fine. An IDE specifically designed for your language is probably the most comfortable, though.

EDIT: As Jerry Coffin has correctly pointed out, this advice isn't really helpful if your goal is to program C++ applications. Although I'd still recommend starting with an easier (high-level) language to obtain general programming skills before you start with C++. If C++ isn't absolutely neccessary for the thing you want to achieve, it also isn't a bad idea to reconsider whether you actually want to use that language.

AardvarkSoup
  • 1,071
  • 8
  • 18
  • +1 for telling the truth about C++ – August Karlstrom Jun 08 '12 at 19:08
  • -1 The OP said: "I [...] want to make native C++ programs for both Linux and Windows." Your advice isn't telling him how to reach his goal -- more just saying: "No, you really don't. I don't like that idea, so you don't really want it either." – Jerry Coffin Jun 08 '12 at 19:12
  • +1 The OP said he was new and wanted to learn. I don't think diving straight into C++ is a great idea. He can learn C++ afterwards and maybe he had the misconception that he had to use C++ to write desktop apps. – sparebytes Jun 08 '12 at 19:23
  • @Kranklin: pointing out that there may be another way to go might qualify as a good *comment*, but clearly isn't an answer (and yes, your "answer" is essentially the same -- a comment, not an answer). – Jerry Coffin Jun 08 '12 at 19:26
  • @JerryCoffin, I disagree, If I had to start all over, I wouldn't begin by learning C or C++. I would learn something else first and then come to C. Learning programming language X and then learning C is still learning C, which is what the OP was asking how to do. I feel like you're splitting hairs. – sparebytes Jun 08 '12 at 19:31
  • 1
    C++ *can be* a high-level programming language. What people find confusing is that it can *also* be a low-level language. I'd recommend to a beginner that they learn as modern a variant of C++ as they can, and try to use good programming practices from the start. As a rule of thumb, beginning modern C++ should not use macros or raw pointers. – bdow Jun 08 '12 at 20:11
  • 2
    You're *not* still manually managing your memory in modern C++. – fredoverflow Jun 08 '12 at 20:25
  • @FredOverflow: auto and reference-counting 'smart' pointers are not sufficient for more complex object-oriented applications. There will still be many occasions where you'll have to manually allocate and delete memory. – AardvarkSoup Jun 08 '12 at 20:33
2

If you want to learn C++, start with C++. You don't need to learn C first; it would actually be somewhat counterproductive, since you'd have to unlearn some stuff when you moved to C++.

C and C++ are different languages, with different goals and philosophies. A well-written C++ program will not look or behave much like a well-written C program.

Once you get comfortable with high-level C++ features, then you can start delving into the lower level details.

John Bode
  • 119,563
  • 19
  • 122
  • 198
1

"If I have seen further it is by standing on the shoulders of giants." -Sir Issac Newton

Do not reinvent the wheel.

start as high and abstracted from the core as you can, and only revisit the core when there is no other way to advance in your road.

Community
  • 1
  • 1
SDReyes
  • 9,798
  • 16
  • 53
  • 92
1

Your question seems to me being more about learning programming. Language choice may be secondary to learning the programing paradigms/concepts.

So if programming is your focus, then you may first learn object oriented programming (OOP) concepts, so that you don't have to "adopt" them in a way people coming from procedural approach often do. Then, if needed, you may dig into procedural way and some C idioms/tricks and low-level approaches.

OOP can be taught in C++ as in Java etc. does not matter on that stage.

Once your mindset is "oriented", then the actual programming will be more about using existing libraries (APIs), which in fact will require more learning than the language itself.

So my advice is to learn OOP concepts first, then review your future language preferences. Have fun!!

vmsnomad
  • 319
  • 2
  • 7
0

Javascript is the first language I learned and I feel lucky that it was. With it I was able to skip past alot of the intricacies and barriers of other languages like static typing, pointers, and compiling. With javascript, you don't even have to install anything, just go here and you can begin trying things out: http://jsfiddle.net/X4PpW/ .

After I had a strong grasp of Javascript, understanding the concept of using pointers and classes in C was easy for me. Another good language to start with would be Python.

Also, what do you intend on making? Not all desktop apps have to be written in C. In fact some new frameworks out there borrow ideas from web applications or even allow embedding HTML from websites into your app.

sparebytes
  • 12,546
  • 3
  • 21
  • 32