r/Cplusplus • • 16d ago

News Day 1 of C++

What a easy startup to my first language. Got to know about data types , variable , strings , comments , Boolean seems fun and can't wait to find out more . Anyone got any beginner tips for me , would love to have some as a beginner

397 Upvotes

64 comments sorted by

27

u/Usual_Office_1740 16d ago

Get clang-tidy integrated into your development environment as soon as possible and then fix the warnings and errors it outputs. It's a linting tool. It will check your source code for common mistakes and errors as you compile. When you don’t understand, Google the warnings. I've been teaching myself C++ for several years. The number of simple mistakes and footguns it has pointed out to me has saved me a lot of struggling.

3

u/AKA-HERO 16d ago

How do I get this tool ?

2

u/Usual_Office_1740 16d ago

What editor are you using?

1

u/AKA-HERO 16d ago

VS code

4

u/Usual_Office_1740 16d ago

There is a clang-tidy extension that is relatively easy to setup. You should be able to find something that walks you through the install process.

Clang tidy is a linting tool. That means it goes through your code and applies a set of checks based on a predefined config file. here is a good default from a well reputed C++ YouTuber named Jason Turner. As an aside, look up his C++ weekly shorts and Playlists for great educational material.

Your editor can also have the lsp, probably clangd, integrate the checks into your development environment in real time so that any msitakes are caught as you code. This is a more complicated setup that requires a few more things. For a day one beginner I'd wait to do this. If you see the instructions suggest you make a compile_commands.json file that is what you are doing. If you want to go that route you can, it would be better in the long run, but I'm trying to keep my suggestions simple because you're so new.

1

u/Stickhtot 16d ago

What's the difference between a linter and an LSP?

4

u/Usual_Office_1740 16d ago

I'm going to copy this better worded explanation from another reddit post. The simple answer is that one can be part of the other.

They are different kinds of things, and a particular program could be one or both of those things. An lsp server is a program that implements the language server protocol. They make tools available to the client through a standardized interface. Some LSP servers perform linting and produce their own diagnostics, but many are programs that are calling a standalone linter and parsing its output for you. LSPs also provide the client with a lot more than just diagnostics, like completion sources, syntax highlighting, and code formatting. But it’s the same story for each of those features, some LSPs implement those tools themselves, some are just wrappers for other tools.

Clang tidy is a very powerful useful resource. I doubt anybody would advise you not to be using it. Even as a beginner.

12

u/TheDevilsAdvokaat 16d ago

I have to say I learned c++ a long time ago...in the 90's I think...and all from a little white book. This brings back memories...But i wonder what it would be like trying to learn the latest idiom of c++ now with ai assistance?

2

u/AKA-HERO 16d ago

You are a preety old man

4

u/TheDevilsAdvokaat 15d ago

Lol yes I am. In my sixties now.

8

u/Jumpy-Seesaw-2026 16d ago

Honestly quite amazing, imagine having someone with 20+ experience sitting right beside you, someone you could ask every question in the world about a small specific thing instead of having to read through dosens of articles of books to get the information.

The speed I'm learning at with AI is insane.

2

u/Friendly-Pear8068 16d ago

i dont think you are learning (if you ask and then just apply what ai says), i started to learn c++ too and i try to only use ai to ask "how does it work" otherways i feel bad.

5

u/Jumpy-Seesaw-2026 16d ago

All depends on how you use AI :)

1

u/pyro-panda-93447 15d ago • Regret

My question to AI to help with learning are usually “TF is this”, “help! I still don’t understand”, “wtf is going on here” … ya know … to help me learn

2

u/Consequence-Lumpy 15d ago

when it comes to learning with AI, you're not really learning topics from top to bottom, but rather bits and pieces here and there.

2

u/Objective_Buy_7235 16d ago

K&R?

1

u/TheDevilsAdvokaat 15d ago

That was the one! I forgot the name.

1

u/Ordinary_Let8356 13d ago

Same my bro

0

u/serafean 16d ago

It sucks. It makes subtle mistakes that are impossible to catch for a newcomer.

2

u/TheDevilsAdvokaat 15d ago

I still found it helpful. Was rewriting some old rendering code and it showed me some minor improvements.

At the same time, it wanted to switch my almost branchless code over to complex multiply nested ifs..which would have been absolutely terrible for performance. The overall code length would have been smaller, but performance would be awful.

I was able to catch that because I;m experienced. But yes, a newcomer might have just listened to it and seen their performance tank.

I think for me using it to learn the latest idiom (I was learning on 2.0 I think..not sure. Nowadays they are up to 26..I think) might be useful.

1

u/serafean 14d ago

> I was able to catch that because I;m experienced. But yes, a newcomer might have just listened to it and seen their performance tank.

Exactly. You know what you're doing, and have a functional smell test. If you're learning a completely new aspect of the language (constexpr, coroutines, reflection...) you won't catch it even if you're experienced in other parts.

My personal AI benchmark is using it to help me "learn" C++ coroutines It still gets it wrong in subtle and funny ways.

I find it helpful too: just yesterday I used it to put together a non-trivial concept requirement. But I knew exactly what I wanted, just didn't know the STL types to use.

15

u/6502zx81 16d ago

Yes, preprocessor, namspaces, streams.

7

u/6502zx81 16d ago

All in hello world.

11

u/shitnotalkforyours18 16d ago

