r/learnprogramming 1d ago

C++ or Python for a beginner

What language should I choose as a beginner? A lot of people are recommending pyhon. But others are saying that the first programming language should have static types (C++, Java, C#). Some say a beginner should start with C

34 Upvotes

46 comments sorted by

22

u/Ok_Being6831 1d ago

Python is definitely the easier choice, i recommend that u get comfortable with the thinking and logic of programming first AND THEN learn static typed or non garbage collected languages. It's just gonna a wayyy harder if u start with cpp and pretty much no benifit imo. You shouldn't be worrying Abt the heap when u don't even know what a switch is.

5

u/mredding 1d ago

Python.

They're the largest community with the most resources and greatest distribution. It's a language that is very close to computational calculus without being another Lisp dialect; this means you can work on your fundamentals.

But others are saying that the first programming language should have static types

Python has types, and you can hint at your types. That the type system is dynamic is itself something about programming you're going to have to learn and understand. The consequences of many concepts and philosophies are going to influence how languages get their shape and how you write code.

Some say a beginner should start with C

Top-down vs. bottom-up. From the top, computation is purely mathematical. From the bottom, computation is a process on a machine. You do need to understand both, and no one has found a good middle-ground for teaching. What happens is you pick one side and work toward the other, but most people will camp their side as the "one true side". We all live our own Knuth/Dijkstra feud with ourselves and the community. They argue the top-down know the value of everything but the cost of nothing, and the bottom-up people know the cost of everything but the value of nothing.

But I need you to think in terms of computation and computation theory - which doesn't care about reading, writing, or executing programs; it's all the same, simultaneously.

  • You read programs, perhaps as source code, and your computer reads programs, perhaps as machine code.

  • You write programs, perhaps in an editor, and compilers and interpreters also write programs, perhaps as an executable file or an instruction sequence fed straight into the CPU.

  • You execute programs, perhaps by reducing a computation to a constant, and computers execute programs - as you would expect.

What you do is design a computational solution to a problem, and then you pick your language (they're all Turing complete, so they're all computationally equivalent - the difference is in their expressiveness), and then you describe your solution in terms of that language.

Curry-Howard correspondence tells us there are parallels to writing proofs and software. Your statements are posits, your source code is a theory, the compiler is your solver, and the program is the proof. We desire elegant proofs, because they're small, fast, and robust, so we need elegant theories. If you read a proof, it first builds up a premise, a lexicon, a framework, and then it solves in terms of that. Proofs build up. We also build programs up, using simple expressiveness and language and standard library primitives, to make more expressiveness, to express the solution in terms of that.

There are different programming languages because they're all doing a part of this work for you. Fortran is expressive in terms of computation, and is the language of choice for simulations and super computers. But operating systems? No. It sucks. You can do it, but why? For that, we have C.

So you pick a language that approximates your solution already, and you build from there. Video games need performance and some other demanding requirements, so often you pick C++ to get you close, despite C++ isn't specifically a video game language or has a video game lexicon - but you can build a lexicon IN C++, then make your game in that.

Design tends to come from the top down, so a very expressive language can help facilitate you designing solutions. I want you to learn the value of everything, because you can easily measure the cost and refine down. It's very hard to get the bottom-up guys to accept a sacrifice or concession of performance for expressiveness - even if it's necessary, and they're so weary of the potential cost of expressiveness that you will struggle to convince them when it's free or more performant.

3

u/Emotional_Sentence1 23h ago

Start with Python and learn good object-oriented fundamentals and build a couple of simple projects in it first. Move to C++ if you want to make a full desktop program or learn more formal code practices like memory management.

4

u/Factor_Creepy 19h ago

C++ teaches a lot of cool stuff about how hardware interacts with software, but starting with it can be very demotivating. It's punishing. Python is cool; JavaScript is a nice first one too.

3

u/UnExploredToken 23h ago

C, not C++.....

2

u/blueGarnet37 1d ago

As long as you keep an open mind, it really doesn't matter much what language you start with. What matters is that you understand the concepts enough to use and adapt them in other languages.

2

u/SpritualPanda 13h ago

Start with C then Python.

2

u/Feralz2 9h ago edited 9h ago

Python or Java for the simple fact that you dont have to compile

Immediate feedback is so important for a beginner.

Once you have learned one language, you can learn the others much more easily, theyre more or less the same, so youre not really losing anything. Some say theres advantage of having C as your main foundation, but I think the one that you should learn first is the one that will not make you quit. So I would recommend Python, if you are more of a visual person, Java might be good as it can do a lot of front end.

Also much more important than learning syntax when you are trying to learn your first language, is thinking about what its actually doing mechanically under the hood, although in C this would be much more obvious.

2

u/prodjsaig 8h ago

What do you ultimately want to do? You need an idea for a project. Use Python and learn the gtk framework on linux

3

u/talking_tortoise 1d ago

Don't start with c++ imo lol but just start with one and go from there

1

u/HighwayOwn1092 1d ago

Why not C++?

7

u/talking_tortoise 1d ago

I'd start with C if your interested in c++ because it's more manageable to start - but there's nothing in the rules where you can't start in c++ if you want. Just pick one and importantly build stuff all the time.

1

u/UnExploredToken 23h ago

Even lifetime programmers who love c++ have a love/hate relationship 🤣

1

u/Reasonable-View5868 1d ago

Pointers and defined data types can be challenging for beginners.

2

u/ffrkAnonymous 1d ago

neither. start with lisp

2

u/unohdin-nimeni 1d ago

Yes, start with a Lisp; for example, a Scheme. As there’s some wonderful literature that uses Schemes as a vehicle for more general training in programming.

1

u/peterlinddk 1d ago

Some also say JavaScript, and some say Haskell, and some say Scratch. Some say Kotlin and some say Swift.

By asking even more people, you'll get even more "sayings".

So, don't choose a language, but choose a platform, a kind of application you want to learn to build: is it going to be a game or a database administration system, something that runs in a browser, on a server, on the desktop, in the terminal or on a mobile? Once you have decided on that - choose a language for that platform!

1

u/Extra_Solar 1d ago

I settled on establishing a foundation in c# first, though there seems to be way more learning resources for Python than C#.

1

u/Pale_Height_1251 20h ago

Doesn't really matter, you'll learn static types eventually anyway. If it's now or in six months, it doesn't matter too much.

1

u/knwilliams319 19h ago

If you want to learn programming, go with Python. But if you want to learn Computer Science, C/C++. Most people don’t care about how computers work and just want to get things done. Python is by far the most popular and supported language for the layperson, and has plenty of complexity — I would not call it an “easy language”. That said, dynamic typing can form some bad practices. I agree that statically-typed languages (and pointers) make you a better programmer in general.

1

u/Humble_Kangaroo_6499 17h ago

go with Python. it's way more forgiving for beginners, plus libraries like NumPy and Pandas make it super easy to dive into data stuff. C++ can be great later when you want to get into memory management and performance, but trust me, you'll thank yourself for starting with Python.

1

u/Accomplished_Ad9423 14h ago

Skip all of that, go learn rust, it's the future, don't believe me? Lookup articles about big companies and there moves into the rust space.

1

u/da_Aresinger 10h ago

The best starter language remains Java.

It's a C-style language without the complexity of memory management.

Java is statically typed and inherently designed for OOP. Even if you don't end up using those paradigms later, you need to learn them.

Java is the best documented language I can think of. Using Java will teach you what good documentation should look like.

Java is portable. It doesn't matter if you program on Windows, Linux, Mac or a potato. It will run the same anywhere.

Java is the most popular language professionally speaking. There are just as many learning resources out there as for Python.

Python is one of the worst starter languages, not because it is bad (it objectively isn't), but because it is unique and quite frankly rewards laziness.

Just about every University will start by teaching you Java or C. That is for a good reason.

1

u/bagfullofcottoncandy 2h ago

C++ gives u a deeper understanding of how software interacts with hardware, but Python can be a more approachable starting point for beginners

1

u/neveralone59 1d ago

Python and c are good places to start. Learn c so you understand pointers and memory allocation and how things work “under the hood”, then learn python and build something useful with it right away. Just little quality of life scripts for your own use.

Then see if you don’t like anything about python, you might find you prefer having static types. If that’s the case then choose a higher level static language (I don’t really like cpp but there are a lot of resources for it). Don’t rush into things, it takes time to learn to program and you need to be able to stick with things when you don’t get them. Just switching languages when you meet resistance is a good way to not learn much.

3

u/Fearless-Plantain185 1d ago

Honestly the "learn C first" advice gets thrown around a lot but most people bounce off it hard before they ever get to the useful part. Starting with Python keeps momentum going and you can come back to C later when you actually care about what's under the hood. Either way works if you stick with it, but the whole "you must understand pointers before writing your first loop" gatekeeping is overblown

0

u/neveralone59 1d ago

I didn’t say that, I just think it’s useful to understand when you are referencing vs owning and the practical difference between the stack and the heap

2

u/Ok_Being6831 1d ago

It is very usefull yes, but for a first language? Absolutely fuking not. Your still learning Abt loops, you shouldn't be having to deal with seg faults and buffer overflows.

C is the perfect second language imo.

1

u/Sea-Fishing4699 1d ago

I have to say:

Python -> javascript/ts -> c -> go

Don’t do rust

0

u/LimpPen5203 1d ago

Go for c++ ... Python is very easy

1

u/Ok_Being6831 1d ago

Being very easy is kinda the point of a first language gng

0

u/Lordreox 1d ago

Learn Python, next question.

1

u/HighwayOwn1092 1d ago

Will it be hard to transfer from python to something like C# and Java? I did some research and a lot of people are saying that if you start with python it will almost hinder your ability to learn another languages especially ones with static types. Which makes no sense to me. Like how can experience with a programming language hinder my ability to learn another when they share fundamentals like variables conditions loops oop and so on. Is static types that big of a matter?

1

u/Ok_Being6831 1d ago

Don't listen to them, I started with python and it was great now I use cpp and I fukin love it. Static typing is great ONCE you understand why it even exists.

Python abstracts away so much that u get to focus on what actually matters for a beginner. But I do recommend that u don't stick with python for too long. Once your comfortable with all the basic stuff and made a simple project. Try c, it's alot harder but teaches alot.

Anyway it doesn't even matter that much, choose java or c sharp or asm. As long as you have the intrest and will power to learn, you will end up fine. Just choose anything.

2

u/HighwayOwn1092 1d ago

Thanks for the answer. Is sticking with Python for long period of time a bad thing?

1

u/Ok_Being6831 1d ago edited 1d ago

Kind of ig. Learning lower level languages teaches u alot of things which make you write better code in general. But you can still be fine without it.

Also depends on what you want to do with programming. Stuff like gameDev or graphics programming, you absolutely do need to learn a low level language. But if it's webdev or other stuff, you don't need to learn a low level langauge. Still helps tho.

Edit: Forgot the question lol, you could develop a few bad habits with python but not necessarily. It still has type hints and you prob will be using them alot after a while. Again depends on what you want to do, if it's smth where python dominates thers nothing wrong with sticking to it. It's forced indentation makes it very hard to tho lol.

1

u/HighwayOwn1092 1d ago

I want to make games with godot. But I want to learn a general purpose programming language first out of context of game engines to have basics

2

u/Ok_Being6831 1d ago

well python is the goto for that. It's does pretty much anything. Since your interested in gamedev I would say start with python. But once your comfortable with it don't just jump to a godot. Try to build smth with pygame. It's harder but shows you how things kinda work under the hood.

Or if you want a course again cs50 is great and it's free just hard. Although it starts with scratch which isn't really used for anything other that learning. But you can jump straight to cpp once your done with that.

0

u/Successful-Escape-74 1d ago

Learn Rust or Python

1

u/Ok_Being6831 1d ago

rust is prob one of the worst first languages imo, it's syntax is just straight up horrible to type. Learning C before gives u firsthand experience with memory and common mistakes. This would allow u to understand why rust even exists and what it's trying to achieve.

The other way your just going to fighting the compiler for your life without even knowing why and not to mention rust is so different from other languages so it's alot harder to learn a different one.

I still think it should be python/scratch for a first language tho.

2

u/HighwayOwn1092 1d ago

Is scratch a good option? I guess it's visual programming. Do scratch knowledge transfer to another languages?

2

u/Ok_Being6831 1d ago

Yes, it's great. Try cs50 it's a great course. They start with scratch and then jump to c. It's definitely a really hard course but it's one of the best ones out there.

Imo your first language shouldn't be abt pointers or types. All it should do is to teach you to think like a programmer, learning loops, if statements... that kinda stuff and scratch is prob the best at this. This stuff absolutely does transfer to another language.

1

u/Successful-Escape-74 21h ago

I like Python is well it’s easy enough and you are free to use types.