« first day (1827 days earlier)      last day (1664 days later) » 

7:41 AM
posted on October 15, 2019 by The Rustup Working Group

The rustup working group is happy to announce the release of rustup version 1.20.0. Rustup is the recommended tool to install Rust, a programming language that is empowering everyone to build reliable and efficient software. If you have a previous version of rustup installed, getting rustup 1.20.0 is as easy as: rustup self update Rustup will also automatically update itself at the end of a

 
 
3 hours later…
10:15 AM
posted on October 15, 2019 by Mike Welsh

Ruffle is an Adobe Flash Player emulator written in the Rust programming language. Ruffle targets both the desktop and the web using WebAssembly.

posted on October 15, 2019 by David Tolnay

 By compiling macros ahead-of-time to Wasm, we save all downstream users of the macro from having to compile the macro logic or its dependencies themselves. Instead, what they compile is a small self-contained Wasm runtime (~3 seconds, shared by all macros) and a tiny proc macro shim for each macro crate to hand off Wasm bytecode into the Watt runtime (~0.3 seconds per proc-macro crate you depe

posted on October 15, 2019 by Sergey Dubovyk

This year’s #hacktoberfest became a great opportunity for me to start learning Rust. In this article, I will share a couple of tricks about how to start mastering this relatively new technology.

 
@Feeds Oo nooooo
 
@Stargateur in some ways I'm happy about this -- the reason is: I have 4-5 years of Flash stuff I created when I was between 12 and 17. I used Flash when it was a Macromedia product and as a creative tool I loved it. In fact, long before I became a developer I understood the concept of a "callback" registered to an "object" triggered by a certain "event". And those files are on my backup drives, haven't been able to open them..
 
@PeterVaro still an adobe thing
 
@Stargateur Yeah, Flash became an Adobe thing 15 years ago, what about it?
 
11:01 AM
> We’ve been hard at work on the next major revision of Tokio, Rust’s asynchronous runtime.
ffs I appreaciate what they are doing but I hate smug attitude -- "an asynchronous runtime written in Rust"
 
11:27 AM
@PeterVaro eh?
 
11:37 AM
There are other asynchronous runtimes
albeit less popular
 
and not blessed by the core Rust team...
 
 
1 hour later…
12:47 PM
@PeterVaro wut ?
 
1:06 PM
I'm reading about actor model: the wikipedia article states that is obviates lock-based synchronization. How is it possible? It can modify its own state, and several messages can arrive at once due to multithreading, thus there must be a synchronisation mechanism somewhere, doesn't it?
Maybe that's a good SO question, but I'm not sure about it :P
 
Several message can arrive at once, but not always be handled. What's inside an actor isn't part of the model
 
What do you mean?
If the actor receives several messages at once that require to mutate its state, how does it handle it?
 
The synchronization which matters is of the external state, which is simple because there's only messages between them, and nothing shared
 
I'm definitely speaking about the inner state, the actor's.
 
Then yes, there's often the need for some buffered queue, with synchronization, but it's private, it doesn't go out of the actor
and you're free to magically handle everything in parallel, I guess
 
1:11 PM
Huh, so that's a lie that the actor model doesn't need synchronization. Or that's only about the user's perspective
 
The point is there's no common synchronization, no shared state, which is where you usually find the synchronization bugs
 
Yes, no shared memory.
A synchronized queue can be lightweight AFAIK tho
 
@FrenchBoiethios most actor system message ingestions are concurrent, not synchronous
akka is notorious for this
 
@FrenchBoiethios yes, I'd read it as from the perspective of the person "filling in" the actor's guts
I'd just write a loop like for msg in mailbox { ... } which doesn't require me to think about the locking or other details
 
1:48 PM
@Shepmaster You don't even need to do that, the method that receives the message is called and that's all
@SébastienRenauld How does it work, tho?
For example, if you have an actor with an int field and a method increment, how do you handle concurrent calls to that method without synchronization?
 
@FrenchBoiethios note that it also says "lock-based synchronization"
I don't think either you or the article are incorrect, there's just some terminology nuance difference somewhere
 
@Shepmaster In the akka language, you mean? I didn't find this information
 
@FrenchBoiethios In any language.
One can have synchronization without locks
e.g. atomic variables do not use locks
and the whole class of "lock-free" types
but yes, there's still some kind of synchronization
 
@Shepmaster Ohh, that's it. The messages queue is synchronized, but with a lock-fre mechanism, I guess
@Shepmaster I guess so, magic isn't still a thing in IT :P
 
there's also the aspect that the person filling in the actor implementation doesn't have to worry about the synchronization, it's been handled by the actor framework
If I don't have to worry about the synchronization details, that's good for me
 
2:00 PM
@Shepmaster That's the ergonomic/correctness aspect of the things, but there's also the performance aspect, and the implementation details matter in that case.
 
@FrenchBoiethios they might, depending on usage (size of / number of messages, for example)
 
Anyway, I was asking those questions before I was looking at the Pony language. Definitely an interesting language.
I wonder what Rust would have looked like with explicit actor constructs
 
2:17 PM
@FrenchBoiethios have you looked at their playground? ;-)
 
