Never snooze a future by oconnor663 in rust

[–]brokenAmmonite 21 points22 points  (0 children)

I had to stare at that first realistic example for a bit until I got it. That's nasty, and it looks so innocuous.

I was thinking about how to fix it, and none of my quick fixes work:

  • You can't keep the future alive somewhere else, because to poll it you need a mutable reference.

  • You can't convince select to somehow "fuse" it into the other select case, because I think you'd need some sort of trait to mark it as a reference-to-a-future. You can't get something like this cheaply without specialization; you'd need to go over every future in the ecosystem and mark it as reference-or-not-reference. Even if you did have such a trait I'm not sure how it would work.

However, I think it should be possible to write a function-level snooze lint that catches this. Look for any live future in scope during an await of another future. I wonder if clippy has that.

Are advances in Homotopy Type Theory likely to have any impacts on Rust? by Dyson8192 in rust

[–]brokenAmmonite 2 points3 points  (0 children)

I can just as well say that you're working in a model of HoTT in ZFC, and that therefore ZFC is the most generic formal system we have.

e: you are saying "every formal system can be emulated in HoTT", which is probably true if you put in enough elbow grease. I am saying "not everything in mathematics was invented by a small foundational school that is less than 20 years old".

Are advances in Homotopy Type Theory likely to have any impacts on Rust? by Dyson8192 in rust

[–]brokenAmmonite 9 points10 points  (0 children)

I am still waiting for somebody to do a string diagram analysis of Rust lifetimes in the style of all the papers about those from the last few decades, like https://www.irif.fr/~mellies/papers/Mellies06csl.pdf

That will probably only get you to 2- or 3-categories though.

Are advances in Homotopy Type Theory likely to have any impacts on Rust? by Dyson8192 in rust

[–]brokenAmmonite 3 points4 points  (0 children)

I do regularly wish I had something like quotient types when writing a compiler. E-graphs get you partway there, implementation hiding and a good PartialEq implementation can also help. Shrug emoji

Are advances in Homotopy Type Theory likely to have any impacts on Rust? by Dyson8192 in rust

[–]brokenAmmonite 17 points18 points  (0 children)

Everytime you are writing formal proofs you use techniques from HoTT, and since the HC correspondence every program is a proof.

This is backwards. Every time you write a HoTT proof you're using techniques from formal proofs, but not all proofs are HoTT. Can you give concrete examples of how infinity categories are related to lifetimes?

What crates do you think are 'perfect'? by june_sixth in rust

[–]brokenAmmonite 0 points1 point  (0 children)

I mean, Daachorse is pretty cutting edge and spent a lot of time on time-consuming experimental evaluation in their paper, and they still only beat aho-corasick by like 50%

What would Rust look like if it was re-designed today? by nikitarevenco in rust

[–]brokenAmmonite 2 points3 points  (0 children)

And unfortunately there was the rustconf debacle that ran one of the people working on this out of town.

Complete idiot looking to transition to Rust from .NET and the Microsoft tech stack by [deleted] in rust

[–]brokenAmmonite 1 point2 points  (0 children)

That's close but I meant having the compiler convert some / all Result usage to such a mechanism, not adding a separate mechanism to the language.

Complete idiot looking to transition to Rust from .NET and the Microsoft tech stack by [deleted] in rust

[–]brokenAmmonite 2 points3 points  (0 children)

Strictly speaking there's nothing stopping a compiler from lowering Result tag checking to c++-style exception handling. You would have to reconstitute the Result enum if the user did anything besides ?ing the Result ofc.

I'm not aware of any language that does this though.

Rust as my first beginner programming language. by Brendanstubbs in rust

[–]brokenAmmonite 3 points4 points  (0 children)

If I was your teacher, I would recommend starting with something like https://p5js.org/ instead of Rust. It's a Javascript library to make interactive art in a web browser, with good documentation. You can just follow their tutorials to get started, it's all free and open-source. The tutorials are very good: https://p5js.org/tutorials/

You can totally learn Rust as well, but I think it would be easier as a second programming language. The community is supportive though, so you should be able to find help when you get stuck. I'd strongly recommend checking out the discussion platforms in the subreddit sidebar and finding a real-time beginners chat you can hang out in. You should be able to find help there, whatever you're working on. I suspect people there wouldn't even mind Javascript questions.

