Game Jam 2 Results
wasm4.org
wasm4.org
WASM-4 seems to be a technically limited "console" (64kb of RAM, 160x160 console), so it's even more of a niche than just doing game dev for WASM.
Even though I'm technically a millennial… but if the next gen start using Zig instead of JavaScript for everything, I'm on board.
I doubt JS will stop being primary language in browsers in my lifetime.
Javascript "mess" in browsers could be reduced by dividing into two parts. DOM stuff, and pure language stuff. The first part can stay as is. Probably wrapped into thin API for new lang interop. The second part is a completely new lang that compile to wasm (ideal if vice-versa) so that backend could also send wasm to browser and be able to interact with DOM too.
Next, backend js "mess" can be stopped because we have a better way for other languages to develop for the web.
People come and go either because of life or work, and complexity piles up. I don't think there are any silver bullets.
There is a reason Worse is Better. It's quicker to ship and spread.
OT: Searching for Spark2014 brings up a lot of results about the 2014 Chevrolet Spark. A shit box of a car of there ever was one.
I usually put "SPARK2014 programming" or "SPARK2014 Ada" in my searches. I used to get annoyed by all of the Apache Spark stuff that came up, but that seems to have waned a bit this past year or two.
Vermont Technical College (VTC) used SPARK2014 to program their CubeSat and the book, "Building High Integrity Applications with SPARK"[1] is a great intro to it in a nice context of practical use.
There was also an article on the AdaCore site about someone who rewrote some drone firmware in SPARK2014, which is another nice real-world application. [2]
[1] https://www.amazon.com/Building-High-Integrity-Applications-...
[2] https://blog.adacore.com/how-to-prevent-drone-crashes-using-...
In fact, I guess in gas cars sparks are "better" since they are engineered in, and doing useful work.
[1]: https://docs.adacore.com/spark2014-docs/html/ug/en/source/la...
For private lone-hacking projects though it feels way too complex and opinionated. Here Zig definitely gets closer to what I need, though sadly it made unused variables an compiler error (curse you golang for making that popular) which is super annoying for prototyping.
But if you comment var A that uses var B now B is unused and you need to commnet B, but now B was using a function parameter C and this param is unused now so you need to update the function signature (I do not use Go,Zig so maybe they did not forced you to also use all the function params my experience is with linters where ehwn you comment something then more unused warnings appear)
Seriously, I have never had this problem while coding in Go, and I'm a very very sloppy coder.
In any moderately complex function you'll have more than one expression, and those can depend on each other. And you want them to be named and assigned; it makes it easier to read and decode intent and debug things (unless you're one of those wizards who get it right on the first try every time, kudos to you then). I'd not approve a PR that inlines/embeds complex concepts within larger expressions just to avoid creating variables...
Edit: typos
If then you refactor away that single final value you need to delete all the previously used variables that now need to be "deallocated" by you.
Did you ever tried to debug some issue and start commenting stuff to try and find the problematic area? Hell when I comment stuff soemtimes private function will get unused , so with a shit compiler you would need to also comment the private functions, remove unused classes etc.
In my code I assure the linter will say 0 warnings.
Funny enough I was correcting my son c++ homework yesterday, he had a complex if statement like
if (somefunction(m,n, y[j]) == m[j])
and I made him make a local variable to make it clear what is happening. then the code was easier to understand and debug because we culd print that local variable and see if is fine.
Btw, try not too respond that smug, you proved that you are an inexperienced coder and a shit person.
https://www.google.com/search?q=go+lang++compiler+warnings+u...
All those people reporting the issue are not Go developers? Or maybe are not true Go developers, just the other kind, the ones that want generic and nice things.
But yeah, I am not a Go dev, I used linters and I would hate having to be forced to clear all the unused warnings before I can test the code.
If it gets to 2-5 minutes the likelihood that you stop writing tests and rely on the compiler for bugfreeness goes up - or the likelihood that you create debt by increasing the complexity of your code organization.
And juggling variables was an ongoing ordeal when I tried. I can't imagine how you would work on code without changing any of the variables.
Compile times of 2-5 minutes can happen in langs that are not rust. You mentioned rust, not me. And anyways the 30s to hn thing is real.
You can leave those "unused variable" warnings and fix them before release
The difference is that warnings are visible, the underscores however suppressed the compiler's ability to help you.
Commenting out a few variables isn't always easy either. Every try to add const to a legacy C++ project - it can take days to fix all the errors resulting from adding const to something that clearly is const in usage. I don't know zig, but I wouldn't be surprised if sometimes you get into this type of situation in a large code base (does anyone have a very large code base in zig yet?)
Only until getting rid of unused variables becomes a habit before you hit the compiler. Which is a good habit to have anyway.
Add to that the snowball effect: you comment out a variable, compile, and you get another error because commenting out variable a made variable b unused. Rinse and repeat.
It's a huge and totally unnecessary time sink.
It should be opt-in, so that it's a warning by default, and then, when I'm ready to push my code, I could run some --strict mode that would force me to clean up my code.
That eliminates the unused chain problem. Not sure if zig included that part of the feature as well.
Generally I agree though. The main problem with forcing unused variables, imo, is that it forces you to think a certain way. When I'm exploring the solution space on something, those constraints feel inhibiting.
If one suggested this in any other language to suppress "unused variable" warnings it would be considered a lazy way to avoid fixing the issue.
Meanwhile the developer of Zig himself recommended doing this[0] which only shows what a bad idea it is to make this a compiler error imho. It encourages workarounds and enforces something we automated long ago in the form of dead code elimination.
[0] https://github.com/ziglang/zig/issues/335#issuecomment-43526...
In Zig, I find that I put a whole litany of "_ = varname;" at the bottom of my functions (starting with the function arguments) and they stay there permanently. This is NOT an improvement.
However, it's not really enough to stop me from using the language as that's an easy thing to evantually fix.
If some enterprising young developer is reading this and wants to make a name for themselves, you should fork the Zig compiler and change those errors to warnings. It would be an extremely popular project.
EDIT: I'll even give you a catchy project name. Wig: Zig with Warnings
I can only see downsides and no upside in this design. Why would you slow down the development workflow for something any decent compiler will discard as basic optimization step? It's an error about something that has absolutely no impact on the resulting program and its execution, you can probably find a dozen better reasons for Zig to throw errors where it doesn't.
Fridays are my live streaming day and I've chosen today's topic to be the user experience of unused variable errors. I have an idea to solve this that can satisfy both parties - those who don't want to be bothered by such errors, and those who want the premise upheld that if Zig code compiles, it does not have any unused variables.
In approximately 60 minutes I'll go live on https://www.twitch.tv/andrewrok/
If you're talking about the `zig fmt` idea, I'd like to draw your attention to a possible pitfall -- Silencing the errors with _ increases the risk that unused vars will be committed to the repo. https://news.ycombinator.com/item?id=32753079
I normally add the equivalent of `-Werror` to pre-commit and CI. But if those warnings are silenced directly in the source code, I can no longer rely on the compiler's guidance to clean up the code, and I would have to hope I could remember all the places I need to clean up before committing. In that way, solving this in the formatter could have the opposite effect on code quality than you intended. I _do_ want the compiler to yell at me... just not yet. Only when it comes time to commit.
Overall I've been impressed reading about Zig's design. You clearly have good engineering taste and I respect you challenging the status quo and trying unconventional ideas, even if I may disagree from time to time. I'm itching to start using the language once this is solved!
If the goal of not having warnings is to increase code quality, it's actually doing the opposite.
I don't understand this insistence on working around the problem by layering on tooling, instead of just fixing the problem to begin with.
Current situation is it's not language-agnostic as movement, it's just c/rust mostly.
So wasm-4 seems to have more interesting examples than the other e.g. https://wasm4.org/docs/tutorials/snake/handling-user-input
The specifications are open and detailed [1]. Specifications like that can be daunting to consume if you want a place to start from instead of a complete overview of the landscape, but there are tutorials in pure web assembly if you want to get started.
[1]: https://webassembly.github.io/spec/core/text/instructions.ht...
Right now I am teaching a VM course on the back-half of the Wasm equation: how to build an engine for Wasm. The course is about more than Wasm, of course, so there is a lot of content about JVMs and dynamic object models, but the projects are based around Wasm.
In the future I envision university compiler courses getting divided into two halves, either as one course with two halves, or two full courses. The first course/half would be entirely frontend: parsing, semantic analysis, IR, translation, lowering--and the target would be WebAssembly. The second course/half would be all about compiling Wasm to machine code. If the second course wanted to go more in the VM/runtime direction, vs focusing on compilation, it could include the upcoming GC extension or a custom extension to have objects.
I think Wasm is the future of code formats and languages, so I'd like to move the needle here for PL implementors.
You read my mind, yes. That's why I said I have AST.
Is your course private? I'm interested.
My guess is that it is about the language tooling, but it would be nice to hear from the authors themselves.
Rust is the highest level represented. I'm guessing the level of control needed to hit the tight constraints of wasm-4 preclude anything that you wouldn't use for a microcontroller. C and c++ would work too, but what fun is that?
https://youtu.be/7ydnjX999kk?t=894
I also think that there is a correlation between the majority of participants being from Europe and Zig. At the moment almost all our meetups are in Europe.
I really enjoy the balance of safety and control in Zig. I can build using Debug mode during development, turning nearly all my bugs into crashes which are easily fixable using in-browser source-level debugging. But in Release-Small mode the result is fast and more importantly really small since there's a 64kb cartridge limit.
Another factor is the Zig Standard Library which designed to be portable and usable on freestanding targets. I can not emphasize enough how pleasant this is. For example I can just use a `std.heap.FixedBufferAllocator` to back a `std.ArrayList` with no problem.
The comptime feature of Zig also comes in handy when you have to minimize code size.
The seamless C interop furthermore improves my productivity since I can just use any C code I like. I've used a C perlin noise library in a previous game for example, saving me a lot of time.
Plus I've used Zig for the previous WASM-4 jam and just liked it so I didn't bother trying any other language.
So basically rust imposes a lot of limitations on how you can structure your program relative to something like Zig or C.
I don't see it imposing that much of a limit. If there is code you know is correct and Rust can't reason about it, do it in unsafe block.
And ECS is not just possible in Rust, but due to mutability guarantees you can make your ECS schedule systems in such way to maximize multi threading. See Bevy ECS.
And how does rust allow you to "maximize multi-threading" over what's possible in other languages? Anything you can express in rust can be expressed in C or Zig as well. The only difference is the implementation you reach will come with static guarantees about memory ownership (so long as you don't use unsafe). So the set of all rust programs is a essentially a subset of all C/Zig programs.
I kinda want to end this assumption. Unsafe only allows few things.
- access to raw pointers.
- implement or accessing unsafe functions (e.g. C FFI)
- implementing or accessing unsafe trait
- access to unsafe union
- mutate global variables.
You can't bypass borrow checker, and you wouldn't do everything in unsafe. If you write everything in unsafe you are definitely doing stuff very, very wrong.
Rust unsafe is a surgeon's equivalent of a scar. Some scars need to happen, and you can tuck them out of sight if you are clever. However if after an operation you look like a map of scars, it means your surgeon is lacking.
No language can prevent you from abusing it, but in Rust it's apparent when you do it.
> And how does rust allow you to "maximize multi-threading" over what's possible in other languages?
Bevy newbie here so take it with a grain of salt. Because Bevy knows when and how Resources are related it systems can freely run in parallel if two resources are unrelated and mutable, or related and immutable.
> Anything you can express in rust can be expressed in C or Zig as well.
Point of a good programming languagues isn't to enable writting programs that can do anything but to aid programmers in writing error-free programs.
Why do you think we use punctuation and spaces? I remember a talk[1] where he noted spaces/punctuation became a thing only when Christian monks started transcribing written words, as a way of error correction. This was how written word looked before:
Withoutspacesitsveryeasytomakierrorsandnotnoticeitinfactdidyounoticeitwhenimadeabunchrightnowassumingthispartdidntcauseheadacheforyouineithercasewrongcodeinrustlooksjustaswrongasthisparagraph
[1] EDIT: Found the talk https://www.youtube.com/watch?v=_EANG8ZZbRs&t=1418s
A few thoughts:
> You can't bypass borrow checker, and you wouldn't do everything in unsafe.
Isn't unsafe still bypassing the borrow checker, in the sense that you're mostly using it because you're doing something the borrow checker does not otherwise allow?
> Because Bevy knows when and how Resources are related it systems can freely run in parallel if two resources are unrelated and mutable, or related and immutable.
But again, I don't understand how that is a unique benefit of Rust. It's completely possible to implement something in C which allows multiple threads to run over unrelated memory locations, or the same immutable memory location. As a programmer you have more options for how to achieve this when not restricted by the borrow checker. Most of the ECS systems in existence solve exactly this problem, and probably most of them are implemented in C++.
> Point of a good programming languagues isn't to enable writting programs that can do anything but to aid programmers in writing error-free programs.
I mean, I think it can't be taken for granted that preventing errors should be the top priority of every programming language. It's probably a priority of most languages, but there's no reason it has to take the number one spot.
I would argue the universal priority of programming languages is to enable the programmer to deliver user value through their program. Rust's thesis is that memory safety issues are such an obstacle to delivering user value that the language should prioritize safety at the expense of a certain amount of pain for the programmer. Languages like Zig and Jai prioritize programmer velocity and relegate safety to optional static analysis tools.
Python is another example: it's very easy to write an incorrect Python program, but the barrier to entry is so low that it enables non-programmers like scientists to do very interesting things by copying a few lines off the internet into a notebook.
There's no one best set of tradeoffs. But as I said from the beginning, if one of the main tasks you are doing is manual memory management, as domains like game dev and HPC require a lot of, you might want to choose a language which prioritizes explicit memory management.
Not really. But using raw pointers and converting to/from memory addresses isn't something borrow checker can check.
It's a borrow checker not address verifier.
E.g. you can take raw pointer, and set two mutable variables to point to it and borrow checker can't know they point to same address.
> But again, I don't understand how that is a unique benefit of Rust.
It's statically enforced by the compiler using Rust's type system.
As far as I know Zig can't say well these two functions can run in parallel because they are at compile time guaranteed to never access same resources and it's impossible to bypass it (outside unsafe). And their content is thread-safe based on the type they satisfy.
> I mean, I think it can't be taken for granted that preventing errors should be the top priority of every programming language.
Douglas Crockford made a good case that every language should on some level try to prevent errors.
> Python is another example: it's very easy to write an incorrect Python program
Python is also older than Java, but even Python is memory safe (GC). Zig and new batch of better C aren't. In that way we definitely regressed.
> I would argue the universal priority of programming languages is to enable the programmer to deliver user value through their program.
If that is truly the case we'd be all programming in Excel and Access. Anything can deliver value, question is - can it be maintained, and at what cost.
In lieu of that a language that makes a set of errors nigh impossible is better than a fast one where those errors are trivial to cause.
That sounds an awful lot like bypassing the borrow checker.
> As far as I know Zig can't say well these two functions can run in parallel because they are at compile time guaranteed to never access same resources and it's impossible to bypass it (outside unsafe). And their content is thread-safe based on the type they satisfy.
Yeah but that's the point. Rust has one way of guaranteeing that two pieces of code don't mutate the same memory at compile time, but that's not the only way to write a correct program which guarantees that. Rust is going to force you to write your program in a certain way to achieve this. There are many other approaches you may be able to use in an unrestricted language which reach a correct and potentially more performant result which are correct, but which rustc cannot verify are correct.
> Douglas Crockford made a good case that every language should on some level try to prevent errors.
That's one opinion. There are many who disagree.
> Python is also older than Java, but even Python is memory safe (GC). Zig and new batch of better C aren't. In that way we definitely regressed.
That's not even an argument. It takes it for granted that lack of memory safety in a systems language is "a regression". That's not an established consensus.
> If that is truly the case we'd be all programming in Excel and Access.
How exactly do you come to the conclusion that Excel and Access are better at delivering value than other programming languages?
> Anything can deliver value, question is - can it be maintained, and at what cost.
Yeah exactly. The point is which language can deliver the most user value in your desired use-case at the least cost. For something like an operating system, where reliability is paramount, it may be a good tradeoff to use something like Rust which is unergonomic and slow to compile because the safety and correctness tools contribute to your use-case directly.
For something like a web front-end project, you're probably not going to choose Rust since it's going to be hard to find enough programmers who are willing or able to get over the Rust learning curve, and Rust's USP's don't do a lot for you.
For something like game-dev, where 30% of what you're doing is thinking about memory layouts, Rust's tradeoffs are actively working against you, and you might appreciate the faster code/build/run loop offered by something like Zig.
I guess you could argue it's bypassing borrow checker in weakest possible sense.
Borrow checker checks borrow. You aren't borrowing you are doing pointer manipulation, and presenting it with stuff that isn't its duty to check. I argue for this because people think that unsafe region is no mans land and that rules of borrow checking don't exist there.
That said, miri should be able to check your unsafe for undefined behavior. https://pramode.in/2020/11/08/miri-detect-ub-rust/
> Rust is going to force you to write your program in a certain way to achieve this. There are many other approaches you may be able to use in an unrestricted language which reach a correct and potentially more performant result which are correct, but which rustc cannot verify are correct.
Yes. It is a small downside, with a huge upside. Seatbelts prevent full mobility but I bet you wouldn't advocate for removing them because crashes rarely happen, and they limit your ability to move during driving.
> but that's not the only way to write a correct program which guarantees that
Rust has a provable way to eliminate a set of errors. You'd need to offer hard proof that code you wrote in alternative way, wouldn't have those issues.
And that alternative way might still be expressible in Rust using some abstraction/unsafe.
> How exactly do you come to the conclusion that Excel and Access are better at delivering value than other programming languages?
You mentioned how Python enabled more people to code. I'm willing to bet if only enabling to code then Excel and Access brought programming to more people, yet we don't see them in use, because maintaining is painful and hair tearingly frustrating. And performance is meh as well, but Python isn't winning any speed medals either.
> It takes it for granted that lack of memory safety in a systems language is "a regression". That's not an established consensus.
I value code that has less footguns than more footguns. Rust showed we can eliminate several cases of footguns, so why add them back? In that sense it's a regression. If you don't value memory safety and enjoy figuring out debugging data races, go nuts. Remove the seatbelts, you probably won't crash. However, if you do - It won't be pretty.
> That's one opinion. There are many who disagree.
3+ billion humans use spaces and punctuation as a error checking mechanism. IDOUBTYOUWANTTOGOBACKTOHOWROMANSDIDIT
Yeah exactly - you're sectioning off parts of the code and telling the borrow checker to trust you that it's ok.
You can't simultaneously argue that unsafe languages are categorically bad and also use unsafe rust as an argument against rust's limitations. Unsafe is either bad or it isn't.
> That said, miri should be able to check your unsafe for undefined behavior. https://pramode.in/2020/11/08/miri-detect-ub-rust/
Static analysis tools outside of the language would also be the way you would check for UB and unsafe behavior in languages like C and Zig.
> Yes. It is a small downside, with a huge upside.
Depending on use-case. Again if your whole programming domain is about memory layouts and the management of allocations, you might want to choose a tool with explicit memory management.
> You'd need to offer hard proof that code you wrote in alternative way, wouldn't have those issues.
Again Rust is only one way to prove those errors don't exist. And for a lot of use cases absolute guarantees of memory safety might not be the greatest concern.
For instance, let's say I am making an HPC program for identifying pricing arbitrage in the market which generates 10 million dollars a day when it's operating. If it takes 10 days longer to implement in Rust, that cost me 100 million dollars. I am not going to care if it crashes twice a day because of an NPE I didn't catch.
> And that alternative way might still be expressible in Rust using some abstraction/unsafe.
Again, once you use unsafe Rust, why not just use an unsafe language?
> You mentioned how Python enabled more people to code. I'm willing to bet if only enabling to code then Excel and Access brought programming to more people, yet we don't see them in use, because maintaining is painful and hair tearingly frustrating.
What's your point? Python is not the easiest code to maintain in the world due to lack of static typing and a host of other issues, but it allows data scientists and others to produce billions of dollars worth of value around the world in ML, AI, and business intelligence operations. You could say they could write more correct, more maintainable programs in Rust, but that pool of practitioners just don't exist who are advanced data scientists and also Rust developers. It's a different tool for a different job.
> And performance is meh as well, but Python isn't winning any speed medals either.
And it doesn't matter because performance isn't relevant in most of the applications where it's used. Just another example of a tradeoff.
> I value code that has less footguns than more footguns.
You might value that but it doesn't mean it's an objective measure of a programming language for all people and all use cases.
> Rust showed we can eliminate several cases of footguns, so why add them back?
It's not "adding them back". Strict ownership enforcement is not a universally accepted advancement in programming languages which every new language gets measured against. It's an experiment Rust is running. It remains to be seen whether it's the right way to do programming.
> 3+ billion humans use spaces and punctuation as a error checking mechanism.
I don't even know what to say to this. Spaces and punctuation got accepted because they're more ergonomic and universally accepted by consensus as the better solution for making text readable. It's a better UX for reading.
Most system programmers do not program in rust. There's no consensus that it has chosen the right tradeoffs.
I'm not arguing philosophically. I'm arguing from a safety viewpoint. A language that's 100% unsafe is worse than a language that's 1% unsafe.
Saying it's not perfectly safe is sophistry. Nothing is perfectly safe, but you still don't hand out your sensitive bank information to random person on the Internet/street/etc.
> Again, once you use unsafe Rust, why not just use an unsafe language?
Assume data race happen. Would you prefer to audit 30k lines or 3? Unsafe language is unsafe everywhere. In Rust, you can limit your search to unsafe regions.
> Static analysis tools outside of the language would also be the way you would check for UB and unsafe behavior in languages like C and Zig.
Define outside language? Miri is maintained by rust-lang team. And Clippy and so on. Sure valgrind and so forth aren't, but their checks are somewhat complementary.
> For instance, let's say I am making an HPC program for identifying pricing arbitrage in the market which generates 10 million dollars a day when it's operating. If it takes 10 days longer to implement in Rust, that cost me 100 million dollars. I am not going to care if it crashes twice a day because of an NPE I didn't catch.
Sure, but if your implementation has a data race error, that when triggered happens causing massive loss of funds. First you'll have to find the issue (good luck searching most of language and deps). Then you need to patch it to prevent future errors. And it can happen again. So maybe 3 days here, 5 days there, 4 days there, and so on.
Granted it's a contrived example, but hey... If you want HPC and safety use Java/C#/Lisp, no Rust necessary.
Point being - Strength of Rust isn't in speed of development, so much as in avoiding certain sets of bugs. And borrow checker isn't the only tool to achieve this.
> Depending on use-case.
On that I agree. If your game is one and done (no maintenance), no user content, no MP, basically worse that can happen is crash sure go ahead. Jams are in that way perfect candidates for small langs where speed of development is crucial.
I'd argue most sold games aren't one and done.
> I don't even know what to say to this. Spaces and punctuation got accepted because they're more ergonomic and universally accepted by consensus as the better solution for making text readable.
Keep in mind that in Rome everything was written without spaces for hundreds of years. From their POV the spaces would be just unnecessary fluff. And there are still languages that have little to no spaces, so spaces aren't even universally accepted. See Chinese and Japanese.
> Most system programmers do not program in rust.
I don't understand, this wasn't specific about just systems language? Going from C# to Zig is a safety downgrade (but a possible performance uplift). And GC langs have been used in OS implementations.
> There's no consensus that it has chosen the right tradeoffs.
Sure, but consensus is a matter of current status and it's not set in stone.
Status quo is C, which has null - a trillion dollar mistake (adjusted for inflation and software spread :P)
> What's your point? Python is not the easiest code to maintain...
My point that we use Python won in ML because allowing people to achieve value isn't the only important aspect. There are many aspects. Sure you get to pick your own, but I've seen too many CVEs caused by memory unsafety.
But safety and reducing footguns should be ideals for any language to strive. Reintroducing footguns? What's next? Return of GOTO Spaghetti monster.
You want to make a nuanced argument that calculated unsafety is better than general unsafety, but you don't want to accept a nuanced argument that Rust's safety tools maybe a detriment in some use-cases.
> Assume data race happen. Would you prefer to audit 30k lines or 3? Unsafe language is unsafe everywhere. In Rust, you can limit your search to unsafe regions.
It depends on the use-case.
> Sure, but if your implementation has a data race error, that when triggered happens causing massive loss of funds. First you'll have to find the issue (good luck searching most of language and deps). Then you need to patch it to prevent future errors. And it can happen again. So maybe 3 days here, 5 days there, 4 days there, and so on.
This is a strawman argument which doesn't reflect reality. C/C++ is actually the main language used in HPC applications like high frequency trading, and they have massive incentives to choose the correct tool for the job.
> If you want HPC and safety use Java/C#/Lisp, no Rust necessary.
You can't. I chose HPC deliberately as an example: in HPC performance is the most important constraint. You couldn't use a garbage collected language because you will not be able to optimize memory performance beyond a certain point since you don't have direct control over allocations.
> On that I agree. If your game is one and done (no maintenance), no user content, no MP, basically worse that can happen is crash sure go ahead. Jams are in that way perfect candidates for small langs where speed of development is crucial.
Then what are we arguing about if you agree with me?
> Keep in mind that in Rome everything was written without spaces for hundreds of years. From their POV the spaces would be just unnecessary fluff.
You don't know that. They might have looked at spaces and understood immediately that it was an improvement.
> And there are still languages that have little to no spaces, so spaces aren't even universally accepted. See Chinese and Japanese.
What point are you trying to make? Wouldn't that support my argument that there's room for different modes of programming, both safe and unsafe?
> I don't understand, this wasn't specific about just systems language? Going from C# to Zig is a safety downgrade (but a possible performance uplift). And GC langs have been used in OS implementations.
I could have also said "most systems programmers don't program in safe languages". The point is the jury is still very much out on whether language-level memory safety is the best solution for all systems programming languages. It's relevant because Zig is the language you are cliticising.
> Status quo is C, which has null - a trillion dollar mistake (adjusted for inflation and software spread :P)
You can focus on the negatives because C is literally the most successful PL ever which the entire world is built on. People are already talking about how GC is a mistake for a lot of applications. Maybe 10 years from now we will be talking about some big mistake Rust made with async colored functions.
Maybe it will turn out Zig's approach is the right one. We don't know yet.
> My point that we use Python won in ML because allowing people to achieve value isn't the only important aspect.
It's the most important aspect. Every other aspect is just relevant to how you deliver value.
> But safety and reducing footguns should be ideals for any language to strive.
I'm sorry but you seem to be missing my entire argument. You agree there are tradeoffs. You agree there are use-cases where safety might not be the most critical thing. You have agreed with every component of my argument but you then want to draw the conclusion that safety is somehow a requirement for every new language.
No. I'm making a simple argument. More safety is better than less safety. You're trying to move argument that since perfect safety is impossible it's not worth pursuing. This is the sophistry part.
> It depends on the use-case.
No it doesn't. Debugging 30k lines is always going to take more than 3/30/300 lines especially when data races are involved.
> This is a strawman argument which doesn't reflect reality.
I said it's a contrived counter example for a contrived example.
> You can't. I chose HPC deliberately as an example: in HPC performance is the most important constraint.
There are HFT systems using Java, few were on HN even. That said, you might have thought of UHFT, but those use FPGA and ASIC, so not even C/C++ would be really correct.
> You don't know that. They might have looked at spaces and understood immediately that it was an improvement.
I know human nature. What we are used to is what we consider natural/ergonomic.
And for the record ancient Greek and Romans made it point of pride to know where and how words end.
> Wouldn't that support my argument that there's room for different modes of programming, both safe and unsafe?
Well, not really. I'm saying ergonomic isn't universal. Due do mixing with English and other such languages what's considered ergonomic is shifting towards spaces and punctuation.
> It's the most important aspect. Every other aspect is just relevant to how you deliver value.
Ok, I see where you are coming from but I fundamentally disagree. If you prioritize delivering stuff fast (move fast, break things) you'll end up with a lot of broken software, and unmaintainable messes along the way.
Maintainability and safety should be primary motivatiors.
Without safety, your performance gains can be rendered moot point anyway. And without maintability your code performance will slowly rot and die.
I'm not trying to move anything. I've made the consistent argument from the beginning that more language-level safety is not the most important design constraint for all use-cases.
> No it doesn't. Debugging 30k lines is always going to take more than 3/30/300 lines especially when data races are involved.
Yes it does. See HPC use-case.
> There are HFT systems using Java, few were on HN even. That said, you might have thought of UHFT, but those use FPGA and ASIC, so not even C/C++ would be really correct.
The point still stands.
> I know human nature. What we are used to is what we consider natural/ergonomic.
Ok now I suspect you're deliberately waisting both of our time. You can't claim to know what romans thought about spaces.
> If you prioritize delivering stuff fast (move fast, break things) you'll end up with a lot of broken software, and unmaintainable messes along the way.
I never said you should prioritize delivering stuff fast. I said you should focus on delivering value. So if your code is an unmaintainable mess, cleaning up your code is going to be the shortest path to delivering more value because it affects your velocity.
If you're writing OS-level networking code, safety is going to be critical to delivering value because security is paramount to your mission.
If you're writing a game, having direct, explicit, ergonomic access to memory may be more relevant to delivering value than slowing yourself down to make sure you are 100% sure every line of code is safe.
> Maintainability and safety should be primary motivatiors.
Unless they're not. If I'm prototyping a project it might me much more important to get something in front of users to see how they like it than it is to make something safe and maintainable.
Some code is used and built on for years and years. Other code is used and thrown away after it serves its purpose.
The HFT systems I know about in Java are mostly not recognizable as Java to most Java programmers. They use static allocation of all data making sure that there is no risk of a GC interrupt and have a fixed set of threads that have assigned cores.
It is sometimes a reasonable way to build a system, but very seldom.
Why not? Rust has unsafe programming as opt-in; and the unsafe stuff is delimited with language constructs.
A nuanced argument is possible like that situation is better than unsafe computation with no opt-out, requiring very careful programming plus ad hoc tooling.
It’s still early days for Bevy but they’re making steady progress.
Independently of Bevy's progress, a parallel ECS is not a good choice for a prototype-like game project.
On the other hand, is the SNES "The Legend of Zelda: A Link to the Past" style everyone's favourite pixel art style, or is it just me? Without tricks it did 256 colours of of 4096 in Mode 7. You can't do art that's as pretty with four colours. Is it a restriction that's too harsh or are we ok with games that just aren't very pretty?
Asking as Rustecean.
Instead of focusing on tradeoffs they chose to call others irresponsible.
However, what I've seen in the discourse of several programmers that claim to prefer Zig is the assumption that Rust is "not really that big of a deal". There's a constant minimization of the advancements both the ownership system and the safety approach provide, and a lack of recognition for the fact that the language is a "game changer" in the industry.
Overall, this looks a lot like rationalization of an emotional choice, which for me is much more close to religious zealotry.
I think you have inadvertently worded this in a way that silently confirms what the parent poster was saying. But more generally, while I can't speak for the entirety of the Zig community, the people involved with Zig directly tend to be aware of Rust's strengths. The problem is that one of the reasons why Zig exists (and is having some level of success) is because some people just don't want to deal with abstraction-heavy code. Some people value simplicity over a complex language with a memory-safe subset.
And the value of simplicity is not just a matter of aesthetics. Simplicity is a defense against bugs, because memory safety is not the end goal, correctness is.
To quote Douglas Crockford: "If you say it hardly happens, it means it happens".
I totally get it's nicer than C, I love it too, but it's completely irresponsible to push a language without a memory safety story, in 2022, this hard.
From that relatively obvious conclusion it devolves into tedious nerdsnipes. Yes there are edge cases.
It is very much not the consensus that memory safety is a requirement for any modern language. Asserting that it should be a requirement is an extreme position.
Assuming that my argument has "fallen apart", or that you have "dunked" seems quite absurd given that you've taken an extreme position which many serious practitioners and academics would disagree with.
Rust is still very much an experiment in terms of systems programming. It has a tiny overall "market share" in terms of use in large production projects compared to C/C++ and it remains to be seen whether the particular set of tradeoffs chosen by the language will lead to long term sustainable success.
Zig takes another approach and is also a worthy experiment.
I'm not diminishing the success of Rust. It's been proven it can be used for serious projects.
It's a bit of a reach to argue it's proven to be the best choice for all system programming use-cases going forward.
It's especially frustrating because you've received a ton of charity and time from strangers, we understand 110% what you're thinking (I wish it was true! I've had an inordinate amount of work for 18 months now because it isn't) but you can't seem to wrap your mind around the idea that there isn't some niche where Zig is perfect and unassailable or the only alternative is rust. I don't think you have much experience in multiple languages, it's actually fairly easy to get something as fast in JS _as in C_.
It's possible in some cases that you can implement something in JavaScript which is competitive with a systems programming language, thanks to all the incredible optimization work which has gone into JavaScript engines, but the performance ceiling of a language like JS is much much lower than that of system programming languages. For instance, if you are optimizing for memory cache performance C or Rust or Zig are going to have tools which just don't exist in JS. There's a reason that HPC - one of the computing fields where profitability literally depends on speed - is all implemented in C and C++.
And not that it matters but I've got plenty of experience with languages. I've been doing software engineering professionally for over a decade, and I've shipped professional projects in probably a half dozen languages or more including C, Rust, and Javascript. I've also done my fair share of programming in the systems domain, including computer graphics and games. I've also implemented programming languages of my own.
> you can't seem to wrap your mind around the idea that there isn't some niche where Zig is perfect and unassailable or the only alternative is rust.
I never said Zig fits a perfect niche. I said the theory of the language is valid, and it's a worthwhile contribution to the field. Zig, like all other languages, is an experiment. It's actually quite an interesting one with different goals than a lot of the other popular languages out there, and which is very appealing for the systems programming domain. I'm arguing against the idea that Zig is "irresponsible", which is an extreme position.
I keep bringing up rust because of you guys insistence that Rust is a counter-example to the idea that a new systems programming language not necessarily be memory safe. For instance this comment:
> We can't ignore the fact that Rust has shown that memory safety is not incompatible with low-level semantics.
Seems to imply that Rust's existence unto itself is proof that every new systems programming language must be memory safe.
C is the current standards bearer for systems programming. Everyone is trying to invent a "better C". Go and Nim are trying to do it with garbage collection. Rust is trying to do it with the borrow checker. Zim is trying to do it with ruthless simplicity and explicitness.
All of these are experiments, and all of them are valid. 20 years from now we'll know a lot more about what works and what doesn't from each of these experiments, but it's too early to conclude that now.
No, Zig is simply not memory safe. That's a property of a programming language that has a definition. Zig does not meet that definition.
> I find it funny that fans of a language of a not-so-young-age that is struggling to find relevance and capture even 1% of the market are treating it as such an inevitability that it's irresponsible to talk about anything else.
Leaving aside your weird description of a language powering software that serves billions of users as "struggling to find relevance", most software in 2022 is written in languages that are memory safe. Zig is quite the outlier here. It would in fact be very reasonable to survey the landscape of popular languages today and come to the conclusion that memory safety is an inevitability.
> It's also detached from reality, as much of the software we all depend on is being written, in 2022, in languages without sound memory safety guarantees.
Virtually all of that software is being developed in C or C++. The most compelling reason to use those languages is that they have a huge install base and a huge amount of code already written in them. This says nothing about whether a brand-new language should be memory safe.
> There are various approaches being tried for how we should write low-level programs in the future, but there is no consensus yet on the best one.
No, there actually is PL consensus that all new languages should be memory-safe, maybe aside from very low-level specialized languages, which Zig is not trying to be--Zig is trying to be a general purpose language.
I didn't claim that it is. I said it has a good memory safety story, i.e. mechanisms that soundly guarantee some kinds of memory safety, plus a design that helps write correct programs. Correctness in general, and memory safety in particular, are very central concerns in Zig's design, it's just that its story isn't one of sound guarantees across the board but, rather, some balanced mix of approaches -- some based on soundness, others based on facilitating comprehension and easier testing.
> Most software in 2022 is written in languages that are memory safe. Zig is quite the outlier here.
No, Zig is a low-level language, and the vast majority of low-level programs in 2022 are written in languages whose memory-safety story is worse than Zig's.
> This says nothing about whether a brand-new language should be memory safe.
That's right. We don't yet have an answer to that question, because we don't yet have sufficient experience with low-level languages that do have sound memory safety guarantees. I mean, it sure is better to have more guarantees if they come for free, but there's no such option in front of us just yet.
> No, there actually is PL consensus that all new languages should be memory-safe
No, there really isn't one when it comes to low-level languages (and the interest in Zig is proof that there is no consensus that it shouldn't exist). Rust is a low level language with sound memory safety guarantees, which comes at a price that makes it unappealing for some, and so various other approaches are being tried as well.
You can't insist there's consensus when clearly there are people who disagree with you. That's the definition of a lack of consensus. I also think it is premature, to say the least, to declare an approach that is currently still far from proving a success as the only way.
Zig doesn't have mechanisms that soundly guarantee some kinds of memory safety. It's not spacially memory safe: extern unions, sentinel-terminated pointers, and multi-element pointers break it. At best, we think there's probably some subset of Zig that you could define that is spacially memory safe. (This isn't a particularly interesting property because it's trivially true for any language, by the way: C without pointers and without arrays is a subset of C that's memory safe, for instance, and also uninteresting.)
> No, Zig is a low-level language, and the vast majority of low-level programs in 2022 are written in languages whose memory-safety story is worse than Zig's.
Zig claims to be a general-purpose language, not just a low-level one. From [1]: "Zig is a general-purpose programming language and toolchain for maintaining robust, optimal, and reusable software."
> I mean, it sure is better to have more guarantees if they come for free, but there's no such option in front of us just yet.
It's better to have more guarantees if the benefit of the guarantees outweighs the cost, not if there is no cost. For example, for many apps, the benefit of memory safety outweighs the cost of a garbage collector.
> You can't insist there's consensus when clearly there are people who disagree with you. That's the definition of a lack of consensus.
Consensus doesn't mean that nobody disagrees. It means that the opposite position is a fringe view.
It does.
> It's not spacially memory safe: extern unions, sentinel-terminated pointers, and multi-element pointers break it.
We've been through that. Those are syntactically delineated unsafe features for C/hardware interop. Rust has them, too.
> This isn't a particularly interesting property because it's trivially true for any language
That's right, but Zig is much closer to Rust than to C in that regard. It has clearly marked unsafe features for C or hardware interop, which aren't used in other situations and could be mechanically excluded -- just as in Rust.
> Zig claims to be a general-purpose language, not just a low-level one.
Surely you agree it's also a low-level language?
> It's better to have more guarantees if the benefit of the guarantees outweighs the cost, not if there is no cost.
Yep, and we don't know if we're there in low level languages. So far it seems that some people find the cost of Rust acceptable and others do not. In other words, there's no consensus on what the acceptable cost is.
> It means that the opposite position is a fringe view.
So disagreeing that the only right design is that of a language that's struggling to get 1% of the market is a fringe view? That's like a Haskeller declaring that it is a fringe view to disagree that non-strict pure functional programming is the only right way to write programs. I think that Odin and JAI, two other low level languages in development, also don't go down the full memory-safety soundness path. Seems to me to be quite far from a fringe view.
If people aren't buying what Rust is selling -- regardless of how strongly some feel about the justice of its approach -- I think that those of us who care about correctness must explore alternatives, and Zig is certainly a fascinating alternative. It might well be the case that neither Rust nor Zig succeed in the market, but even in that case, both can certainly serve as inspiration for the languages that follow.
And again we're assuming that the ones we went over in the previous thread are all there is. I found some more: @intToPtr, @bitCast, @alignCast. Some of those @ functions are spatially-memory-safe, and some are not: the differences are not clearly called out.
(I'm going to charitably assume that taking a pointer to an element in a dynamically-allocated array, and then shortening that array and dereferencing that pointer, is a temporal memory safety violation rather than a spatial one.)
> That's right, but Zig is much closer to Rust than to C in that regard. It has clearly marked unsafe features for C interop.
How are they clearly marked, when they're neither relegated to a separate section of the documentation nor behind a switch? As far as I can tell, the person who has gone through the most effort to isolate the spatial memory safe subset of Zig is me, in these HN threads.
> So disagreeing that the design of a language that's struggling to get 1% of the market is the only right way is a fringe view now?
Again, "struggling to get 1% of the market" is a weird way to describe a language that's serving billions of users right now.
No one is assuming that. Like Rust, Zig has a set of unsafe operations that are well known to Zig programmers.
> How are they clearly marked, when they're neither relegated to a separate section of the documentation nor behind a switch?
They are syntactically distinct from the safe features, and they might be hidden behind a switch when there's demand for such a feature.
> As far as I can tell, the person who has gone through the most effort to isolate the spatial memory safe subset of Zig is me, in these HN threads.
So not only is disagreeing with you a fringe opinion, you're now the most knowledgeable on Zig's safety, a subject that is of great interest to Zig programmers? Those who spend the two days required to learn Zig know which operations are unsafe.
> Again, "struggling to get 1% of the market" is a weird way to describe a language that's serving billions of users right now.
Haskell and Erlang are also "serving billions of users" in the same way. The fact is that at an age where almost all programming languages (Python might be the sole exception) were in the ballpark of their all-time peak popularity, only a tiny portion of developers choose Rust. Like Zig, Rust is a language whose future success is uncertain.
Look, not everyone would like Zig, not everyone would like Rust, and for all we know it's quite possible that the main difference between the two approaches is that they appeal to different people. But trying to make Rust's design appear inevitable or uniquely legitimate for low-level languages when that language is doing poorly, or claiming to speak on behalf of a consensus where there clearly isn't one and several other languages targeting the same domain prefer a very different approach, make you sound detached from reality.
I find it a questionable choice to design a new complex language when complex languages tend to do poorly in the market, or to attempt a language for low-level programming that tries to appear high level on the page after C++'s lacklustre success with that approach, but I recognise that not everyone has the same taste as me, and I wouldn't call my opinions a consensus.
Which language and which project is this referring to?
This is an extremely strange argument. How much market share do you think C has in 2022?
You seem to massively underappreciate the dominance of the web and the hegemony of languages like JavaScript and PHP. System languages are a very tiny niche and there's much less changes there than in other domains.
Rust has obviously way less than 1% market share but it's still extremely successful in the niche it's targeting. (And btw, we're talking about the only niche that still hasn't embraced memory safety, mainly because there was no acceptable tools for that meeting their requirements)
Extremely successful? It's not even mediocre. A more realistic description of its current position in its niche domain might be "still hanging in there", "not yet completely written off" or "not out of the race but waiting for a miracle."
Rust is barely at 5% of the low-level market. Its performance in its target domain is so abysmal at over seven years old that some who'd want to try it don't because its future looks so uncertain. For comparison, almost every programming language reached or at least neared its all-time peak popularity around age 10. Even if things improve we're looking at a peak of 20% of its target niche before the novelty wears off and other languages join the fray. It needs to double its market share in the next couple of years not to be "extremely successful" but just to stay relevant.
This is an extremely vague claim with so many caveats that it doesn't end up meaning anything yet if you state it confidently you might fool idiots into thinking you said something consequential.
It'd be great if there was all the real competition you seem imagine for Rust, but we don't see that. What we see are people pretending that it doesn't matter if they produce crap software using unsafe languages, but their customers are starting to notice.
As to "crap software", most of application software these days -- crappy or excellent -- is written in safe languages, and nearly all low-level code is written in unsafe languages, including some of the world's most dependable software, from avionics to OSes. We can say with close to certainty that we can do better than C, but we can also say that full soundness (Idris) is not the answer, so the sweet spot is obviously somewhere in the middle. But we really don't know where exactly -- except that it's not at either end -- or even how wide the sweet spot is (or maybe there are multiple ones, which could be either universally equivalent or dependent on some variables).
There's more we don't know about software correctness than what we know -- it's extremely complicated and affected by factors ranging from formal languages and complexity theory to management, economics, psychology, and social psychology -- but we believe noe that the ideas of the 1970s of full soundness being the only path have proven wrong (including an acknowledgment even by Tony Hoare [1]), and, indeed, Rust doesn't adopt soundness fully, and relies on testing, code reviews and other unsound processes as the main means for correctness, like virtually all mainstream programming languages.
Anyone who cares about correctness (like me -- https://pron.github.io) knows to be very skeptical of any claims for absolute answers, let alone simple ones, on that extremely complex subject.
@pron I was with you before: I think pcwaltons' take on zig is ... Err, unduly negative to the point of rudeness and closed minded — and kinda paints a clear picture for why we're seeing all of the defensiveness in twitter from andrewkelly and the zig folks.
But — I think you're coming into it similarly here against Rust. Unnecessarily rude, antagonistic, and on technical points: closed minded.
@pcwalton The zig team feels they've made good pragmatic choices around memory safety? Cool. Leave a few reasons why it's different from/and why rust took another approach and your take. Dope.
@pron The Rust folk are happy and proud of the inroads they've made in adoption. Dope. Sure, there's different ways to slice the numbers and you feel what? They've taken unearned pride in their work?
I'm a fan of all of your work, but man. This thread has been disheartening.
Not at all. I think Rust is a groundbreaking and influential language. Regardless of its success in market, it is a great and lasting contribution to programming language design.
I am, however, triggered by misleading claims about software correctness -- a subject I care deeply about -- which recently tend to come from the Rust community (replacing Haskell), and then annoyed further by claims of inevitability that I find hard to reconcile with the data. Sorry, but I am human :)
The Rust team is rightfully proud of their achievements, in language design, documentation, and also in offering those of us who are interested in software correctness another novel approach to consider.
The idea it's either "Rust or Zig" allows the poorly considered logical jump to Zig. I wouldn't use Rust because it's annoying too, but I also wouldn't choose Zig because I consider part of my professional responsibility to be using...literally any language that has memory safety.
If you think it's your responsibility to use only memory-safe languages, then if you had to do low-level programming, you'd have few option, and those options have their own downsides. That's just the reality of low level programming in 2022 -- it can often only be done in non-memory-safe languages. I actually do quite a bit of low-level programming, and I consider it my professional responsibility to strive to do that in a language that is explicit and simple; there are no languages, to my knowledge, that meet my requirement and are also memory-safe, so I must compromise on something because I live in the real world.
That isn't true. You want to use a language that is more "explicit and simple". That's your prerogative, even if I disagree with it. But you do have a choice, and you are explicitly choosing to reject memory safety.