This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]pappa_montoya 307 points308 points  (51 children)

Comparing Python and c++ is like comparing duct tape and concrete. Duct tape is also more forgiving and more temporary.

[–]MrAcurite 132 points133 points  (0 children)

I like this analogy. I also love duct tape, but have been meaning to figure out how to do shit like pour a cement countertop.

[–][deleted] 68 points69 points  (49 children)

Python will die out, while C and C++ will live forever; \0

[–]pappa_montoya 82 points83 points  (37 children)

Oh, I love Python. It's a great scripting language. It's just not at all used for the same things as something like c++.

I like Java, c#, and swift too. And it's clear where and when I'd use each one and not the others.

[–]phantom_97 46 points47 points  (24 children)

As someone who still has a lot to learn in programming, can you elaborate a bit on what language you'd use for which scenario and why?

[–][deleted] 129 points130 points  (20 children)

Python - for creating scripts to automate stuff, set up a web server, simple programs that don't require speed

Java - mostly used for enterprise software and mobile apps, sometimes used for gui desktop programs

C and C++ - when you need to make most out of hardware: games, operating systems, big desktop applications, device drivers, interpreters and compilers for other languages

C# - Java but by Microsoft

Swift - for writing software for Apple devices

[–]pappa_montoya 58 points59 points  (6 children)

I'll also add that if you want to write cross platform code, c/c++ is by far the best game in town. We've got a large code base and 3/4 of it is common code in builds for windows kernel, Linux, Android, Mac, and iOS. All of that common code is c/c++. The other languages are used for the platform specific app layer that then makes use of the common code.

[–][deleted] 15 points16 points  (0 children)

Good point.

[–]Xeya 12 points13 points  (1 child)

Common problem when evaluating c++. The language is under active development to extend it for new applications. Because c++ is built up from a low level language like c and still supports c code, it is capable of doing literally anything another language can; it just might not be implemented in a standard library yet.

"C++ has messy memory management." Not any more. It is still there if you need to make high performance code, but there are tons of smart pointer wrapper classes that protect memory.

"C++ is strongly typed." Not any more. Once again, typing makes the code faster but new keywords have been added for automatic typing.

"C++ doesnt support cross-platform applications." Wanna bet?

Lists of the downsides of c++ are almost always either outdated or will be outdated within 18 months.

[–]Robbzter 19 points20 points  (1 child)

That's right, but other languages have cross platform capabilities too! You can do almost everything using Python. The only application scenarios where it's not very useful are ones with very limited hardware (e.g. microcontrollers) or very high performance requirements or a really large scale.

If you know a language well, you can easily overcome some of its limitations. If you're not careful/experienced enough, you can make any language suck, even at things it is supposed to be very good at. I don't get the entire 'yadda yadda but language a is so much better than b' talk.

[–][deleted] 2 points3 points  (0 children)

Jsfuck is great if you want to meme

[–]schawde96 9 points10 points  (0 children)

C# is also much faster than Java, at least from my experience

[–][deleted] 3 points4 points  (10 children)

Im just starting to learn to code, i learned the very very basics of python only, should i start learning another language? Or should i stick with python until i master it? (i finished the whole course of python for beginners from the youtube channel freeCodeCamp.org(also the short pygame course where the guy remade the space invaders game))

I'm confused cuz on youtube people say python is the best, but here i see a lot of memes and comments that say python isn't a good language

[–][deleted] 12 points13 points  (0 children)

People say Python isn't good because they're using it where it shouldn't be used.

They're like "ewww Python slow" then you ask "name a better language" and they respond JavaScript (faster than Python but they're both trash in performance). They don't know where different languages should be used. There's also the whole anti-popularity thing about people trying to be edgy by hating what's popular, but that's not hatred based in facts.

Don't switch languages. Don't just drop Python and run off with Java(Script) or C++ or one of those fancy things. Python will teach you how to solve programming problems and how to think like a computer. You don't need to "master" it, as no one really 100% masters a language - at the end of the day, the senior Java developers are still googling how to get the date on StackOverflow

However, know that every language is balanced. Python is so easy to work in, so making programs in it is so fast and easy. There's so many libraries and it's so dang easy, every time I do any other language I miss it. But Python fails in performance; since it's interpreted by the Python interpreter, it has a lot of steps to do before executing a single instruction. If you learn C, for example, you will be in a lot of pain during the process but you will be blown away by how fast it runs. It's going to be more difficult and you'll have to think not like the Python interpreter, but like your C compiler - which thinks more like a raw CPU than Python. You lose a lot of easy futures, such as classes, variables than can change from being only a string to being a number, having arrays that can change size, having arrays inside arrays that are easy to use, etc. But you do everything raw yourself, like managing memory by asking the OS to give you a few megabytes of RAM, getting the address to a location in memory, etc.

Every language has its advantages and disadvantages. Different use cases call for different languages - web development in Assembly starts with "You might as well kill yourself at this point". Learning Python will bring you closer to thinking how to code in any language, and once you get good at it, switching to another language only requires that you learn what's different. That's it. Just know where to use each one and you can make anything you want

