« first day (930 days earlier)      last day (2561 days later) » 

10:34 AM
"... the onliest way ..." -> is this a common mistake amongst native speakers? I'm just curious because in German, this is a very common mistake to say "das einzigste" which is the superlative of "einzige" (roughly: "the only one").
 
 
2 hours later…
12:24 PM
@LukasKalbertodt Personally, I can't imagine any Portuguese native saying that, but the circumstances are dissimilar.
 
12:38 PM
@LukasKalbertodt If an English person said that, I would assume they were doing it intentionally, maybe trying to be cute, rather than making a mistake.
 
 
5 hours later…
5:21 PM
@LukasKalbertodt believe in yourself
@PeterHall Cute like in youtube.com/watch?v=d5ab8BOu4LE
 
 
1 hour later…
6:41 PM
@LukasKalbertodt Were I to use it/see it used I'd be as a superlative form of "only", e.g. "the only way do to this is to kill yourself, but the onliest way to do it is to take your family with you".
Is there a chunks() equivalent for iterators yielding an iterator of iterators of length <= specified?
 
@Shepmaster Of course, it's in itertools
Cheers fam
 
@набиячлэвэли itertools should be the second place to look w.r.t. "can an iterator do X"
 
@Shepmaster :<
 
6:53 PM
@LukasKalbertodt You'll get over it in time
then you can close dupes left and right
 
We'll see ^_^
 
Now I want someone to point out to stackoverflow.com/q/43723489/155423 that they haven't done the things
like, they edited the question and put the error message in the wrong place
and didn't put the complete error message
or put the MCVE
What's a polite way to tell someone
> Hey, you don't understand what you are doing yet, so you shouldn't try to summarize any error messages
 
@Shepmaster Damn why does it panic when size=0
 
@набиячлэвэли what
what would that do
 
wait I'm misreading this
ignore
I honestly thought it meant the iterator length :v
 
7:04 PM
@набиячлэвэли that would be an annoying API
> Here's an iterator, you tell me how long it is
 
7:24 PM
Kinda wish there was an in-place String::replace() variant, muh purrformance :v
But who am I kidding, this thing is network-bound
 
@набиячлэвэли are you always replacing with a smaller string? Otherwise I'm not sure it would be more performant
 
let mut line = String::new();
while try!(reader.read_line(&mut line)) != 0 {
    line = line.replace('\r', "").replace('\n', "").replace('\t', &TAB_SPACING);
    // use line, w/e
}
let _ = line;
Here's the chunk
Now it always allocates >twice, then deallocates previous chunks
4 allocations, 3 deallocations
@Shepmaster With in-place replace this would only be potential resize-allocations, which aren't all that often in my usecase
 
so not so much performance, but allocations (and performance stemming from that)
 
> >not performance but performance
Memory allocation is incredibly costly
 
[benchmarks required]
anywho
7
Q: Split a string keeping the separators

KehoIs there a trivial way to split a string keeping the separators? Instead of this: let texte = "Ten. Million. Questions. Let's celebrate all we've done together."; let v: Vec<&str> = texte.split(|c: char| !(c.is_alphanumeric() || c == '\'')).filter(|s| !s.is_empty()).collect(); which results wi...

, then you can split on &[\r, \n, \t]
and collect it all
or preallocate and extend
 
7:34 PM
As in split-map-collect?
 
line.replace(&['\r', '\n'][..], "") might also save you one allocation
 
Pattern API is shady I didn't delve into it, neat
 
@набиячлэвэли yeah, I just wasn't sure if you get an iterator or what
I wrote something somewhere that is an iterator that returns Foo::Match Foo::NotMatch enum
for something similar
 
@Shepmaster That still doesn't forces an allocation of new line and deallocation of source/old line
*doesn't forces -> forces
 
yep
> might also save you one allocation
 
7:42 PM
I meant the split-map-collect method
 
8:06 PM
 
@Shepmaster Nice find. Yep, that's a dupe, I think.
 
@LukasKalbertodt care to do the honors?
 
Since when are those casts not needed anymore? 0_o I was already confused when writing my answer that it worked without.
 
@LukasKalbertodt I forget. I remember being excited when it happened
 
@Shepmaster It was your find, but sure ;-)
 
8:10 PM
@LukasKalbertodt gotta ease you into using the hammer
 
@Shepmaster Uhh! Another language question (so sorry in case it's annoying). You said "I forget", but you meant that you "forgot", right? So why not using the past "forgot" here?
 
@LukasKalbertodt It is not annoying
 
@Shepmaster This reminds me of every movie villain training its successor in doing horrible things :P
 
Hmm.
I feel like if I had said "I forgot", that would have meant that in the past I knew X, then later on, but still in the past, I stopped knowing X.
At the present, I may or may not know X
 
@Shepmaster Interesting. But to me, "I forget X" sounds like "I'm forgetting X in this moment". Which is strange...
It's probably just because I'm coming from another language, but "I forgot" sounds good to me. If I wanted to say that I forgot in the past but reremembered, I would be more explicit, like "I once forgot X, but then re-remembered it".
But there is probably no point in arguing against the rules of natural language :D
So many people approach "writing fast programs" incorrectly :/ it's sad. The amount of time wasted to think about irrelevant aspects of the program is astonishing.
It's best to just accept that no one understands the machine :P
 
8:37 PM
> re-remembered it
that's a strange one too
When I learn something the first time, do I remember it then?
 
@Shepmaster Good point :P
 
(Also, I often screw up a / an, so the fact that a native speaker says it doesn't mean nothing)
 
@Shepmaster I heard it ("forget") in a video of a native speaker, so you're certainly not my only "source"
 
8:52 PM
@Renato Hi there! Quick response, I'm impressed ;-)
 
hi
Thanks for helping out!
If I used the enum solution by @Shepmaster
 
So... what is your application all about? So apparently a CLI thingy?
 
IT would make the code nicer and faster, right?
Yeah, it's just a socket client that will send its input off to another process to run.
I wanted it to run very fast, so I decided it was a good time to use Rust :)
 
What "enum solution" are you talking about right now?
 
as any cli app, it needs to take input from either stdin, a file or user options
3
A: Are polymorphic variables allowed?

wingedsubmarinerDefining a custom enumeration is the most efficient way to do this. This will allow you to allocate on the stack exactly the amount of space you need, i.e. the size of the largest option, plus 1 extra byte to track which option is stored. It also allows direct access without a level of indirectio...

 
8:56 PM
@Renato Good idea ;-) however, writing fast programs is not as easy as it sounds. And while it's often the case that most of your code becomes magically fast when written in idiomatic Rust, this doesn't apply to everything. So just by using Rust, you might now gain the speedup you wished for ;-)
 
> just a socket client
Likely most time will be waiting for network as well
 
no, it's run locally.
 
so like UNIX sockets then?
 
Very fast from my measurements. probably just a file as far as the kernel is concerned.
yes
you can run remotely, of course, but that's not my goal.
right now , it's not ready, but feel free to have a look: github.com/renatoathaydes/jgrab
 
So the enum version works without dynamic dispatch which is good in theory, but it has some... dispatching via match. This suggestion by Shepmaster probably performs better.
 
8:59 PM
sure... but repeating my code for a few nanoseconds is a little too much to stomach... but avoiding heap allocation seemed like a large gain.
 
@Renato So... the deamon is keeping the JVM alive. Invoking the CLI app sends the java code to your deamon which then uses a in memory java compiler to compile and execute the code on the JVM?
@Renato Well, you wouldn't repeat a lot. You would only repeat the function call twice :P
 
yes, that's what it does!
Java itself is really fast as long as you don't count startup and warmup
 
And in the context of your whole application: I don't think the sending Java code actually makes a big difference. Again, allocating heap memory with jemalloc (Rust's default allocator) for a file descriptor (which is tiny) won't cost that much time...
 
from my tests, using Rust I can compile/run Java classes in under 1ms
 
I'm not saying that there isn't a better solution or that you should use heap allocations. I'm just saying that it probably won't matter ^_^
 
9:03 PM
learning is a goal of course.
 
Example of the repetition needed
 
never thought about stack VS heap until learning Rust now... that's already eye-opening for me.
 
Yeah, before Rust only C or C++ programmers would be concerned about it. :)
 
(my hyper optimization coming right after a completely useless Vec allocation)
 
:D
 
9:06 PM
@Renato Always nice learning about stuff like that, right? ^_^
@Shepmaster uh wow, nice one indeed :D
 
very different concerns from what I'm used to.
nearly always, speedups at work are from DB connections, caching etc.
not from heap allocations!
 
A quick and dirty benchmark: allocating 64bit with Box takes about 50ns ... compare that to 1ms compile-time...
 
oh well... guess I should stop worrying about that.
getting late here... you'll probably hear from me on SO :) See ya
 
@Renato Which is equally true for Rust. Tweaking heap allocations doesn't make a lot of sense when you are accessing a database afterwards. But if you are not limited by IO and stuff like heap allocations is really a notable contributor to the time spend running your program, then you can optimize that ^_^
@Renato Good night!
 
9:36 PM
@Shepmaster Another native English friend of mine agrees with you: "I forget" is 'correct'
 

« first day (930 days earlier)      last day (2561 days later) »