« first day (2176 days earlier)      last day (2776 days later) » 

12:04 PM
 
got an upgrade to 32GB RAM at work
 
welcome to 2011
 
@BartekBanachewicz welcome to the club of 32 GB guys
 
@PatrickM'Bongo Oh btw, we'll switch to MSVC2013
 
Ok. Here's the verdict: Rust <-> C++ interop is painful as fuck.
6
 
12:12 PM
brand new tech
 
@Rerito ... what
 
yeah
 
@R.MartinhoFernandes just throw in a couple more .unwrap!
 
@PatrickM'Bongo I can launch so many vagrants now
so many
 
@Rerito that's sad
 
12:12 PM
@PatrickM'Bongo Never a problem, really.
 
SOLID principles wtf is that/..
 
Your machine will end up as a hobo shelter
@PatrickM'Bongo Well at least the cpp11 coverage will be better than on vc10
 
Not really, 2013 is still badly broken
 
it's 2013 update 4 I think
 
That's like saying "I'm glad I stepped on a dog shit rather than human shit!", well, you still stepped on shit.
 
12:14 PM
But while we're there, I think I'll try to push a move towards vs15
 
@ProblemSlover Super Old Looser Idiotic Dogmas
 
@PatrickM'Bongo What's broken in MSVC 13 btw?
Just so that I know what I can do (or cannot...)
 
Probably easier to list what's not broken
 
@BartekBanachewicz just accidentally showed up in google
 
@PatrickM'Bongo C++'s fault mostly.
 
12:16 PM
never mind then
 
@R.MartinhoFernandes For example?
 
Most Rust vocabulary types have (unsafe) destructuring and restructuring functions.
C++'s? Fuck you.
Can't destructure a shared_ptr.
C++ FFI is pain as soon as you leave the C subset.
 
also why isn't what-if updated :/
 
ADG
I saw the code and SIGSEV is on 'callq 0x402c47 <division(int)>'
 
C++'s FFI is incidental. It happened to come along by inheriting C.
Though to be fair, shared_ptr isn't a great example, cause Rust's Rc doesn't have destructuring either.
vector would be a better one.
You can destructure it (v.data(), v.size(), v.capacity()) but there's no way to rebuild it without copying everything.
 
12:22 PM
@R.MartinhoFernandes interesting
well you can't really express "move from raw memory into ownership" in C++
all pointers are deemed unsafe unless proven safe
 
This sort of thing forces you to do awkward gymnastics for things that aren't unusual at all.
Like passing manual "vtables".
Building those is annoying and boring and repetitive and while codegen might help, sometimes you need to deviate from the norm in those vtables.
 
pogrgraming is annoying and boring
 
user406009
I usually just do everything through a C ABI when I want to do C++/Rust interop.
 
user406009
Yeah, there is certainly a lot of unnecessary copying.
 
user406009
So many repeated parameters of char* data, int length or whatnot.
 
12:28 PM
write your own stdlib
that allows such construction
 
@Lalaland That's fine. The problem is that C++ std types have a tendency to not be marshalable across a C ABI.
 
Rust lets you be less safe than C++
 
@ratchetfreak The difference is that it lets you do so when you need it, not when you least expect it.
 
which makes rust safer in general use unless you explicitly start aiming the gun at your own feet
 
@BartekBanachewicz Wrap everything in template <typename T> struct abi_ref<T> { T* ptr_to_leaked_object_on_the_heap_for_restoring_with_unique_ptr_later, manually_destructured<T> relevant_bits_of_the_object_or_callback_table_whichever_you_prefer; };
 
12:33 PM
@R.MartinhoFernandes everytime I see }; it makes me sad as well
 
You can make that pass ownership by adding the deleter to the vtable.
I can think of many different ways to work around the issue, but they're all painful.
 
move semantics would almost be a solution
 
Good FFI = C ABI + comprehensive marshalling
 
but, as usual, C++ doesn't give a shit
 
C++ fails at the latter bit.
 
12:36 PM
oh well
 
Actually surprised unique_ptr::release is a thing.
 
user406009
github.com/Lalaland/data_channel/blob/master/src/server/ffi.rs was how I did it the last time I had to do C++/Rust interop
 
That doesn't seem to return anything back to C++, though.
(I might have missed it)
 
user406009
Callbacks with char* data, int length.
 
user406009
process_websocket_message
 
12:40 PM
Right. That's what I'm doing, except I need a zillion such callbacks because I have complex large objects :/
 