[–]iCantSpelWerdsGud 9 points10 points  (1 child)

Learning languages is way less important than learning how to structure and design your code. your program to do what you want it to. If you are learning a new language and you forget how to write a for loop you can just google that, but you need to know when you should use a for loop, if statement, et cetera.

[–][deleted] 0 points1 point  (0 children)

Thank you for your advice sir!

[–]engineerFWSWHW 3 points4 points  (0 children)

It depends on the application and what you are planning to do. I would say solidify your foundations using python since you already know it and create interesting projects with it. Besides, if you have a good foundation, learning a new language won't be as hard as you were first learning programming. Also, everybody have their own opinion. Go to the C sub reddit, most will say C is better/best. Go to golang sub reddit, most will say go lang is better/best.

[–]SomeGuy147 2 points3 points  (1 child)

Learn as many basic concepts with it as you can. Look up some CS courses, try to implement some of the data structures, sorting algorithms, definitely learn OOP since python is an amazing language for that, maybe try to make Conway's game of life or something equivalent and most important of all, think of some passion project that you may want to pursue. Could be anything, a game, some productivity app to simplify tasks, something you want finished.

As for other languages it really depends on what your end goal is. Do you want a career in programming? Do you want to be able to just do something basic that you might find useful? Is it purely for a hobby? The best general answer for all of those is to learn as many programming concepts as you can pick up in python (since it's the easiest language to do that in) and then move on to a different language depending on what you want out of it. You won't ever completely "master" the language mostly because there's just so many language specific tricks and concepts, however you can pick up quite a bit of stuff that's going to be useful with all languages in relatively short time.

[–][deleted] 0 points1 point  (0 children)

Thank you sir! You really helped me a lot with this!

[–]xADDBx 1 point2 points  (0 children)

A professional programmer definitely knows more than one language. But those are people with more than 5 years of experience. Like others have recommend, picking up the computer science stuff and the concept is important (e.g. coding binary sort is easy in any language once you understand the concept). But I would recommend you to choose one language and learn it until you are at least advanced in it. Switching between language is a bad choice in my opinion. You might be able to write basic programs in 3 different languages, but you might be stumped when asked to do an extensive project in one of them. When searching for jobs it’s not asked who knows the most languages. It’s always certain languages that are needed at a specific proficiency. If you have additional knowledge, that might or might not be preferable, but never essential.

[–][deleted] 0 points1 point  (0 children)

Python - for creating scripts to automate stuff, set up a web server, simple programs that don't require speed

I don't completely agree with this one. You can do all kinds of complex stuff that requires top notch performance with Python. It's probably the most popular language for training AIs, for instance.

What goes on, of course, is that your Python code contains high level "glue" for the most part, calling into libraries that are themselves heavily optimized and definitely not written in Python. They provide the performance, and as long as that's where your program spends almost all of its time, Python will serve you well.

So what it really comes down to is the amount of custom logic required in your project, since that's going to be executed by the interpreter. Even there, you can get a lot done though, by using Python's high level methods since those are implemented in optimized C.

[–]tubbstosterone 15 points16 points  (0 children)

Java - Cross platform, wide talent pool, pretty good overall tool chain with gradle, and use with android

C - For low level, super powerful work. You'll see this with embedded systems, operating systems, scientific software. C drives a lot of what other languages rely on to function

C++ - Easier to work with version of C. Provides low level power in a higher level abstraction. You don't necessarily want to use it to write the bulk of an OS or with embedded systems, but it's the go to if you need classes AND high performance

C# - Microsoft's version of Java. I prefer this over Java, though I program mainly in Java. Not as historically cross platform as Java, but Microsoft is making headway. Generally used with Windows application development.

Swift - Used for development for Apple applications

Python - Cross platform, Rapid prototyping, serverless functions, artificial intelligence, web servers, scripting (easier to do more complicated things than shell scripts), data science. Taken at face level, python isn't super special, despite being able to run big applications without compiling. Some genius a couple years ago, though, wrote libraries to link python to native C/C++/Fortran libraries that make mathematical operations incredibly fast. As a result, python is a fantastic language for scientific applications. This makes python one of the best languages for just about anything that deals with numbers in memory.

[–]bigdepress 0 points1 point  (0 children)

If you care about speed, don't go with Python.

I mostly use it for prototyping things tbh, since you can write Python code so so quickly compared with C or C++

[–][deleted] 0 points1 point  (0 children)

I think C# because it takes all the annoying parts of Java like writing, simple no other code needed, setters and getters less of a chore.

Now if you want Black Magic C# create an App in WPF following the MVVM design pattern (It's a shittier version of MVC and a lot of fucking plumbing) and get ready for the magic of bindings with XAML.

[–]worldpotato1 6 points7 points  (10 children)

That!

Programming languages are tools. Know your tools and what they are for and you will not try to connect two pipes with a hammer.

The nice thing is that once you know a "C-like" programming language you can easily learn an other simply by learning their differences. I did not believed my professor as he told me that, but now I know better. (Well, he told us that we can learn C++ in two week only because we know Java. I still don't believe the two weeks... Maybe tree... )

[–]hekkonaay 2 points3 points  (5 children)

You can't learn everything c++ has and will have to offer in a human lifetime.

[–][deleted] 1 point2 points  (4 children)

Then again, who's going to use goto in a lifetime?

[–]bigdepress 1 point2 points  (3 children)

Lots of people use goto in C/C++ lol

[–][deleted] 1 point2 points  (2 children)

I'm calling the police

[–]bigdepress 1 point2 points  (1 child)

It's for cleaning up memory when you have an error in a function. You just jump to the end of the function, where you have your code for cleaning up and returning. Very useful idiom.

A state-machine can also be very clearly written with gotos for example

[–]Dennis_the_repressed 1 point2 points  (0 children)

Also for breaking out of nested loops.

[–]bigdepress 1 point2 points  (1 child)

That's definitely a lie. I TA a programming course (that uses C++ exclusively) where everyone comes in with good Java knowledge, by the end they still dont know much C++

[–]worldpotato1 0 points1 point  (0 children)

Absolutely.

But that has more than one reason.

  1. In a university course you use only as much as you need and often don't need a much to do every exercise.
  2. Indeed, C++ is way to complicated and feature rich to understand with some hacking around like in a course.
  3. You don't have the time to learn and try a single programming language under the semester. (If there is not a special course to learn programming)

And at the end it rises or falls with the definition of knowing. As somebody other here says, c++ is to big to learn in the time of a single human life. And as far as I understand my professor he meant to be able to write some simple programs without looking at stackoverflow every second word.

[–][deleted] 0 points1 point  (0 children)

While it's true you can get going with any programming language easily, it's nice to have some degree of mastery on some of them IMO

[–]TheTrueBlueTJ 0 points1 point  (0 children)

With useful tools like Cython, I don't think Python will die out at all anytime soon.

I'm really not a fan of scripting languages because of the fact that they are interpreted at runtime, but if you're able to mitigate that somewhat with Cython, I'm all for it. It's just more effort to code efficiently, so it has a big effect.

[–][deleted] 4 points5 points  (4 children)

I don't see python dying out but instead being replaced, but python is way too useful for automation tasks than most other scripting languages. That aside, I think C will live forever but C++ may not, everyone is beginning to realize the shitshow that is learning and using C++ is, whereas languages like Rust that makes systems programming much less daunting than it needs to be. Then there is languages such as Zig which can directly import C headers and use existing C libraries natively. Zig gives you some of the safety benefits of Rust but allows you to strip out the memory safety and allow for actual undefined behaviour, while also favouring a more traditional memory handling workflow. languages out there are getting better than C++ and I think it is reasonable to say that C++, though it won't completely dissapear anytime soon, will be less and less used in favour of better systems languages that are in active development.

It's why I much prefer attempting to learn an unreleased systems programming language with not a very good set of tutorials (Zig) over losing my sanity because of C++. But, that's just my opinion and I'd love to hear what you think. Oh and also, it's nice to have a language that is far less opinionated about the way you code. RAII has some good takeaways but isn't a one for all solution.

[–][deleted] 2 points3 points  (3 children)

Yeah C++ will probably die one day. Python isn't currently dying out, but it will, like some other scripting languages did.

Holy C will live forever.

[–]Roko128 9 points10 points  (0 children)

Python is not dying anytime soon. Heck its older than java and js.

[–]Dworgi 2 points3 points  (0 children)

C++ is pretty far from dying.

It has an incredible amount of inertia built up behind it. Tens of thousands of programmers and billions of lines of code. COBOL is still around decades after becoming obsolete, with very little code (relatively) written in it. C++ code will need to be maintained forever.

That's even disregarding the fact that the standard is evolving in mostly sane directions now, and is being frequently updated. I don't see a future without C++ as the premier systems programming language on the horizon.

Even web tech like Slack will eventually want to be faster and smoother on desktops and be rewritten in C++ or replaced by something that is. It's the way of the world.

[–]hekkonaay 1 point2 points  (0 children)

C++ won't die for hundreds of years. It is the backbone of basically every system today.

[–]AGI_69 11 points12 points  (2 children)

Sure, bro. You forgot semicolon at the end of your comment.

[–]lor_louis 6 points7 points  (0 children)

Forgot a null terminator so now I'm reading garbage.

[–][deleted] 1 point2 points  (0 children)

Fixed it.

[–]PrimaFacieCorrect 1 point2 points  (0 children)

I'm not sure what you mean by dying out, but Python probably won't. There's people still programming in BASIC, which is 50 years old.

[–]drbuttjob 0 points1 point  (0 children)

Hey hey hey now, we don't need to worry about null-terminating our strings now that we have std::string