« first day (1890 days earlier)      last day (1592 days later) » 

2:44 AM
I think current Box::new implementation have different behaviors from what I expect, or at least we should comment this "optimization" on its rustdoc. — racaljk 8 mins ago
haha
 
3:18 AM
stackoverflow.com/q/59254637/155423 as needs MCVE. OP even "answered" it and basically said "I dunno, it works now", so any hope of it being useful seems gone.
 
 
10 hours later…
1:08 PM
Whelp. It seems as if everyone is working on an error handling library or framework these days.
 
Aren't you just looking at averages ? I think there's a boat lacking developer who makes about three per day so it kind of messes with the stats
 
1:39 PM
@FrenchBoiethios had my first proper go at typescript
it's really, really refreshing after plain old JS
like, night-and-day
@E_net4isunsafe those two are the most opinionated areas in development
actually, there's a third one - validation
 
2:05 PM
@DenysSéguret The boatless friend isn't the only one. ;)
 
2:55 PM
Grr.
0
Q: Is there a way to allocate directly to the heap without using the unstable box syntax?

w.brianI'm in the process of getting a project of mine targeting WASM, and it appears that the stack size in the browser is relatively small and non-configurable. A consequence of this is that my application will overflow the stack while attempting to allocate a large struct on the heap, due to the int...

This new question has a dupe
but now it has two answers, some of which are indeed unique.
2
Q: How to allocate structs on the heap without taking up space on the stack in stable Rust?

mrnateriverIn this code... struct Test { a: i32, b: i64 } fn foo() -> Box<Test> { // Stack frame: let v = Test { a: 123, b: 456 }; // 12 bytes Box::new(v) // `usize` bytes (`*const T` in `Box`) } ... as far as I understand (ignoring possible optimizations), v ge...

 
@SébastienRenauld it most certainly feels like that at first.. until it bites back..
which I believe, you, as an experienced developer with the knowledge of proper type-systems will quickly realise
once you start building a bit more complex application with it
 
@SébastienRenauld Yeah, isn't it?
 
3:11 PM
@Shepmaster Honestly, if it's that much trouble, I'll just delete the question, use Go instead (where it seems easy to do this) and be done with it. — alastair 2 mins ago
I'm shaking!
All because I tried to get the OP to ask a reasonable question.
 
3:24 PM
haha
 
3:48 PM
"it seems easy" is one of the most insidious idea I have to deal with.
 
@FélixGagnon-Grenier TBH, I bet that this is (more) easy in Go.
 
It is
 
Since Go has channels as a first-class language concept
 
select in Go is very very convenient
And that was of course why it was introduced in crossbeam and why it seduced people
 
now, I dunno how good the "spawn a process and get channels to the stdout / stderr" support is
but given that goroutines are cheap & easy, it's probably not bad to make it
 
3:51 PM
dealing with stdout and stderr of another process is pleasant in no existing language.
 
heh :p It was more of a perspective on how I have to deal with my own "oh this seems easy" than this current situation, as I'm pretty new to either Rust or Go
But, thanks for the precisions
 
    let mut cmd = Command::new("/tmp/slow.bash")
        .stdout(Stdio::piped())
        .stderr(Stdio::piped())
        .spawn()
        .expect("cannot spawn");

    let stdout = cmd.stdout().take().expect("no stdout");
    let stderr = cmd.stderr().take().expect("no stderr");

    let stdout = BufReader::new(stdout).lines().map(Either::Left);
    let stderr = BufReader::new(stderr).lines().map(Either::Right);

    stream::select(stdout, stderr)
        .for_each(|l| {
            async move {
It was already indented 1x... shrug
 
@ÖmerErden that's still not doing it in the pattern, correct? — Shepmaster 5 mins ago
 
there are only three hard things in programmation, naming things, cache invalidation and Stack Overflow chat markdown
2
 
@Shepmaster you mean the extra &mut * breaks it ?
 
3:55 PM
At least this doesn't seem terrible. It's probably more lines than the Go equivalent though.
@ÖmerErden I wouldn't say "break", just not directly addressing the specific (silly) case the question posed
 
@Shepmaster hmm at least i tried ^^ this one is also same i guess : play.rust-lang.org/…
 
@ÖmerErden I'm pretty sure the answer is "no", and I'd be happy accepting such. If you really want the bounty, an ideal answer would try to "prove" that by pointing at some compiler code / reference / github issue / IRLO discussion.
 
4:20 PM
... they could have let a few minutes for the commenter to turn their right suggestion as an answer..
 
@FélixGagnon-Grenier comment are not answer there is not "I was first"
 
@FélixGagnon-Grenier Or it could have been marked as the easily-findable duplicate
 
@Stargateur Indeed. I believe I am aware of this. There is, however, "hey your comment was helpful. It puts into light that this question could be closed, or we could add an answer with that. Is it ok if I write it so we can get this over with quickly, or do you prefer to do so?"
The duplicate finding would be probably be the Right Thing™ however :P
 
I know that the SO search is not great, but I don't see how it couldn't have found this one
 
a cynical part of me would say, that to find you must first search
 
4:37 PM
@FélixGagnon-Grenier when you ask a question you get the suggested duplicates, so you may not even have to actively search. You do have to look at that list though...
 
But thanks for the down vote. Stackoverflow is as motivating as usual. 🙄 — Sarien 10 mins ago
I did something bad and get downvote
look surprise
I have a meme for that
 
hahaha indeed
Oh wow. It just occured to me that, to modelize this Dungeons and Dragons town generator I'm trying to make, Rust's enum that allows for built data directly fits the need for traditional government with monstruous influence.
 
@Stargateur flag'd
 
@E_net4isunsafe delete a message doesn't delete the problem :p
 
@Stargateur The problem is in too many people complaining unreasonably. What's in our reach is to remove them.
@FélixGagnon-Grenier I'm not entirely sure I have all the context there, but it's true that sum types enable nice design decisions.
 
4:48 PM
I thought the problem was the general perception that a downvote directly attacks a human
 
I have occasionally missed them when using Java.
 
mm, yes, sum types are excellent
 
@FélixGagnon-Grenier hence the "unreasonable" part. :[
 
I just cant happily use a language without sum types…
 
4:53 PM
hmmm right I'm not sure of how it's called
enum IpAddr {
    V4(String),
    V6(String),
}
this^. this is sum type?
 
yeah (sum type is the general type-theory name for it)
 
ok
It's one of those "I didn't know I needed it before I learned about it"
 
in rust, you can just say "enum", but in general programming enum often means the limited form like in C or Java
C's enum == a slightly fancy integer
 
indeed, it's the first time I see such a glorified enum :)
 
Unfortunately, it's often a "now that I know this exists, I must have it"
which sucks for languages without it
 
4:56 PM
:D
 
@Shepmaster that more Rust that shouldn't name them enum but variant
 
@FélixGagnon-Grenier The name is intuitive: when you add a variant, you add its number of possible representations to the previously existing one. In the other hand, with a product type (struct) you multiply the possible representations when you add a field.
 
@FrenchBoiethios intuitive if you think about "how many possible values can a type have", which I very rarely do ;-)
 
For example: enum Foo { A(u8), B(u8) } can hold 256 + 256 different representations while struct Foo { a: u8, b: u8 } can hold 256 * 256 one.
@Shepmaster Well, once the explanation is known, it's easier to remember the names.
 
hmmm, I think I see what you mean, thanks
 
5:02 PM
@FrenchBoiethios that I'll agree to
Now, where are the "Subtract" and "Division" types? :-)
 
I'll rather see an exponent type
@Shepmaster That's quite unfortunate that there is no other commonly used word to express that. People can see the usage of "sum type" as pedantic.
enum is clearly a bad name because people usually think "C-like enum"
 
yesterday, I was trying to use the serde_json crate and got a problem trying to derive a serialized struct. Adding the dependency in the Cargo.toml as instructed in the GitHub repo was not sufficient, I had to add the derive feature to the toml as well. Is using derive keywords from crates a thing that I should know requires an additional line in the Cargo file? Could it be worthwhile to PR the repo with a note?
 
17
Q: How do I fix "cannot find derive macro in this scope"?

jerryI have this: #[derive(FromPrimitive)] pub enum MyEnum { Var1 = 1, Var2 } And an error: error: cannot find derive macro `FromPrimitive` in this scope | ...

> requires an additional line in the Cargo file
It doesn't, always. For example, SNAFU always exports the derive macro
> Could it be worthwhile to PR the repo with a note
Absolutely
For Serde, you can also directly use the serde-derive crate instead.
 
lol, literally an answer for this specific crate :)
 
@FélixGagnon-Grenier Serde is a super popular crate, so that's not too surprising
 
5:10 PM
I see
@Shepmaster Oh, as is generally the case, it appears I mostly can't read a README from top to bottom, and jumped to the section about serialization without seeing the link for setting up the derive line...
 
@Shepmaster Arguably, NonZero is a specific realization of a subtraction type. :>
 
@FélixGagnon-Grenier Serde also has a website with useful information
 
5:34 PM
@PeterVaro Already encountered that. The generic type system in typescript is ass.
and it has all the warts that JS does, they're just hidden below a layer of polish
 
5:45 PM
@SébastienRenauld EXACTLY.
IMO TS is a massively missed opportunity..
 
Still miles better than vanilla JS though
like
not having to enforce schemas with @hapi/joi is fucking 11/10
 
we used flowjs for our latest project. so far pretty cool, I think I prefer it to TS a bit
 
6:05 PM
Now that WASM is a standard, you can just wait for all frontend to be (re)written in Rust
 
@Shepmaster exactly what I'm waiting for.. once WASM will have native access to the GPU
there will be virtually no reason to stick with JS (or the DOM nonsense)
 
@Shepmaster yes
 
Well, except for all the things written in JS :-)
Like, the Playground makes heavy use of Ace, for example
 
@Shepmaster which are 99% reinvented wheels in a very inefficient and bad way..
 
@Shepmaster I'm not sure that'd be a good idea though
but then again
reinventing the entire stack happens every other day in the JS world, so it's not like they're not used to it
 
6:18 PM
@PeterVaro hmmm... wait what? what is there, except HTML to present documents from servers? in other words, what wheels were there? (unless you mean the library duplication that is rampant? :)
@Shepmaster heh, as long as form validation and user feedback gets actually fun to do...
 
@FélixGagnon-Grenier I've thought about what good validation would look like for Rust (and I guess many others have as well, as alluded to earlier in the channel)
Ultimately, I think it's just a hard problem
 
@FélixGagnon-Grenier every library which uses some sort of JS implementation instead of the native one (on client side it would mean the browser; outside the browser basically everything else)
(browser: you could think of the virtual DOM for example; others: node and IO)
 
lol, wait until you learn about machine learning javascript libraries runs away
 
:see_no_evil:
 
:P
There's a thing I read in a tweet a while ago, and I was unable to ever implement it in a way that I found satisfactory, and it was a pattern to consider user inputs as async promises. It's really mind blowing to me.
kinda makes the validation part of the process of receiving input
let value;
while (waiting_for_value()) {
  try {
    value = await input();
  } catch (e) {
    notify_user(e);
  }
}
(that's js)
 
6:29 PM
yeah, and that nicely dovetails with the need for the validation to be async anyway (e.g. checking if a username is taken)
Wouldn't you use some fancy JS generators there, anyway?
Mostly I'm wondering if it would be a Rust Future or Stream
 
Hmmm, interesting, this made me realize I only ever use generators in node. but apparently browser support is good as well..
while next could be a better api indeed, and allow the input component to receive the error message from the validation part
 
@Shepmaster This depends on where your validation occurs and why it occurs
 
@SébastienRenauld got any concrete examples for me?
 
Take the analogy of username taken; that's pure business logic and is an early return on validation, but it's not the earliest
 
This might also veer into reactiveX type things, I suppose
 
6:42 PM
as in, in the validation chain it's "username not empty" -> "username valid" -> "username not taken" -> registration, at least on the user domain
 
when the command is being run (as in, user registration happens), additional validation can occur there
that's the "late" validation
 
Add on that multiple validations may fail in parallel
And you want to report as many as possible
 
Do you?
I don't know about you, but in most applications I have a validation tree
for instance, "username valid" may have 10+ different rules and you want to show every failure
 
Do you appreciate it when the compiler gives you one error, you fix it, then you get another error that you could have fixed the first time?
 
6:48 PM
on the other hand, some other validation may have 5+ parallel rules and you only want to show one of them, because they're not linked and it's FCFS
 
e.g. "username too long and contains invalid characters"
 
that's the "10 and show all of them"
consider the case where somebody wants to order stuff to fit in a box that can contain 4 items; they picked 5 and there's only 3 in stock
the "you can only have 4 in a box" is not worth showing because "we can only ship you 3 right now" supersedes it
 
maybe I'm missing your point. It seems like you were disagreeing with me ("Do you?") but then agree with me ("10 and show all of them")
 
I'm saying it's not always the go-to
 
Would it have been better if I had said "and sometimes you want to show multiple parallel validation failures"?
 
6:50 PM
there are cases where you definitely want to show each individual validation failure, and cases where you do not
and the worst is that it's entirely based on the display/UX requirements
 
or the best, depending on the viewpoint :)
 
I don't like building validation pipelines due to that
it'd be so much easier if everything could fail hard, fail fast and cost nothing to repeat
the problem is that if you make somebody submit the same form 3 times they move to your competitor's website
 
7:10 PM
Nice solutions for returning Result<T, Vec<E>> would be something I'd like to see
It's something that the implementation of SNAFU has ugly code for
but it's the same idea: reporting many errors in parallel
 
It goes further than that; what if a validation is a warning?
what do you do then?
i.e. "Your password isn't entirely safe"-kind of warning
 
yup, especially when the warning code can have errors before and after
like string -> int (can have error); int -> price (can have warning)
 
@Shepmaster If I understand correctly the blog post about error, now error have a way to have an inner source error, and so can be recursive. So E => E => E => ... => None
no need for vec
but I don't know if it's good for perf
 
@Stargateur sure (and it always had that)
but that's for the cause of an error
I'm asking more for two related errors
like Error::TooBig and Error::NotEven
 
7:22 PM
neither of those is caused by the other
 
@Shepmaster so two error in the same time ?
 
yep (make sure to read the scrollback, where we are talking about validation)
 
I don't really see why bother this, just return the first error
 
think of the memes about the password validations always having another different error from the previous one
better know that your password can't be "yomamasfat" AND that you need special characters all at once
 
7:37 PM
@FélixGagnon-Grenier that a special case but I will use a bitfield in this one
combine a error with docs.rs/bitflags/1.2.1/bitflags inside
 
I recall having used naive if elses when validating forms in past projects. Never had to go maintain those parts of the software.
push localized messages in a list, throw them in red under a field.
I should note here that this particular project used angularjs (the first version), so "passing the least amount of time as humanly possible" in that code was a strong incentive for me.
 
@Shepmaster That wonderful F
 
so, I think, based on the last few days experience with rust, that the hipsterliest project I could imagine would use Rust and SvelteJS.
 
@FélixGagnon-Grenier The Playground uses Rust / React / Docker, so almost there!
 
7:59 PM
Svelte is a little too cutting edge for me at the moment
> We have no TS support yet
> How do I do testing Svelte apps?

> We don't have a good answer to this yet,
 
@FélixGagnon-Grenier I'll probably start soon enough one with Rust both server side and as wasm. Is that hipster enough ?
 
It's exactly on point :)
 
I would have started it sooner if a customer hadn't finally cancelled a contract... I was cautious and used java+js instead ^^
(if my company has no money for the project, I can't hire Rust coders to work with me)
 
> I would have started it sooner if a customer hadn't finally cancelled a contract
I don't think I'm reading that correctly
 
sorry for my English
 
8:05 PM
I er, don't know enough about both Rust and WASM to even try doing that, but I've been meaning to have the time to understand it enough to hello world something on screen
@Shepmaster it appears that you are :)
 
I always do the client frameworks myself so that I don't have to learn the other ones... doing it for wasm/rust doesn't seem to be a problem
 
you mean like, create a component ui library, state manager, et al?
 
Parts depend on the time, but yes. You know you don't really need a lot for a state manager, depending on your approach
 
@DenysSéguret lazy_static!(EVERYTHING)
or better
static mut EVERYTHING
 
My approach to web apps is that they're just applications like the other ones, and they communicate with a server (usually in Rest)
The client and the server are different applications
 
8:11 PM
@DenysSéguret possibly, I've never had the occasion to try at it. I've found the MobX + React place to be exactly what I need
 
And what if you don't need anything ?
 
What do you mean?
 
Your browser is a very capable OS with a good graphical lib
 
I do like native browser apis
But I'm not sure how you relate those to state management, unless I'm massively misunderstanding?
 
Like you do in any other application
 
8:14 PM
I wouldn't want to implement a whole observer / subscriber system over local storage, for instance.
Oh, yeah. Please note, that I'm barely just a web guy, I don't have any desktop application experience per se, only what I've pieced rogether flailling around with qt from time to time, but I assuredly do not have experience with state management in a desktop application.
 
You can separate your model and your controller locally. You don't have to directly connect the model to the screen components.
 
One thing is that state management doesn't really change based on if you are server / client / desktop / mobile :-)
 
IMO there should not be a direct mapping between the model and the widgets as is done in many frameworks
 
Do you consider the props / rendering system in react to be a direct mapping?
 
Note that I'm biased because my applications deal with massive data, like millions of numbers and objects in memory, things that can't possibly be mapped with fantom dom and the likes
 
8:18 PM
yeah, can you expand on what "mapping" means in this case, and what "direct mapping" means?
 
direct mapping means you say there's a part of your model which should be rendered at some part of the screen, more or less trivially, when it changes. or the reverse. Or be synchronized on your server.
 
I assume you also mean "there shouldn't be only / a forced direct mapping"? That is, sometimes you will have a direct mapping (say displaying the username), but there are times you definitely won't / can't
 
I mean there should always be a controler
 
oh. yeah, I think I totally agree on that
 
But it's my approach and, as I say, somebody dealing with small data or small flows can have a different sensibility
 
8:23 PM
"controllers". How quaint
 
What's an example of a framework that only allows the direct mapping?
 
@DenysSéguret With more context, I generally see web applications as applications, indeed, with a structure that allows for different parts of the system to be responsible for their part of managing the applciation, be it rendering data, launching requests, validatign things or pestering the user
As one of two frontend person where I work, a non negligible part of my time has been used to to convince people that I do, indeed, need to test those parts and that there is, indeed, an architecture for that application to be meaningful over a longer term
 
@Shepmaster There isn't one anymore
There used to be, but then angular scorched the earth and everybody else followed
I think the last one I can remember was riot
 
9:11 PM
I have a very strong I don't know what I'm doing vibe with wasm
 
@FélixGagnon-Grenier Don't be overwhelmed by the toolchain. You don't need much of it. You don't need node, npm, and the like to build a wasm app
@FélixGagnon-Grenier this isn't really a tutorial but here's an example of rust+wasm which doesn't make you install node, webpack, etc. github.com/Canop/wasm-tictactoe
 
9:27 PM
hmmm, gotta go but I'll check this out when getting back, thx :)
 
@DenysSéguret You do have to install a webbrowser though :-)
 
@Shepmaster yes, and the cargo tool chain. But in order to learn wasm+rust you should not have to deal with webpack+npm+node+babel
 

« first day (1890 days earlier)      last day (1592 days later) »