Earlier quoted context omitted.
That's another aspect of it. Please see this answer of mine: https://news.ycombinator.com/item?id=27642630 In short, memory unsafety makes programmer bugs exploitable, instead of generally just failing.
I understand what you are saying, and I understand that this is a real security issue in modern computing. However I would put the question to you in a different way: Let's say we have two programs, A and B. Program A by its very nature needs to have write access to the system's file permissions in order to fulfill its core purpose. Program B only needs R/W access to a sqlite database installed in a specific director…
Goodbye C++, Hello C
211–220 of 222 posts
Re: Goodbye C++, Hello C
#212Earlier quoted context omitted.
Sure, its just that these kind of strings were historically called Pascal-strings [0] because they were the way Pascal implemented strings. [0] And still are! For example, Python refers to them as such, see the "p" (lowercase p) character code here: https://docs.python.org/3/library/struct.html#format-strings
Not all C++ string libraries use Pascal strings. Some of them use a fat pointer instead, with a mix of counter, pointer to the end, and null terminator for C compatibility.
Re: Goodbye C++, Hello C
#213Earlier quoted context omitted.
> Vulkan is not officially supported on OSX And neither is OpenGL
Deprecated, not unsupported. And, like, Apple ported OpenGL to Apple Silicon macs. I suspect it's going to stick around, it's just never, ever going to get updated.
Re: Goodbye C++, Hello C
#214Earlier quoted context omitted.
Deprecated, not unsupported. And, like, Apple ported OpenGL to Apple Silicon macs. I suspect it's going to stick around, it's just never, ever going to get updated.
You're kidding. The OpenGL implementation/support of Mac is pretty nonexistent/poor.
Re: Goodbye C++, Hello C
#215Earlier quoted context omitted.
Not all C++ string libraries use Pascal strings. Some of them use a fat pointer instead, with a mix of counter, pointer to the end, and null terminator for C compatibility.
That's ingenious, but I don't think I've heard a name for those kind of strings.
Re: Goodbye C++, Hello C
#216Yesterday I finished a complex library in C++20, which I wrote "Rust style" by following the ISO C++ guidelines. I used 0 `new`, no smart pointers, all by-value returns, move semantics and STL containers. It literally took a month to write, but it worked as expected at the second attempt (first failed due to forgetting a `}` in a format string). I did not see a single segmentation fault and it works fine on both Linu…
> And I won't get started with C strings, which are just a historical BadIdea™. What's the better alternative to null-prefixed strings you are referring to, length prefixed?
struct string_type {
char *ptr; // or char[]
size_t size;
}
because the whole idea of scrolling a whole string just to get its length it's an immense waste of CPU time. It has been optimized to death given that C does that for historical reasons¹, but still it's unwieldy and less safe.For instance, C strings make 0-cost string slicing impossibile: for instance, if you wanted to slice a string to get str[2;4] (i.e. a 2 char string from position 2), it would be simply
string slice { .data = str.data + 2, .size = 2 }
with the C++/Java/Rust/whatever approach. With C strings, given that you have to put a '\0' terminator at string end, you're forced to allocate memory and memcpy() the string, or to corrupt the original string.¹: size_t is much bigger than char (2x on 16 bit, 8x on 64 bit machines), so it made sense on a memory constrained machine like the PDP-11 to waste CPU time in order to save memory.
Re: Goodbye C++, Hello C
#217Yesterday I finished a complex library in C++20, which I wrote "Rust style" by following the ISO C++ guidelines. I used 0 `new`, no smart pointers, all by-value returns, move semantics and STL containers. It literally took a month to write, but it worked as expected at the second attempt (first failed due to forgetting a `}` in a format string). I did not see a single segmentation fault and it works fine on both Linu…
How are the compile times? That's a really big point in the article and you don't mention them at all.
The wall of text generated by GCC/Clang/MSVC when template substitutions fail is a much worse issue, IMHO. Thankfully concepts help a lot in cutting off SFINAE earlier, so you don't get flooded with useless errors about the compiler trying to substitute random constructors in places or something.
Re: Goodbye C++, Hello C
#218If you really like the simplicity of C I highly recommend Nim: * Compiles to C, so you stand on the shoulders of giants wrt compilers. * Very low overhead GC that doesn't "stop the world". I was working on a project recently where I had to just write a bunch of stuff to disk, and I tried Node, and then Java, and they were about the same, and I figured - yep, makes sense, it's IO bound. Nim got twice the throughput w/…
Re: Goodbye C++, Hello C
#219Earlier quoted context omitted.
You're missing the point. You can't make such a claim about complexity based off the amount of software there is. Games are by far the more popular software to make. This is why I've narrowed it down for you, hopefully you can understand that. > features in a game are non-comparable to browser features You can't hand-wave this away. I'm certain you need a lot more math knowledge if you want to implement something lik…
The fact is that a single person with a decent amount of knowledge can write a game engine that is more or less complete, while not even FANG companies can write a web browser from scratch should definitely be proof that the latter is more complex. Some physics and linear algebra, while I’m not saying is easy, but it is not a complex layouting and CSS engine, with a state of the art language runtime, with all the pos…
Again you're trying to backtrace the results to the complexity of the task and the linkage simply does not make sense.
> Some physics and linear algebra, while I’m not saying is easy, but it is not a complex layouting and CSS engine, with a state of the art language runtime, with all the possible requests, sandboxing, etc. — of course you don’t necessarily have to write an optimized browser, but still, just implementing a usable subset of the web is ridiculously hard.
Well it seems to be easier because you can literally look it up through the internet and implement it as a set of rules. The hard part would be the combinatorial number of cases. If you don't have the math requirements to make a game with a 3d world from scratch it will not feel good.
Re: Goodbye C++, Hello C
#220Earlier quoted context omitted.
With the possible exception of Rust, safety always had performance implications. Forcing people to write their program in C# or Swift or Java causes many programs to be slower than they really need to be, forcing us to either wait on them, or buy a faster palmtop. (Now most devs don't care about performance, so they don't see that as a problem. As a user however I can tell you, I hate when my phone lags for seemingly…
> With the possible exception of Rust, safety always had performance implications. This is common piece of received wisdom, but I don't think it's held up well over the last decade: both Java and C# have extremely well-optimized runtimes that perform admirably after an initial startup period, and (I believe) Swift compiles to native code with many of the same optimization advantages that Rust has (e.g., simpler alias…
Sure, if what you're competing against is some kind of pointer fest, forget about locks, just jumping around the memory will trash your cache, and it won't matter how optimised your local processing is. But if you follow some data oriented principles and take good care of your memory access patterns, I have a hard time imagining Java or C# beating C++ or Rust.
Now there's this peculiar version/subset of C# that Mike Acton was promoting for Unity… though I'm not sure that counts.