TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

The search for easier safe systems programming

194 pointsby praseodymabout 1 year ago

19 comments

estebarbabout 1 year ago
I don&#x27;t get why people are scared of GC. After working in embedded software, using mostly C, it was evident from profiling that C programs spend a lot of time allocating and releasing memory. And those programs usually release memory in place, unlike GC languages where the release is deferred, done in parallel, and with time-boxed pauses. Most &quot;systems&quot; programs use worse memory management strategies than what a modern GC actually offers.<p>Sure, some devices require using static memory allocations or are quite restricted. But a lot of other &quot;system programming&quot; targets far more capable machines.
评论 #40298258 未加载
评论 #40297568 未加载
评论 #40298732 未加载
评论 #40300768 未加载
pjmlpabout 1 year ago
This is a common trend among D, Chapel, Vale, Hylo, ParaSail, Haskell, OCaml, Swift, Ada, and now June.<p>While Rust made Cyclone&#x27;s type system more manageable for mainstream computing, everyone else is trying to combine the benefits of linear&#x2F;affine type systems, with the productivity of automated resource management.<p>Naturally it would be interesting to see if some of those attempts can equally ping back into Rust&#x27;s ongoing designs.
评论 #40296511 未加载
评论 #40296195 未加载
评论 #40296116 未加载
评论 #40296137 未加载
评论 #40296082 未加载
nercuryabout 1 year ago
struct Node&lt;&#x27;a, &#x27;b, &#x27;c&gt; { data1: &amp;&#x27;a Data data2: &amp;&#x27;b Data data3: &amp;&#x27;c Data }<p>Wow. It&#x27;s like teaching C++ and starting from SFINAE. Or C# and starting from type parameter constraints.<p>Please think of a real-world examples when teaching stuff. I am very eager to see the program a beginner would need to write that requires: 1) references in a struct; 2) 3 separate lifetime parameters for the same struct.
noelwelshabout 1 year ago
Effect systems strike again! They&#x27;ve come up a few times recently on HN, and region-based memory management is another problem they can solve. This paper describes a type system that region-based memory management falls out of as a special case: <a href="https:&#x2F;&#x2F;dl.acm.org&#x2F;doi&#x2F;10.1145&#x2F;3618003" rel="nofollow">https:&#x2F;&#x2F;dl.acm.org&#x2F;doi&#x2F;10.1145&#x2F;3618003</a>
评论 #40299383 未加载
pronabout 1 year ago
&gt; Rust&#x27;s focus on embedded and system&#x27;s development is a core strength. June, on the other hand, has a lean towards application development with a system&#x27;s approach. This lets both co-exist and offer safe systems programming to a larger audience.<p>I think this is a mistake, both on June&#x27;s part and on Rust&#x27;s. All low-level languages (by which I mean languages that offer control over all&#x2F;most memory allocation) inherently suffer from low abstraction, i.e. there are fewer implementations of a particular interface or, conversely, more changes to the implementation require changes to the interface itself or to its client. This is why even though writing a program in many low-level languages can be not much more expensive than writing the program in a high-level language (one where memory management is entirely or largely automatic), costs accrue in maintenance.<p>This feature of low-level programming isn&#x27;t inherently good or bad -- it just is, and it&#x27;s a tradeoff that is implicitly taken when choosing such a language. It seems that both June and Rust try to hide it, each in their own way, Rust by adopting C++&#x27;s &quot;zero-cost abstraction approach&quot;, which is low abstraction masquerading as high abstraction when it appears as code on the screen, and June by yielding some amount of control. But because the tradeoff of low-level programming is real and inescapable, ultimately (after some years of seeing the maintenance costs) users learn to pick the right tradeoff for their domain.<p>As such, languages should focus on domains that are most appropriate for the tradeoffs they force, while trying to aim for others usually backfires (as we&#x27;ve seen happen with C++). Given that ultimately virtually all users of a low level language will be those using it in a domain where the low-level tradeoff is appropriate -- i.e. programs in resource-constrained environments or programs requiring full and flexible control over every resource like OS kernels -- trying to hide the tradeoff in the (IMO) unattainable hope of growing the market beyond the appropriate domain, will result in disappointment due to a bad product-market fit.<p>Sure, it&#x27;s possible that C++&#x27;s vision of broadening the scope of low-level programming was right and it&#x27;s only the execution that was wrong, but I wouldn&#x27;t bet on it on both theoretical (low abstraction and its impact on maintenance) and empirical (for decades, no low-level languages have shown signs of taking a significant market share from high-level languages in the applications space) grounds. Trying to erase tradeoffs that appear fundamental -- to have your cake and eat it -- has consistently proven elusive.
评论 #40297012 未加载
评论 #40296807 未加载
taosxabout 1 year ago
I don&#x27;t know why but Rust&#x27;s syntax just nails it for me. The more I use it the more I appreciate it. I see many projects that diverge from Rust&#x27;s syntax while being inspired by it. Why ?
keyleabout 1 year ago
Related, I really like the look of hare[1], sadly they don&#x27;t seem to be interested in a cross-platform compiler. As I understand it, some of the design decisions have basically led it to be mostly a linux&#x2F;bsd language.<p>I personally love C. I think designing a language top-down is a poor approach overall, I prefer the bottom-up approach of the C-inspired for system languages, that aim to fix C rather than <i>this is how the world should beeee!</i><p>[1] <a href="https:&#x2F;&#x2F;harelang.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;harelang.org&#x2F;</a>
samuellabout 1 year ago
The discussion of grouped lifetimes reminds me of the principles of Flow-based programming (without the visual part), where one main idea is that only one process owns a data packet (IP) at a time.<p>My own experience coding in this style [1] has been extremely reassuring.<p>You can generally really safely consider only the context of each process at a time, since there aren&#x27;t even any function calls between processes, only data sharing.<p>This meant for example that I could port a PHP application that I had been coding on for years, fighting bugs all over, into a flow-based Go application in two weeks, with a perfectly development time perfectly linear to the number of processes. I just coded each processes in the pipeline one by one, tested them and continued with the next. There were never any surprises as the application grew, as the interactions between the processes are just simple data sharing which can&#x27;t really cause that much trouble.<p>This is of course a radically different way of thinking and designing programs, but it really holds some enormous benefits.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;rdfio&#x2F;rdf2smw&#x2F;blob&#x2F;master&#x2F;main.go#L58-L150">https:&#x2F;&#x2F;github.com&#x2F;rdfio&#x2F;rdf2smw&#x2F;blob&#x2F;master&#x2F;main.go#L58-L15...</a>
评论 #40299633 未加载
pjc50about 1 year ago
This seems to be an &quot;arena&quot; or &quot;pool&quot; allocation approach. Conceptually quite a mature technique, but this adds the benefit of statically checking against pool lifetime?<p>Probably works quite well for systems programming, where things are either &quot;live forever&quot;, &quot;reallocate within some pool&quot; (thread handles, file descriptors, etc), or &quot;transient&quot; (for the lifetime of a system call or similar).
osigurdsonabout 1 year ago
So many comparisons to Go and C# on this thread. While at some level of abstraction, all languages are the same, comparing GCed languages to non-GC languages doesn&#x27;t make sense in my opinion. Rust would have never been made if the creators were fine with Java.
评论 #40302188 未加载
zozbot234about 1 year ago
&gt; Effectively, this would mean that a data structure, like a linked list, would have a pointer pointing to the head which has a lifetime, and then every node in the list you can reach from that head has the same lifetime.<p>Right, isn&#x27;t that what GhostCell and its variants (QCell) are all about? This would be great if it led to a more elegant and principled implementation of that pattern, that could also end up being fully supported in Rust itself.
anonymoushnabout 1 year ago
This lifetimes thing is maybe not even a top 3 mistake Rust makes. I hope successor languages can have a metaprogramming system that is less dreadful than proc macros, the ability for users to write libraries that are generic over user-provided writers, readers, and allocators, and the ability to bubble up errors from functions that call fallible functions from 2 different libraries without writing your own huge struct definition every time.<p>It may also be nice if constructs that don&#x27;t cause memory accesses and only ever do the correct thing or crash on the target cpu (such as integer division or pshufb without an address operand on any intel chip ever) were not unsafe. Placing &quot;Well, LLVM says this arithmetic operation is UB and we won&#x27;t bother to fix it&quot; and &quot;What if one day there&#x27;s an x64 chip that does something other than crash if it encounters instructions from ISA extensions it does not have?&quot; into the same bucket as &quot;playing with raw pointers&quot; is a bit weird.
评论 #40298842 未加载
评论 #40301535 未加载
评论 #40299611 未加载
评论 #40297480 未加载
评论 #40297316 未加载
kkukshtelabout 1 year ago
Seeing Mads Torgersen on the list of collaborators for this made me take this seemingly random blog post 100x more seriously.
netbioserrorabout 1 year ago
For use cases which aren&#x27;t bare-metal embedded:<p>1) Prefer the stack wherever possible.<p>2) RC.<p>3) Unique pointers by default unless explicitly noted otherwise.<p>4) Immutable arguments and returns by default unless explicitly noted otherwise.<p>There&#x27;s a language that does this all already, and it&#x27;s called Nim.
mightyhamabout 1 year ago
I&#x27;m not very well versed in Rust, but isn&#x27;t it possible to implement this sort of checked arena allocation in rust using lifetimes? Something like slotmap (<a href="https:&#x2F;&#x2F;docs.rs&#x2F;slotmap&#x2F;latest&#x2F;slotmap&#x2F;" rel="nofollow">https:&#x2F;&#x2F;docs.rs&#x2F;slotmap&#x2F;latest&#x2F;slotmap&#x2F;</a>) except all of the pointers&#x2F;keys have their lifetime tied to the arena&#x2F;pool&#x2F;map.
bjourneabout 1 year ago
How would the language guarantee no use-after-free scenarios?<p><pre><code> let x = new Foo() if (y == 1) { recycle x } println(x)</code></pre>
评论 #40297626 未加载
aetherspawnabout 1 year ago
Better systems programming is model based design and automatic code generation, period.<p>It is the be-all and end-all that will make those scenes in Star Trek where they alter some core starship system programming in 2 minutes flat without mistakes actually plausible.
unautabout 1 year ago
Amm, is this some kind of reinvention of C and C++ but from high-end backwards?
cornholioabout 1 year ago
Seems like the wrong problem to solve. &quot;Systems programming&quot; is hard, and should be hard, for reasons unrelated to the programming language used. Something like Rust which forces you to constantly reevaluate your design before you even press the compile button, is ideal.<p>What&#x27;s really lacking are safe, easy, strong typed general purpose languages that can leverage AOT compilation for high performance and static analysis etc. A language with the learning curve of Python, near C performance and strong safety guarantees of Rust. There is nothing that suggests to me such a language would not be possible. Swift and C# come closest but they are warped by their respective corporate overlords.
评论 #40297672 未加载
评论 #40296398 未加载
评论 #40296562 未加载
评论 #40296750 未加载
评论 #40296824 未加载
评论 #40296546 未加载
评论 #40296388 未加载
评论 #40296264 未加载
评论 #40297140 未加载
评论 #40296584 未加载
评论 #40296685 未加载
评论 #40296299 未加载
评论 #40296406 未加载
评论 #40297770 未加载
评论 #40296436 未加载
评论 #40298643 未加载
评论 #40297630 未加载