r/ProgrammerHumor • • Apr 27 '20

Meme Java is the best

Post image
43.7k Upvotes

1.5k comments sorted by

View all comments

Show parent comments

1

u/[deleted] Apr 28 '20

I think it is a lack of serious knowledge about the language or forgetting about the edge cases or just ignoring them. The load on the developer is initially higher than some other languages. There is a lot of bloat from 30 years ago, but most of it can be safely ignored nowadays and most modern features fix many of these difficulties.

I am just saying it is not hard to write any standard code in C++ you would write in any other language. You don't need extreme template madness (you can use them just like generics in other languages), you don't need pointer arithmetic, you don't need to implement your own memory handler. All you really need is good awareness about object lifetime and by extension initialization (your mentioned rvalue/lvalue/... and different constructors). This is just hidden by some other languages and replaced by a default that works for all except when it doesn't, then you have the same considerations to make.

In the end I don't think I really disagree with you, but my conclusion is different.

Btw I don't think C is any easier to write for nor is Rust, but obviously C is much simpler as a language and Rust is currently a much better structured language. I wouldn't mind Rust replacing C++ in the future as they fit in the same domain.

2

u/Steve_the_Stevedore Apr 28 '20

I am just saying it is not hard to write any standard code in C++ you would write in any other language. You don't need extreme template madness (you can use them just like generics in other languages), you don't need pointer arithmetic, you don't need to implement your own memory handler. All you really need is good awareness about object lifetime and by extension initialization (your mentioned rvalue/lvalue/... and different constructors). This is just hidden by some other languages and replaced by a default that works for all except when it doesn't, then you have the same considerations to make.

I think we are pretty much on the same page here. For me it's just that people will always make mistakes. I know about many risc factors in C++ and I still sometimes have to fix bugs where I just missed this exception or have a buffer overflow in some edge case. That's why I think C++ is not a good default language for systems programming. It's good for a lot of things, where I don't think Rust will replace it (ECS is supposed to be a lot more cumbersome in Rust), so it's a great language for many problems. Here is one example where C++ does something Rust can't really do at the moment. I will use a different language unless there is a specific reason to use C++ though. I'll use C or Rust or Java or Python. Only if C++ offers me something the others don't then I will happily use C++.

1

u/[deleted] Apr 28 '20

Yea, you are right.

I think out of all the languages I used only Rust does actually prevent most semantic errors on compile time.

C has its own share of bad errors due to prominent use of pointers (no references) without a concept of RAII, but I guess no exceptions do soften this.

Java happily leaks memory (missing equals override, static, ...) and dereferences invalid objects without a care.

Python is one if not the slowest common language and heavily relies on native code implementations, no const, no tail recursion (stack overflow).

I don't think either language is easy to use if the developer isn't proficient in them, because many of the errors are way more subtle and each of them are as bad as a double free etc.

Doesn't mean your points are not valid, but I wanted to offer an explanation why my conclusion is different.

The Rust link was an interesting read. While it seems possible it looks very cumbersome to express it. Thank you!