5 ms·
Rust is impl-first bottom-up and it's stuck with a single implementation and GCC for Rust is still in the works, meanwhile C++26 reflection is already in GCC tr
by remix2000 4mo ago
Rust is impl-first bottom-up and it's stuck with a single implementation and GCC for Rust is still in the works, meanwhile C++26 reflection is already in GCC trunk.
- bitwize 4mo agoRust is also the systems programming language of the future. They're pretty much doing everything right.
- uecker 4mo agoWhat IMHO Rust does not get right and why I do not use it: long compilation times, high complexity, its syntax, polymorphism based on monomorphization, the requirement for many dependencies to get anything done, an ecosystem susceptible to supply-chain attacks, no ISO standard.
- nicoty 4mo agoOut of curiosity, what do you think is wrong with monomorphization-based polymorphism? The other alternatives I'm aware of are 1. type-erasure via v-table based dynamic dispatch (which Rust also has in the form of the `dyn` keyword), which has performance and memory-allocation overhead and 2. macros, which Rust also has and, if used for polymorphism, would essentially be like compile-time monomorphization, but clunkier. Maybe I'm missing something though and there are other alternatives done differently in other languages?
- uecker 4mo agoThe correct choice IMHO is type-erasure. It does not necessarily have overhead, because optimizers can specialize or devirtualize. Of course, this my depend on how you implement your language, but in C this works nicely. The problem with monomorphization is that it leads to exponential expansion, which later passes of the compiler can not unify again (at least this is much harder than not expanding in the first place). It should also fundamentally limit what you can do, because expansion has to stop at some point, but I haven't thought about this too much. I also think that where you want monomophization, macro seem fine. I do not think this necessarily has to be clunky, but this is just a guess.
- tialaramex 4mo agoI don't think the numbers bear out that "this works nicely" in C, it seems like you have worse perf numbers for some common cases like sorting ?
- uecker 4mo agoNot sure what numbers you are talking about. If you use qsort from the C library the comparison function will not be inlined, but if you provide your own, this is no problem.
- tialaramex 4mo ago> if you provide your own, this is no problem. If just "providing my own" would help why wouldn't the stdlib benefit too? You're going to have to spell out what you think can actually work here if you want me to believe there's "no problem".
- uecker 4mo agoIt would also, but nobody cares enough because qsort is already fast enough for most things, and if you cared it is simply enough to do yourself. Are you doubting that C compilers can devirtualize function calls? Here is a small example that illustrates this. The compiler dervirtualizes all calls than folds the result: https://godbolt.org/z/E6cMMr8vx https://godbolt.org/z/E6cMMr8vx
- tialaramex 4mo ago[dead]
- fluffybucktsnek 4mo agoType-erasure does have an inherent overhead. Sure, optimizations can be made, but they can be fickle and specialization is basically implicit monomorphization. Using C macros to replicate Rust's monomorphism has several drawbacks: they are inherently unhygienic, even in comparison to Rust's own; you can't set type-bounds; they aren't even a part of C proper, etc. I prefer Rust's approach with the choice between generics, macros, dyn and Any.
- tialaramex 4mo ago> no ISO standard I'm sure I could argue with you about the actual technical differences but this part in particular is very, very stupid. JTC1/SC22 † shouldn't exist at all. A committee structure is a bad way to do this work, and the practice of having periodic meetings - exclusively in person for much of the time these existed - actually makes it less rather than more useful. ISO mandates a bunch of rules and procedures which surely make some sense if you're agreeing on thread dimensions for oil pipelines but are completely inappropriate for this work and yet because they're ISO committees the WG14 and WG21 processes are captured. I don't think it makes good sense to use an SDO for this work, but if you must have an SDO for some reason beyond ego then you could do a lot better than ISO. Check out TC39 for example. † The C and C++ standards committees are respectively Working Groups 14 and 21 of the Sub-committee on Programming Languages, SC22, of the (First and only) Joint Technical Committee between ISO and the IEC. Yes it's committees all the way down. "This programming language standard could have been an email".
- uecker 4mo agoIt doesn't have to be ISO, but some organization which follows some official rules and not some entity dependent on industry donations.
- tialaramex 4mo agoLOL. You do know ISO/IEC 29500 exists right? ISO agreed that despite there being an existing, popular, broadly supported and open XML document standard they should define Microsoft's proprietary alternative OOXML as an international "standard". They even held votes repeatedly until the voters gave the "correct" answer... no worry about "industry donations" there.
- uecker 4mo agoI remember the story, but it was considered outrageous for a reason.
- 4mo ago
- Someone 4mo ago> its syntax I haven’t used rust, but having gotten used to C and C++ at a time, I expect that would happen with rust, too, if I started using it. Because of that, I think this is just a matter of familiarity. > polymorphism based on monomorphization Implementation detail (yes, there is only one implementation at the moment, but this means it can be changed without changing the language) > the requirement for many dependencies to get anything done Fixable if a party is willing to write or package together a fairly large set of dependencies into a single package. > an ecosystem susceptible to supply-chain attacks Fixable if that party is trustworthy. Also, for which languages is this less of a problem? You either have third-party libraries and a potential security problem, or you don’t, and need to write more code.
- uecker 4mo agoSome of Rust's problems may be fixable, but they are not being fixed at the moment and with something as complex as Rust, this is unlikely. I do not think monomorphization is an implementation detail, rather than a fundamental language design mistake that is difficult to correct.
- fluffybucktsnek 4mo agoBeg to differ. After musing for while, I realized Rust could only have chosen monomorphism for its goals, thus it's not a fundamental design mistake, but a necessary choice. One of the overall philosophies is zero-cost abstractions, and only designing a polymorphic system with monomorphism in mind may provide that, because the alternative requires pointers (different type sizes, vtable, etc.). While, as discussed previously, devirtualization + inlining is a thing, it is not assured and relatively easy to disable. Writing a program relying on these optimizations would produce something bristle and error-prone, and building a polymorphic system around this would be antithetical to the Rust's ZCO philosophy. Meanwhile, monomorphization can fit functions around the size of the type arguments and access method implementations directly, removing the need for any indirection in the first place. While indirection-based polymorphism can't reliably reimplement monomorphic polymorphism, the reverse is not true. You can reliably reimplement any indirection-based polymorphism with monomorphism, from fat pointers (in fact, Rust already has trait objects to help with that), class-based hierarchies, dynamic typing, etc.
- pjmlp 4mo agoExcept for compilation times, no it isn't the complexity of the language, it is the toolchain. See Ada, D, Delphi,.... Granted, priorities, one cannot fix everything at the same time.
- zamadatix 4mo agoC++ has had it's own long periods of badly lagging/buggy implementations of the standards. It's better today but I'm not sure how much of that I'd credit/discredit that to the way the standards process works. So long as there is one quality implementation it doesn't matter much anyways.
- zarzavat 4mo agoIs that supposed to be a bad thing? I like having only one implementation. Multiple compilers is annoying for users, have to write "portable" code which can only target the lowest common denominator. Only when a feature ships in Clang, GCC and VC++ can you use it. Each compiler needs its own flags/project as well. Loosely coupling a language to its compiler is 20th century thinking for when programming languages were simple. It works for C because C is simple enough to be implemented over and over again. But for today's hyper complicated languages, multiple implementations is a pain for everyone.
- asddubs 4mo agoIt's a bad thing if you want your language to be truly portable and be able to work on anything
- NooneAtAll3 4mo agoyes monopolies are always a bad thing
- zarzavat 4mo agoA programming language with a reference implementation is not a "monopoly", it's a standard. By having a common implementation to write code against we can avoid wasting time on pointless minutiae such as which features are portable in practice and which are not. When a programming language community fractures into multiple incompatible implementations everyone is worse off.