4 ms·
C++ and Python are not competitors. Sure both are Turing complete so you can implement anything in either. However if you should is a different question. Python
by bluGill 3y ago
C++ and Python are not competitors. Sure both are Turing complete so you can implement anything in either. However if you should is a different question. Python is very difficult to maintain when you program goes over 100k lines of code, while the static type system of c++ is good for millions. C++ compiles to fast binary code, while Python is typically 60x slower for logic (though often Python calls a fast algorithm implemented in a compiled language for anything significant so this is hard to measure in typical programs). However if your programs are not very large and you don't need every last bit of speed Python is going to be easier to work with. (And frankly if not working with a legacy c++ codebase you should look at rust, ada, go, or something else i'm not aware of, c++ has many ugly warts that you shouldn't need to worry about)
- germandiago 3y agoAs a person who uses C++, I must say something that also applies, somewhat, to Java. We have all the cool kids like Kotlin, Rust, etc. However, when it is about finishing a project, beating C++ or Java ecosystems is almost impossible. Besides that, C++ has improved a lot over time. It still has its warts and knives but you can code very reasonable C++ with a few guidelines and there are also linters, and -Wall -Wextra -Weverything -Werror. That takes you quite far in real life provided you have a reasonable amount of training. I would choose C++ over Rust any day. The only hope I have for C++ successors are Cppfront and Carbon and they are highly experimental. As successors those two fit the bill. There is a third one, my favorite. It is this one: https://www.hylo-lang.org/ https://www.hylo-lang.org/ but I am not sure how compatible it will/would be.
- no_wizard 3y agoThe one thing Rust is getting right that I hope Carbon et. al take from it is using the type system to manage memory. not having to explicitly remember `free` in safe Rust code is amazing. Knowing that if my types are sound that memory will be managed reasonably is great. I also think that immutable by default, mutable by explicit declaration is pretty great. I do think there is a lot of room to add better ergonomics on these ideas however
- germandiago 3y agoThe amount of complexity that Rust adds is not worth in most scenarios in my opinion. I can think of Rust as something for OS with critical safety or so. Besides that, in real life you end up having C in most of your software, so I am not sure how Rust behaves compared to well-written C++ with all warnings and linters on and using smart pointers. But my hypothesis is that they do not stay very far apart in safety. There are many ways to achieve safety, and the most promising, IMHO, is the path that Hylo programming language is taking. It sticks to Generic programming and mutable value semantics. The language base draws from Swift and it has very strong people behind that know what they are doing. For example David Abrahams and Sean Parent. This is an implementation in a language of many of the ideas from "Better Code" from Sean Parent. It has a very solid foundation. Besides being a solid foundation for generic programming, value semantics, and concurrency, what I like the most is how much it simplifies the model by not escaping references all around and preventing unnecessary copies. This removes the (IMHO) mess that is to have to manage reference escaping constantly in Rust, reason why many patterns such as Linked lists are not even possible. And Lists are not just an academic exercise, as I was told sometimes by Rust proponents. Linked structures (Inmutable linked structures actually) are important in scenarios such as TelCo backend where you need replication, fast moving of data and history versioning, rollbacks and so on.
- no_wizard 3y agoAll this may be true (I'm not the strongest C++ developer in the world, relatively limited exposure), however the Rust memory management via the type system feels natural once you wrap your head around it. That idea is really good. I always hated dealing with `delete`, `free` and `malloc`. Being able to offload all that busy work to the type system is just nice. There are definitely ergonomic improvements that could be made around this. All the rest? I'll leave that to someone else to talk through, as I'm no expert here.
- germandiago 3y ago> however the Rust memory management via the type system feels natural once you wrap your head around it It disallows many valid patterns. That is why I recommend to take a look at Hylo programming language (before called Val lang) to see what I think it is a very good example of how to make a language safe without making the learning curve so steep and without a need for a GC.
- bb88 3y ago> However, when it is about finishing a project, beating C++ or Java ecosystems is almost impossible. Yet, somehow people do this with python, perl, and ruby. Google hires professional python people too.
- hbrn 3y agoNot only do this, but do it way more successfully. I'll never get tired of repeating that among top YC startups, Java as a primary language contributes to roughly 1% of value, while Python + Ruby are almost at 70%. https://charliereese.ca/y-combinator-top-50-software-startups/ https://charliereese.ca/y-combinator-top-50-software-startup...
- germandiago 3y agoIf by successfully you mean time to market, for sure you are right. C++ gives more return when you start to save in infra because you have a more efficient language, if coded properly. Same goes for Go vs Python. The right tool for the right job. I would use (and will, I am on it) Django for a SaaS that I have for the backend. If things start to work relatively well, then, I will keep identifying, if there are, bottlenecks and migrate with a hybrid architecture parts of the workload to C++. This allows me to save in infrastructure bills.
- fuzztester 3y agoHylo page says it was formerly Val. IIRC, Val has been mentioned on HN sometimes earlier.
- bb88 3y agoAs painful as the Python package system is, C/C++ is so much worse. I remember trying to compile GTK+ on a solaris system a decade ago, and remembering how terrible it was to even to get it to compile. You're really deluding yourself if spending your time in compiler dependency hell is so much better than python.
- intalentive 3y agoThe new CMake package manager may make things easier.
- hbrn 3y ago> Python is very difficult to maintain when you program goes over 100k lines of code, while the static type system of c++ is good for millions I see this argument a lot, but people often forget that Python is very concise (yet readable) compared to other languages. 100k LOC in Python typically contains way more business logic than C++, so it is only natural to be harder to maintain.
- bluGill 3y agoPython ismuch less concise at this size. Sure your algorithms are more concise, but you lose all of that and more because it you don't have 100% test coverage you never know when a stupid typo will make your program crash, while with c++ you typically can be fine with more reasonable coverage, say 80% where the last 20% is things hard to test that are unlikely to fail anyway. At that scale Python is slower to build as well because c++ lets your tests depend only one the files that changed and this your code-build-test cycle is faster despite c++ being famously slow to compile.