Readit News logoReadit News
rom-antics commented on Zig: The Modern Alternative to C   infoworld.com/article/368... · Posted by u/mkrasnovsky
kaba0 · 2 years ago
Which is absolutely not solved by assigning it to _ neither, if anything it will just make the variable appear used in syntax highlighting and that will make me forget to properly use it!

IDEs just gray out the unused variables and that is an 1000x better way of handling this issue.

rom-antics · 2 years ago
I agree. I gave Zig a fair shake, even went so far as to find the compiler PR that automatically adds `_ = foo` to your source code while compiling[1] and set up the VSCode extension with autofix. I couldn't get used to seeing the lines with `_ =` appear and disappear all over my code while I was typing.

With the usual warnings approach, you can rely on compiler/IDE/pre-commit tooling to find unused variables - they'll all nag you until it's fixed. With Zig's autofix approach, those problems are immediately silenced and you don't have any help from the compiler or tooling to find unused variables. It's quite an ironic outcome if you think about it.

[1]: https://github.com/ziglang/zig/pull/12803

rom-antics commented on Yyvette's Bridal   yvettesbridalformal.p1r8.... · Posted by u/Nition
rom-antics · 3 years ago
Yvette and Ling would be perfect for each other. https://www.lingscars.com/
rom-antics commented on Getting Past “Ampersand-Driven Development” in Rust   fiberplane.com/blog/getti... · Posted by u/emschwartz
eternalban · 3 years ago
Came to say the same thing. Rust requires explicit annotation of usage semantics. This information somehow has to get conveyed to the compiler and runtime. So the 'ergonomic' issues are fundmantal.

I think from a PLT perspective, the interesting question is 'can the problems Rust is supposed to solve be resolved in a simpler (but radically different) conceptual model'? We started off originally with a spatial conceptual model -- stack, heap, scope -- that mapped lifecycle semantics to spaces and transitions between spaces. Concurrent programming stressed out that model and we're here with explicit mapping of semantics by the programmer. I've been wondering lately whether a new spatial approach can yet again simplify matters.

rom-antics · 3 years ago
> I've been wondering lately whether a new spatial approach can yet again simplify matters.

I've been closely following the development of Vale since I first saw it here. Though their approach is slightly higher-level than Rust and requires (some) runtime safety checks (though to be fair, so does GC).

https://vale.dev/

https://verdagon.dev/blog/zero-cost-memory-safety-regions-ov...

I think it would be tough to change the spatial model in a language as low-level as Rust, because that spatial model is just reflecting how your CPU actually works under the hood. If you try to hide that away, the programmer is going to end up losing some control.

