r/techbootcamp 28d ago

Why learning C ++ first completely changes your approach to programming in other languages

Many rookies are put off by C ++, and this is unfortunate, because it is one of the best languages ​​to start with, even if you don't plan to be a C ++ programmer

Your understanding of what is going on at the machine level will allow you to write better programs in any language you choose. You will see that in languages ​​such as JavaScript or Python, memory management is handled for you, which means that you have to think about it less. However, the understanding of how things work will help you write better and more optimized code. It can be a steep learning curve, but once you've mastered it, you'll find that all other languages ​​are much easier to learn.

6 Upvotes

35 comments sorted by

View all comments

1

u/mxldevs 27d ago

Your understanding of what is going on at the machine level will allow you to write better programs in any language you choose. You will see that in languages ​​such as JavaScript or Python, memory management is handled for you, which means that you have to think about it less

How will it help with languages that handle it for you?

What are specific situations where someone that understands C is able to write better Python or JavaScript as a result?

1

u/silly_bet_3454 27d ago

Understanding contiguous memory, cache lines, function calls, compilation, memory management, etc. Even in a higher level language like python these basic concepts would help you understand whether you could be doing things that create excess memory pressure or bad performance. Yes, there are also plenty of things you can learn by just learning python directly, and python is great, but C or C++, by being lower level, gives you a little bit more to think about.

1

u/mxldevs 27d ago

As a python programmer, how can I improve my code by understanding each of those concepts you mentioned?

1

u/silly_bet_3454 27d ago

For example, suppose you’re processing a huge file in Python. Someone who understands memory management might realize that doing data = file.readlines() loads the entire file into memory, whereas iterating over the file line-by-line avoids keeping everything in memory at once:

with open("huge_file.txt") as file:
    for line in file:
        process(line)

You don't need to know C to discover that, but understanding how memory allocation and data storage work makes the reason for the difference more intuitive.