6 ms·
Should I learn C++ or Python?
- discardorama 10y agoYes. On a serious note: these are the 2 primary languages at companies like Google, so it can't hurt.
- yawaramin 10y agoNeither; learn OCaml
- codr4life 10y agoC or Lisp would be better choices if maximum learning is the goal, or Haskell if hard core type fundamentalism appeals.
- simplehuman 10y agoWell, They teach ocaml as part of masters functional programming in uiuc.
- spraak 10y agoI 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
- HeavenBanned 10y agoI've been reading HN for a bit; why is there so much talk about Go?
- yawaramin 10y agoBear in mind that the original question is 'Should I learn C++ or Python?' This suggests the asker already knows C and is looking for the next step. Given that, w.r.t. to Lisp, I believe an ML-family language like OCaml would be a strict superset of the learning offered by a Lisp, and w.r.t. Haskell--hard core type fundamentalism rarely appeals to people trying to decide between C++ and Python. I suggested OCaml for its static typing features, speed (comparable to C++), potential to deploy universally (desktop, mobile, web), and last but not least because of its pragmatism--if you need to do some imperative programming, it gets out of your way.
- magnumkarter 10y agoI agree, type inference, sane object and classes, modules and ADTs and MirageOS. Looking back i wish F# or OCaml was my first language
- deleted 10y ago[deleted]
- wyldfire 10y ago> "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 10y agoI 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 10y agoAt 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++.
- hermitdev 10y agoA 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).
- gravypod 10y agoYou 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.
- hackits 10y agoWhy 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-python.html http://neverworkintheory.org/2016/06/13/polymorphism-in-pyth...)
- other_herbert 10y agoI will add though after converting from a huge jpa spring boot rest service to just read since data from a database, node and graphql and plain SQL is a joy... That might have more to do with the fact that I'm starting this thing over and not inheriting design decisions..
- hackits 10y agoGive it time. You can get a lot done with node, graphql and plain SQL. Although when you're working on a project with 50+ developers that is where the Spring JPA, Spring Boost, Tomcat, Maven come in their own managing less skilled developer to contribute to the team. The other problem is when you're starting out you lose out on a lot of historic perspective. You get smashed over the head with Maven, Spring 1,2,3 (ORM, JPA) inverse versioning code, Hibernate, Transactions, Annotations, Servlet, JSP document/JSP pages. Each collectively take about a year to get confident to give accurate quotes for large government projects. Let alone figuring what the hell the framework is doing.
- ExactoKnight 10y agoThis is why Ruby on Rails is running circles around the Java projects.
- hackits 10y agoFree time i use mostly php/python. Havent given Ruby on Rails a go, how does it compare with connection pools? Oracle db connection drivers and Postgres databases?
- imode 10y agothe 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?
- flukus 10y agoC 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 10y agoOne 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 10y agoModern 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 10y agoC++ 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.
- rdtsc 10y ago> "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.
- unix 10y agoYou should learn C++ and Javascript;
- AstralStorm 10y agoI'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.
- crusso 10y agoLearn 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.
- Waterluvian 10y agoI always make the woodworking analogy. You don't hear people say "I'm a huge router fan." "I'm a tack hammer kind of gal." "I was born a radial arm saw user and I'll die one!" Maybe you want to make cabinets, or houses, or decks. Pick the tools that help you make what you want to make.
- pekk 10y agoTo take an example, Java can be used for a great many things. It's nowhere near as specialized as a tack hammer. So this isn't as easy a decision as you are making out.
- AstralStorm 10y agoTechnically, you should learn the most general tools first. Java is not one, it is designed to be explicitly limited. Both Python and C++ are general albeit Python had a major disadvantage in performance while C++ in clarity. (That said, more modern versions of both have the disadvantages reduced.)
- grzm 10y agoHow is Java "designed to be explicitly limited"? It's a general purpose programming language with a huge number of libraries available.
- eddie_31003 10y agoWhat'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 10y agoPython 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 10y ago> 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?
- innocentoldguy 10y agoIf 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.
- gigatexal 10y agoI 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?
- deleted 10y ago[deleted]
- tmuir 10y agoObviously, 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.
- snippet22 10y agoI'd say the complete opposite. Today a company I know that uses a super aged language php decided to buy some .Net software that was crazy slow and had a million tables you know they built with wizards. It just every day becomes more and more clear how they haven't a clue what they are doing. It's freaken amazing to see them drop in speed tests.
- RhysU 10y agoLearn 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.
- AstralStorm 10y agoThat corner is very far though and showed up only in resource restricted systems. Mind you, for a big enough problem any system currently available is restricted.
- dagw 10y agoAfter 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.
- snippet22 10y agoLearn golang. Great article on why https://hackernoon.com/why-go-ef8850dc5f3c#.gqw0x9wft https://hackernoon.com/why-go-ef8850dc5f3c#.gqw0x9wft Inspirational video on the guy who created golang. https://youtu.be/IjvjqAVkvYo https://youtu.be/IjvjqAVkvYo https://changelog.com/gotime https://changelog.com/gotime - podcast on go https://gobyexample.com https://gobyexample.com - let's you run examples Wiki https://en.m.wikipedia.org/wiki/Go_(programming_language) https://en.m.wikipedia.org/wiki/Go_(programming_language) https://www.jetbrains.com/go/ https://www.jetbrains.com/go/ - ide for go Davy is great. https://dave.cheney.net/resources-for-new-go-programmers https://dave.cheney.net/resources-for-new-go-programmers Todd is awesome too. https://youtu.be/c7XMV2HM6IQ https://youtu.be/c7XMV2HM6IQ https://mobile.twitter.com/todd_mcleod?lang=en https://mobile.twitter.com/todd_mcleod?lang=en Newstack is great http://thenewstack.io/make-a-restful-json-api-go/ http://thenewstack.io/make-a-restful-json-api-go/ Books on it. https://github.com/dariubs/GoBooks https://github.com/dariubs/GoBooks Nice resource on structs and interfaces https://www.golang-book.com/books/intro/9 https://www.golang-book.com/books/intro/9 Just golang news https://golangnews.com https://golangnews.com
- agarden 10y ago> "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.
- raymondh 10y agoA 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.
- snippet22 10y agoOr learn neither haha https://hackernoon.com/react-studio-public-beta-2-1ec0eb8076f4#.stsqgbz6c https://hackernoon.com/react-studio-public-beta-2-1ec0eb8076... https://medium.com/@nicolasblanco/how-ive-saved-some-every-month-and-learnt-serverless-at-the-same-time-eba3cebbdc6b#.iofhvp1su https://medium.com/@nicolasblanco/how-ive-saved-some-every-m...
- kayman 10y agoPick 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.
- fjbarrett 10y agoGreat answer I completely agree.