Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Honestly I like well-designed modern C++ as a library/app developer; it's fast, type-safe, and (more or less) expressive. The worst thing about it is unnecessarily complex syntax/concepts (TMP scares me, `template<typename> using Foo` simplifies code, concepts are complicated but help avoid TMP) and slow compile times (unavoidable to my knowledge) I looked at nlohmann/json's homepage and I find the API surface perfectly readable (if you avoid ""_json and the more complex stuff, I didn't look at the library itself).

Similarly I think that fmtlib is a beautiful piece of software (fmt::memory_buffer is beautiful, but I dislike the mysterious template errors when you write code wrong, and poor documentation for how to avoid them). It's as convenient as C format strings (but type-safe, and thankfully uses fat strings composed of a pointer and length, or begin and end, rather than null-terminated strings with O(n) strlen), and much better than C++ streams, which hold string formatting state (setw, precision) which is wholly wasteful for binary file IO, and is evil global state (possibly TU-local) for console IO.

Modern C++ also a lot better than the 3+ layer deep inheritance hierarchies of 2000s C++, where Child::f() delegates to Base::f() which calls g(), which is a virtual function pointing to Subclass::g(), which delegates to Base::g(), which is alive and well in Qt and KDE code.



What bothers me about libraries like nlohmann/json isn't so much the style or the public interface (which is fine and I actually like, too).

It's the fact that a conforming and performant JSON parsing and serialisation library doesn't require 22kloc in C++. That's madness. I also struggle to call a library "modern" that uses goto-statements. Especially if the library is even slower than smaller alternatives like [1].

But that's just my personal opinion, I understand that other people have different priorities and are fine with including 785kb of C++ template headers as long as the public interface suits their needs and taste.

This is just an example for the kind of freedom software allows for, because it doesn't cost you anything and there is no objectively "better" in this case.

[1] https://github.com/kazuho/picojson




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

Search: