6 ms·
> However, the entire point of Rust is that it’s safe. It’s really not. That is a fringe benefit; there are a dozen other reasons to use Rust over, say, C++. T
by ironmagma 6y ago
> However, the entire point of Rust is that it’s safe.
It’s really not. That is a fringe benefit; there are a dozen other reasons to use Rust over, say, C++. The syntax is cleaner, there are async await semantics, locking is way better, destructors aren’t a dumpster fire, macros aren’t the wild west, there just isn’t as much cruft... and et cetera.
- pjmlp 6y agoJust wait until Rust manages to be used by all major industry players for 40 years and counting. So they finally sorted out the remaining issues with Drop traits and everything macro related works on stable?
- nine_k 6y agoI remember what C++ looked like in 1990s. No, the roots, the general unkempt hacked-together style had started by then already :( it's the efforts of last decade or so which made a relatively reasonable language out of C++. It wasn't corrupted by the industry, but it did corrupt the industry to some extent.
- pjmlp 6y agoMe too, a systems language that allowed me to avoid C as much as possible since 1993, already primitive versus the feature list of Turbo Pascal 6.0.
- burntsushi 6y agoRight, just like Rust is a system language that allows me to avoid C and C++ as much as possible since about 2015. There are very few other languages I could have realistically used for several of my projects.
- pjmlp 6y agoSadly I cannot say the same about Rust in what concerns my work domains, as explained at "Have you stopped using Rust? And if yes, why?" discussion thread on Reddit. C++ helped me avoid C, because I could drop down to the C subset when obliged to do so, and still take advantage of C++'s improved type safety, just validating at the end that a C compiler would also be happy with the code, and thanks to its Bell Labs heritage it has always been a first class language across all major UNIX/POSIX platforms.
- burntsushi 6y ago> Sadly I cannot say the same about Rust I know. It's hard to miss. :P My point was to reflect your claim of the suitability of C++. Rust is still young. Much younger in some domains than others. GUI is obviously one of them, and I suspect it will be quite a while before it ever catches up, if at all. If that were my requirement to use Rust, then I'd forget about it and check back in five years. I'm not sure where you are on the innovation curve[1], but I'd say Rust and GUI are all the way to the left right now. (I don't think Rust itself is, but GUI in Rust is.) There are bindings to existing toolkits, but as you say, they're hard to use. So I think some innovation is required and people are working on it. My guess is that you're somewhere in the "late majority" group on that curve. Partially because you seem to require support by the platform itself (not just platform support by the language) and also due to requiring a mature solution to a deeply complex problem (GUI). Those things tend to take a really long time to happen, if at all, unless they are built and created by the platform itself. Your desire for binary libraries isn't as out of reach though I think. It's just a hard problem to solve and there just honestly isn't a ton of motivation to do it as far as I can tell. It might require a well funded player to help move that along. (Not just in the work required to do it, but in the resources required to provide it I think.) [1] - https://www.ou.edu/deptcomm/dodjcc/groups/99A2/theories.htm https://www.ou.edu/deptcomm/dodjcc/groups/99A2/theories.htm
- cube2222 6y agoCould you please expand how destructors in C++ are a dumpster fire? (just curious)
- iso8859-1 6y agoRead this article and tell me it all makes sense to you: https://eli.thegreenplace.net/2015/c-deleting-destructors-and-virtual-operator-delete/ https://eli.thegreenplace.net/2015/c-deleting-destructors-an...
- jcelerier 6y agoHow else would you implement class-level customisation of dynamic allocation / deallocation ?
- Thorrez 6y agoCustom deletion operators are a much much more advanced topic than destructors. Destructors are a basic essential topic all c++ programmers need to know. The vast majority of c++ programmers don't need to know that custom deletion operators even exist.
- qalmakka 6y agoOverloaded delete operators are a relic of a past where malloc() was crummy and inefficient, and almost every object was allocated using new. Quoting Stroustrup: Introducing operator new thus made the use of free store more convenient and less error−prone. This increased its use even further so that the C free store allocation routine malloc() used to implement new became the most common performance bottleneck in real systems. This was no real surprise either; the only problem was what to do about it. Having real programs spend 50% or more of their time in malloc() wasn’t acceptable.I found per− class allocators and deallocators very effective. The fundamental idea is that free store memory usage is dominated by the allocation and deallocation of lots of small objects from very few classes. Take over the allocation of those objects in a separate allocator and you can save both time and space for those objects and also reduce the amount of fragmentation of the general free store. I think almost no one needs custom new and delete today, not only because they are very clunky and obscure, but especially due to the fact that modern C++ features such as move semantics, allocators, std::optional<> and NRVO make them almost redundant and unnecessary.
- tomjakubowski 6y agoExtensive pattern matching syntax and built in sum types are the only reasons I need to almost always choose Rust over C++. The rest is all bonus!
- pjmlp 6y agoThen have a look at what C++23 might bring, http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1371r2.pdf http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p137...
- lights0123 6y agoFinally. > 7.7 Matchers and Extractors: Other Languages Hmm... that "Other Language" looks quite familiar. And still no sum types.
- pjmlp 6y agoDepends on how you look at it, https://www.ida.liu.se/~TDDD38/lecture/slides/sum_types.pdf https://www.ida.liu.se/~TDDD38/lecture/slides/sum_types.pdf
- dimitrios1 6y agoThis just further proves the dumpster fire point made by others here. C++ is a kitchen sink language. It just has gradually become every and any paradigm. It no longer has any true identity, and I can't imagine that any new dev coming into the language has much of a shot of being successful. I do wonder how they are able to pull it off. It is truly remarkable in some way that they are able to have so many language features without it being detrimental to the language.
- pjmlp 6y agoSame applies to any other programming language of the same age. Or do you think that Fortran 2018, C17, C# 9, Java 15, Python 3.9, COBOL 2014, Ada 2014,... are any different?
- chrismorgan 6y ago> and et cetera. FYI, the “et” means “and”. https://en.wikipedia.org/wiki/Et_cetera https://en.wikipedia.org/wiki/Et_cetera is good reading.
- greggyb 6y agoAnd the 'cetera' means essentially 'the rest'. Though it is common in modern usage to to use 'et cetera' to imply a continued list of items not named. A stricter interpretation would only use 'et cetera' to refer to the rest of a full list that has been previously explicitly enumerated earlier in the text. As an example: The authors of the text were James, Malik, Susan, Srini, and Ying. ... <some more text goes here> ... This was the primary finding supported by Srini, James, etc. Above, the usage of 'etc' is to shorten the sentence, by avoiding a second instance of the full list. A simple translation to English shows that the common usage can leave much up to the interpretation of the reader. As an example: I like sweet foods: cherries, apples, grapes, and the rest. So, do I actually mean fruits? Do I mean all other sweet foods that exist? This sentence leaves a lot of interpretation to the reader, and depends on shared context to have any useful meaning. This usage of 'et cetera' generally means "and more in a sequence made up of items categorically in line with what I've named, which I assume, you, the reader, can infer." This reply is not meant to critique modern usage. Language is a fluid thing, and the use delineating implication, rather than eliding a fully enumerated list, is perfectly acceptable in the vernacular. I just wanted to share some additional nuance regarding the phrase.
- chrismorgan 6y agoIn your authors example, etc. is not what is conventionally employed, but rather et al. (https://en.wiktionary.org/wiki/et_al%2E https://en.wiktionary.org/wiki/et_al%2E, https://en.wikipedia.org/wiki/List_of_Latin_phrases_(E)#et_alii https://en.wikipedia.org/wiki/List_of_Latin_phrases_(E)#et_a...). This is an extremely strong convention. Increasingly I’d say I observe et al. being used for (a) lists of people, and (b) finite, known lists; and etc. being used for lists of unknown length. (You may notice there is some unspecified area in that classification. This is deliberate.) This is a definite shift from the original Latin.
- zelly 6y ago> there are async await semantics There are coroutines in C++20 now. It has the async/await syntax except it's extensible to any kind of coroutine semantics, not just Futures like in Rust. > locking is way better RAII was inspired by C++. For making a mutex own its associated data, that's a simple template class which is a well-known pattern. You're also not forced to use it when it is not a good fit. > The syntax is cleaner You got me, I have been trolled.
- ironmagma 6y ago> It has the async/await syntax except it's extensible to any kind of coroutine semantics Interesting, I didn't know about this. > You're also not forced to use it when it is not a good fit. But like all language criticisms that contain this sentence, it's better when the language makes it somewhat tedious to go outside of the norm, where the norm is defined as the 99% use case. C++ is the opposite; you have to go out of your way to use the generic, safe features like smart pointers or create copy constructors. Rust's syntax takes cues from ML which means that things like switch statements (matches), if's, and even return are also expressions, which makes it nicer to refactor and allows you more choices when structuring your code.