Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This is where C fails against Rust. I have to use static analyzers to find such problems.

But I do use them, and I also use sanitizers against large and thorough test suites, with excessive fuzzing thrown in for good measure. And I mix all of that with crash-happy code littered with gobs of `assert()` calls that document as many of my assumptions as I can find.

Those help me find about all I can find.

But I'm still writing a language that is as safe as Rust that I will auto-translate my code into when it's done.

By the way, I'm not using Rust because I don't like it. That doesn't mean it's not good, but I really hate async/await, along with a few other Rust design decisions.

I'm kind of picky as a programmer.

Yes, C fails against Rust here, but that's why I put in the extra effort to bring it up to the same level regardless.



> But I'm still writing a language that is as safe as Rust that I will auto-translate my code into when it's done.

Just curious, how do you intend to make it memory safe? By using a garbage collector, automatic reference counting, a borrow checker, or something else?


By structuring the language around RAII and structured concurrency. More details in my great-great-great-great-grandparent post. [1]

tl;dr: If threads never exit before their descendants, and you only borrow an item in callees and in descendant threads, that would negate the need for a borrow a checker.

As for sharing an item across threads and still not having data races, this will be done by implementing something close to Rust's Send/Sync.

There will be ARC implemented by RAII, just like Rust.

Basically, the language will be built around structured concurrency, including the standard library.

Does that answer your question?

[1]: https://news.ycombinator.com/item?id=32907696


Ah, sorry, my bad, I should have read the whole thread in detail first instead of just skimming it. (:

So do you also intend to completely disallow mutation? Because that's the only way I could see this matching Rust's safety guarantees without actually having a borrow checker.

Say, for example, that you allocate a new string, and you take a reference to it, and then you append to that string within the same scope. This triggers a reallocation which will make that reference invalid. To make that safe you'd either need to have a borrow checker (to be able to detect at compile time that the reference was invalidated), or you'd have to disallow mutation (the act of mutating wouldn't actually mutate that string, but create a new one, leaving the old one alone until it goes out of scope).


Mutation will be disallowed in general, yes. It's a bit more subtle than that, but you get the gist.

In my language, there are strings, which are fixed size and cannot be reallocated, and string builders, which hide the actual string behind another layer of indirection to avoid the problem with mutation.

That sort of pattern would be used as necessary to avoid the problems with mutation in the same thread. And Send/Sync would take care of the rest across threads.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: