Hacker News new | past | comments | ask | show | jobs | submit login

Because people like you, who suggest that there are alternatives, fail to mention them.

Which other languages close to C, without a run-time, and without a garbage collector, give you proven memory and thread safety?

Not C, not C++, not D, not Nim, not Go, not Swift, not Ada, ...




Without a garbage collector? A garbage collector is a gift, not a restriction. A garbage collector is a fallback for when other mechanisms fail, and a helpful tool for prototyping.

A garbage collector is a function that frees memory through tracing. It doesn't stop you from freeing memory another way. D's GC isn't a Java or JavaScript or Go GC, it doesn't have overhead-inducing write barriers.


If my software could afford a garbage collector, I would write it in Python or a JVM language, not in D.

My software that can afford a garbage collector typically doesn't need a high level of safety either. If it fails, I restarted, and if it gets compromised, so be it.

> D's GC isn't a Java or JavaScript or Go GC, it doesn't have overhead-inducing write barriers.

I wouldn't use D for any application. If my application requires high-performance and/or correctness, I'd use Rust or C++.

D buys you memory safety with a garbage collector, but it doesn't buy you thread safety, so from the safety POV, it is not enough. It also isn't free. If you disable it, you can't use most libraries. And if you enable it, you pay for a big runtime. Also the performance that D does buy you comes with the cost of being a language at the same level of complexity of C++.

Rust gets you much better safety than D, no run-time by default and all libraries support this, better meta-programming than D, etc. all at a lower complexity cost than D.

Sure D is better at prototyping than Rust, but Python and many other languages are much better at prototyping than D. If I need to write a prototype, I'll use python. And if I need to make my prototype fast, I'll just write that part in Rust and call it from python. Gives me the best of both worlds.

Picking D would mean picking something that's not bad but not great at anything either.


C and Ada variations have done so for many years, way before Rust was a thing.

Ada and D are also in the process of adding memory safety to the base language too.

The actual question is why nobody cared that much until now to put it in mainstream languages. The answer is, as you know, browsers.


> C and Ada variations have done so for many years, way before Rust was a thing.

Not giving any concrete examples is just proving my point.

Which C variations are both thread and memory safe? Which Ada variations are both thread and memory safe ?

AFAIK, such variations do not exists, and people claiming that they do on the internet and then failing to provide a simple link when requested multiple times by others to do so just seems to confirm that.


What C variations have given safe system programming for many years? I'm not sure I know of any.


MISRA C is a subset of C / set of rules that is used in the auto industry, and supported by many tools.


> Rule 20.4 (required): Dynamic heap memory allocation shall not be used

So anyway, what subset of C allows the use of dynamic heap memory allocation and enforces safety?


> MISRA C is a subset of C / set of rules that is used in the auto industry, and supported by many tools.

That's true, and I know you are not claiming this, but MISRA C is neither memory nor thread safe, which is what we are talking about here.

Writing MISRA C code with data-races is trivial, and no "linter" for it finds those.




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

Search: