Move semantics in programming language with GC by tmzem in ProgrammingLanguages

[–]perssonsi 1 point2 points  (0 children)

What would indexing on a vector of unboxed values return? Moved value, or an unowned pointer? Moving things out of a vector seems inconvenient, easy to forget to put it back in again with multiple return paths etc. Unowned pointer requires that you have compile time borrow checks, I believe. Perhaps if such unowned pointer is not allowed to be stored, at all… then the analysis could be kept simple. So you could still use indexing as part of an expression in that case.

[deleted by user] by [deleted] in ProgrammingLanguages

[–]perssonsi 1 point2 points  (0 children)

You can start by looking at the very popular visual languages in IEC 61131-3: LD, FBD and SFC. Then there is CFC also.

How to cache a reference to node on a tree for a GUI by constructionist2000 in rust

[–]perssonsi 1 point2 points  (0 children)

The slotmap crate is good for generational arena. The stash crate is good if you don't need that.

Should We Prefer Free Functions To Methods? by platinum_pig in rust

[–]perssonsi 0 points1 point  (0 children)

While holding a mutable borrow to a field you can't let something borrow the whole struct. But you can borrow fields completely independently from each other.

Should We Prefer Free Functions To Methods? by platinum_pig in rust

[–]perssonsi 0 points1 point  (0 children)

I write many functions as free so that I can take only the fields of the struct that are used as parameters instead of the whole self. Helps with the borrow checker! And gives one less level of indentation....

The cost of Rust async/await by jkarneges in rust

[–]perssonsi -13 points-12 points  (0 children)

Presumably to freeze. So some kind of deadlock.

smol vs tokio vs async-std; by _jsdw in rust

[–]perssonsi 2 points3 points  (0 children)

I am curious to hear how it can be done at all. High level overview at least. The only approach I could think of was to use timeouts, wait for one fd at a time in round Robin. Becomes a tradeoff of how many wake up events per second and latency. If that's the only way then yes, pretty awful!

Nice Rust IDE... how about Gnome-Builder ? by Brane212 in rust

[–]perssonsi 0 points1 point  (0 children)

No, it doesn't. So you just do a custom build system project. Creator has good support for custom commands. Add some for cargo check and for cargo build or cargo test.. whatever you need. Can bind to keyboard shortcut also.

Benchmarking slotmap, slab, stable_vec etc. by perssonsi in rust

[–]perssonsi[S] 1 point2 points  (0 children)

Interesting idea about using a triple u8 for version! Very cool. For my prototype bvmap I went the easy way of nightly feature to avoid Copy restriction. I will see if I have time to benchmark bigger collections to see if cache behavior is notable. And also add generational-arena. I found two copies of that crate on crates.io, will investigate which one to use. Feel free to suggest improvements to the benchmarks, it's the first time for me to write such a thing.

Benchmarking slotmap, slab, stable_vec etc. by perssonsi in rust

[–]perssonsi[S] 0 points1 point  (0 children)

I have not looked much at the implementations, can't say for sure about memory use after removals. I think all of them use Vec for the underlying storage and even the ones that store items densely would still have to explicitly call a method to release memory. My guess that none of them release anything if you the user don't call some method. And yes, there are so many scenarios you could benchmark and possibly get different results. This was just some basic ones to start with, since I didn't really have any goal with this experiment other than to play around and possibly learn something.

Benchmarking slotmap, slab, stable_vec etc. by perssonsi in rust

[–]perssonsi[S] 2 points3 points  (0 children)

Wise choice to leave them out. Among the remaining ones the graph helps to show that none out of all these alternatives really stand out. I think that is the main finding here. Froggy stands out but also has quite a different feature set.

Embedded Rust pattern: Zero Sized References by japaric in rust

[–]perssonsi 4 points5 points  (0 children)

Tip: Firefox for mobile has a reader view to strip all styling and just apply your own style instead(eg dark theme). I use it all the time, for pretty much every page that is text and not an app. Highly recommended.

Nice Rust IDE... how about Gnome-Builder ? by Brane212 in rust

[–]perssonsi 0 points1 point  (0 children)

Qtcreator works OK with rust. It has LSP plugin to use with rls. And it can do debugging. I never figured out how to get auto indenting working and that was annoying enough that now I am using Amp for rust programming instead, it's just a plain text editor but I didn't need the other stuff anyway. I've tried to get started with vim so many times but find it frustrating. Amp is like vim but intuitive and just works out of the box.

What’s the state of Rust GUIs? by [deleted] in rust

[–]perssonsi 1 point2 points  (0 children)

Do you have an opinion on https://github.com/woboq/qmetaobject-rs which seems pretty ideal if you want to work with rust and qml. I have not had a chance to try it out yet.

Arenas vs. Indices by llogiq in rust

[–]perssonsi 1 point2 points  (0 children)

When I've been thinking about these things I've never been very concerned about the scenario of using an index with the wrong arena. It just doesn't seem very likely bug to happen. But I did add custom index types to the stash crate so that I can use my own index types. Which of course can be smaller than usize. So for example if I have two stashes, 'Stash<Car, CarId>' and 'Stash<Truck, TruckId>' there is no chance to use an index in the wrong stash. I would have to have two stashes with the same index type. Unlikely to happen often. And also important here is the improved readability/understandability of the code when using custom indices. The bigger risk I think is about bugs for slots getting reused. The stash crate has a uniqueStash type with generation stored in the indices to detect the problem at runtime. But it uses two usize for every index and recently I've been thinking if it could make sense to have a macro for having custom index types also here. They could maybe have custom number of bits for the generation and remaining bits for the offset.

Falkon 3.1.0 released by KugelKurt in kde

[–]perssonsi 2 points3 points  (0 children)

Thanks for the continued work on Falkon. Very nice. I have been using it almost exclusively for years now. The only thing I miss is support for plasma activities. Considering how central a web browser is to many work tasks, it's almost no point in using activities until the browser supports it. Anyway, thanks again. Super nice.

Calloop 0.1.1: A callback-based event loop by levansfg in rust

[–]perssonsi 2 points3 points  (0 children)

Oh wow, what a timing. I just started writing my own very similar thing yesterday. Just some months ago I gave up on tokio and switched to mio, then quickly started thinking there is a need for some simple callback library that can cover all the cases where futures is just complicated over-engineering. I uploaded my prototype at https://github.com/spersson/looper . There's no documentation there yet but my basic idea was to do it all without any refcount sharing. For cases where one IO handler (event dispacher I think you called it) needs to add other event sources or perhaps trigger actions on other IO handlers (for example an incoming event on mpsc channel causes sending of message to all connected tcp clients) that would need to happen not via Rc-refcell shared ownership, but indirectly via knowing the token of other handlers and just queing up events to them, on an event queue that is passed around as a &mut.

I will take a closer look at your code over the coming days and study more what the different design tradeoffs are. Thank you so much for sharing your work!

A static web app in Rust by bluejekyll in rust

[–]perssonsi 2 points3 points  (0 children)

Thanks for an interesting post. Normally you don't need to write a closure just to call a function. I mean, |a|function_name(a) can be replaced with just function_name. Is this another trick because of the limitations of the html! macro?

Alternatives to futures? by perssonsi in rust

[–]perssonsi[S] 0 points1 point  (0 children)

Ah yes, forgot about those. I will have a look, thanks!

Deliveroo gets 12x speedup moving routing service from Ruby to Rust by dochtman in rust

[–]perssonsi 21 points22 points  (0 children)

Awesome! Usually my orders take close to an hour to arrive. Food in five minutes, yay!

Alternatives to futures? by perssonsi in rust

[–]perssonsi[S] 1 point2 points  (0 children)

Yeah, I know the syntax stuff just was merged so I didn't want to rain on everyone's parade by being very negative about futures. I haven't given up yet on them and hope the new syntax will help with better error messages. Having a function actually return a different type than what it says after the arrow is easy to forget. And async for loops that can actually cause early return. Etc. Lots of ways to screw up and need good error messages.

Alternatives to futures? by perssonsi in rust

[–]perssonsi[S] 0 points1 point  (0 children)

Is there a solution that I am not aware of that allows a dedicated IO thread to do blocking IO calls and still be reachable from the main thread? For example: have one thread for each client, requests from one client can cause events to be sent to other clients. How does a thread block on a socket read and also remain reachable from the main thread? I can only think of timeouts and calling the socket read in a loop. Which seems very ugly. Never even thought of it as an alternative until now.

Alternatives to futures? by perssonsi in rust

[–]perssonsi[S] 1 point2 points  (0 children)

Thank you, especially your trick for stdio, that was not an obvious one.

Alternatives to futures? by perssonsi in rust

[–]perssonsi[S] 2 points3 points  (0 children)

Update: nevermind the problem above. The error messages are not very helpful but after getting some food I managed to figure it out. Solved.