rom-antics commented on Getting Past “Ampersand-Driven Development” in Rust   fiberplane.com/blog/getti... · Posted by u/emschwartz
iandanforth · 3 years ago
This is a great post demonstrating just how bad the ergonomics of Rust are (I know I know, that's not the point of Rust). But for people who care about language usability you can point to this post and say "they were not thinking about the user journey during the design process, how would you have designed it differently?"

Take the first two sections as a perfect example. You decide you want to introduce a single-character control symbol `&` (which is questionable by itself), how do you apply it? In one case you decide that this control symbol indicates that a value is immutable and in another it's part of the declaration of a value as explicitly mutable. You've now introduced a semantic contradiction that a learner has to overcome.

Now obviously Rust works, and that's its point, and people love that enough to overcome all the ergonomic challenges the language puts up. What I can't wait for is Pythonic Rust where we have a language that treats humans as first class citiziens but offers the guarantees that Rust does. The only question in my mind for if this will ever happen is if the fully literate programming modality enabled by LLMs will make it a moot point.

rom-antics · 3 years ago
On the other hand though, it brings symmetry to types and values, and makes destructuring feel natural.

  let i: i32 = 1;
  let &i: &i32 = &1;
  let &mut i: &mut i32 = &mut 1;
  let (i, &mut j): (i32, &mut i32) = (1, &mut 2);
I'm not sure how you'd recreate this symmetry without using the same symbol in both places.

rom-antics commented on Battery-free Game Boy (2020)   freethegameboy.info/... · Posted by u/thunderbong
rom-antics · 3 years ago
When I was a kid I had a toy electronics kit and one of the circuits was an AM radio that worked without batteries. A normal radio station signal is strong enough to drive a pair of earbuds without any additional power. Since then I've always wondered if you could harvest that same radio energy to power other things without batteries, maybe even a Game Boy. There's electromagnetic radiation in the air all around us. And I'm sure you could build a Game Boy using today's tech that's much more power efficient than the ones from the 90s.
rom-antics commented on Who owns private home security footage, and who can get access to it?   politico.com/news/2023/03... · Posted by u/thunderbong
shapefrog · 3 years ago
You could still be served a court order to hand over the footage, it is just a couple of steps harder than the one stop shop that is Ring / Amazon.
rom-antics · 3 years ago
You mean due process? Sounds great, sign me up!
rom-antics commented on Zig as an alternative to writing unsafe Rust   zackoverflow.dev/writing/... · Posted by u/zackoverflow
foldr · 3 years ago
One random thing that bugs me about Rust's syntax is array initialization. In Go I can initialize an array (or strictly speaking a slice) of structs like this:

    var foo []my_struct = {{"foo", 1, "bar"}, {"foo", 1, "bar}, ...}
This is often useful in tests (where each struct value represents a test case). Rust doesn't seem to offer any similarly compact initialization syntax for arrays or Vecs. You have to write some abomination like this:

    let foo = [MyStruct{a: "foo", b: 1, c: "amp"}, MyStruct{a: "bar", b: 1, c: "fff"}, MyStruct{a: "amp", b: 1, c: "aaa"} ];
Sure, it's more explicit. But even if I add a type annotation to 'foo' specifying the array type, I still have to repeat MyStruct for every member.

rom-antics · 3 years ago
If you want compact, use an array of tuples:

  const foos = [("foo", 1, "bar"), ("foo", 1, "bar"), ...];
  for (str1, num, str2) in &foos {
      // ...
  }
For a proper struct you have to name the fields, because otherwise refactoring the fields could cause struct instances to silently get out of sync with the definition.

rom-antics commented on Discord, or the Death of Lore   ascii.textfiles.com/archi... · Posted by u/pabs3
jhgg · 3 years ago
Because it would be obscenely expensive (in terms of computational resources) to search history via grep. Hence why we use an inverted index.
rom-antics · 3 years ago
This is megabytes (at most) of text we're talking about, not gigabytes. And ripgrep is absurdly fast. Grepping a 5MB text file should be pretty much instantaneous.
rom-antics commented on Discord, or the Death of Lore   ascii.textfiles.com/archi... · Posted by u/pabs3
Panzer04 · 3 years ago
It’s a little unsettling to think about how much information and knowledge is being locked up in walled-garden servers on discord, basically unsearchable (discord has a search feature, but it’s pretty awful). There’s so many communities that end up moving to it because it serves their most engaged members so well, but it’s terrible for everyone else.

For example, “Voron” 3D printers are an awesome open-source design, but more and more I am directed to their discord to ask questions - many of which were, in all likelihood, asked dozens of times before. It’s great for their engaged members, who are all super helpful - but if it’s a reddit thread I can get my answer almost immediately, rather than asking, waiting and consuming someone else’s time for trivialities.

Sites like reddit at least can be readily searched from a conventional search engine, and can be crawled and stored externally in a pinch. Discord has its place, especially for game communities or other such personal things, but I’m not sure it’s ideal compared to a conventional forum as time passes and more information is built up and either lost or hidden away.

rom-antics · 3 years ago
> discord has a search feature, but it’s pretty awful

Their search makes me want to pull my hair out.

Why can't I just search the history with grep? That's a feature I would pay for (if anyone at Discord is reading this and wants my $10/month)

u/rom-antics

KarmaCake day1034February 15, 2020View Original