r/cpp_questions • u/undistruct • Sep 24 '24
OPEN C++ as first programming language.
Hey guys! So i was wondering if its even possible to leaen cpp as ur first programming language or not? I know the python basics but not morw. Id like to hear yalls opinions
12
11
u/Mandelvolt Sep 24 '24
C++ was my first language, if you master it you can do pretty much anything, just realize it is a steep learning curve. Best of luck!
5
u/Pupper-Gump Sep 24 '24
c++ encapsulates all of the knowledge you'll need for any other language. With it, you can be as specific as setting a single register or as abstract as Python. However, with c++ you will need to know how to set up, debug, and google just about everything.
Once you learn it, languages like Java and Python appear very harsh and impractical rather than convenient. Although it is slower to make things with it. It's like walking on foot compared to driving a semi truck. The semi can go long distances on a well-paved road pretty quickly, but in town it's stuck to the roads and basically clogs up traffic.
If when you program, you want to make something new, use c++. If not, use most other languages. Also, Rust is overhyped.
0
Sep 25 '24
[deleted]
1
u/Pupper-Gump Sep 29 '24
c++ translates almost directly to machine code.
0
Sep 29 '24
[deleted]
1
u/Pupper-Gump Oct 01 '24
0
Oct 01 '24
[deleted]
1
u/Pupper-Gump Oct 01 '24
It didn't post correctly. Look at the languages used in Linux Kernel.
C: 98.3%
Assembly: 0.7%
Shell: 0.4%
Python: 0.2%
Makefile: 0.2%
Perl: 0.1%
Other: 0.1%No mention of Rust
0
2
2
u/emrainey Sep 24 '24
I started with Basic, Java then C then C++. I would say that it's challenging to jump into C++ first but possible.
3
u/inexorable_stratagem Sep 24 '24
I would recommend learning C instead, because it's simpler and the knowledge from C is 100% transferable to C++, but there's nothing wrong on C++ as first language except for the fact that you need to be careful not to shoot yourself in the foot
1
Sep 25 '24
I would not recommend learning C is the goal is to learn C++. I saw too much bad code that is "C with class" and become hell to maintain.
Better learn idiomatique C++ from the start0
u/Sure_Magician_4208 Sep 25 '24
But c++ is basically C with classes and templates, I would also recommend learning basics of programming, algorithms and data structures with C and then extending the knowledge of the C++ extras
1
Sep 24 '24
It prolly is the best one to learn. Adapting to different languages after it is ridiculously simple. Just stay from java. That shit will literally ingrain OOP in your blood
1
u/SmokeMuch7356 Sep 24 '24
Sure, it's possible. I don't think it's the best choice for learning how to program, but it's certainly serviceable.
C++'s chief virtues are that it's mature, well-established, and has a lot of authoritative reference and example material that's easy to find (there's also a lot of really bad reference and example material that's equally easy to find, so caveat programmator). You don't need fancy tools or runtime environments to start working with it.
It's also a huge, gnarly, eye-stabby mess of a programming language with complex semantics, and you'll spend as much time randomly yelling WHY AREN'T YOU WORKING as you will getting any real work done.
1
1
Sep 24 '24
Of course it's possible, it's just a programming language, loads of people experience it as their first language in university.
1
u/Fullbox200_griddi Sep 24 '24
take the time to learn the history behind the languages, why they exist, what problems the language was invented to solve, what workarounds had to be implemented, it explains alot of design choices made regarding the language
1
u/underground_sorcerer Sep 24 '24
It was my first. However - if you learn on your own, ask yourself ”why”. It depends on what you want to do with it. For example, if you are interested in web programming - you are better with JS. Android applications? Learn Java/Kotlin. IOS? Learn Swift.
1
Sep 24 '24
Beware of survivorship bias. Most people who start learning programming do give up. Will you give up? Will starting with a potentially more complex language make you more likely to give up?
Try starting with C++, if you aren't enjoying it after some time, feel free to try sth else. This career is about finding out what you enjoy.
1
u/ManicMakerStudios Sep 24 '24
The stuff you'll be learning with C++ to start is the same as the stuff you'd be learning with any other language...variables, loops, and evaluations. They're largely the same from language to language, just that some languages will do a little more for you and trick you into thinking that's the standard.
1
u/parceiville Sep 24 '24
I would recommend learning C first, it will be much easier to understand the Abstractions and features Cpp adds
1
u/northby1 Sep 24 '24
of course it’s possible. my first language was C++ and it was the best decision of my life, was the reason I got into Software Engineering. I just started my first year, don’t regret a thing. C++ is one of the best languages you can start with in my honest opinion.
1
u/MythicJerryStone Sep 24 '24
If you can learn C++, you can quickly learn basically every other programming language.
C++ is great at teaching how to code. That same understanding can then be used in every other language, just with different syntax, functions, etc.
For a first language, it might be a bit tough to pick up and to get a good understanding of, but it is definitely worth it.
1
u/illyay Sep 24 '24
In our school C was taught in cs 101 for some reason. Java was taught in cs 102.
C++ wasn’t even used until a few years later in elective 3d graphics classes where we learned open gl. By then, a lot of people knew c++ just from working on other projects.
Modern C++, c++ 20 and 17 are great and make so much easier.
When I was in college we had just gotten c++11 and it was wonderful. I experienced both pre C++11 and post C++11.
I imagine for you learning c++ as a first language will be much more pleasant.
1
u/tbonesteak33 Sep 25 '24
If anything it’s probably better to start out with lower level languages like C or C++ - it will force to learn not just how to code, but also fundamentals of computer science like OOP, memory management, asynchronous programming, etc that most other higher level languages like JS or python abstract away for you. It will be a bit harder at first but it will pay off in the long run.
1
u/DataPastor Sep 25 '24
First you should decide what the heck do you want to do with the language. It is okay learning the basics of a language and then doing nothing with it, but it is better to be excited about something and learning the appropriate language for it. Having said that, I am not sure if C++ would be a good language for a beginner. I think a smaller, compact language like C itself or Go is better (as a first language). But actually if you already know a little Python, why don’t you just learn Python properly? It is a very nice language, too.
1
u/jepessen Sep 25 '24
it's the best language because it does not hide anything about low level management like pointers etc. Then you can use higher level languages even better.
1
1
1
Sep 24 '24
Learn it, but at first use it as a better C.
0
u/MoarCatzPlz Sep 24 '24
If they don't already know C, I think that's counterproductive.
1
Sep 24 '24
That’s the way I learned it back in the Zortech days on a PC. It was C with classes and years before templates.
2
u/MoarCatzPlz Sep 24 '24
That's fine but it doesn't necessarily apply to OP's situation today. They don't already know C and modern C++ is well established (or at least much better than it was years ago).
1
u/Kats41 Sep 24 '24 edited Sep 24 '24
Syntactically, C++ isn't really all that difficult. You've got your usual run of primitive types, if, else, for, while, etc. This might lead a novice programmer down a path to assume that C++ is a simple language when, in reality, that's far from the truth.
The main source of frustration that you'll experience as a new dev is with the standard library and all of the various functions and interactions it has, and object management (constructors and destructors). The thing about C++ is that it expects you to have a certain foundation of knowledge, not just in programming in general, but also specifically the underlying structures.
It's so easy to use something like a vector for example, a simple dynamic array, and not realize how it works under the hood and be the source of innumerable problems that feel impossible to debug because they have no obvious source. C++ expects you to have a strong understanding of how memory and object construction and destruction works and not having that foundation can lead you to fighting with the language in really strange and obtuse ways.
It's for this reason that I actually recommend you learn C first. Unlike C++, which only appears simple, C actually is simple. It's a far more forgiving language for you to build up your knowledge base and build some of those systems that become more prominent in C++, such as dynamic arrays, linked lists, pointer arithmatic, memory allocation and deallocation, etc.
Yes, you will use different semantics for allocating memory (malloc/free vs new/delete), yes it has slightly different expectations with memory management (C expects you to have total ownership over memory), no it doesn't have a concept of objects or constructors or destructors, templates, etc. But that's all stuff you can learn really quickly once you transition into C++, honestly.
You can do 90% of the work of getting comfortable with C-like languages by just starting with C, and then when you've built a project like a small game in C or something, you can be confident you have the knowledge base necessary to start transitioning into C++ without experiencing as many of those first-timer headaches. You will actually understand what vector and map and list are doing under the hood and you'll have that knowledge to help you debug all of the stupid ways objects self-manage that'll make you pull your hair out.
Sources: Me, I learned C++ as my first programming language and I spent years pulling my hair out trying to debug things without foundational knowledge. I would have learned so much better if I'd just learned C first.
1
u/Prestigious_Carpet29 Sep 24 '24
I learnt (and got a lot of experience in) BASIC before I learnt C and C++.
BASIC was a lot more forgiving, and because it's an interpreted language (like Python) you can just print variables and things at the command line to help debug where things went wrong.
C (and C++) is less forgiving in that it's harder to debug, and if you mess up on pointers (e.g. access beyond the end of an array) things can crash or have very weird results that would be very hard to spot for a beginner. There's also loads of different ways of doing (much) the same thing with different libraries in C/C++, and a lot of historical obscure syntax such as all the printf format-modifiers, If you learned C/C++ you'd want to stick to a more modern subset!
I couldn't recommend BASIC now, as its well out of fashion, but Python is very popular, and widely used, and might be a better place to start while you develop the skill of thinking of problem (or task) to algorithm to code.
Python also has a huge collection of libraries to solve all sort of common problems (including the maths numpy), whereas although libraries must exist for C, you'll likely end up having to build a lot more from the ground up (for better or worse).
As someone who has done assembly language programming and has a pretty deep idea of how things work at a low level, C and C++ work well for me, and the things I tend to do (including low-level signal- and image-processing, and sometimes Embedded) - but it's not the right tool for every job.
1
u/BoredBSEE Sep 24 '24
No, it is not possible for you to learn C++ as a first programming language. You already know Python.
0
u/WikiBox Sep 24 '24
I'd recommend Python, since you already know it.
Using python it is likely to be much easier and faster to write simple GUI programs and become "productive". With C++ it may be slower going.
But best might be to combine C++ and Python. Combine the best of two worlds. The raw power of C++ and the ease of use of Python.
-1
u/pm-me-your-x Sep 24 '24
It's possible but don't expect the same levels of productivity as Python (or even C# or Java).
1
u/Pupper-Gump Sep 24 '24
When you run out of other people's libraries to use your productivity will go way down in those languages.
Also I'm learning Java now and would argue that it's the least productive language of them all. Very unintuitive.
1
u/pm-me-your-x Sep 24 '24
It's about simple things like being able to simple things without insanities such as using the erase-remove idiom.
1
u/AnimusCorpus Sep 24 '24
std::erase exists for exactly this.
1
u/Pupper-Gump Sep 29 '24
yea c++ has things in one giant library, it's organized. While java is all over the place.
20
u/[deleted] Sep 24 '24
Many of us started with C or C++ or Java.
You'll be fine. I would definitely suggest learning a large, well-established language as your first language.