ADG
12:55 PM
Can somebody tell if this is a good question that i asked?
 
we can tell that you shouldn't post it here
 
ADG
@Abyx what do you think then? and why?
 
I want it that way
 
user406009
@ADG The main thing is that you need a complete compilable example which shows the problem.
 
user406009
Also, if you want to ask questions here in the chat, you need to ask them in chat.stackoverflow.com/rooms/116940/c-questions-and-answers.
 
user1804599
1:04 PM
@R.MartinhoFernandes There's Box WIP, maybe Rc will be added one day
 
user406009
(I didn't make the rules but all questions go in there)
 
user1804599
General mechanism would be rad.
 
user1804599
I like that Rust doesn't add atomicity to Rc.
 
user1804599
Rc<String> is super useful. Wish you could construct Rc<str>.
 
user406009
How would Rc<str> make any sense at all?
 
user406009
1:07 PM
That's Rc<&String>
 
user1804599
How would it not?
 
user1804599
No, it's not.
 
ADG
... and now i'm banned
for asking bad questions... hope including a sscce will help?
 
user1804599
str is an unsized type, String is a boxed str.
 
ADG
currently making
 
user1804599
1:07 PM
Rc<String> is double boxing.
 
user1804599
Rc<str> is like shared_ptr<char[]>.
 
user406009
@ADG Yeah, don't mind the bans. People on SO get to trigger happy with bans nowadays.
 
also theory exam on wednesday
#psyched
#fast
 
@rightfold Rc is being improved soon.
 
user1804599
yay
 
user406009
1:10 PM
@rightfold Oops, you are right. I remembered incorrectly.
 
@rightfold Currently you can't do Rc<Trait> and that's seen as a big issue, AFAICT.
Rc<Box<Trait>> is a really annoying workaround.
 
user1804599
Well.
 
Rc<RefCell<Box<Trait>>>
 
user1804599
You can do Rc<[T]>, if you first make an Rc<[T; N]> and then cast.
 
let x: Rc<[i32]> = Rc::new([1, 2]); compiles on stable.
 
1:17 PM
uegh people ranting about having to do the exam on the 650cc because "oh noes I'm a small woman I don't have enough strength"
such freaking bs
 
Ell
650 is nathing mate
 
well first off it's not about strength when you're driving :F
you're not supposed to fight with it or force it into turns
 
Ven
:P
 
my first driving around doing the 8s was super tiring and I felt like I had to lift the 200kg myself, but after some riding it all become much more relaxed
and the seat is still actually quite low, not much more than on the sporty 300s
 
Hey guys, I'm thinking of a classical question and am wondering whether there's a solution neater than the one I have in mind. So I have a thread pool, whose workers run in an infinite loop, and are awaken by wait_condition. When there's work, the threads are notified through the wait_condition and they pull an element from the queue and process it.
So what I'm wondering about is: If in my main program I push all the tasks I need to process, how can I know that all workers have finished their work before calling to join them? My naive method is to just check whether the number of tasks is zero continuously, and if it's zero, I make the workers exit the loop and call join. Is there a better way to do this?
 
1:26 PM
actually it's identical, 785mm on both Gladius and Ninja 300
 
ADG
@Lalaland is it better now?
 
> The Quantum Physicist: Hey guys, I'm thinking of a classical question
Very funny.
 
@R.MartinhoFernandes Well, it's quite classical, as I find many people asking the same question only but no clear neat solution out there xD
 
The level of cludge in this project is amazing
 
user1804599
1:53 PM
@R.MartinhoFernandes Yes but [1, 2] is evaluates to an array, not a slice.
 
user1804599
It must have a static size.
 
Don't see a difference there.
 
user1804599
Rc::new([1, 2]) is Rc<[int; 2]>.
 
Rc<i32> is one pointer; Rc<[i32]> is two.
 
user1804599
You can't create Rc<[int]> when you don't know the length at compile-time.
 
1:55 PM
Rc<str> can work the same way. Two pointers.
Let me put it another way: what's the difference because Rc<str> and Rc<[u8]>?
 
user1804599
There isn't, str is just [u8] with UTF-8 invariant.
 
That's my point, there's no reason it shouldn't work.
 
user1804599
Maybe you can unsafe coerce Rc<[u8]> to Rc<str>, but to obtain a Rc<[u8]> you still need to know the size statically.
 
Nope, you can't name Rc<str> at all.
 
user1804599
Rc<&[u8]> is a different story, but again one more indirection.
 
user1804599
1:57 PM
@R.MartinhoFernandes I'm pretty sure you can; Rc has no Sized constraint.
 
Oh wait, you just can't new it.
 
user1804599
Yes.
 
user1804599
And you can convert Rc<[T; N]> to Rc<[T]>, but you can't new a Rc<[T]> directly.
 
user1804599
Only by converting an rc'ed array you can obtain an rc'ed slice.
 
I don't get how Rc<[i32]> works.
Actually, it does.
 
user1804599
2:00 PM
?Sized, not Sized.
 
Oh, right.
 
user1804599
Sized constraints are added to all type parameters by default. You can disable this with ?Sized.
 
@rightfold How does this convert? I don't see anything in the interface.
 
user1804599
I have no idea, but it works. :P
 
I think it's because [T; N] is a second-class type.
Because of missing integer generics
 
user1804599
2:02 PM
> Arrays coerce to slices ([T]), so their methods can be called on arrays.
 
impl<T, U> CoerceUnsized<Rc<U>> for Rc<T> where T: Unsize<U> + ?Sized, U: ?Sized
Ah, guess it's this.
 
user1804599
> Trait that indicates that this is a pointer or a wrapper for one, where unsizing can be performed on the pointee.
 
user1804599
 
user1804599
So yes, that should be it.
 
I wonder if dropping impl CoerceUnsized<str> for String {} in the stdlib would work :D
 
user1804599
2:08 PM
Then you'd have to allocate a boxed string before you can make an Rc<str>. :/
 
user1804599
Maybe if it can move.
 
Right, we'd need a StaticString<N>.
But no integer generics.
 
user1804599
Well, you can acquire the length from a str.
 
user1804599
So an Rc ctor that does that would be enough.
 
But that's the unsized type already.
We need a T where T: Unsize<str>.
 
user1804599
2:11 PM
impl Rc<str> { fn new_str(&str) -> Self { ... } }
 
@rightfold But a different ctor is cheating :P
Also not entirely sure that is enough.
 
user1804599
impl Rc<str> {
  fn new_str(s: &str) -> Self {
    let mem = malloc(s.len());
    memcpy(mem, s.data(), s.len());
    bla(mem)
  }
}
 
user1804599
well, byte len, not code point len
 
user1804599
ygtp
 
Ben
Could we have a census on preferred programming languages?
 
user1804599
2:16 PM
If you get it to work for slices then getting it to work for str is just a transmute away.
 
preferred by whom?
 
Ben
@BartekBanachewicz eh, by the participants of this room.
 
@rightfold But that copies. Rc::new([1, 2]) can allocate the array in place.
 
@Ben i host one roughly every one year
 
(It works for non-Copy types)
 
Ben
2:18 PM
@BartekBanachewicz you do?
 
Ben
@BartekBanachewicz neat :)
 
