News for hackers. Stuff that matters.
Re:Translations of Russ Cox's Thompson NFA C Program to Rust by yakubin on Friday November 03, 2023 @07:23AM (#38127115)
You would need to do the same in C++, since the underlying dynamic array is being resized throughout the algorithm, i.e. pointers to its elements are being invalidated. Except C++ won’t warn you about it. You’ll just corrupt memory.

And in garbage collected languages you’d do the same to avoid the cost of GC.

Re:Translations of Russ Cox's Thompson NFA C Program to Rust by vidarh on Friday November 03, 2023 @08:00AM (#38127421)
In C++ you can trivially opt out of using a dynamic array.

There are plenty of reasons not to use C++, including the lack of memory safety, but if you've already decided to ditch that, C++ does let you pick and choose which parts you want to use.

Re:Translations of Russ Cox's Thompson NFA C Program to Rust by spoiler on Friday November 03, 2023 @11:43AM (#38130489)
> does let you pick and choose which parts you want to use

Isn't that the case for most programming languages (ie, you can use the implementation you want/need), though?

Re:Translations of Russ Cox's Thompson NFA C Program to Rust by vidarh on Friday November 03, 2023 @12:38PM (#38131205)
Not to the extent of C++. E.g. you can't opt out of dynamic dispatch overhead in Ruby, because everything is method passing, but "virtual" in C++ is a choice.

The commitment to ensure that features do not add cost(memory, runtime) if you don't use them is something fairly uncommon in other languages, and many languages have features you can't meaningfully avoid.

Re:Translations of Russ Cox's Thompson NFA C Program to Rust by ernst_klim on Friday November 03, 2023 @08:55AM (#38127990)
You don't have to use an array based on realloc. You can use a vector based on linked list of memory pages, or linked list if you need deletion (or gap buffer or any other data structure depends on your needs).
Re:Translations of Russ Cox's Thompson NFA C Program to Rust by yakubin on Friday November 03, 2023 @10:39AM (#38129501)
And at that point you’re slower.