<woodruffw>
does anybody have an opinion on a `Bool.to_i` method? i think it'd be nice to have one, since `Bool.hash` already normatively provides `1` and `0` for `true` and `false`, respectively
<FromGitter>
<edwardloveall> congrats on shipping 0.24
ashirase has quit [Ping timeout: 240 seconds]
ashirase has joined #crystal-lang
<FromGitter>
<elorest> What's the best way to return bytes of a file? `File.open("name").gets_to_end.to_slice` works but it seems wrong to turn it into a string and then back to bytes.
nkts has joined #crystal-lang
rohitpaulk has quit [Read error: Connection reset by peer]
marius has quit [Read error: Connection reset by peer]
rohitpaulk has joined #crystal-lang
marius has joined #crystal-lang
rohitpaulk has quit [Read error: Connection reset by peer]
<FromGitter>
<picatz> You're probably right though -- or at least I agree -- that turning it into a String then into a Slice of Bytes isn't the way to go.
marius has quit [Ping timeout: 240 seconds]
<FromGitter>
<picatz> I'd like an `all_bytes` method I think myself.
marius has joined #crystal-lang
ashirase has quit [Ping timeout: 260 seconds]
ashirase has joined #crystal-lang
marius has quit [Read error: Connection reset by peer]
marius has joined #crystal-lang
<FromGitter>
<elorest> What that would make sense. Weird because File is very similar to IO and IO::Memory has a #to_slice method.
nkts has joined #crystal-lang
marius has quit [Read error: Connection reset by peer]
<FromGitter>
<elorest> Is there a way to send `Bytes` through a TCP::Socket. Whenever I try it comes through as a string representation `message # => "Bytes[133, 163, 108, 97, 116, 171, 49, 50]"` Which isn't very useful. How would I get an array of Bytes out?
rohitpaulk has quit [Read error: Connection reset by peer]
rohitpaulk has joined #crystal-lang
marius has joined #crystal-lang
<FromGitter>
<picatz> @elorest From what I can tell, hilariously you actually need to have a string to send out.
<FromGitter>
<elorest> with @bew's answer it comes through as a corrupt string but that works. I can treat it as bytes on the other end.
<FromGitter>
<bew> Seems logic, as the bytes are not necessary a correct string
<FromGitter>
<bew> About the file 2 bytes, I think you should create a slice of a given size, then do `io.read slice_content`
<FromGitter>
<bew> To know the size you can do file.size for example
<FromGitter>
<bew> Or read chunk by chunk (e.g: by block of 4096 bytes)
<FromGitter>
<elorest> `io.gets_to_end.to_slice` works as well? What do you think is the most effective way to get the while files as bytes. I the cases I currently care about I just need the whole file in bytes.
<FromGitter>
<bew> My method is better
<FromGitter>
<elorest> :)
<FromGitter>
<bew> Yours will create an intermediate string
<FromGitter>
<elorest> I believe you but why?
<FromGitter>
<bew> ΛΛ
<FromGitter>
<bew> And it'll probably be a bit faster
<FromGitter>
<bew> Why do you need the file in bytes?
<FromGitter>
<elorest> Yeah that's what I was thinking above... ^ But yours runs 3 commands size Bytes(size), and read
<FromGitter>
<elorest> In this case so that I can encode it into protobuf.
<FromGitter>
<bew> Yes @elorest but under the hood gets_to_end will probably do more things
<FromGitter>
<elorest> In other cases I've need to have it so that I could decrypt it.
<FromGitter>
<elorest> #peek seems to work as well but isn't predictable.
<FromGitter>
<bew> Or less efficiently as you already know the size (gets_to_end will just read until the end, but it doesn't know where the end is)
<FromGitter>
<elorest> True but size is found by reading until the end as well.
<FromGitter>
<bew> Nop
<FromGitter>
<bew> Not for a file!
<FromGitter>
<elorest> If I could just dump all bytes til the end it would be most efficient.
<FromGitter>
<elorest> Hmmm ok.
<FromGitter>
<bew> The filesystem can give you the file size
<FromGitter>
<elorest> Good point.
<FromGitter>
<bew> Not even sure about that, should be 1 syscall at all
<FromGitter>
<bew> At least 1 read instead of potentially many
<FromGitter>
<bew> And 1 allocation
<FromGitter>
<bew> Need to go, bye!
<FromGitter>
<elorest> Thanks.
faustinoaq has quit [Quit: IRC client terminated!]
<FromGitter>
<picatz> I wonder if there's like... some sort of optimization being done by LLVM? ( I have no idea what I'm talking about )
<FromGitter>
<elorest> Perhaps. I'm sure @bew or <oprypin> have some idea of why this would be. Could be that it's faster but uses a lot more memory or something.
<FromGitter>
<picatz> Computers are just the craziest things.
snsei has joined #crystal-lang
<RX14>
makes sense to me
<RX14>
IO is buffered
<RX14>
actually no it doesnt
<RX14>
read_bytes being slower does though
<RX14>
ah actually yes
<RX14>
gets_to_end basically copies into the stack then into a string
<RX14>
idk why peek is slower, it shouldn't be as it does only one copy
<RX14>
your slice/read one should be slower as it does 2 syscalls
<FromGitter>
<bew> 2 ?
<RX14>
also the benchmark is basically entirely void as it leaks file descriptors
<RX14>
size and read
<RX14>
the others dont bother
<RX14>
they read it by chunks and use realloc
<RX14>
it's going to end up faster when your original guess is close to correct
<RX14>
syscalls are incredibly expensive
<FromGitter>
<bew> I would think that reading by chunk and realloc-ing would be slower than reading the whole file directly
<RX14>
just the simplest getpid syscall is 200+ cycles
<RX14>
read() will be 500+ cycles and wreck your caches
marius has quit [Quit: marius]
<FromGitter>
<bew> Maybe it's true only for huuge file, bit then it probably doesn't makes sense anymore...
<RX14>
keep in mind that the buffer size quickly approaches the correct size
<RX14>
String::Builder does * 2
<RX14>
and most of the time libgc will just return you the same pointer in a microbenchmark
<RX14>
because the previous time around left a whacking great hole just the right size
<RX14>
in this microbenchmark all your objects are the same size
<RX14>
so realloc is essentially free
sky_ has joined #crystal-lang
sky_ is now known as relyks
relyks has quit [Client Quit]
rohitpaulk has quit [Read error: Connection reset by peer]
alex`` has joined #crystal-lang
rohitpaulk has joined #crystal-lang
claudiuinberlin has joined #crystal-lang
rohitpaulk has quit [Read error: Connection reset by peer]
mark_66 has joined #crystal-lang
rohitpaulk has joined #crystal-lang
pleiosaur has quit [Remote host closed the connection]
<lvmbdv>
built 0.24.1 with LLVM 5.0.1 with no problems during the build, just checking in
<lvmbdv>
i don't bother with the spec tests tho so don't take my word :^)
<FromGitter>
<bararchy> I got the strangest issue.... β I can run specs on a shard that binds to c lib, it runs and works, trying to use it in a project raises a compile issue from the linker β both are on the same machine, on the same user and in the same shell
Yxhuvud has quit [Read error: Connection reset by peer]
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 240 seconds]
<crystal-gh>
[crystal] MakeNowJust opened pull request #5466: Fix to look up NamedTuple from self (master...fix/crystal/5464-instantiate-namedtuple-by-self-restriction) https://git.io/vbdnp
hightower3 has quit [Ping timeout: 272 seconds]
hightower3 has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
cremes has quit [Quit: cremes]
rohitpaulk has joined #crystal-lang
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 252 seconds]
<RX14>
@straight-shoota those instructions are wrong
<RX14>
You need to test them and tweak them a bit
<RX14>
For example the cmake command should use -D for all the options
<RX14>
Which caused me much pain
<RX14>
Also we dont need all those libraries yet
<RX14>
And the wording around build_path is super confusing
<RX14>
Also just use pcre 8.41
<RX14>
And skip the edit step
<RX14>
You can just unpack 8.41 and it works with the correct cmake options out of the box
<FromGitter>
<straight-shoota> I've so far only built libgc myself
rohitpaulk has quit [Ping timeout: 268 seconds]
rohitpaulk has joined #crystal-lang
<RX14>
Well
<FromGitter>
<straight-shoota> yeah I know...
<RX14>
@straight-shoota if you try to run my branch with specs working
<RX14>
You will get a link error with pcre
<RX14>
The pcre built by bcardiff also followed the wrong instructions
<RX14>
So it links until you actually try to use some regex
<FromGitter>
<straight-shoota> haven't tried that yet
<RX14>
And then it instantly breaks
<RX14>
Well windows looks to have severe Codegen bugs
<RX14>
So I'm not too excited to work on iy
<RX14>
It*
<RX14>
Given I know nothing about crystal codegen
<RX14>
Or the internals of llvm
<FromGitter>
<straight-shoota> that's probably still more then I
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 246 seconds]
rohitpaulk has quit [Ping timeout: 265 seconds]
cremes has joined #crystal-lang
rohitpaulk has joined #crystal-lang
literal has quit [Ping timeout: 240 seconds]
snsei has joined #crystal-lang
rohitpaulk has quit [Read error: Connection reset by peer]
snsei has quit [Ping timeout: 272 seconds]
rohitpaulk has joined #crystal-lang
faustinoaq has joined #crystal-lang
<hightower2>
Papierkorb: re. Fancyline, I copy the basic 3 lines from "Step 0: Most basic usage" and get: lib/fancyline/src/fancyline/widget/history_search.cr:25: instance variable '@display_handle' of Fancyline::Widget::HistorySearch must be Int32, not UInt64
rohitpaulk has quit [Read error: Connection reset by peer]
rohitpaulk has joined #crystal-lang
<FromGitter>
<bararchy> how do I test if Float_a is 0.5 points near to Float_b? I remmber specs had something for it
<FromGitter>
<straight-shoota> @RX14 I've improved the instructions for libpcre (and tested it myself) and commented out the other libraries that are currently not needed
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 252 seconds]
snsei_ has joined #crystal-lang
<FromGitter>
<bararchy> Running neural networks in Crystal really makes me itch for multi-threading
snsei_ has quit [Remote host closed the connection]
marius has quit [Quit: marius]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 252 seconds]
snsei has joined #crystal-lang
vivus has joined #crystal-lang
snsei has quit [Ping timeout: 256 seconds]
rohitpaulk has joined #crystal-lang
mark_66 has quit [Remote host closed the connection]
<FromGitter>
<codenoid> hi
<FromGitter>
<codenoid> how i can do simple login with crystal (http client)
<FromGitter>
<codenoid> and doing some action after login ?
<FromGitter>
<codenoid> please give me some example code
<FromGitter>
<codenoid> i'm trying with standart post but it's doesnt work
<FromGitter>
<paulcsmith> I've narrowed it done to the line I linked to above but it doesn't make sense that it would failed because of raising and I'm unsure how to handle it. Any ideas?
aarongodin has joined #crystal-lang
snsei has quit [Remote host closed the connection]
manveru has joined #crystal-lang
aemadrid has joined #crystal-lang
mroth has joined #crystal-lang
literal has joined #crystal-lang
<FromGitter>
<straight-shoota> @paulcsmith #5460
<FromGitter>
<straight-shoota> or rather #5224
<FromGitter>
<straight-shoota> Until this is fixed you can try `--no-debug`
<FromGitter>
<paulcsmith> --no-debug worked. Thanks a ton @straight-shoota
aroaminggeek has joined #crystal-lang
rohitpaulk has joined #crystal-lang
snsei has joined #crystal-lang
<FromGitter>
<drosehn> `$_` was popular in perl. I'm not sure that it still is. Early ruby picked up the idea of `$_` from perl (because it picked up a lot of ideas from perl), but I haven't seen any ruby programs which take advantage of that. That doesn't mean there aren't any, but I think use of the magic `$_` variable was strongly discouraged in ruby at some point.
<FromGitter>
<drosehn> ... at some point, many years ago.
rohitpaulk has quit [Ping timeout: 260 seconds]
snsei has quit [Ping timeout: 246 seconds]
<hightower2>
Yeah, use of a global was never encouraged in ruby
<hightower2>
(global $_ I mean)
cremes has joined #crystal-lang
<FromGitter>
<fridgerator> RX14 - I dont know if some work was done on travis to get crystal 0.24.1 working, but it worked for me yesterday