user1804599
@R.MartinhoFernandes [1, 2] has a static size. :p
 
user1804599
You want to special-case &'static str, I think.
 
10 mins ago, by R. Martinho Fernandes
Right, we'd need a StaticString<N>.
 
user1804599
2:21 PM
Well at some point you need to copy the data.
 
@rightfold No, I want the blank in "[T] is to [T; N] as str is to ___".
 
user1804599
[1, 2] is stored in memory too. Perhaps in the machine code as immediate operands, perhaps in static storage.
 
user1804599
And it's copied to the Rc.
 
user1804599
You can't get around the copy.
 
@R.MartinhoFernandes I thought any C++ iterop was painful?
 
2:34 PM
ugh shit
the bike I wanted to get is still available
but ofc may not be after I get my licence
sadz
 
@BartekBanachewicz you can't put a hold on it?
 
it's too far for me to go check it out without coming back on it I guess
~460km
and buying it without seeing it even once is even sketchier
maybe I could get someone else to go check it out and buy it for me
here's the beauty
 
2 hours ago, by R. Martinho Fernandes
@PatrickM'Bongo C++'s fault mostly.
 
incidentally it's a kind of bike I'm not really afraid to get on a 400km trip back home
meh, patience, bartek, patience
 
Ben
@Bartek I'm picturing you on that bike with your glasses speeding through the city, evading someone.
 
2:41 PM
it's not really a thing you use to run from someone
it's an adventure tourer
 
Ben
@BartekBanachewicz no, no, like in action scenes in movies.
 
Ben
@BartekBanachewicz yes, maybe even carrying a glock as well.
anyway, nice bike.
 
I mean technically
the fine for driving w/o the license is just 300PLN (because I have B already)
compared to the savings I could make that's actually... freaking low
but
the policeman can also make the case go to the court
which could set a fine of up to 5k PLN and and order preventing me from driving anything
grghg
 
@BartekBanachewicz o_O - dafuq, driving in Slovakia without driving license can end up with you being in jail for public endangerment
 
2:49 PM
I think it can also happen here if the court decides so
but the very fact that legally it could be just the monetary fine and then "w/e go on your way" without even any points towards losing your other licence
 
honestly that's no joke, because the assumption is that you can't drive if you don't own one
 
Ben
I think the law may be a bit more lenient in NZ, in terms of driving without a license.
 
if it was guaranteed that not having that "A" label could only result in the fine, it'd be kind of a no-brainer
that's the cost of fuel for driving to that place
OTOH there's also the insurance problem. If I happened to kill someone without the licence, I'd be royally fucked
 
@BartekBanachewicz You sure about "w/e go on your way"?
 
Ven
2:53 PM
Yeah better endanger people by not learning how to drive instead of just... learning.
 
I'd hazard that they wouldn't let you drive right after.
 
@R.MartinhoFernandes actually, yeah. I mean they will typically say "I formally forbid you to drive any further"
but that's also often followed by "I can't really check that so"
 
it's quite simple, don't drive without a driving license really ^^
 
@Ven I've finished my course already. I'm pretty sure I can drive that thing.
Hopefully gonna prove that over the next week on the exam
 
Ven
Yeah, you're "pretty sure"
 
2:55 PM
I took the "inner exam" at my school that's mandated by polish law and passed it
it's essentially identical to the official one.
 
I am pretty sure you can essentially wait a few more days then.
 
yeah, the insurance risk is too high
OTOH I'll be really sad if someone gets that bike during that time
oh well.
 
there was a public case a few years ago in Slovakia (in my city too) with a 16 year old guy stealing a fucking bus and driving around the city for 3 hours, causing no accidents nor anything; pretty impressive, I don't think I could drive a bus even after having driven a car regularly for a few years now
 
Xeo
I really respect bus drivers, especially with narrow streets n stuff
 
@ScarletAmaranth I read about a case in Italy once, where a woman drove for like 30-something years without the licence and never ever got checked
 
3:01 PM
:D
bus drivers are the shit indeed, in crowded cities it's insane
 
yeah, OTOH they drive for hours each day, I guess it just comes with experience
I still do feel uneasy when they brake 1m behind me though
 
and a special course
 
well, I don't know where the said boy learned to drive (a fucking bus at that too)
 
@ratchetfreak well, "special" - it's just the D category
inb4 D jokes
 
I don't think I have good enough space awareness to be able to drive a bus
 
3:03 PM
then consider truckers
 
sometimes I can't park properly my car :P
 
they need to line up trailers to the loading bays
backwards
 
and they have like 16 gears
and retarders
and pneumatics
 
and no synchromesh
 
Sep 26 at 14:32, by Shoe
I have a truck driving license exam tomorrow
how did it go @Shoe
 
3:10 PM
what? he's gonna be a truck driver? way to go son!
 
he said it's just because he can
 
sounds like a good reason for putting a lightbulb in your arsehole
 
@ratchetfreak GOSH maneuvering with a trailer is horrible.
Never again.
 
handy if you go on vacation with a camping trailer
 
Not handy if you have to park outside a camping park, though.
Worst two hours of my life.
(Ok, it was more like 10 minutes, but still)
 
3:19 PM
lol
new VW Passat actually has a trailer driving mode
where you can drive it with a joystick and it automatically turns to keep the trailer properly aligned
 
user1804599
VW Assad
 
user1804599
@BartekBanachewicz is that Bjarne?
 
user1804599
Hmm, if I do struct Event<'a>(&'a [u8]) instead of struct Event(Vec<u8>) then my pipeline can have only one allocation instead of two.
 
@Abyx p sure it's because he's a closeted homo
like all truck drivers no exceptions
 
3:43 PM
Should I deal with recruiters who don\t bother to check my stackoverflow profile /
or let me rephrase who don't know what stackoverflow is :P
 
you don't have to deal with people you don't want to
 
3:58 PM
These errors
are gonna make me barf.
 
> Transmuting an & to &mut is UB

- Transmuting an & to &mut is always UB
- No you can't do it
- No you're not special
 
Ven
@ThePhD are you using better errors?
 
@Ven YOU'RE a better error. >:l
 
Ven
thanks bby <3
 

« first day (2176 days earlier)      last day (2776 days later) »