<FromGitter>
<dscottboggs_gitlab> aw man there's no way to stick docs onto the Mapping. nevermind. :/
<FromGitter>
<dscottboggs_gitlab> this whole thing would be so much easier if the JSON api and crystal didn't have different capitalization conventions
<FromGitter>
<Blacksmoke16> you could just name your properties those, wouldnt be real crystal like but meh
<FromGitter>
<dscottboggs_gitlab> it wouldn't work because the first letter is capitalized and you can't name methods starting with a capital letter
<FromGitter>
<Blacksmoke16> ah, then yea thats the way to do it
<FromGitter>
<dscottboggs_gitlab> also that would be...offensive to look at
<FromGitter>
<dscottboggs_gitlab> lol
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 268 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 252 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
<riceandbeans>
How would you compare crystal to rust?
<FromGitter>
<drujensen> Are you looking for a list of differences? What makes each stand out?
<FromGitter>
<drujensen> If so, I think Rust’s memory ownership model is unique.
<FromGitter>
<drujensen> It lacks Inheritance for OOP
<FromGitter>
<dscottboggs_gitlab> idk most langauges it's about a tradeoff between development time and workload processing time for a given domain. For most domains I'd say crystal would be much faster to develop for but run somewhat slower than rust. To be fair though, I haven't really gotten into rust, it could just have a really steep learning curve and be really fast and easy to use once you get over that.
rohitpaulk has quit [Ping timeout: 245 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 252 seconds]
rohitpaulk has joined #crystal-lang
Liothen has quit [Quit: The Dogmatic Law of Shadowsong]
Liothen has joined #crystal-lang
<FromGitter>
<swinSpo> rust is way harder
<FromGitter>
<proyb6> I would say Rust is easy but not easy to spent time looking at long compilation
_ore has quit [Ping timeout: 244 seconds]
<FromGitter>
<farrspace> Can anyone help me or point me to docs for capturing Process output? I saw an example ( https://stackoverflow.com/a/35490899 ) using MemoryIO, which I think is now IO::Memory, which looks like what I want, but that won't work because Process's output needs to be IO::FileDescriptor | Process::Redirect. I'm trying to write a shell if that makes a difference in strategy (as in bash/zsh/fish/etc). =) ⏎ ⏎
<FromGitter>
<pitosalas> Anyone familiar with crystal_db? I want to update a record. I see how to get a recordset and read column names and values, but I don't see how to change a value. Is that a different class? Or is it TBD? Or do I use a sql statement to do this?
<jokke>
j8r: Expected Socket::Error with "getaddrinfo: Servname not supported for ai_socktype", got #<Socket::Error: getaddrinfo: Unrecognized service> with backtrace:
<jokke>
getting this when building in dockerfile
<jokke>
any easy fix for this?
<FromGitter>
<proyb6> Any tools to profiling the internal details of the code like memory consumption and how long each took to execute is important for Crystal to be top performant?
valera has quit [Quit: leaving]
<FromGitter>
<proyb6> I think we need that to make it easy for Developers to measure and knowing in and out so that you can be confidently promote Crystal
rohitpaulk has quit [Ping timeout: 252 seconds]
<FromGitter>
<j8r> jokke: yes I had this too
<jokke>
j8r: you didn't find a way around it?
<FromGitter>
<j8r> for this there is a patch for
<FromGitter>
<j8r> I've kept it now, only removed the one for libressl (noz supported)
<FromGitter>
<j8r> the specs still need to be patched :/
z64 has joined #crystal-lang
<jokke>
j8r hm weird i literally copied the files from your branch and tried building but it didn't work.
Raimondi has joined #crystal-lang
<FromGitter>
<j8r> jokke: it seems that running specs inside docker fails, due to networks restrictions
<jokke>
yeah
<FromGitter>
<j8r> except that, everything sounds OK
<jokke>
mhm
<jokke>
i just wonder if there's a way to make it work otherwise it's really hard to build an image :P
<jokke>
i mean, i could skip the specs of course
<FromGitter>
<j8r> you can just remove the spec part
<FromGitter>
<j8r> or remove the one from tcp
<jokke>
i really hope future releases will deprecate methods before removing them
<jokke>
it's really annoying because of exactly these issues.
<jokke>
yeah i know, pre 1.0
<jokke>
still. It's not much extra effort
<jokke>
at least not when methods are just renamed
<FromGitter>
<j8r> yes, we should have a standard way to deprecate things
<FromGitter>
<j8r> with an annotation, that will print a warn at compile time. Even outside Crystal itself
<FromGitter>
<proyb6> I wonder anyone knows about Golang benchmark which their string builder benchmark shown 5 B/op but Crystal seems to be so large ⏎ 536871664B/op if builder.write("x".to_slice) is similar to Golang? ⏎ ⏎ > go test -bench . -benchmem ⏎ goos: darwin ... [https://gitter.im/crystal-lang/crystal?at=5be067f60445e15fad29739d]
<FromGitter>
<yxhuvud> @j8r: can it be that it got optimized away?
<FromGitter>
<j8r> @yxhuvud what do you mean?
<FromGitter>
<dscottboggs_gitlab> @proyb6 you're benchmarking two different things.
<FromGitter>
<yxhuvud> oh, wrong receipient. it was proyb that posted the benchmark
<FromGitter>
<dscottboggs_gitlab> your `fastest` method does the same thing the go one does, but 200000000 times
<FromGitter>
<dscottboggs_gitlab> Also I love that it's faster than the go one :D
<FromGitter>
<dscottboggs_gitlab> Although, I suspect both are optimizing away the "x".to_slice process and saving it as a constant, so a more interesting comparison might be writing a random letter
<FromGitter>
<j8r> it's there, why? And if not here, I should have `doesn't exist: /home/jrei/Desktop/Projects/dppm/spec/temp_dppm_prefix/pkg/test_0.1.2-beta` instead
<FromGitter>
<dscottboggs_gitlab> oh actually it's slower but less B/op
<FromGitter>
<proyb6> @dscottboggs_gitlab True, with your new code, it's 9ns in Crystal vs 4.xx ns in Go
tankf33der has left #crystal-lang [#crystal-lang]
<FromGitter>
<dscottboggs_gitlab> yeah I was looking at the B/op since that's what you were highlighting before but yeah that's about par for what I've seen so far.
<FromGitter>
<proyb6> Would the nanosecond differences affect that with large text?
<FromGitter>
<proyb6> Especially for web server
<FromGitter>
<dscottboggs_gitlab> yes, I'm sure
<FromGitter>
<proyb6> I think we could see if anyway to optimize String::Builder and others builders?
<FromGitter>
<dscottboggs_gitlab> so the golang in this case is 1.68 microseconds vs crystal's 1.46
<FromGitter>
<dscottboggs_gitlab> honestly with the results this close together, it doesn't make that much of a difference. I see crystal and go as mostly neck and neck, with crystal trailing a bit due to OOP and sugar. They're both AT LEAST an order of magnitude faster than Python or Ruby, who are where most of the mindshare is coming from.
<FromGitter>
<dscottboggs_gitlab> If you want something noticeably faster than crystal you should probably use rust but I don't personally think that's worth it. you could use C but that's just asking for trouble
<FromGitter>
<dscottboggs_gitlab> that was fun! :D
<FromGitter>
<proyb6> I'm glad that Crystal is easy to code is a huge advantage!
<FromGitter>
<kingsleyh> hey - what's an efficient way to convert a hex string like this to bits (binary) 00b3e054bf00116eef6234a4fd9eee9c8b21f61396d47f1
<FromGitter>
<dscottboggs_gitlab> you want to read the whole thing as a single number?
<FromGitter>
<kingsleyh> hmm actually I don't think that's what I want
<FromGitter>
<dscottboggs_gitlab> yeah I think its too big
<FromGitter>
<dscottboggs_gitlab> you want each pair of digits evaluated as a byte!
<FromGitter>
<kingsleyh> I think I want to use the underlying byte array and apply a mask to it
<FromGitter>
<dscottboggs_gitlab> z64 nice I'll have to keep that one in mind
<z64>
oh yeah, i ended up messing around with that tcpsocket / channel thing i brought up last time. didn't go so well! lol
<FromGitter>
<dscottboggs_gitlab> oh? what happened?
<FromGitter>
<z64> what i ended up coming up with ended up being almost mechanically the same ⏎ it exposed a "race condition" i can exploit to actually get the desired behavior - but it won't work "safely" or "as fast as possible" - not sure how to word it correctly :) ⏎ ⏎ by this i mean, i can `sleep 1` for example during my read buffering loop *before* i check `channel.empty?`, and multiple messages will be buffered
<FromGitter>
<kingsleyh> how do I construct a mask I mean
<FromGitter>
<kingsleyh> say I have a byte array of 512 length - and I want to extract the first 5 bytes using a mask
<FromGitter>
<kingsleyh> I would create a mask byte array of 512 length? but what would I put in it?
<FromGitter>
<dscottboggs_gitlab> oh jeeze
<FromGitter>
<kingsleyh> or am I not making any sense lol!
<FromGitter>
<j8r> (I solved my getcwd issue finally)
<FromGitter>
<Blacksmoke16> what was it
<FromGitter>
<dscottboggs_gitlab> @kingsleyh in what way does the byte mask modify the byteset you're dealing with?
<FromGitter>
<kingsleyh> it should not modify it
<FromGitter>
<dscottboggs_gitlab> @z64 a bare sleep yields the fiber, maybe that would be less hacky, but I think requiring the fiber to yield is a weird bit of the way crystal works right now.
<FromGitter>
<j8r> @Blacksmoke16 I runned the spec, and a spec `Dir.cd` on a dir that will be deleted. When executing a further spec, the directory no longer exist and doing a `Dir.cd {}` produces the error
<FromGitter>
<Blacksmoke16> that would do it
<FromGitter>
<j8r> So I `Dir.cd *DIR*`, solved
<FromGitter>
<kingsleyh> arg I'm confused
<FromGitter>
<dscottboggs_gitlab> are you trying to transform one set of bytes by a second (known) set to receive a third?
<FromGitter>
<kingsleyh> if I said: Slice(UInt8).new(512) <--- that is a byte array with a length of 512 bytes? which is 4096 bits?
<FromGitter>
<dscottboggs_gitlab> I think you have to do `Slice(UInt8).new(512, 0)` to properly initialize the whole thing
<FromGitter>
<dscottboggs_gitlab> that sets everything to zero
<FromGitter>
<kingsleyh> no I'm trying to tell if a hash has a number of leading zeros
<FromGitter>
<kingsleyh> but I don't want to count the leading zeros in the hash - I want to count them at the bits level
<FromGitter>
<dscottboggs_gitlab> oh.
<FromGitter>
<dscottboggs_gitlab> do `sprintf "%b", "hash value".to_big_i`
<FromGitter>
<dscottboggs_gitlab> that gives you the binary string of all the bits
<FromGitter>
<dscottboggs_gitlab> then check how many leading zeros
<FromGitter>
<dscottboggs_gitlab> although... you wanted efficient, which that is not.
<FromGitter>
<kingsleyh> I think that will mostly fail with Invalid BigInt though
<FromGitter>
<dscottboggs_gitlab> initialize a slice set to all zeros like I said, then copy in the string two characters (one byte) at a time, then count how many zero bytes are in the slice
<FromGitter>
<kingsleyh> and it's not very efficient
<FromGitter>
<dscottboggs_gitlab> actually since you know the length you should use StaticArray instead of slic
<FromGitter>
<dscottboggs_gitlab> that's the best I've got
<FromGitter>
<dscottboggs_gitlab> hahaha you can `#rewind` a IO::Memory nice find @z64
<FromGitter>
<bew> @kingsleyh your hash is a String?
rohitpaulk has quit [Ping timeout: 244 seconds]
<FromGitter>
<z64> @dscottboggs_gitlab yep :)
<FromGitter>
<dscottboggs_gitlab> so your stuff is deadlocking in `read_response`? or somewhere else?
<FromGitter>
<z64> nothing is deadlocking now - see the spec & Travis failure. Two immediately sequential responses from the server should be buffered and returned to the client as one response. however, the data is handled "too quickly" and after the first message from the server is handled, channel.empty? is truthy and it only returns the first response. The two responses will be buffered together correctly by slowing down
<FromGitter>
... read_response before the break
<FromGitter>
<dscottboggs_gitlab> did you try sticking a bare `sleep` in that while loop? if that doesn't do it i don't know
<FromGitter>
<z64> yes that's exactly what I mean. I just said sleep 1 as an example. in the real world, I don't know yet what will be a realistic value
<FromGitter>
<z64> so that *will* work; but I'm still not confident this is the best - and safest - solution
<FromGitter>
<z64> for all I know it seems like the best I can do with the data I have
<FromGitter>
<dscottboggs_gitlab> bare `sleep` or `Fiber.yeild` I think is what you're looking for.
<FromGitter>
<z64> Hm not sure. I'll try it anyways, easy enough. I think I could get a reasonable speed for that loop by measuring the latency of the response after logging in, and padding it some
<FromGitter>
<dscottboggs_gitlab> yeah maybe if you want to wait for a little network latency
<FromGitter>
<kingsleyh> ok new question how can I convert a byte array to a BitArray?
<FromGitter>
<z64> @dscottboggs_gitlab yeah `Fiber.yield` does nothing, and just `sleep()` will block forever. ⏎ i'm thinking now that maybe responses should just be handled async, and the user should just register a callback.. i don't think there is much use case for actually handling responses from this protocol other than debug output. (they are not meant for machines to read) *shrug* ⏎ Thanks for the input, anyways (:
<FromGitter>
<dscottboggs_gitlab> :/ sorry to hear that didn't wrok
<FromGitter>
<dscottboggs_gitlab> is there a way I can have a string literal not be interpolated?
<FromGitter>
<dscottboggs_gitlab> i want to put a method name in a string literal in a macro which means `"#{{variable}}"` which crystal tries to interpolate
<FromGitter>
<z64> i believe you need to use concatenation in that case: `"method: " + {{variable}}`
<FromGitter>
<dscottboggs_gitlab> ah that would do it thanks
<FromGitter>
<kingsleyh> is there a way to convert a string e.g. "0b1110" to 0b1110
<FromGitter>
<z64> in short, `"0b1110"[2..-1].to_i(2)` - you can use `String#starts_with?("0b")` etc to detect the binary decorator and do this trim if necessary
<oprypin>
in Python: `int('0b1110', 2)` or `int('0b1110', 0)` for autodetect :p
<non-aristotelian>
Hello; I upgrade to Crystal 0.27.0 via Homebrew, and now I'm getting this when attempting to `require` code: https://pastebin.com/raw/GpY9Nuh3 ;; I did the "same thing" yesterday on a different machine, upgraded from 26 to 27, and it went okay ;; ideas?
<FromGitter>
<z64> `11` in binary is `0b1011`. the "significance" of a single bit is that bit's place value - the impact it has on the value of the number when the bit is flipped. you can see from the example, it reads `1101`, since the rightmost bit is the least significant
<FromGitter>
<kingsleyh> ah I see
<FromGitter>
<z64> I think that example would be improved by using base 2 literals like the other example of `#bits_set?` below it..
sagax has joined #crystal-lang
<non-aristotelian>
`property? session : Salt::Middlewares::Session::Abstract::SessionHash?` -- `property?` builds `#session=` and `#session?` ;; What does the ? at the end of SessionHash mean?
<non-aristotelian>
oprypin: I was just reading that ;; that answers the property? part, not the ClassName?. -- Okay I see, ClassName? is basically like saying (ClassName | Nil). Cool beans. TY
<non-aristotelian>
I like the idea of being able to reject nil -- feels like avoiding NULL in SQL.
<non-aristotelian>
I wonder why library-author decided to let `session` be nil at all...
<non-aristotelian>
Especially when he raises error via @session.not_nil!
<oprypin>
non-aristotelian, maybe because session is not viable to initialize in `initialize`
<non-aristotelian>
oprypin: Hmm.. Possibly. I still think a sane default-value is better than nil.
<non-aristotelian>
E.g. an empty-hash.
<oprypin>
sometimes it is
_ore has joined #crystal-lang
dannyAAM has quit [Quit: znc.saru.moe : ZNC 1.6.2 - http://znc.in]