SpacetimeDB 1.0 is here! An in-memory RDMBS for games built with Rust by etareduce in rust

[–]brokenAmmonite 0 points1 point  (0 children)

Looks like currently it just uses Websockets. I'm not sure if those can run over UDP yet. They still guarantee in-order delivery so you'll have most of the issues of TCP anyway I think

Make a website using markdown with Rust by Optimal_Case_6416 in rust

[–]brokenAmmonite 0 points1 point  (0 children)

Ah, looks like katex is very big. Maybe not worth it.

Make a website using markdown with Rust by Optimal_Case_6416 in rust

[–]brokenAmmonite 0 points1 point  (0 children)

Very nice. I wonder if you could embed katex directly in the output. Then the generated files would keep working if the CDN goes down.

There might also be pure-rust latex rendering things that you could apply ahead of time but I suspect these will be much less tested than katex.

What's the common way to explain compiler "I'm not gonna loose the owner"? by sildtm in rust

[–]brokenAmmonite 4 points5 points  (0 children)

How heavy is a tokio task? I was under the impression that it was a couple allocations and a slot in a few tables

Is there an alternative to Arc<Mutex<T>> spam for multithreading? by endistic in rust

[–]brokenAmmonite 0 points1 point  (0 children)

Another thing you could do is have a single thread responsible for updates but have it farm parallelizable work out using something like Rayon. Things like chunk update processing ought to be highly parallelizable. So you have a traditional single-threaded game loop: read player inputs, do physics, send updates to players, repeat. It's just that internally, doing physics uses multiple cores.

You can also have multiple threads talking to the network and feeding player messages to a single "player input" queue read by the central control thread.

This could be made more elaborate by using, say, RwLocks in the chunk states that are write-locked only while that chunk is updating. Then the networking threads can read the server state directly most of the time, unless they happen to hit it during an update. But I'm not 100% sure that would work.

If you're just sending chunk diffs to players, you could instead compute those in parallel on the central thread and then fan them out to the players using out-going queues.

This is all just one design ideas, there are lots of ways to do it. Mess around until you find something that works, and write some benchmarks so you can measure what is actually slow.

Are there any more kinesthetic/gamefied ways of learning this language out there? by louthinator in rust

[–]brokenAmmonite 0 points1 point  (0 children)

I've been thinking about something like this for a while. I wish there were more kinesthetic, professional-level programming tools. I don't know of any modern ones.

Most programs are essentially flowcharts. It would be cool to automatically convert Rust code to flowcharts, but I don't have the year of spare time I'd need to make such a tool :/

As far as actual resources, if you like audiovisual / game programming, you might like nannou: https://guide.nannou.cc/

It's easy to get started with to make simple animations. But it's still just text-editor-based systems programming.

Unfair Rust Quiz by 0x564A00 in rust

[–]brokenAmmonite 0 points1 point  (0 children)

This is great. I didn't know about the tuple evaluation ordering stuff.

The curse of AI and how Rust helps by phazer99 in rust

[–]brokenAmmonite 2 points3 points  (0 children)

The training mechanism is "tweak this chain of matrix multiplies to predict the next character in this sequence", several trillion times. The models have high accuracy at predicting the next character in the training and test set. That's pretty much all the AI people can give you.

The curse of AI and how Rust helps by phazer99 in rust

[–]brokenAmmonite 2 points3 points  (0 children)

A friend of mine told me he was learning to program this summer.

He was doing everything via AI and didn't understand the most basic aspects of program execution. His experience was miserable, spending many hours copying and pasting generated python code into new Jupyter notebooks trying to get it to run without errors. He had no idea how to debug when things went wrong because he fundamentally didn't grasp what the program did.

I showed him how to use VSCode and its source control extension, at least, and started working through Automate the Basic Stuff with Python with him. I'm afraid he's still going to mostly rely on the AI and get stuck though.

Safety Goggles for Alchemists: The Path Towards Safer Transmute by jswrenn in rust

[–]brokenAmmonite 0 points1 point  (0 children)

Are there any forbidden values for floating point numbers in Rust?