@Shepmaster déjà-vu :D
 
@FrenchBoiethios wall of text inc.
 
@SébastienRenauld ?
 
@FrenchBoiethios about the actor model, I bet ;-)
 
The wikipedia article?
 
2:23 PM
The way the akka actor model is designed is such that akka takes care of the inter-actor synchronization, but requires multiple assumptions to be true. From memory:
- `receive()` must be sequential (to the point that the `receive()` method on every actor and everything it touches can be considered single-threaded)
- `receive()` must not block its thread (this is because this is actually run by the dispatcher)

In turn, this solves a ton of synchronization problems in between actors - you pass messages around through akka, which handles the mailbox concurrency issues (a mailbox is a buffer t
 
@SébastienRenauld True.
 
That's from memory, some details may not be entirely accurate but the general gist of it is there
a mailbox effectively turns into a message queue and your actor as a transactional consumer. Message comes in, you do stuff, you end the "doing" and it is considered "received" by the dispatcher
 
Ah. "inc." as incomming. Do you know that it can mean "incorporated" as well?
Thanks for the explanation
 
and "increment"
 
I've used it for "includ[ing/ed]"
 
2:30 PM
Also.
 
not that abbreviations have much rhyme or reason, but if I were to shorten that I'd use "incl."
 
In a massive win for consistency, I think I've written it both ways. Maybe even in the same couple of lines.
 
The lesson here is to save time by spending the time to write it out
 
2:58 PM
@PeterHall @Stargateur the wording: "Rust's async runtime", it is a runtime written in Rust, it is not "Rust's"
 
@PeterVaro AFAIC it's the definitive runtime and non-expert users should not be distracted by any alternatives.
It's not arrogant. It's just how it is.
 
Yup. And right now the primary alternative would be for embedded worlds, AFAIK
 
It's not just an async runtime, is it ? Can it be embedded in wasm for example ?
 
@Shepmaster not even
 
for tc in 1.0.0 1.2.0 1.4.0 1.5.0 1.12.1 1.14.0 1.15.1 1.16.0 1.17.0 1.18.0 1.19.0 1.20.0 1.21.0 1.22.1 1.23.0 1.24.1 1.25.0 1.26.2 1.27.2 1.28.0 1.29.2 1.30.1 1.31.0 1.31.1 1.32.0 1.34.0 1.35.0; do
    rustup component remove --toolchain $tc rust-docs
done
Ahh, bliss
 
3:02 PM
well, depends on your definition of embedded, some people talk about embedded linux
 
@PeterHall meh :)
 
@SébastienRenauld My specific meaning is for the AVR
@DenysSéguret do you mean can Tokio be embedded in WASM? If so, I think the answer is no. I expect that in browser land, you'd want to use the browsers / JavaScript's executor. In bare WASM, you'd be close to the embedded usecase again, but I don't know enough about WASM to know how you would do that...
 
I guess by embedding a simple light executor, just like you embed a simplified allocator ? That's why I reacted to tokio being said to be THE executor
 
@DenysSéguret well, for bare WASM, I was thinking that I don't know how you'd ever do a wakeup notification. AFAIK, WASM doesn't have threads (yet?) or interrupts
 
I won't try and answer this until I venture more into rust async model ;)
 
3:13 PM
@DenysSéguret certainly, but Why is my Future implementation blocked after it is polled once and NotReady? might give you just enough background on my point.
 
But would you say that today if you want to use the async/await model in a rust application you almost inevitably use tokio ?
 
@DenysSéguret that will be extremely difficult, and yeah, shep is right. that's all you need for an executor
the hard bit with wasm will be emulating what is effective epoll/select
not inevitably. I have no_std futures running on a rt8710
rtl8710*
that means no tokio
 
Do tokio need OS threads ? I mean, the golang executor can work with only one real thread if you want
 
tokio specifically, and some operations require them specifically as well too
if you want a good example of single-threaded OPness, check node
 
@SébastienRenauld node is a little cheating, as you have one user thread but all the scheduling and real IO is done in separate threads (and not in JS)
But goroutines can run with only one thread (of course there's less parallelism)
(I guess most of my questions will be answered the day I dive into rust async/await, I should not waste your time on my silly questions)
 
3:20 PM
I strongly doubt go does not cheat on I/O
as the underlying I/O is blocking
that or it busywaits like an alcohol addict in a wine bar
I knew it. Golang's scheduler does the same trick node does
 
@DenysSéguret While Tokio needs OS threads, Rust's Future abstraction does not.
But when a future says "I got nothing for you", something will generally inform the executor later "hey, go back and check it again"
 
@Shepmaster Yes, I got that. So there might be some room for some lighter executor, for embedded or wasm if the future model is to become the Rust norm
 
That builds the most basic executor possible
And as mentioned in the last paragraph, a next step could be to loop over the future forever
polling the future over and over
so you would have a process using 100% CPU
which could be fine for certain embedded systems, but is unlikely to be good in most cases
 
@Shepmaster processor-specific
 
panic!("This executor does not support futures that are not ready") :'D
 
3:34 PM
on a call, can explasin in 5. typing one handed is hard
 
@FrenchBoiethios // TODO make useful ;-)
 
I wonder if a very small functional executor can be made
 
@FrenchBoiethios define functional :-)
You could take what I have and add os threads and mutex and it would work.
 
@Shepmaster I was thinking of something like that.
 
Okay, done
If you want to make an executor and you want to make it single-threaded and concurrent you're going to need full control of the underlying I/O
on #[no_std] that's a perfectly fair assumption BTW
you can then spinlock your way to victory
it is evidently less efficient than if you had threads, but it works nicely
Thinking about it, there's a ton of stuff you can do with this method. Operating a SPI bus is np, for instance, since that's host-driven
you're going to struggle on anything where the clock isn't driven by the host, since you won't be able to control it
 
4:04 PM
0
Q: Allocate large struct from mmap using MALLOC_MMAP_THRESHOLD_

Gurwinder SinghI have a big struct (~200Mb) that I deserialize from a large JSON file using serde_json and this deserialization occurs again when new data is available. The struct has vecs, hashmap of strings and structs of strings etc. while looking at http://man7.org/linux/man-pages/man3/mallopt.3.html, I f...

My head
It hurts
 
 
2 hours later…
6:16 PM
small question, amid the big conversations here,
in let x = "kjadnhsf";, what is the type of x?
is it string or str
 
from what i understand, str is just utf-8. So if i do this,
```let s = "Hello world!";
let char_vec: Vec<char> = s.chars().collect();```
does it get converted to String type? how is it that i am able to call chars on a utf8 bytes
 
199
Q: How do I print the type of a variable in Rust?

