News for hackers. Stuff that matters.
Re:Some Thoughts on Zig by socialdemocrat on Thursday July 21, 2022 @10:16PM (#32187698)
Nice balanced writeup! However, I am not convinced one can make something solving all the things Rust solves which is substantially simpler as language.

Whether we look at Zig, Go or Julia they stay relatively simple because they simply avoid solving certain problems. I think that is a fair tradeoff. I think good language design is really about figuring out what problems can we dump on the user which they will be able to handle relatively well.

A reason why there are so many languages I think is because different people have different preferences in terms of what problems the want to avoid dealing with and what problems they are fine dealing with.

Personally I think that if you "solve" a problem by making the language so complex that developers cannot easily read and reason about the code, then you haven't actually solved any problem. Priority must always be placed on the ability of developers to read and understand code.

Unreadable code will naturally be a source of bugs.

Re:Some Thoughts on Zig by josephg on Thursday July 21, 2022 @11:30PM (#32188174)
> However, I am not convinced one can make something solving all the things Rust solves which is substantially simpler as language.

I wonder a lot about this too. As far as I know, rust is alone. It’s the first language to exist which does compile time memory management in a safe way. Every other language either is memory-unsafe (C, Zig) or garbage collected. (Go, JS, etc).

Rust might the first language of its kind, but it probably won’t be the last. I’d be very surprised if we’re still using rust 100 years from now. Subsequent languages can learn from rust’s accidental complexity and clean up the approach.

Personally I suspect it’s possible to have a borrow checked language that’s much simpler than rust. I don’t know what that would look like, but it would be surprising to me if we found the best programming language in this space on our (collective) first attempt at it.

But I don’t have enough insight to figure out what rust’s successor would look like either. But luckily for both of us, there are a lot of smart people thinking about the problem now. Let’s give it a decade and see.

Re:Some Thoughts on Zig by verdagon on Thursday July 21, 2022 @11:46PM (#32188280)
There's some exciting work already going on in this space, in fact!

* Andrew Kelley is looking into combining escape analysis with allocators to assist in Zig's memory safety. [0] It could be quite a step forward!

* D is adding a borrow checker! [1]

* Cone is adding a borrow checker on top of user-definable allocators. [2]

* We're currently prototyping a region-based borrow checker [3] for Vale, which should get us most of the benefit of Rust's borrow checker with only a fraction of the complexity. It's opt-in, not upwardly infectious, and can stay near the "computational leaves" of one's program.

[0] https://news.ycombinator.com/item?id=31853964

[1] https://dlang.org/changelog/2.092.0.html#ob

[2] https://cone.jondgoodwin.com/memory.html

[3] https://verdagon.dev/blog/zero-cost-refs-regions

Re:Some Thoughts on Zig by pcwalton on Thursday July 21, 2022 @11:59PM (#32188356)
It sounds like the "region borrow checker" is fundamentally based on reference counting, which makes it a garbage collected system. Also, statically eliminating reference count traffic from the stack isn't new; it goes back to Deutsch and Bobrow 1976. Actually, I suggest reading the paper; it seems like a quite similar system [1].

[1]: https://www.memorymanagement.org/bib.html#db76

Re:Some Thoughts on Zig by verdagon on Friday July 22, 2022 @12:04AM (#32188393)
The region borrow checker was originally designed for a reference-counted system, but not any more.

We later discovered generational references, a method for memory-safe single ownership with no borrow checker, reference counting, nor garbage collection. To our delight, the region borrow checker works even better with generational references than with reference counting =)

Re:Some Thoughts on Zig by zozbot234 on Friday July 22, 2022 @03:30AM (#32189491)
Generational references are best seen as an alternative to RC that makes different tradeoffs. They add overhead to reads/writes thru the managed reference, as opposed to the overhead for changes in ownership you see wrt. RC/ARC in something like Rust. (Note that other languages like C++ or Swift cannot cleanly separate ownership changes to the same extent as Rust, so their overhead is ultimately a lot higher. Especially Swift, with its ARC-for-everything approach.) They look like they might be good complementary approaches.
Re:Some Thoughts on Zig by Nomentatus on Friday July 22, 2022 @01:37PM (#32194756)
I'd be curious as to whether my comment here hypothesizing an AI wizard stikes you as "just nuts", or not.
Re:Some Thoughts on Zig by glowcoil on Saturday July 23, 2022 @01:44AM (#32200712)
Frankly it seems strange to me to be comparing Vale's generational reference system and Rust's borrow checker directly. They have completely different characteristics and are not direct substitutes for one another.

First, Rust's borrow checker incurs zero runtime overhead for any pointer operations (whether dereferencing, copying, or dropping a pointer) and requires no extra storage at runtime (no reference counts or generation numbers); it's entirely a set of compile-time checks. Generational references, on the other hand, require storing an extra piece of data alongside both every heap allocation and every non-owning reference, and they incur an extra operation at every dereference.

Second, since Rust's borrow checker exists entirely at compile time, it doesn't introduce any runtime failures. If a program violates the rules of the borrow checker, it won't compile; if a program compiles successfully, the borrow checker does not insert any conditional runtime panics or aborts. Generational references, in comparison, consist entirely of a set of runtime checks; you won't found out if you violated the rules of generational references until it happens at runtime during a particular execution and your program crashes.

Finally, Rust's borrow checker applies to references of all kinds, whether they point to a heap-allocated object, a stack-allocated object, an inline field inside a larger allocation, a single entry in an array, or even an object allocated on a different heap and passed over FFI. Its checks still apply even in scenarios where there is no heap. Generational references, on the other hand, are entirely specific to heap-allocated objects. They don't work for stack-allocated objects, they don't work for foreign objects allocated on a different heap, and they don't work in a scenario with no heap at all.

All of these are fundamental differences which mean that Vale's generational reference system is not at all a replacement for Rust's borrow checker. It's not zero-overhead, it doesn't catch errors at compile time, and it's fundamentally specific to heap-allocated objects. In these ways it's more comparable to Rust's Rc, which introduces runtime overhead and is specific to heap-allocated objects, or RefCell, which performs checks at runtime that can result in aborting the program.

Re:Some Thoughts on Zig by hayley-patton on Friday July 22, 2022 @08:33AM (#32191241)
Borrowing, in a way, looks a bit like the anchored pointers suggested by Henry Baker in [1]. I recall reading someone did a static analysis to detect what pointers could be anchored, but forgot which someone. However the "deferral" suggested is very different to the Deutsch-Bobrow deferral; what makes me think it is more like borrowing is that anchoring avoids destruction due to linear types, like borrowing avoids moving or copying. (Regions in Cyclone would be somewhere in between, too.)

[1] https://plover.com/~mjd/misc/hbaker-archive/LRefCounts.html

Re:Some Thoughts on Zig by fancl20 on Friday July 22, 2022 @12:43AM (#32188602)
It doesn’t have to. If your allocator is the first-class citizen in the language, simply check the allocated memory when allocator itself is manually destroyed (exit its region) is enough for detecting memory leak.
Re:Some Thoughts on Zig by dunefox on Friday July 22, 2022 @02:56AM (#32189301)
D is adding everything, it seems.
Re:Some Thoughts on Zig by Matl on Friday July 22, 2022 @01:53PM (#32194997)
I wonder if that could actually be hindering its adoption. I think the 'kitchen sink' C++ style is not so popular anymore.
Re:Some Thoughts on Zig by Tozen on Friday July 22, 2022 @08:43PM (#32198975)
When it comes to language popularity, we have to keep in mind that D is way more popular than so-called up and coming languages (where it's oddly ignored they came out many years ago) such as Zig, Nim, Crystal, etc... Dlang often floats around the top #30 in the TIOBE rankings.

It really is a very tough hill to climb to crack the top 10 among languages. Relatively speaking, D has done well for itself, and arguably is in the position to climb further up and possibly be in the top 20 of language rankings.

Have seen a lot of talk and theories about why D didn't or hasn't become more popular. Some of them have to do with circumstances, not just about the number of features. For instance, Dlang's DMD reference compiler was under license restrictions by Symantec, which wasn't changed until 2017 (now it's under the commercial friendly Boost license). A lot of companies and corporate sponsors get leery about licensing issues.

There were also early squabbles about API design, like Tango versus Phobos, which are mostly resolved these days. But, years ago, it was less clear about the direction or how it would get sorted out.

D, as a contender to climb even higher up the language ranking charts, is still a strong possibility. D might even remain and always be more popular than Zig will ever be (especially if it wants to fight and die on the more syntactically complex "better C" hill), despite this view on D adding so much. Which could even be more of a selling point (kitchen sink included), than an hindrance, and particularity as an already established and developed older language.

Re:Some Thoughts on Zig by dunefox on Saturday July 23, 2022 @07:07AM (#32202246)
If D is in the top 30 of languages according to these rankings that just shows how flawed they are.
Re:Some Thoughts on Zig by Nomentatus on Friday July 22, 2022 @01:39PM (#32194790)
Fascinating (and heartening.) I wonder whether this work takes us any way toward an AI wizard "in between" Rust and Zig (say) as I've described in a longer comment here. Am I nuts to hope for such a thing?
Re:Some Thoughts on Zig by pcwalton on Thursday July 21, 2022 @11:42PM (#32188252)
There have been memory-safe non-GC languages before, like Ada SPARK, but they generally disallow heap allocation altogether. If you heap allocate you get a GC. There were also some academic languages, most notably ML Kit, that offered a safe no-GC region-based memory management system that has a lot in common with Rust. Also, there are academic languages like Cyclone that have a very Rust-like memory management system, but they all use GCs in the end. Still, if you know Rust, Cyclone's ideas will be very familiar.
Re:Some Thoughts on Zig by throwaway17_17 on Friday July 22, 2022 @12:01AM (#32188369)
Small point of contention, but it’s actually Rust that has a Cyclone-like memory management system.

Cyclone’s initial release was ‘02 and it finalized in ‘06.

Re:Some Thoughts on Zig by pcwalton on Friday July 22, 2022 @12:05AM (#32188402)
Oh, I'm sorry, I didn't mean to imply that Rust invented any of those things. Cyclone was a big influence on Rust actually. We chatted with Dan Grossman early on, and his presentation "Existential Types and Imperative Languages" is the earliest description of the problem the borrow checker is trying to solve (check it out, it's a great presentation!)

We stand on the shoulders of giants :)

Re:Some Thoughts on Zig by chriskrycho on Friday July 22, 2022 @12:08AM (#32188421)
You just (accidentally, no doubt!) well-actually’d someone who helped build Rust and has been invoked in it since long before 1.0. ;-p He’s aware of the direction of influence and was just saying they’re similar, not saying one influenced the other.
Re:Some Thoughts on Zig by throwaway17_17 on Friday July 22, 2022 @12:23AM (#32188503)
I’m aware of pcwalton’s involvement in Rust. So it wasn’t accidental in any way. It was however slightly tongue-in-cheek, but I probably could have used a /s to indicate it wasn’t an attempt to score ‘I’m smart points’. I was also very aware that, despite anything else, they were almost certain to be aware of which came first.

I may take serious issue with pcwalton’s assessment of the performance characteristics of OS threads vs other concurrency implementations, but fun HN arguments aside; I have never seen or heard of any lack of acknowledgement of preceding language/implementation work leading to Rust’s development. So I certainly wasnt attempting to imply any stealing or denial of credit/attribution.

Re:Some Thoughts on Zig by pcwalton on Friday July 22, 2022 @12:11AM (#32188436)
No worries, it's my fault for not being clear. The absolute last thing I want to do is to take credit for things we didn't do. Rust wouldn't exist without that academic work by Tofte, Talpin, Grossman, etc.
Re:Some Thoughts on Zig by throwaway17_17 on Friday July 22, 2022 @12:29AM (#32188537)
I said it in my sibling comment above, but to be clear, I was well aware you almost certainly knew Cyclone’s general age. I don’t want you to think I was implying or hinting anything near taking or denying credit.
Re:Some Thoughts on Zig by jolux on Friday July 22, 2022 @12:06AM (#32188404)
Likeness is bidirectional and doesn’t imply derivedness, though.
Re:Some Thoughts on Zig by throwaway17_17 on Friday July 22, 2022 @12:31AM (#32188554)
I feel like I stuck my foot in my mouth with my comment, but separate from that…

This is an interesting perspective, I can’t think of a reason you would be incorrect, but I know I have some default intuition that likeness is most often used to imply derivedness. Also, that’s a great way to phrase what you meant.

Re:Some Thoughts on Zig by fanf2 on Friday July 22, 2022 @02:38PM (#32195584)
I gather that in later versions of the ML Kit, the contents of regions were also garbage collected. The problem they had with the compile-time lifetime / region analysis was that in difficult cases an object would be given a longer lifetime than necessary, leading to space leaks
Re:Some Thoughts on Zig by amenghra on Thursday July 21, 2022 @11:56PM (#32188335)
There are several languages which use linear types, Rust being the most popular. For example, https://github.com/austral/austral claims to be simpler than Rust and was discussed on hackernews a few days ago.
Re:Some Thoughts on Zig by brundolf on Friday July 22, 2022 @04:43PM (#32196883)
Another possibility is Rust continues to get more advanced in ways that remove constraints over time, making it less complex to use in practice. We already see a lot of (small, incremental) improvements of this type, where a bunch of compiler work goes into proving that new cases are actually safe and therefore allowed

Basically what I'm wondering is if Rust has room to become that language that's learned from the ways Rust has been clunky in the past, without introducing dramatically breaking changes

Re:Some Thoughts on Zig by pjmlp on Friday July 22, 2022 @02:03AM (#32189019)
Rust is the first achieving commercial success (so to speak), several others have precedded in the use of affine types.

While we cannot, and should not, take away its glory in achieving this, we should also not address it as if all belongs to Rust alone.

Re:Some Thoughts on Zig by nomel on Friday July 22, 2022 @12:15AM (#32188461)
If people are still typing words with fingers to make computers do things, in 100 years, technology has failed!
Re:Some Thoughts on Zig by flohofwoe on Friday July 22, 2022 @03:20AM (#32189452)
Maybe, maybe not. Technologies that are 'good enough' just stick around forever instead of being replaced by something entirely else. Wheels are still round, we still print words on paper, we still use glass lenses when eyesight starts to fail, rifles don't look fundamentally different from when they first appeared, etc etc...
Re:Some Thoughts on Zig by nomel on Friday July 22, 2022 @12:44PM (#32194085)
> rifles don't look fundamentally different from when they first appeared, etc etc...

I would claim that a modern rifle flies at hundreds of miles an hour, and is operated remotely.

Re:Some Thoughts on Zig by network2592 on Friday July 22, 2022 @12:00AM (#32188363)
There is also Vlang [0] which the Zig core maintainer seems to both look up to [1] as well as look down upon [2].

[0] https://github.com/vlang/v [1] https://news.ycombinator.com/item?id=19086589 [2] https://news.ycombinator.com/item?id=31795445

EDIT to reflect critical attitude as indicated by [2].

Re:Some Thoughts on Zig by super_flanker on Friday July 22, 2022 @01:31PM (#32194676)
I'm not sure how are you getting "look up to" vibe, Andy commented that[1] before vlang was released, solely based on feature lists from vlang's website.

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

Re:Some Thoughts on Zig by throwaway17_17 on Friday July 22, 2022 @12:03AM (#32188389)
I don’t have a real opinion in this particular topic area, but I am certain many people will find the Andrew Kelly reference to be not entirely accurate.
Re:Some Thoughts on Zig by network2592 on Friday July 22, 2022 @12:09AM (#32188427)
Neither do I. The word seems was used as a tentative qualifier rather than an assertion. Feel free to provide context that would indicate otherwise if you deem it salient.
Re:Some Thoughts on Zig by demindiro on Friday July 22, 2022 @12:25AM (#32188516)
Re:Some Thoughts on Zig by network2592 on Friday July 22, 2022 @12:35AM (#32188566)
Thanks for pointing this out. At the very least, there are conflicting attitudes. Comment will be edited to reflect that. Initial reply made a valid point.
Re:Some Thoughts on Zig by Tozen on Friday July 22, 2022 @12:23PM (#32193801)
You did nothing wrong in pointing out the difference in attitude. The change in views is arguably indicative to the extent that Vlang was perceived as a real threat, competition, or could become more successful.

Vlang has continually maintained its development pace and popularity (https://github.com/vlang/v/releases), so that pretending to dismiss it as if it was nothing or attempting to smear the author just does not work. It's not going away. Vlang is also not a one-man show, but has numerous other committed developers, new contributors, and loyal long time supporters.

Re:Some Thoughts on Zig by rudedogg on Friday July 22, 2022 @12:34PM (#32193932)
I think the reason Vlang gets so much heat is that they dismiss criticism and make claims that PL people think are misleading.

You can see this in the latest Vlang release thread. I suggest those curious take a look at it and judge for themselves.

Re:Some Thoughts on Zig by Tozen on Friday July 22, 2022 @01:12PM (#32194464)
Actually, what people can find is the author of Vlang has been shown to welcome constructive and helpful criticism versus outright trolling or blatant smearing. For example- "What don't you like about V / what would you like to be changed?" (https://github.com/vlang/v/discussions/7610).
Re:Some Thoughts on Zig by nyberg on Wednesday July 27, 2022 @02:19PM (#32254362)
It was rather a failure to deliver on the promises than perceived as a threat to Zig and the target audience for both differ enough that V doesn't have an effect on the success of Zig nor does Zig have an effect on the success of V. They are both reaching for success within their own domains with some but not much overlap.

I know you're very fond of V but misrepresenting criticism or a negative view of the project as "fear", "perceived threat", and so on is rather dishonest and a disservice to the project. The above is a comparison of before release and long after where there's been a chance to evaluate V for what it is rather than for what it advertised.

Re:Some Thoughts on Zig by verdagon on Thursday July 21, 2022 @11:29PM (#32188167)
> Nice balanced writeup! However, I am not convinced one can make something solving all the things Rust solves which is substantially simpler as language.

I used to think this too, but my opinions have evolved a bit.

Recall the transition from goto-heavy assembly code to C; it solved all the things assembly solved, and was a substantially simpler language. One of the keys to designing a good language (or any good abstraction, really) is to identify the patterns that already informally exist.

So if we want to see a simpler Rust, we need to look at the informal patterns that exist in Rust.

* Zig did this with Rust's async/await, by making it colorblind. [0]

* Vale did this with Rust's generational indices, by making generational references, a way to get memory-safe single ownership without a borrow checker. [1] It then adds a hardened FFI boundary to get more solid safety guarantees than Rust could. [2]

* HVM did this for Haskell by looking at Rust's particular blend of borrowing and cloning, and making it happen automatically. [3]

* Lobster did something similar for an imperative mutable language, to reduce RC costs lower than ever before. [4]

I think Rust is an amazing first attempt at an interesting new problem space, and a huge step forward for the field. Now, language designers are starting to notice that the building blocks that Rust trailblazed might be combined in new interesting ways, to make new interesting languages.

It's an exciting time for programming languages!

[0] https://kristoff.it/blog/zig-colorblind-async-await/

[1] https://verdagon.dev/blog/generational-references

[2] https://vale.dev/memory-safe

[3] https://github.com/Kindelia/HVM

[4] https://www.strlen.com/lobster/

Re:Some Thoughts on Zig by ghoward on Friday July 22, 2022 @07:40AM (#32190890)
> Zig did this with Rust's async/await, by making it colorblind.

Zig's async/await is not colorblind. [1] It just appears that way at first because the compiler infers as much as it can at compile time.

[1]: https://gavinhoward.com/2022/04/i-believe-zig-has-function-c...

Re:Some Thoughts on Zig by nyanpasu64 on Friday July 22, 2022 @12:46AM (#32188622)
Saying C solved all the problems assembly solved is a bit too strong; bootloaders and kernels, green thread or coroutine implementations (like libco), and cryptographic code are all implemented in part in assembly.
Re:Some Thoughts on Zig by flohofwoe on Friday July 22, 2022 @03:23AM (#32189464)
IMHO if C could solve all the same problems as assembly, it would need to be down on the assembly language level - which it isn't, C is clearly a high level language, it's much closer to any other programming language than any assembly dialect (maybe with the exception of Forth-like languages).

In general, the higher level the language, the more flexibility you need to give up (but that's ok for many solutions).

Re:Some Thoughts on Zig by verdagon on Friday July 22, 2022 @08:59AM (#32191423)
Good point, the statement was too absolute. Perhaps I should instead say that for a lot of use cases C solved enough of the problems that assembly previously solved.
Re:Some Thoughts on Zig by Sammi on Friday July 22, 2022 @06:56AM (#32190622)
Wow, this perspective makes me really excited for the future of new programming languages. Thanks.
Re:Some Thoughts on Zig by Nadya on Thursday July 21, 2022 @11:38PM (#32188223)
I'm keeping an eye on Vale [0] but will continue to use Rust for hobby projects because the community/tooling that has built around it has made it much easier over a few years than when I first gave it a try in 2018 and especially as support for development on Windows grew. I went from absolutely struggling to get so much as a win32 GUI window to open [1] to writing a basic counting app [2] for a game I play to completely rewriting that app to not suck [3] (even though the code is still awful).

Zig looks nice to read and understand. However at my skill level (more or less a skript kiddie) I don't trust myself to not cause major memory-related bugs. In fact, I can't help but wonder if it's hubris or what when extremely intelligent, college educated, programmers with more than my lifetime of experience who still manage to write programs riddled with memory safety issues and in the very next breathe say memory safety isn't an issue just write safe code. I wonder what skill/knowledge thresholds are where "I don't trust myself to not make those mistakes" turns into "I won't make those mistakes."? Honestly it reminds me of the low IQ/high IQ meme [4].

[0] https://vale.dev/

[1] https://gitlab.com/NadyaNayme/rusty-eyes

[2] https://github.com/NadyaNayme/Dorothy

[3] https://github.com/NadyaNayme/Dorothy-egui

[4] https://kimiwo.aishitei.ru/i/sZaEWnY3NvfXecLm.png

Re:Some Thoughts on Zig by kaba0 on Friday July 22, 2022 @02:53AM (#32189287)
I have to agree. Adding safe, non-automatic memory management to a language will increase its complexity considerably, and I don’t see it changing even with the below mentioned new languages/techniques. Even just fundamentally, manual memory management begets functions that know about the memory architecture of your program, solidifying a given architecture. Changing this latter will result in a recursive refactor, which even if safe, is problematic/complex.

Sure, it is a worthy tradeoff in certain, very niche cases (though other than writing other performant runtimes and realtime audio processing, I fail to see another area where a GC couldn’t fit - including even OSs), for which we need a language, but I really don’t get this recent hate for garbage collection, when it is truly one of the biggest productivity improvements for a PL, while simultaneously it being very performant (quite likely outperforming any naive manual take on more complex problems).

Re:Some Thoughts on Zig by Tozen on Saturday July 23, 2022 @12:55AM (#32200511)
> ...Priority must always be placed on the ability of developers to read and understand code.

The importance of this can't be overlooked, which is debatably why people and companies are constantly looking for a way to escape heavily complex languages and syntax. It is part of the thinking behind somewhat newer languages like Go, or newer offshoots like Vlang (https://vlang.io/), which has a focus on high readability and general usability.

If a language is being geared towards the majority or mass appeal, then it has to find that correct sweet spot. There is simply going to be a cap on how far complexity will be embraced or how much specialization will be found useful.

“Genius is making complex ideas simple, not making simple ideas complex.” — Albert Einstein

> ...I am not convinced one can make something solving all the things Rust solves which is substantially simpler as language.

Debatably, such languages making the attempt, are less likely to succeed. Off rip, Rust already occupies that space. So, trying to make a "better Rust", which is already a specialist in that field (safety) and has already got "the push" from large corporate backers (Mozilla, Samsung, Quantum...) will usually mean failure, remaining in niche status, or overcoming incredible odds (like hitting a Lotto jackpot). The more the language specializes on that particular use case, then arguably the less general appeal and general use. And if there is already competition doing it better or being more known for that focus, the harder the hill to climb.

For that matter, trying to make a "better C", is another tough hill. Not only because C is so entrenched and established, but that there is already a long list of quasi "better Cs" out there such as Object Pascal, D, Nim, etc... Add in more complex or confusing syntax, less features, less functionality, or less usefulness... Then the hill gets even more steep. Hitting the bullseye, just isn't easy.

Re:Some Thoughts on Zig by vageli on Thursday July 21, 2022 @10:44PM (#32187878)
> Whether we look at Zig, Go or Julia they stay relatively simple because they simply avoid solving certain problems.

Could you expand on the specific problems that each language avoids?

Re:Some Thoughts on Zig by adgjlsfhk1 on Friday July 22, 2022 @12:08AM (#32188424)
Julia mostly ignores static compilation (although there now is work to add the ability to statically compile for a relatively large but limited subset of the language).

The big thing that this allows is for you take the ideas of C++ templates to the extreme. In Julia pretty much every function behaves like a C++ function that is templated on the type of every input. This has the major advantage that it is really easy to write extremely fast generic code. This only works in general though because Julia only has to generate code for the types that actually appear rather than all the type combinations that static analysis can conclude might appear.

Re:Some Thoughts on Zig by sk0g on Thursday July 21, 2022 @10:55PM (#32187937)
Till recently, Go lacked generics. Aside from that, it has a GC that is pretty nice to work with. Manual memory management is semi-supported, using C interop instead of native language constructs (from when I last looked into it).
Re:Some Thoughts on Zig by kaba0 on Friday July 22, 2022 @02:42AM (#32189230)
Go is a thoroughly uninteresting language bringing nothing new to the table. D, C#, even Haskell all has and had for decades now GC with manual memory at places. Other than virtual threads, which I have to give credit for, there is zero new thing from a PL perspective.
Re:Some Thoughts on Zig by Tozen on Friday July 22, 2022 @08:08PM (#32198705)
That's a pretty harsh take on Go. Many people find how it does concurrency, OO without classes (methods assigned to structs), its simplicity, and compilation speed as refreshing. At least in comparison to C, of which few would know how to make a better "successor" language for general use among the masses, than Ken Thompson (who co-developed C too).
Re:Some Thoughts on Zig by flohofwoe on Friday July 22, 2022 @03:28AM (#32189481)
Erm, Go channels were a pretty big deal in the beginning, as well as the idea of creating a 'better C' (instead of a 'better C++').
Re:Some Thoughts on Zig by masklinn on Friday July 22, 2022 @07:12AM (#32190702)
> Erm, Go channels were a pretty big deal in the beginning

In what world did people not know about MPMC queues?

Re:Some Thoughts on Zig by flohofwoe on Friday July 22, 2022 @08:47AM (#32191335)
When Go came around I wasn't aware of other popular languages which has channels as a core language feature (but maybe I was just ignorant).
Re:Some Thoughts on Zig by pjmlp on Friday July 22, 2022 @09:08AM (#32191509)
Erlang came out in 1986.

Here are the experiences of Wooga and Activision/Blizzard using it.

https://www.gdcvault.com/play/1016648/Why-Erlang

http://www.erlang-factory.com/upload/presentations/395/Erlan...

Re:Some Thoughts on Zig by Matl on Friday July 22, 2022 @05:48PM (#32197507)
While true, Erlang is a dynamic language, which has its own problems.

Go's concurrency builds on CSP and they're open about it, but it is not just about who came up with it but who made it mainstream and for that Go certainly deserves credit.

Re:Some Thoughts on Zig by masklinn on Friday July 22, 2022 @09:02AM (#32191457)
> other popular languages which has channels as a core language feature

That’s because other languages did not need channels as a core language features.

Go does for the same reasons it needs e.g. hashmaps or append as “core language features”: no generics.

As far as I could see, there was one cool thing Go brought to the table, and it’s select {}. That was (and still is, I think) pretty uncommon, though not unheard of (Erlang’s receive is similar, though it has different capabilities owing to different language semantics).

Re:Some Thoughts on Zig by cdelsolar on Saturday July 23, 2022 @08:57AM (#32202867)
What is a MPMC queue
Re:Some Thoughts on Zig by kaba0 on Friday July 22, 2022 @03:48AM (#32189596)
I absolutely don’t see anything in Go resembling C from a technical perspective, other than (before generics) being similarly unexpressive. It is much closer to JS than C in any way and shape.
Re:Some Thoughts on Zig by flohofwoe on Friday July 22, 2022 @04:35AM (#32189873)
I don't know, I currently write both C and JS on a daily basis, and I just can't see how Go is anything like JS. For me, Go is definitely in the C syntax family, while trying to solve roughly the same problems where Java has been used extensively (backend services).
Re:Some Thoughts on Zig by agentultra on Thursday July 21, 2022 @10:50PM (#32187908)
Unreadable as in, “this code is unfamiliar and I haven’t talent the time to understand it,” or “this code is syntactically designed to be difficult to parse by humans and I cannot read it?”
Re:Some Thoughts on Zig by abirch on Thursday July 21, 2022 @11:12PM (#32188047)
What about, I can't read this code. Who's the idiot who wrote it?

git blame

Oh that was me.

Re:Some Thoughts on Zig by timeon on Friday July 22, 2022 @05:04AM (#32190039)
This was often my issue. But I remember while learning more Rust I was like: 'now I can go back to my early Rust project to improve it!' and when I did check it: 'oh.. this is actually not bad! How was I able to do it?'
Re:Some Thoughts on Zig by ghoward on Friday July 22, 2022 @07:39AM (#32190878)
I think you are absolutely right about everything you mentioned, except for one:

> I am not convinced one can make something solving all the things Rust solves which is substantially simpler as language.

You could be right about this, but boy, I hope you are wrong. And I'm trying to prove that it's possible.

I think the answer is structured concurrency [1], and here's why:

1. Structured concurrency can replace everything async/await can do. At least, I believe so, kind of like it's believed that structured programming can replace any unstructured use of goto.

2. If you extend structured concurrency a bit so that the thread tree is actually a DAG [2], you basically get a borrow checker for free because every item is rooted in a thread stack somewhere, and where it is rooted is always before everything that it could own and after everything that could own it.

3. Making the thread tree a DAG also means it's easy to implement RAII and have it work meaning no use-after-free, no double frees, etc.

Put that on top of a language that has memory safety by default, and you will have everything that Rust gives you without the complexity.

This isn't theoretical; I have implemented this in C. [3] (See [4] for a use of it.) I have even implemented bounds checking in C. [5]

However, I'm also implementing a programming language with these ideas (see [6] for the example file and [7] within that file for how structured concurrency might be exposed in the language).

As for readability, I do think that what I have is readable. However, I appreciate comments; readability is important to me too, but I've spent so long with this work that I am blind to what is actually readable to other people.

[1]: https://gavinhoward.com/2019/12/structured-concurrency-defin...

[2]: https://lobste.rs/s/8msejg/notes_on_structured_concurrency_g...

[3]: https://git.yzena.com/Yzena/Yc/src/branch/master/include/yc/...

[4]: https://git.yzena.com/Yzena/Yc/src/branch/master/src/rig/bui...

[5]: https://git.yzena.com/Yzena/Yc/src/branch/master/include/yc/...

[6]: https://git.yzena.com/Yzena/Yc/src/branch/master/src/yao/exa...

[7]: https://git.yzena.com/Yzena/Yc/src/branch/master/src/yao/exa...