Live data from Hacker News

Getting Past C

blog.ntpsec.org

361–370 of 504 posts

Re: Getting Past C

#361
post #348

Earlier quoted context omitted.

> there's nothing stopping the compiler from optimizing the GC out. I don't know of a single language that comes with a GC that does this, do you? > He was comparing against what you'd get if you dropped down to ye olde C or Assembly and wrote the same algorithm there, without redundant work or waste. Right. I agree with this. But basically, we are arguing over an extremely fine semantic, which is "should you even wa…

> I don't know of a single language that comes with a GC that does this, do you? Java, .NET, Go, ML and Lisp compilers. Escape analysis allows to do that, even if just in certain special cases. Plus the more one uses value types and less heap, the GC needs to work less, specially if we take languages like Modula-3 into this mix.

This is more than escape analysis, this is removing the GC and associated runtime bits entirely.

Escape analysis may not use the GC for those variables, but it is still a pervasive runtime cost in both senses unless it's totally gone.

Re: Getting Past C

#362

Earlier quoted context omitted.

His point is that you're not forced to do that. And anyhow, that doesn't solve the issue since you can bungle the creation of the slice with the wrong offset or length.

I wasn't refuting their point. I was just pointing this out. However, you can't bungle the creation of a slice in rust without using explicitly marked unsafe code.

Not bungle in the sense of overflowing the underlying buffer, but overflowing the logical buffer that is contained within it, i.e. getting the wrong slice.

Re: Getting Past C

#363

Earlier quoted context omitted.

C union declarations should correspond pretty closely to rust enum declarations. It's a surprisingly important feature. Every large codebase I've worked on has clunky workarounds for storing heterogeneous types in collections. Haven't seen a silver bullet; dynamic languages are great at this until you have to scale (either in lines of code, number of types or dataset size) and then they become unmanageable. Static la…

Close, but not quite: unless the type is NonZero, you need space for the tag. c-style unions are in nightly behind a flag; they're not stable yet.

[deleted]

Re: Getting Past C

#364

Earlier quoted context omitted.

Obviously, one can program C to do anything, and write all the provably safe abstractions wished. But, that's not really the point. The point is that doing such is not the default. It requires engagement and knowledge of the programmer, especially on distributed projects with loose communication, such as many open source projects. And it only takes one programmer mistake to bring the whole house of cards down. Why al…

Why allow programmers to make mistakes? For a philosophical counterpoint: Why allow anyone to do anything that might possibly be incorrect, harmful, or otherwise perceived by some to be negative? I've looked at a lot of the talk surrounding "safe/secure languages", "safe/secure programming", etc., and yet every time I've heard people preach about the benefits, I feel like I just vehemently disagree. At a very deep an…

People rely heavily on software in many aspects of their lives. They entrust it with their personal information, their money, and in many cases their physical safety. Engineers building software and companies selling it are ethically obliged to make a good faith effort to prevent defects that might betray their users' trust and cause harm. Languages designed to enhance the safety and security of software written in them are one tool that can be used in this effort.

Are engineering standards for public buildings evil because they stifle architects' freedom to design whatever crazy structures tickle their fancy? Should power tools not include safety features like blade guards because their users' freedom to accidentally kill or maim themselves must be held sacrosanct? Probably to both questions, the reasonable answer is "no".

If you're building something for yourself, and offer it to others only with clear warnings, then go nuts and make all the mistakes you want. Nobody's saying you can't do that; that sounds rather dystopian, a society where pointer arithmetic is illegal! But you can't treat a project people are meant to trust and rely on as your personal art project.

Re: Getting Past C

#365

Earlier quoted context omitted.

I wasn't refuting their point. I was just pointing this out. However, you can't bungle the creation of a slice in rust without using explicitly marked unsafe code.

Not bungle in the sense of overflowing the underlying buffer, but overflowing the logical buffer that is contained within it, i.e. getting the wrong slice.

Oh, sure. Like I said, I wasn't refuting their point.

Re: Getting Past C

#366
post #354

Rust has some very desirable properties to me. Writing Rust programs from scratch is not as scary as I've heard of from the internet either. The documentation is excellent, the compiler diagnostic messages are very helpful and the notorious borrow checker didn't stand in my way that much. And I love Cargo and Cargo.io. I have some projects where Rust is the saner choice than Go or other GC based languages. That said,…

RLS will hopefully full that gap.

RLS?

Re: Getting Past C

#367
I do not contest on the opinion that Rust is a good language, but it slightly hurts me when people club C and C++ together. One can easily write correct by construction code using modern C++. Use of meta-programs allows you to create typesafe constructs. It provides you with zero cost abstractions to specify ownership of resources and ..... One has to just strive to not use the C baggage that comes with it.

Re: Getting Past C

#370
post #348

Earlier quoted context omitted.

> I don't know of a single language that comes with a GC that does this, do you? Java, .NET, Go, ML and Lisp compilers. Escape analysis allows to do that, even if just in certain special cases. Plus the more one uses value types and less heap, the GC needs to work less, specially if we take languages like Modula-3 into this mix.

This is more than escape analysis, this is removing the GC and associated runtime bits entirely. Escape analysis may not use the GC for those variables, but it is still a pervasive runtime cost in both senses unless it's totally gone.

Yes, but making it run less also helps reducing the cost.
Post reply on HN