user2431012I have the following: let mut my_number = 32.90; How do I print the type of my_number? Using type and type_of did not work. Is there another way I can print the number's type?

@illiteratewriter SO chat doesn't handle mixed code and prose. You'll want to put the code in a separate message and use the "fixed code" button that will appear once you have multiple lines
@illiteratewriter It does not get converted to a String. A String also contains UTF-8 bytes
 
@illiteratewriter not entirely sure what you're asking; there is no string conversion there
 
327
Q: What are the differences between Rust's `String` and `str`?

Daniel FathWhy does Rust have String and str? What are the differences between String and str? When does one use String instead of str and vice versa? Is one of them getting deprecated?

 
6:27 PM
a Vec<char> is not a string; a Vec<char> does not have to be valid utf8 also, so &str -> Vec<char> is perfectly fine
the opposite direction would be worthy of a Result
 
@illiteratewriter The chars iterator walks over the UTF-8 bytes and constructs chars.
 
BTW @Shepmaster, still testing the waters on this idea; how would you feel about a self-hosted registry with similar features to docker hub?
 
And String::chars is actually &str::chars; through the magic of Deref.
@SébastienRenauld We wrote a large chunk of it at I32, but went for hosted instead. Then GitHub said "hey we are gonna do Rust registry any day now" and we had a baby, so let it sit on the side.
 
"any day" huh
;-)
 
@SébastienRenauld self-hosted would probably make certain classes of companies very happy.
 
6:30 PM
Should be able to protect it through sensible licensing tbh
to, i.e., prevent Amazon from doing what it did to elastic
(All this while allowing people to just host their own, even in a corporate environment)
 
One nitty-gritty detail I haven't figured out is what is the right way to distribute such things and handle upgrades
Once you do self-hosted, then the support burden seems to go up.
I'd guess that in the current world, shipping a Docker container is probably the easiest
 
That was the way I was going to go about it
create a Dockerfile template for all major archs, build the container for each, call it a day
I'm more curious about the scope of things, though. For instance, I really want to be able to effectively "base" a registry off, say, crates.io and add a few packages
but then there's no limit to how much you can do if you have that mechanism
you could then have user B effectively "fork" my registry and also add a few
 
I think the normal phrasing is a pass-through cache
Cargo's multiple registry support should handle this
I'd say to run two instances of the software
one in passthrough cache mode for crates.io
one in "my own crates" mode for private stuff
 
6:46 PM
That's somewhat what I had in mind
 
crates published to the second instance may access stuff from crates.io
 
Waiting for the malloc dude to join chat; his question is potentially very complex
 
and developers / CI / whatever configure to use the first instance as crates.io
 
There may be legitimate cases to block out crates.io for a specific crate
 
what do you mean by "block" here?
 
6:48 PM
take a good example, a certain lib I built professionally requires a modified version of a crate used as a transitive dependency
probably won't happen often but it's a possible case
I have an A -> B -> C dependency where A is hardcoded to use a version of B and I'd like all the features of B but it comes with a hard dependency from C to (in this case) systemd-udev
and that's a no-go
 
so you'd publish the modified version to the "my crates" instance and then use Cargo's [replace] to replace all instances with the modified one
would you implement the block on the cache instance just to prevent people from using it accidentally?
 
Would have to be done on every run of CI, which kinda sucks
I was thinking of allowing a pass-through with as many layers as needed, i.e. my crates -> my other crates -> some dude's crates -> crates.io
 
I don't follow; why wouldn't it be commited in the Cargo.toml?
 
Is there a way to mask a crate when it is being referenced by a third-party crate by version?
(When you have no control over said third-party crate and would rather not have that as a managed dependency either)
 
I'm still not following...
You'd have
[patch.crates-io]
uuid = { registry = "mine", name = "uuid" }
"anything that asks for uuid from crates.io, get it from this other registry instead"
(syntax not tested, but that's the gist)
 
6:59 PM
Does require specifying this outright in one or more Cargo.toml files depending on the project though
 
Yep, but isn't that a good thing for reproducability
 
It is, until you need to replace registry = "mine" with registry = "yours" across everything ;-)
 
