« first day (1878 days earlier)      last day (1601 days later) » 

12:00 AM
To elaborate: I had originally linked the user to a related question that did not answer their question directly, but found two later. So I'm not saying it's a dupe of the first one I linked in the comments, but either of stackoverflow.com/q/46829539/3650362 or stackoverflow.com/q/55868434/3650362 work IMO
 
 
6 hours later…
6:21 AM
@loganfsmyth Yes I initially thought it sufficient to urlencode the data (instead of json encode). However, it seemed I have to set Header as well.
 
If your server supports JSON body data, you could also avoid the extra step of URLEncoding, but it depends on what the server API expects
 
 
3 hours later…
9:47 AM
Does it make any sense?
It is a no_std environment, but my team import most of the core libs, and some of the alloc::*, so I have alloc::vec to use. Thank you for your reply! 🙏 — Jimmy Chu 3 mins ago
 
9:57 AM
:48026891 What is the point to remove String but keep Vec?
 
nano optimization perhaps, if they think it bloats their binary ?
 
Oh maybe, that's an explanation
 
But given OP had to ask for such an easy computation, I guess their choice should not be considered sane a priori
 
You've got a point :P
 
I mean... who goes to such lengths as to strip String and then isn't able to go from ['1', '2'] to 12 ?
 
10:07 AM
However, OP is maybe a beginner and the team has some more experimented developers who did those choices
 
I guess so but this team looks ill managed if he asked us
 
10:57 AM
@DenysSĂ©guret Somebody coming straight from C
that's the most likely explanation in this case
 
 
1 hour later…
12:10 PM
@FrenchBoiethios what it doesn't make sense is a coder that doesn't know basic math :p
and yes I think this stupid
either you keep std or not
 
12:24 PM
"experimented developers"
This sounds quite right, in fact, here...
 
 
3 hours later…
3:06 PM
It's so hard for me to understand async/await… If I'm not wrong, I cannot wrap a synchronous IO bound operation so that it becomes asynchronous, right?
 
3:34 PM
@FrenchBoiethios in general, do you know how async/await runtimes work under the hood?
 
Sorry I misunderstood your question
 
no worries, I was just wondering if you look at this as a magical black box, or if you know how to build one yourself from scratch
(as in, know the basic building blocks and their mechanisms)
 
Roughly
When an IO bound operation is launched, it is "forgotten" temporarily, so that the thread can do something else. When the operation is finished, the code continues past this point.
I've created some futures, but it's still somehow "magic" to me :P
 
are you familiar with the concept of a thread-pool? and light/green threads?
 
I know what a thread pool is, and how to use it. As per green threads, it allows to write concurrent code AFAIK, by switching from a context to another
 
3:55 PM
Right, my understanding of this is that the main idea is the following: the runtime is taking care of spawning the threads (and joining them at the end) but these threads are not doing specific things but all of them are executing the same thing: waiting for tasks to execute from the task-manager (part of the runtime). It is therefore heavier than 1:1 (a.k.a OS-level) threads, but they require less setup and management and boilerplate -- these are all taken care of
now, there must be a way to define tasks for the runtime, and that's where futures/promises/observables/etc are all coming into play
with async/await you describe them as plain "imperative" code, instead of nested callback hells
and basically that's that in a nut-shell
(I'm probably not the right person today to explain all the bits and pieces in detail today, as I have a splitting-headache, hence I'm typing things in the chat instead of my text editor..) -- but I'm happy to get back to you tomorrow if no one else is taking over explaining things in depth.. sorry :/ )
 
 
1 hour later…
5:25 PM
@FrenchBoiethios I don't know if you know Node.js, but just like in this one, you can call a synchronous function (e.g. fs.readFileSync ) inside an asynchronous function, but it will still block on that call.
 
@E_net4saysReinstate So that's totally useless if that doesn't liberate the thread for another task
 
That's why I originally wanted to explain how things work under hood -- there's no magic there, these are still just threads and if a function call blocks a thread, it will block the chain of tasks ("stream") in an async runtime as well
and that's the main reason why you want to have and prefer non-blocking IO operations in the first place
but all in all, async/await won't turn blocking things into non-block magically
 
Hum, I understand, now. That's tempting to see async/await as a magical thing since it's the feeling one get using rayon for example
 
the runtime itself has magical and clever elements in the manager/scheduler
but the concept is very, very simple
 
5:41 PM
Not all use cases "ask" for async, but many serious ones do.
 
@E_net4saysReinstate the principles are the same as with concurrent programming -- there's obviously an overhead of managing threads and other related resources under the hood which may or may not cost more than the benefit of doing things in parallel
 
6:03 PM
Purrty much.
I pinned the latest blog post. Don't forget to fill in the State of Rust Survey. :)
 
6:31 PM
@PeterVaro That's not even entirely correct, though, but you need to dig even further down to figure out why
i.e. AIO/epoll/kpoll
there's a lot of nuance
 
6:43 PM
AIO ? what's AIO ?
 
@DenysSĂ©guret async IO
 
(oh, it's posix AIO, so something which basically makes async directly on system threads without polling)
@PeterVaro thanks, found it, didn't knew it.
 
@SĂ©bastienRenauld from the implementation PoV it is more complex than that, but as a theoretical model, it is sort of correct, isn't it?
(I'm happy to be corrected, I mainly did traditional threading before -- quite a lot actually -- and I briefly used AIO things before. I have no hands on experience with Rust's async/await as of yet, though I used async/await runtimes with Python and JavaScript before)
@DenysSéguret but something has to poll at the end
I mean, maybe I'm totally wrong here, but at the lowest levels
something has to indicate that a task has been completed, and something has to actively check if that actually happened..
 
@PeterVaro it can be your own threads or one of the systems like libeuv or, I assume, the rust async enghines
@PeterVaro epoll lets you just poll, without checking everything
 
7:15 PM
@PeterVaro The key thing is that in 90% of cases you don't need more than one thread
the beauty of epoll/kpoll/AIO is that, even though the operations are blocking, you effectively tell the OS to notify you when any fd changes state
 
@SĂ©bastienRenauld thus the "OS" (kernel) is polling for you
someone at some point has to poll, no?
 
Yeah; it's just not done in userland if you can avoid it
 
of course, of course
my question was more about: I'm not aware of any other magic close to the hardware than actually polling for changes
but that doesn't mean there can't be any magic in modern processors which I'm not aware of
(hence my question)
 
There is no magic; all operations are synchronous
what turns synchronous ops into asynchronous ops is some really clever threading in the kernel
 
@SĂ©bastienRenauld phew I'm glad I didn't miss something extraordinary development in recent years..
 
7:28 PM
there is something on the way but it's still experimental
 
 
1 hour later…

« first day (1878 days earlier)      last day (1601 days later) »