3 ms·
I find it curious that both the team that used C++, and the author, both appear to believe that sum types and related facilities are not usable or conveniently
by ncmncm 7y ago
I find it curious that both the team that used C++, and the author, both appear to believe that sum types and related facilities are not usable or conveniently expressible in C++.
I got that Boost Spirit, a powerful parsing library, was forbidden. Were all the Boost libraries similarly embargoed?
- trishume 7y agoThere was a general prohibition on libraries that don't ship with the compiler, but you could ask the professor for an exception. Someone asked about Boost and a blanket exception for the non-parsing and scanning parts of Boost was granted. However the C++ team I talked to didn't use it. Also note that it's not only the sum types that are important, powerful pattern matching facilities are part of what makes them so valuable.
- shaklee3 7y agoC++ has had sum types for years, so I'm not sure why that was mentioned. If you aren't familiar/experienced with the language, then the comparison is not fair overall.
- jcora 7y agoYeah it's had everything for years. I'd rather shoot myself than use those features outside of a modern language where they aren't just bolted on along a billion other things.
- ncmncm 7y agoIt is correct to note that C++ lacks some core language features that many newer languages have, tailored to more convenient and, often, safer use of slippery sum types. Sum types are a step away from lexical typing, and without that support add risk that strong typing was invented to contain. There is an active project to have a powerful pattern-matching primitive ready in time to adopt into C++23. In the meantime, C++17 supports "structured bindings" that are often helpful.
- xyzzy_plugh 7y ago> Boost Spirit, a powerful parsing library I regularly use Boost Spirit as an example of "sounds good but actually a nightmare", and am always surprised to see it mentioned in the wild. It is truly a modern horror. Boost is like Apache -- a collection of libraries of various quality and stage of development, not all alike. A lot of stuff in there is designed to prove out experimental language features ahead of the next standard revision. A lot of that stuff is convenient, but a complexity nightmare under the hood. For your own sanity, and of those you care about, don't accept all of Boost equally. Be suspicious, and treat each package as if it were some random library you found on the internet. (There are of course tons of great things in Boost, but tread carefully)
- ncmncm 7y agoYou won't catch me arguing in favor of using Spirit. In general, it is rarely a good idea to rely on a library you don't understand. But Boost has serviceable variant, option, and result types.
- jcora 7y agoYeah the issue is whether the language makes it easy to use them on all levels from syntax and features (simple constructors, pattern matching) to use in the stdlib and wider community
- jcelerier 7y ago> I regularly use Boost Spirit as an example of "sounds good but actually a nightmare", and am always surprised to see it mentioned in the wild. It is truly a modern horror. huh, I have written a few parsers (half a dozen maybe ?) with spirit and absolutely don't regret it - why would you say that ?
- rcxdude 7y agoI mean, they aren't. The ergonomics of sum types in C++ are terrible and are actually useful in far fewer situations than they are in nearly any other language which supports them.