@SébastienRenauld It was a point I brought up (IIRC) in the multiple registries RFC, but it seemed small enough.
Any private registry is likely to be able to just tell all their users "call it this".
 
I know, but I'm going to break him in gently on that
I don't think he knows
however, he has the right mindset and a decent approach so I'm more than happy to coach him through
 
That's just me in the wrong window
 
7:07 PM
I like questions like that, and problems like that in general
helping people find solutions is something I dearly miss
 
You have not
 
The actual data storage for the indexing is all in memory, loaded from JSON, which is why I was amused by the multiple comments of "200MB is soo big"
 
I'd laugh but the 23-node sphinx cluster taught me not to
that was fun
 
I mean, I also know that a real implementation would need the fancy backend, it's just that this doesn't yet
 
7:28 PM
Having a proper look; does sound like something fun but I'd see it more for "weirder" languages
 
@SébastienRenauld So there's two relevant parts. One is Strata itself (not Strata Rust).
That's the underlying tech that allows for some interesting query types
 
I was looking specifically at that
 
Then Strata Rust is intended as a demonstration, as programming languages naturally have the nesting
 
Three obvious questions
 
"obvious"
 
7:35 PM
1. Why did you have to invent your own DSL? :-(
2. I'm seeing what is effectively 2-grams; possibility for more?
3. On strata-rust itself, what if I want to search for a code block containing a variable defined outside the code block. Right now, from what I'm seeing, I don't think that is possible due to effectively lack of sub-documents; correct?
 
The DSL being the command-line query language? If so, that's just supposed to be something that maps directly to the underlying operations. I'm unaware of a better DSL. It's effectively a Lisp expressed as JSON.
 
I'm about to inherit something very similar in JS - github.com/weixsong/elasticlunr.js/commits/master
I spent a month decoupling the DSL from the actual implementation in order to be able to swap them
the advantage of having a DSL that is already out there is that, effectively, all the tooling built for it would also work out of the box; for that project I went with elasticsearch's query DSL, since it felt natural
This might also be a case for it unless you add more exotic operations (and the idea on #3 might be worthwhile, not necessarily for rust but if you ever decide to branch out into another language)
 
I think I'd always keep what I have (more-or-less) as it's really a debugging console.
I wouldn't object to a nicer DSL (and eventually maybe some kind of human-language query parser)
but those are non-trivial and hard, respectively
Re: 2-grams; can you provide an example?
 
A follows B requires you to store that association in some way
the way most full-text search engines do it is by storing [A, B] as a token (i.e. N-grams, well, 2-gram in this case)
it's a trick that is extremely useful to index and search Chinese (2-grams) and japanese (3-grams) text, for instance
I saw the Follows operator definition so I assumed that was in place
 
Ah, gotcha. Nope, that's part of the interesting implementation. You can do A -> B -> C -> D -> ...
and "document containing (A followedby (B and C))"
which would be order independent for B/C
so ABC and ACB
 
7:49 PM
Interesting choice of implementation
 
And your point 3, something like
let foo = 4;
{
    drop(foo);
}
Is that what you mean?
 
Yeah, that'd be a good example
 
I'm not 100% on how exactly it would work, as at some point there needs to be a "join" like thing.
you could do (both code_block (containing (variable_usage foo) (not_containing (variable_declaration foo))
which hard-codes "foo"
 
I'd split the documents
as in, make a document be a lexical block
 
you can choose what unit you want to return (and in strata-rust, what unit you highlight)
but I'm not sure how that would help this case.
 
8:06 PM
I was thinking of languages where you can accidentally leak or create globals
 
I mostly don't know how to say/implement
"for each variable V used in a code block"
as part of that single query
By itself it's easy: (contained-in variable-declaration code-block)
 

« first day (1827 days earlier)      last day (1664 days later) »