
Should I learn C++ or Python? - discombobulate
https://secretsofconsulting.blogspot.com/2017/02/should-i-learn-c-or-python.html
======
crusso
Learn a language you can immediately do something fun with. If you're excited
about desktop 3D video games, pick up C++ and, say, the Unreal Engine.

If you're excited about web servers, pick up Ruby/Rails - or if you think you
might want to create a client side application, pick up Javascript and some
framework like Angular or React and build something that you can deploy as
soon as possible.

If you're into Machine Learning, pick up Python and start going through ML
tutorials and jupyter notebooks while attempting to solve some problem in ML
that you find interesting.

Don't pick a language based upon some esoteric development principle that
undergirds it. Pick a first language based upon its ability to keep you
banging away at the keyboard all night, doing something you think is cool.

~~~
SrslyJosh
> If you're excited about desktop 3D video games, pick up C++ and, say, the
> Unreal Engine.

Or get Unity and learn their built-in scripting language. No need to spend
years learning C++, OpenGL, etc. if you're not planning on being the next
Carmack.

~~~
isaacremuant
Even better. Many people start learning C# with Unity and can move on to other
things from there if they wish to.

------
wyldfire
> "Should I learn saws or screwdrivers?"

The answer to this question is unequivocally "screwdrivers". The answer to the
original question (if you find yourself asking it), is "Python."

The analogy is perfect for this situation, but the answer provided here is
wrong.

The original question [1] is unqualified, so I will take a liberty or two here
and assume that they're new to programming and want to learn more. And since
there's no real dichotomy here, I'll infer they're really asking "should I
learn C++ or Python [first]?"

Well, C++ is indeed a saw and while they're incredibly capable, injuries are
included for free. Python, like a screwdriver offers maximum utility. Learn
Python first.

> Do you think someone could be a top-flight carpenter knowing only one?

Who cares about being a top-flight carpenter? Just figure out how to open up
the battery pack for your kids' toys and you will be a hero. Whether you're
starting a career in CS or you just want to cleanup the data in the office's
mega-spreadsheet-that-has-all-our-critical-info, start with Python. Get that
productivity that enables a positive feedback loop of design/test.

I started with C/C++ before Python existed and it was just so easy to get
stuck on several classes of failures that were difficult to understand without
outside help. Python has some of those but IMO far fewer.

[1] [https://www.quora.com/Should-I-learn-C++-or-
Python](https://www.quora.com/Should-I-learn-C++-or-Python)

~~~
candiodari
I would actually disagree if you're learning programming. C++ will teach you
far more. Python, for all it's advantages, is C++, with all sorts of
restrictions imposed on what you can do (e.g. shared_ptr for everything, with
the pros and cons of that).

It'll be hard for a while, but you will have learned a lot when you get there.

Python is what everyone's switching to because it's easier. If that's your
goal, just build stuff and don't care about how it works, then sure, go
python. And I would encourage you to learn Python (and Java, and Go, and
Haskell, and Prolog, ...) to get more tools in the toolbox eventually.

~~~
eddie_31003
At many Universities and Colleges, Python is taken as their first programming
course. Then for the second and/or third course you study Java and/or C++.

~~~
AstralStorm
The Java course is a waste of time, the language does not bring anything new
against Python when compared to C++.

Only a few Java specific things and an emphasis on patterns and workarounds
for things you cannot do directly because the language is so limited.

Java is a decent first choice, but not a second one.

------
rdtsc
> "Should I learn saws or screwdrivers?"

I think when we talk about languages we talk about 2 different things. Some
people talk about syntax and some about paradigms. Computer languages and some
claim human ones too (see
[https://en.wikipedia.org/wiki/Linguistic_relativity](https://en.wikipedia.org/wiki/Linguistic_relativity))
shape how we think about problems. They are not simply tools. Languages
withing the same paradigm can probably be interchanged as tools. I programmed
in C++, Java, Python and C#. I can switch between them effectively after a few
weeks of remembering "how things are different", well ok maybe not C++... But
I cannot switch easily to logic programming like that though. Even if it had a
C like syntax instead of Prolog or LISP, because it requires a different way
of thinking.

One you learn a paradigm you start solving problems differently and
potentially a lot more efficiently, (Well and some less efficiently too). And
also it may be hard to switch to another paradigm, because once everything is
an object, and you keep state there, switching to functional language can be
trickier than just starting with functional to begin with.

------
hermitdev
A craftsmen is never disserviced from having multiple tools in their toolbox
and mastery of them all. With experience comes the wisdom and intuition of
knowing which tool is appropriate for the problem at hand. Whether it matters
how quickly you need to deliver or what level of performance is needed.
Inevitably in any engineering problem, there are always multiple solutions,
but having appropriate information to make a qualified judgement to provide a
sufficient solution as cheaply as possible (often, in software, this may be
qualified in terms of time to market) that meets stated requirements
(functional requirements, performance - i.e. load, latency & minimal hardware
requirements).

------
agarden
> "Should I learn saws or screwdrivers?"

The analogy is bad. One cannot use a screwdriver to cut boards. Those two
tools serve completely different functions. But most of the things that one
can do with C++, one can also do with Python. And considering you are just
starting out, that "most" is virtually 100%.

A better analogy would be, "Should I learn band saws or circular saws or hand
saws?" To become a master carpenter, one will of course need to learn them
all. But when just starting out, picking one kind of saw is just fine.

------
hackits
Why not Java? I tend to find that anything larger than parsing and data
collection Python/Nodejs becomes a bit of a maintainable mess for me.

Java/C# are boring, but once that little script grows into a massive beast you
will be glad you can rely on the compiler doing a basic unit test of your
program.

This is even considering that even though you have a huge amount of advantage
with a dynamic type system most people don't end up using it.
([http://neverworkintheory.org/2016/06/13/polymorphism-in-
pyth...](http://neverworkintheory.org/2016/06/13/polymorphism-in-python.html))

~~~
pekk
> once that little script grows into a massive beast you will be glad you can
> rely on the compiler doing a basic unit test of your program.

Not if I bother to write a few suitable unit tests, which I should really be
doing anyway. Typechecking is absurdly far from substituting for checks that
my code actually does what I intended it to do.

~~~
hackits
Tend not to write unit tests as most evidence show they have little or no
impact ([http://neverworkintheory.org/2016/10/05/test-driven-
developm...](http://neverworkintheory.org/2016/10/05/test-driven-
development.html))

~~~
AstralStorm
Treat unit tests as a form of documentation in an executable format. It is
invaluable in long running or larger projects.

(As opposed to automated functional tests or pure regression tests.)

Also that evidence was comparing test driven against test later, not against
no test. That project tested was small enough and short enough to be ran by a
single dev.

------
raymondh
A programming language is a door. It can be easy to open (Python) or take more
effort (C++). The reason to open a door depends on what is on the other side.

The Python door opens to a large and playful room with about 100,000 packages
ready for download on an incredible range of topics.

The C++ door opens to a room of lower level tools that can help you understand
how your machine "thinks" about problems and how the data flows. It gives you
more low level control but takes it also takes more effort to write multi-
featured applications.

IMO, programmers should know at least one high level rapid application
development language (such as Python, Ruby, or Perl) and at least one lower
level language (such as C, D, Go, or Rust).

In addition, it is worthwhile to learn Javascript because it has a near
monopoly on an enormous ecosystems of client-side tools.

------
gravypod
You should learn to program and then get experiance using C++ and Python.

The language is fluff around the concepts. Get the concepts and you can go to
any languages.

------
RhysU
Learn C++.

If you learn C++ you will understand the collection of tradeoffs that go into
making Python surface-level pretty and below-surface as ugly as anything else.

If you learn Python you will be wildly productive until you paint yourself
into a corner.

~~~
dagw
After a few years playing around with BASIC I tried to teach myself proper
programming with C++. I quickly ended up confused and bored at not getting
anything non-trivial working that I gave up on programming all together. It
wasn't before years later I when was introduced to Perl and then discovered
Python before I started programming again. When I few years after that again
took another stab at C++ it was so much easier.

------
gigatexal
I was always told if you could be competent with C++ you could learn just
about any other language, so wouldn't learning C++ make the most sense?

------
eddie_31003
What's nice about Python is it so easy to get up and running. Plus its syntax
is very expressive. If you're a Computer Science student, like you actually
want to learn about data structures and computer organization, then you'll
definitely want to study C++. Even as a secondary language to Python. However,
you can start with Python to get any idea of what it means to be a programmer.

~~~
rectangletangle
Python has many solid example's of properly applied data structures, with nice
encapsulated high-level interfaces. It's a good language to learn if you're
interested in the application of data structures.

For instance you have your standard list, which IIRC is implemented as a
dynamically allocated array of pointers to Python objects. This gives very
fast append and pop operations on it's right side, making it a wonderful
stack. However it's interface specifically lacks a dedicated
prepend/appendleft operation, because appending to the left of the array
involves shifting the entire structure over one place in memory. This is a
very slow operation, because it must copy the entire structure to simply
insert a single element. Python get's away with append on the right, by
allocating a bit of extra "padding" memory on the right side, to avoid having
to copy the structure. For the situation where you want to append to either
side, Python offers `collections.deque`. This structure is implemented with a
linked list of pointers, IIRC. Which gives very fast append operations from
either side, because adding a new element only involves "hooking" the new
element to the preferred side, kind of like a chain.

However for understanding how these structures are implemented C based
languages are the way to go.

~~~
rajathagasthya
> For instance you have your standard list, which IIRC is implemented as a
> dynamically allocated array of pointers to Python objects. This gives very
> fast append and pop operations on it's right side, making it a wonderful
> stack. However it's interface specifically lacks a dedicated
> prepend/appendleft operation, because appending to the left of the array
> involves shifting the entire structure over one place in memory. This is a
> very slow operation, because it must copy the entire structure to simply
> insert a single element. Python get's away with append on the right, by
> allocating a bit of extra "padding" memory on the right side, to avoid
> having to copy the structure.

Not quite sure I get this. What's this got to do with Python? Arrays, or more
specifically resizing arrays, are supposed to work like what you just
described. Appends are constant time and you almost always have extra memory
because of the resizing nature. Is this different in other languages?

~~~
rectangletangle
Basically Python offers many nice interfaces, which encourage relatively
efficient use of the underlying implementation. It would be trivial to
implement an `appendleft` method for Python's list type (you could compose
`list.insert`), but its omission was a good design choice, in my opinion. The
language tries to guide you toward using the more appropriate data structure
for the task, in this case a dedicated queue type. There're are numerous other
similar examples scattered throughout the language. The way Python applies
it's data structures is really well though out, and shows a great deal of
attention to detail. There's a lot of wisdom wrapped up in Python's design
choices, which I believe helps aspiring coders pick up solid techniques.

This isn't to say that Python is somehow, the be-all end-all language, but
it's a very nice language, with many nice aspects to learn from.

~~~
rajathagasthya
Thanks for the explanation. I think I might have slightly misunderstood your
original comment.

------
flukus
C is something you should learn because it is the foundation for so much of
the industry.

C++ and python are something you may want to learn depending on your needs.

~~~
sidlls
One should learn C if one wants to enter the world of highly resource
constrained computing. Once the community matures and the ecosystem matures
I'd recommend Rust for that domain, if they are serious about competing at the
systems level.

~~~
AstralStorm
Modern C++ does constrained resources better again than C, giving you more
expressive options and compile time computation.

Rust might have a future or it might be dead in 10 years. Its main focus is a
very narrow definition of safety (memory safety and partial data trace safety)
at low cost.

~~~
sidlls
C++ can do constrained resources better than C, it really depends on the
context. In general, C will almost always be usable, though, even in cases
where the use of C++ doesn't add anything because of severe constraints.

For Rust, I agree 100%, and that's why I qualified my statement the way I did.
It's too immature a language used mainly by people who are vested in it and
few others.

------
innocentoldguy
If you want to pick one to learn first, then whatever you decide will be the
right choice, as long as you are committed to learning more. As the article
states, being just a JavaScript developer, for instance, is a lot like being
just a screwdriver operator. It's not easy to compete in the job market with
just one skill and just one facet of understanding.

------
yawaramin
Neither; learn OCaml

~~~
codr4life
C or Lisp would be better choices if maximum learning is the goal, or Haskell
if hard core type fundamentalism appeals.

~~~
spraak
I was going to suggest Go for its utility usefulness while not being quite as
complicated as C or Haskell, though Python serves that well too

------
discardorama
Yes.

On a serious note: these are the 2 primary languages at companies like Google,
so it can't hurt.

------
kayman
Pick one, learn it. There are libraries to do what you want to do in both
languages. If you get good at one, you'll figure out a way to shoehorn it into
the problem you're trying to solve.

------
imode
the answer is "the one you've heard of/touched upon first", or "the one you're
familiar with", or "the one you're comfortable with".

typically, those new to programming have written in some language prior. it's
usually just a few lines, but it's enough to get them hooked!

encouraging them to explore what they've already touched upon gives them
something to latch onto. they presumably already had the tools set up, so
what's wrong with continuing?

------
unix
You should learn C++ and Javascript;

~~~
AstralStorm
I'd recommend PHP instead of JS of you want to learn the truly worst language
and ecosystem in the world. JS is just second place.

------
fjbarrett
Great answer I completely agree.

------
tmuir
Obviously, the most important skill for a programmer to learn is dogma. Dogma
provides a perpetually frictionless path back to the primacy of your own
ideas. Dogma obviates the need to become self aware, allowing you to pop out
such gems as "So, stay out of this quasi-religious controversy", while
portraying your own method as the One True Way.