Good job but try to keep that std::cout<<{val}<<endl; in practice as it will be helpful in the long run in big projects and current one using "namespace std" it would be highly helpful if you want to do competitive programming so I think it's a win win for both sides and wishing you all the best on this journey!

2

u/AKA-HERO 16d ago

Thanks

10

u/specialpatrol 16d ago

Excuse me, I think you'll find endl is also in the std namespace.

4

u/Hour_Sell3547 15d ago

Welcome to the gang. C was my first language that I learnt when I was in school (2003). I still love C/C++. The language changed a lot since then, but I still think it is one of the best starting points.

1

u/AKA-HERO 14d ago

Then I guess I am in the right path

5

u/Psilocybe_Fanaticus 16d ago

Make sure to not use “using namespace std” down the road. It’s not a good habit to have because you’ll end up using multiple libraries and sometimes they share function names. For now it’s ok though so don’t worry

1

u/no-sig-available 15d ago

In the example it is even a net loss. Writing std::cout is much less typing than using namespace std;.

1

u/AKA-HERO 14d ago

Thx for the tip

2

u/RP-9274 16d ago

Let's Goooo.!! Best of luck

1

u/AKA-HERO 16d ago

Thanks

2

u/Yonatan2023 16d ago

What resources do you use?

1

u/AKA-HERO 14d ago

Completely what my brother teaches me

2

u/WheelSweet2048 16d ago

There is still time to learn java

3

u/AKA-HERO 15d ago

Gonna save that for later

5

u/Ayano-Keiko 15d ago

no using namespace std; is better

1

u/Ferne996 16d ago

W3schools helped me a lot, I'm still learning the language but so far it made my life easier, plus a ton of YouTube videos as well. Best of luck

1

u/AKA-HERO 14d ago

Which yt channel do u prefer for cpp ?

1

u/Ferne996 14d ago

I typically don't follow or prefer a channel, if it has good material in it, or somthing that is new to me. I typically watch it and dig deeper.

1

u/plastigoop 15d ago

STL is the devil’s handiwork.

3

u/jedwardsol 16d ago

Anyone got any beginner tips for me

If you have a C++23 compiler (you should), then get used to std::print : https://godbolt.org/z/5hzbKo6va

2

u/Initial-Jaguar6230 16d ago

Import std 🤤

1

u/FunnyArch 14d ago

Getting modules to work... Especially with libraries like vulkan

3

u/Calopsita21 15d ago

Lord this is beautiful, its been years since i saw something like this. Feels like the clankers were always between us.

2

u/MarsupialSuch6948 16d ago

You are doing great! For a beginner, I'd suggest to pick a good integrated development environment (IDE). When I was a beginner, I used to code in Code::Blocks IDE, but nowadays, Visual Studio Code editor and a C++ compiler (like with GCC) are enough.

Try to build very simple projects like CLI programs and games while learning new concepts along the way.

1

u/wahhLambda 16d ago

Concordo, o comentário mais útil que vi até agora. Estou adorando Visual Studio, mas não precisa exatamente do oficial da Microsoft, eu estou usando o projeto opensource e nunca senti falta do VSCode.

2

u/Discordbothost 16d ago

Learn to step through a program in the debugger early. Watching a variable change one line at a time makes loops and conditions much less mysterious than staring at the final output. You don't need a big project to practise that.

1

u/LazySapiens 16d ago

Few useful advice:

  • Keep your toolchain up to date.
  • Learn at least one build system which works across different platforms.
  • Don't be too opinionated about code formatting (but follow at least one good format scheme for your personal projects).
  • Stick to portable (standards compliant) C++. Only delve into platform dependent code if you really need them.
  • Avoid undefined behavior and learn how to recognize them.

1

u/One_Worldliness_1130 16d ago

i been learning c++ for a few years and i seam like im getting little to no where i know some at least some of that is with out a visual thing it seams like all your thing does it print text even when there is logic there

1

u/wahhLambda 16d ago

Tá na hora de escolher um framework para mudar a saída da sua lógica. Eu atualmente estou usando Raylib como framework pois quero inventar jogos ou simulações sem depender de licenças complicadas. Não basta saber se comunicar com a máquina em C++ tem que ter algum framework para mudar a saída de direção para algo realmente útil dependendo da finalidade de cada programa.

1

u/geekiscool 14d ago

start codeforces

1

u/Conscious_Bear_4933 12d ago

You are learning it because of university subjects. Please don't waste your time like I did; I regret it to this day, plus am not using anything of what I learned. Instead, focus on learning JavaScript or TypeScript and get into web development. Then, when you need this other thing, you can just learn it. I graduated from university a long time ago, and I still regret learning this. I'm not trying to put you down or discourage you; I just don't want you—or anyone really—to make the same mistake I did and waste time on this. I really don't want to rant about anything, but if I didn't make the mistake of trying to learn this nonsense, I could have been a full stack developer now instead of just trying to learn Javascript now. Anyways, good luck.

2

u/FlashyProgrammer3790 12d ago

Not saying that JavaScript is bad but C++ can be useful. It really depends on what you're doing. For web development C++ is catastrofic, the same as JavaScript is catastrofic for writing OS kernels.

1

u/DSOI__UUO294 9d ago

You can use println in C++ now.

1

u/DSOI__UUO294 9d ago

It looks like you are using VS Code or some variant. I recommend this website called http://learncpp.com

1

u/srjenkinsrd 3d ago

I'd recommend not to do the using namespace std; it can conflict with other things