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.

Ask HN: Memory-safe low level languages?

61 pointsby hyperbrainer21 days ago
I am looking for memory-safe languages that can be used for systems&#x2F;graphics programming. I love Rust, but it often feels like too massive a language with too much stuff going on. Is there a language like C, which is simpler (obviously without all the UB and other problems)?<p>This is an especially hard ask, given how useful the FP-like features of Rust are, and I find it almost impossible to live without them. Basically, I am looking for a middle ground between C&#x2F;Zig and Rust.<p>One such language I have found is Austral[0]. What other such languages are there?<p>[0] https:&#x2F;&#x2F;austral-lang.org&#x2F;

34 comments

khaledh20 days ago
Check out Nim. I&#x27;m using it to build an x86-64 kernel¹ (Fusion OS), and it satisfies a lot of the low-level system programming requirements with an elegant and expressive syntax. For memory management you can choose between ARC&#x2F;ORC and&#x2F;or manual. It has two downsides though: small community, and the BDFL can sometimes be rough to interact with.<p>¹<a href="https:&#x2F;&#x2F;0xc0ffee.netlify.app&#x2F;osdev" rel="nofollow">https:&#x2F;&#x2F;0xc0ffee.netlify.app&#x2F;osdev</a><p>I, too, have been looking for a unicorn systems programming language, but it doesn&#x27;t exit yet. Here&#x27;s what I looked at so far (only languages that don&#x27;t rely on a GC):<p>- C: lots of UB, less safe (memory- and type-wise)<p>- C++: too complex, not a big fan of OO<p>- Rust: too complex, gets in the way when writing mostly unsafe kernel code<p>- Zig: Good, but syntax is too noisy; lacks interfaces&#x2F;dynamic dispatch<p>- Swift: Doesn&#x27;t have a good bare metal story<p>- D: Seems interesting, I may be looking at it (although need to use betterC mode, i.e. not all language features)<p>- Odin: Game programming focused, small but growing community<p>- Ada: Strong candidate, but it has too much ceremony<p>- Pony: I like the capabilities model, but tiny community<p>- Hare: Also tiny community, lacks polymorphism<p>- Hylo (Val): Experimental (mutable value semantics), too immature<p>- Vale: Experimental (regional memory management), seems stalled<p>- V: Good candidate, but mixed reviews on its claims vs. reality<p>- Austral: Experimental (linear types), tiny community, not much progress<p>- Jakt: Built for Serenity OS, not sure if it&#x27;s getting enough attention<p>- Jai: Focused on game programming, good reviews, but currently closed source (beta)<p>- Mojo: (Python-like) Seems very interesting and I&#x27;d give it a try, but too focused on GPU&#x2F;parallel programming; also too early for adoption
评论 #43867442 未加载
codr721 days ago
There have several attempts at cleaning up C without giving up too much of its simplicity; from what I can see, Zig is the only one even close to reaching critical mass.<p>A programming language is always going to make some kind of compromise; better at some things, worse at others.<p>Simplicity&#x2F;power and safety pull the design in different directions.
评论 #43828895 未加载
评论 #43819980 未加载
评论 #43811662 未加载
tiffanyh21 days ago
SPARK (Ada) is about as memory-safe as it gets.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;AdaCore&#x2F;spark2014">https:&#x2F;&#x2F;github.com&#x2F;AdaCore&#x2F;spark2014</a>
评论 #43811998 未加载
shakna21 days ago
V [0] aims for something along those lines, but I&#x27;ve had a few issues with the safety aspects of the language. Breaking through the checker isn&#x27;t that difficult.<p>I absolutely adore Ada [1], but the Pascal-syntax isn&#x27;t for everyone.<p>I haven&#x27;t used it yet, but have been hearing rumblings about Odin [2] a fair bit in these kinds of discussions. I tend to avoid too many symbol-heavy langs, but it&#x27;s probably still less than Rust (I use a screenreader half the time).<p>[0] <a href="https:&#x2F;&#x2F;vlang.io&#x2F;" rel="nofollow">https:&#x2F;&#x2F;vlang.io&#x2F;</a><p>[1] <a href="https:&#x2F;&#x2F;ada-lang.io&#x2F;" rel="nofollow">https:&#x2F;&#x2F;ada-lang.io&#x2F;</a><p>[2] <a href="https:&#x2F;&#x2F;odin-lang.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;odin-lang.org&#x2F;</a>
评论 #43815148 未加载
评论 #43811844 未加载
评论 #43811920 未加载
评论 #43821856 未加载
评论 #43811802 未加载
andrewflnr21 days ago
F-star, which was used to build a verified TLS implementation. <a href="https:&#x2F;&#x2F;fstar-lang.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;fstar-lang.org&#x2F;</a> Though I guess that&#x27;s actually on the far side of Rust relative to what you&#x27;re looking for.
评论 #43811949 未加载
thih921 days ago
(link from the description, clickable)<p><a href="https:&#x2F;&#x2F;austral-lang.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;austral-lang.org&#x2F;</a><p>&gt; Austral is a new systems programming language. It uses linear types to provide memory safety and capability-secure code, and is designed to be simple enough to be understood by a single person, with a focus on readability, maintainbility, and modularity.
评论 #43816550 未加载
efficax21 days ago
<a href="https:&#x2F;&#x2F;dlang.org&#x2F;articles&#x2F;safed.html" rel="nofollow">https:&#x2F;&#x2F;dlang.org&#x2F;articles&#x2F;safed.html</a> check out the safed subset of the D language
评论 #43812045 未加载
评论 #43811985 未加载
sn920 days ago
You might try OCaml [0] or SML [1] if you want speed, memory safety, and an expressive type system.<p>[0] <a href="https:&#x2F;&#x2F;ocaml.github.io&#x2F;ocamlunix&#x2F;index.html" rel="nofollow">https:&#x2F;&#x2F;ocaml.github.io&#x2F;ocamlunix&#x2F;index.html</a><p>[1] <a href="https:&#x2F;&#x2F;matt.might.net&#x2F;articles&#x2F;best-programming-languages&#x2F;#ml" rel="nofollow">https:&#x2F;&#x2F;matt.might.net&#x2F;articles&#x2F;best-programming-languages&#x2F;#...</a>
modeless20 days ago
C can be memory safe now! <a href="https:&#x2F;&#x2F;github.com&#x2F;pizlonator&#x2F;llvm-project-deluge">https:&#x2F;&#x2F;github.com&#x2F;pizlonator&#x2F;llvm-project-deluge</a><p>Yes, this is a real project that really works. It can compile real and widely used software written in C including SQLite, OpenSSL, and CPython, giving them true memory safety without escape hatches.
评论 #43824989 未加载
jedimastert20 days ago
Side question and possibly off topic, but is there a formal definition to the term &quot;memory safe&quot;? It seems to mean different things to different people and I&#x27;m unsure if I&#x27;m just out of the loop and there is an actual definition.
评论 #43816382 未加载
fpoling20 days ago
Vale is interesting, <a href="https:&#x2F;&#x2F;vale.dev&#x2F;" rel="nofollow">https:&#x2F;&#x2F;vale.dev&#x2F;</a><p>For memory safety compared with Rust it does not use a borrow checker for the price of more checks and extra memory usage at runtime while avoiding GC or even reference counting.<p>I think this is very interesting trade off. Plus there are plans to implement few interesting ideas that even Rust type system cannot implement while keeping the language simple.
gwbas1c12 days ago
&gt; I am looking for memory-safe languages that can be used for systems&#x2F;graphics programming.<p>C# was kinda-sorta for this; as long as you&#x27;re targeting an environment where GC is acceptable. (IE, as long as you&#x27;re running in user-mode, as opposed to writing a kernel or a driver.)<p>It does allow for C-style pointers, which might be useful if you need to call a lower-level system API. (Unfortunately, you can&#x27;t just suck in a header file.)<p>One thing you might miss is how errors, in Rust, are 0-cost. C# encourages exceptions over error codes, and throwing an exception has a much higher overhead than panic, because it captures a stack trace and allocates an object. (I must admit that I like Rust&#x27;s error handling over C# because it differentiates cleanly &quot;anticipated&quot; errors versus <i>exceptional</i> situations.)
oconnor66320 days ago
Can you give some examples of Rust features that you don&#x27;t need? Unfortunately a lot of common answers (the borrow checker, traits, move semantics) are things that are fundamental to the safety story. I guess one thing you could definitely subtract is async (Rust shipped without it after all).
评论 #43823618 未加载
pjmlp21 days ago
GCC nowadays offers Modula-2, Ada and D in the box.<p>Then you have FreePascal, as FOSS ObjectPascal dialect.<p>On Apple&#x27;s turf, Swift naturally, given its bindings for all Metal anything frameworks.
评论 #43816235 未加载
carterschonwald21 days ago
So one kinda cool direction is what they do for the sel4 prject. They have a sequence of high to low level impls and prove correctness wrt spec of the high level etc and prove that each lowering is an implementation of a refinement of the higher level implementation
mparis20 days ago
I also love rust and we use it heavily at our startup, but I agree with you and wish there were a mainstream alternative that kept much of the type system, pervasive expressions, and pattern matching while being smaller. I’d accept “very fast” even if it’s not as fast as rust.<p>One project I’ve seen that I don’t think is particularly active but that I really like the ideas behind is borgo. It compiles to go (thus GC) but is decidedly more rustacean.<p>Check it out. I hope someone makes something like this wide spread.<p><a href="https:&#x2F;&#x2F;borgo-lang.github.io&#x2F;" rel="nofollow">https:&#x2F;&#x2F;borgo-lang.github.io&#x2F;</a><p>PS. I have no affiliation with borgo, just an online fan.
sargstuff20 days ago
Very old school:<p>ASP[0] was old way to do character animations for unix finger command .plan.<p>Recall HN post using python to do the same (handled animation independent of serial terminal speed).<p>Related HN post &quot;John Carmack&#x27;s .plan file&quot; [3]<p>hascii mation [1]; Use standard graphics techniques and run through [2] or .plan with unscii[4]<p>&quot;sheltered code&quot; via mindcraft : <a href="https:&#x2F;&#x2F;youtu.be&#x2F;7sNge0Ywz-M" rel="nofollow">https:&#x2F;&#x2F;youtu.be&#x2F;7sNge0Ywz-M</a><p>------<p>ascii animation tutorial : <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=o5v-NS9o4yc" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=o5v-NS9o4yc</a><p>[0] :Ah, ASP link has been merged with &#x2F;dev&#x2F;null. :(<p><pre><code> ASP and related things for animated .plan : https:&#x2F;&#x2F;superuser.com&#x2F;questions&#x2F;253308&#x2F;scrolling-plan-file </code></pre> [1] : <a href="https:&#x2F;&#x2F;github.com&#x2F;octobanana&#x2F;asciimation">https:&#x2F;&#x2F;github.com&#x2F;octobanana&#x2F;asciimation</a><p>[2] : <a href="https:&#x2F;&#x2F;www.geeksforgeeks.org&#x2F;converting-image-ascii-image-python&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.geeksforgeeks.org&#x2F;converting-image-ascii-image-p...</a><p>[3] : &quot;John Carmack&#x27;s .plan file&quot; : <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=3367230\">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=3367230\</a><p>[4] : unscii : <a href="http:&#x2F;&#x2F;viznut.fi&#x2F;unscii&#x2F;" rel="nofollow">http:&#x2F;&#x2F;viznut.fi&#x2F;unscii&#x2F;</a>
noam_k21 days ago
You may want to look at Lua[0]. It&#x27;s often used as an embedded scripting language in larger projects (and games), has good performance, is memory safe, and is extensible in the same manner as Python (write your performance bottleneck in C&#x2F;C++).<p>I don&#x27;t remember specifics, but there are some odd footguns to look out for.<p>[0] <a href="https:&#x2F;&#x2F;www.lua.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.lua.org&#x2F;</a>
tiu21 days ago
See <a href="https:&#x2F;&#x2F;wiki.alopex.li&#x2F;SurveyOfSystemLanguages2024" rel="nofollow">https:&#x2F;&#x2F;wiki.alopex.li&#x2F;SurveyOfSystemLanguages2024</a><p>and the related discussion <a href="https:&#x2F;&#x2F;lobste.rs&#x2F;s&#x2F;c3dbkh" rel="nofollow">https:&#x2F;&#x2F;lobste.rs&#x2F;s&#x2F;c3dbkh</a><p>Serious total MSLs that have a defined memory model to allow &quot;low level&quot; operations seem to be scarce if not any. Hence I do not think there is any single one that comes between C&#x2F;Zig and Rust.<p>I would have said <a href="https:&#x2F;&#x2F;www.hylo-lang.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.hylo-lang.org&#x2F;</a> but, personal opinion, seems like there is too much going on as well. See also <a href="https:&#x2F;&#x2F;vale.dev&#x2F;" rel="nofollow">https:&#x2F;&#x2F;vale.dev&#x2F;</a><p>P.S Mind mentioning what FP-like features are in Rust? (Genuinely have not looked into Rust that much but I am interested).
pron21 days ago
If you love Rust -- use Rust. Trying to find a language that&#x27;s just right for you risks it being just that: right for you and few others.<p>Just remember that even if writing memory-safe programs is your goal, using a memory-safe language is just a means to that goal, and even Rust isn&#x27;t really memory-safe. Many Rust programs try to achieve memory safety while using a non-memory-safe language (be it C or unsafe Rust), and there&#x27;s an entire spectrum of combining language features that offer sound guarantees with careful analysis and testing of unsafe code to achieve a safe program. On that spectrum, Zig is much closer to Rust than to C, even though it offers fewer guarantees than Rust (but more than C).
评论 #43811896 未加载
评论 #43816676 未加载
评论 #43817481 未加载
评论 #43812215 未加载
SloopJon21 days ago
Personally, I don&#x27;t know what you mean about Rust being too massive. One thing I am wary of is using a truly massive language like C++ on a multi-programmer project without consensus on which features to use and how to use them. Maybe you have in mind something like that?<p>If you want the simplicity of C with more safety, maybe tooling like Frama-C, a MISRA C conformance checker, or just aggressive use of static and dynamic analysis tools like ASAN and UBSAN. You can also disable certain optimizations (e.g., strict aliasing) to steer away from some of the major pitfalls of UB.
hardwaregeek21 days ago
If performance is not ultra critical, I&#x27;d use Go. It&#x27;s simple and a small-ish language. Otherwise there&#x27;s not many options. Not to belittle your question, because it&#x27;s a good one, but it&#x27;s a little like asking if there&#x27;s a simpler aircraft. There can be, but there&#x27;s a certain amount of required machinery to keep it in the air. Rust&#x27;s memory safety rules are as simple as we can get it for now. Maybe in a few years it&#x27;ll be different!
SkiFire1321 days ago
Have you considered trying one of the older Rust versions (e.g. 1.0.0 or a bit after that) without all the new shiny features?
markus_zhang20 days ago
What I dream about is a C with less UB, range based loops, array slicing (supporting negative slicing too), safer and easier string functions (because my pet project is a compiler so gotta write a scanner), pattern matching switch, and maybe a few other stuffs.<p>Oh maybe less preprocessing black magics :&#x2F;
评论 #43819724 未加载
musicale19 days ago
C is improving a bit with things like -fbounds-safety<p><a href="https:&#x2F;&#x2F;clang.llvm.org&#x2F;docs&#x2F;BoundsSafety.html" rel="nofollow">https:&#x2F;&#x2F;clang.llvm.org&#x2F;docs&#x2F;BoundsSafety.html</a>
lproven20 days ago
Pascal (e.g. FreePascal).<p>Modula-2 (e.g. GCC).<p>Oberon (e.g. Oberon, Oberon 2, Oberon-07, Oberon+.)
gus_massa21 days ago
Have you tried &quot;modern&quot; Fortran? I&#x27;ve seen horrible &quot;old&quot; Fortran programs, but once you add modules it get&#x27;s much better.
评论 #43813913 未加载
cyrc20 days ago
<a href="https:&#x2F;&#x2F;cyclone.thelanguage.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;cyclone.thelanguage.org&#x2F;</a><p>How about Cyclone?
评论 #43819303 未加载
qwke21 days ago
<a href="https:&#x2F;&#x2F;gleam.run&#x2F;" rel="nofollow">https:&#x2F;&#x2F;gleam.run&#x2F;</a>
foota21 days ago
It&#x27;s not really recommended for us, but maybe Carbon?
MelodyUwU21 days ago
i was actually looking for an answer to a similiar question, so this thread is very much useful! as of now, i looked somewhat at odin
farseer19 days ago
Use a subset of C++, STL maybe Boost and avoid raw pointers. You will avoid most memory related problems.
p_ing21 days ago
C# has been used as the primary language in various hobby&#x2F;research kernels.
评论 #43811745 未加载
frizlab21 days ago
Swift can now be used on embedded platforms