Hacker News new | past | comments | ask | show | jobs | submit login

I tend to think that the C++ standards committee went off into template la-la land a few years back. Everything has to involve templates, "metaprogramming", and excessive gyrations within the type system. If you want to compute at compile time, C++ templates are a terrible way to do it.

The fundamental problem with C++ is that it has hiding ("abstraction") without safety. No other major language does that. In C, there's no memory safety but everything is explicit in source. In memory-safe languages, there's memory safety even if there's lots of abstraction.

Rust has a brilliant idea in the borrow checker, but the type system is kind of weird, the attempt to bolt on functional programming is marginal, and error handling involves hacks such as "try!()". But with enough use, those aren't so bad. Maybe. Personally I would have preferred Python-type "with" clauses and exception handling to RAII. If anything goes wrong in a destructor, Rust cannot help you.




> If you want to compute at compile time

I assume you're not up to speed on all the constexpr work.


I didn't realize that as of C++14, you can now execute loops at compile time. Does that work in many compilers?


Wouldn't any fully standards compliant compiler for c++14 support that feature?


gcc's optimizer will often do it for plain C

(recent versions at least)


You'd prefer explicit "with" clauses even for, say, reference counted types?

I mean, Objective-C tried explicit [foo release] for a long time, but I haven't heard anyone clamoring to go back to the pre-ARC world…


I mean "with" for opens and the like, not structures. Python "with", not Pascal "with".

For Python's "with", someone figured out what to do if something goes wrong in __exit__, which is called as control leaves the with clause. An exception in an __exit__ is handled well, and nested exceptions work reasonably. Failure to get this right results in problems such as unnoticed truncated files because the status on the close after a write wasn't checked.


Right, I'm referring to Python's "with". How do you write reference counted smart pointers without RAII?




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: