pawnbox has quit [Remote host closed the connection]
dannluciano has joined #crystal-lang
soveran has quit [Remote host closed the connection]
trapped has joined #crystal-lang
dannluciano has quit [Ping timeout: 264 seconds]
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has joined #crystal-lang
nakilon has joined #crystal-lang
nakilon has quit [Ping timeout: 260 seconds]
onethirtyfive has joined #crystal-lang
onethirtyfive has quit [Ping timeout: 240 seconds]
jfontan has joined #crystal-lang
onethirtyfive has joined #crystal-lang
pawnbox has joined #crystal-lang
onethirtyfive has quit [Ping timeout: 258 seconds]
onethirtyfive has joined #crystal-lang
<FromGitter>
<sdogruyol> BlaXpirit cool one
soveran has quit [Remote host closed the connection]
onethirtyfive has quit [Read error: Connection reset by peer]
dannluciano has joined #crystal-lang
onethirtyfive has joined #crystal-lang
onethirtyfive has quit [Read error: Connection reset by peer]
dannluciano has quit [Ping timeout: 252 seconds]
onethirtyfive has joined #crystal-lang
onethirtyfive has quit [Read error: Connection reset by peer]
onethirtyfive has joined #crystal-lang
onethirtyfive has quit [Remote host closed the connection]
ponga has joined #crystal-lang
nakilon has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
nakilon has quit [Ping timeout: 260 seconds]
Philpax has quit [Ping timeout: 252 seconds]
<RX14>
i should make a ROM/datamapper sort of thing in crystal
pawnbox has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has joined #crystal-lang
<FromGitter>
<sdogruyol> @RxX14 that would be great
soveran has quit [Ping timeout: 250 seconds]
mark_661 has quit [Quit: Leaving.]
mark_661 has joined #crystal-lang
<RX14>
i like the idea of the "orm" just handling converting between tuples from the database driver, and custom objects
<RX14>
and possible providing coem macros to create model objects
<RX14>
i think querying should be done through SQL, because thats what it's designed for
<RX14>
but then ROM is cool because it's not sql limited, and can map from http and other things, which makes it more complicated.
<RX14>
designing things is hard :)
<FromGitter>
<kofno> Go has `range`, which lets you iterate over a channel until the it's empty and closed. (https://gobyexample.com/range-over-channels). Is there something similar for Channels in crystal?
<RX14>
if you use an unbuffered channel you need 2 fibers though
trapped_ has joined #crystal-lang
<FromGitter>
<kofno> I don't know go, but I think that example uses a buffered channel.
<RX14>
i think so too
<RX14>
because of the 2
<FromGitter>
<sdogruyol> yeah that's a buffered channel
<FromGitter>
<sdogruyol> oh god, Go looks so archaic :(
<BlaXpirit>
well just add a fiber, not to add the scary requirement of a buffered channel https://carc.in/#/r/14wi
trapped has quit [Ping timeout: 258 seconds]
<RX14>
its hardly scary
<FromGitter>
<sdogruyol> it's not scary
<BlaXpirit>
an arbitrarily picked size limit is always scary
<RX14>
not in an example
<FromGitter>
<sdogruyol> haha
<RX14>
not if you explain it
<FromGitter>
<sdogruyol> uhmm, is there a way to check if a method is inlined or not?
dannluciano has joined #crystal-lang
<RX14>
@sdogruyol, why do you need it?
<FromGitter>
<sdogruyol> curiousity it is :P
<FromGitter>
<sdogruyol> and also for profit hehe
<FromGitter>
<kofno> Thanks everyone. My goal was just to get more comfortable using Channels and Fibers, so I've been looking at Go for examples and seeing how they translate to Crystal. Mission accomplished :)
<FromGitter>
<sdogruyol> @kofno good job!
<FromGitter>
<kofno> Thanks!
<RX14>
i know I can see when methods are inlined when i profile crystal
<RX14>
kinda
<RX14>
but i'm not sure how to just dump the whole thing
<RX14>
plus, nearly everything is inlined when used only once
<FromGitter>
<sdogruyol> @kofno my friend also wanted to compare the go versions to crystal so he created this repo
<FromGitter>
<sdogruyol> RX14: how about blocks
<FromGitter>
<sdogruyol> or any callable
<RX14>
blocks are always inlined
<FromGitter>
<sdogruyol> now, that's cool
<RX14>
yield literally pastes the block contents
<RX14>
and inlines the containing method
<RX14>
its just how they are implemented
<FromGitter>
<sdogruyol> is it the same for Proc e.g?
<RX14>
hence 3.times generates the same code as a while loop when desugared
<RX14>
uhh, i don't think proc is the same
<RX14>
well it can't be
<FromGitter>
<sdogruyol> yeah
dannluciano has quit [Ping timeout: 265 seconds]
<FromGitter>
<kofno> @sdogruyol That's cool. Part of this is a learning exercise for me. I want to see if I can translate these patterns myself, so I can understand them. That will make it easier for me to put them together later when I need to build something with it.
<FromGitter>
<sdogruyol> @kofno cool
<FromGitter>
<sdogruyol> i mean what if a Proc is generated but never used later?
<FromGitter>
<sdogruyol> does it even baked into the result or get rid of
<RX14>
if llvm can prove the variable is never used then it probably discards it like any other variable
<RX14>
proc is just a function pointer i think
<FromGitter>
<sdogruyol> yeah, probably but Proc is pretty tricky
<FromGitter>
<sdogruyol> dunno about LLVM representation though
<RX14>
the pointer and closure data are Void* though so they must be compiler details
<FromGitter>
<sdogruyol> LLVM is pretty damn neat
<FromGitter>
<sdogruyol> i have to study it sometime
Philpax has joined #crystal-lang
dannluciano has joined #crystal-lang
rolha has joined #crystal-lang
rolha has quit [Client Quit]
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has joined #crystal-lang
trapped_ has quit [Read error: Connection reset by peer]
dannluciano has quit [Ping timeout: 250 seconds]
<djdarkbeat_>
Hoping for a good pointer. Found something on google saturday didn’t know what it was at the time but now cant’ find the search result again.
<FromGitter>
<sdogruyol> what's it?
<djdarkbeat_>
I thought I saw something where you could write the format of the slices you wanted
<djdarkbeat_>
but I seem to be stuck on pulling each byte group off IO
<djdarkbeat_>
tuple.from_io
<djdarkbeat_>
that could be good.
<RX14>
actually no
<RX14>
doesn't seem to be
<RX14>
that would be useful
<djdarkbeat_>
I have packets that are packed from multiple integer and string components, mixed endianness from different manufacturer hardware, including bitpacked elements that are boolean
<djdarkbeat_>
wrote this once in Ruby 3 years ago and it’s SLOW, would love to speed it up.
<FromGitter>
<kofno> hrm... just noticed that carc.in doesn't work on chrome.
<FromGitter>
<sdogruyol> really?
<FromGitter>
<sdogruyol> I'm always using Chrome
<FromGitter>
<kofno> hrm... really. Maybe it's my chrome. I usually use Opera. It works there and on firefox, but not chrome.
<FromGitter>
<kofno> I get bad gateway errors when I try to run code.
pawnbox has quit [Read error: Connection reset by peer]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
Philpax has quit [Ping timeout: 258 seconds]
Oliphaunte has joined #crystal-lang
soveran has quit [Remote host closed the connection]
dannluciano has joined #crystal-lang
<FromGitter>
<asterite> @kofno Note that concurrency patterns are missing in Crystal because that whole part isn't finished yet. Channel should probably have an `each` method so you can iterate it. That would be the equivalent of Go's `for ... range channel`
dannluciano has quit [Ping timeout: 240 seconds]
<FromGitter>
<sdogruyol> @asterite are you working on parallelism atm, is it the first priority?
<FromGitter>
<kofno> @asterite Thank you. I know crystal is still WIP, but I'm pretty excited about it, so I'm playing w/ now :)
<FromGitter>
<DougEverly> relatedly, is there a `channel.receive(timeout)`?
<FromGitter>
<asterite> @sdogruyol I'm actually cleaning up the compiler's code. There are many places where code could be improved. My idea is that it should be really easy to understand and contribute to. So that's one my priorities right now. It might seem like a slowdown but in the long run it will make us (and everyone) go faster
<FromGitter>
<sdogruyol> @asterite yeah, i definitely agree with you
<FromGitter>
<sdogruyol> imho, we should have a little guide to jump into Crystal compiler development itself :P
<FromGitter>
<asterite> djdarkbeat_ seem to be gone, but the method he was needing was IO#read_bytes; https://crystal-lang.org/api/0.18.7/IO.html#read_bytes%28type%2Cformat%3AIO%3A%3AByteFormat%3D%3Cspanclass%3D%22t%22%3EIO%3C%2Fspan%3E%3Cspanclass%3D%22t%22%3E%3A%3A%3C%2Fspan%3E%3Cspanclass%3D%22t%22%3EByteFormat%3C%2Fspan%3E%3Cspanclass%3D%22t%22%3E%3A%3A%3C%2Fspan%3E%3Cspanclass%3D%22t%22%3ESystemEndian%3C%2Fspan%3E%29-instance-method
<FromGitter>
<sdogruyol> will make it much more easier to contribute
<djdarkbeat_>
@asterite I’m using read_bytes
<FromGitter>
<asterite> @sdogruyol I'm slowly cleaning up things and documenting how things work. I think the compiler's logic is very simple. It's just a regular program. Most of the hard parts are done by LLVM
<FromGitter>
<asterite> Oh, great! :)
<FromGitter>
<sdogruyol> @asterite yeah, it's great and simple for a compiler, but i think i'm not that smart enough to grok it at once
<FromGitter>
<sdogruyol> :D
<FromGitter>
<sdogruyol> i start reading the compiler source and i find myself somewhere i don't even know haha
<FromGitter>
<asterite> Yes, but that's because there are many messy parts and its not documented
<FromGitter>
<asterite> I truly believe a compiler is a simple thing. It's just about processing syntax trees
<FromGitter>
<sdogruyol> yeah, but the thing is that you're biased because you've been developing a compiler for more than 3 years, right? :P
<FromGitter>
<asterite> Maybe it's better to read the whole chunk of bytes at once and map them to a struct of some sort
<FromGitter>
<sdogruyol> isn't that inefficient?
<FromGitter>
<asterite> @DougEverly not exactly, we plan to have a select expression similar to Go, where in one branch you could specify a timeout
<FromGitter>
<asterite> Oh, but there's the endianess... mmm... I guess it needs to be done field by field
<djdarkbeat_>
I guess it would,
<FromGitter>
<asterite> it can probably be simplified with macros
nakilon has joined #crystal-lang
pawnbox_ has joined #crystal-lang
<djdarkbeat_>
I swear on Saturday I googled something where I found a result someone had working where they were initializing a slice off a struct like this Int16,Int16, Int32,Int32,Int32,Int32,Int32,Int32
pawnbox has quit [Read error: Connection reset by peer]
<djdarkbeat_>
from IO
<djdarkbeat_>
but I can’t find it and browser history is letting me down, starting to wonder if I imagined it.
<FromGitter>
<sdogruyol> are you talking about record?
<RX14>
i don't think so
<RX14>
i'm pretty sure record doesn't have that method
<RX14>
nop
<FromGitter>
<DougEverly> looking forward to it @asterite ... also I know that current Crystal has mutex and condition variable private. Are these going to be public with the new concurrency model? There are cases where global state structures may need to be modified and synchronized and these come in handy. Go even has these in the `sync` package despite favoring channels in most cases.
nakilon has quit [Ping timeout: 260 seconds]
<FromGitter>
<asterite> @DougEverly Mutex is now fiber-mutex, the old thread-mutex is now Thread::Mutex, so you can use that right away. We are still missing fiber-condition-variable, though
<RX14>
it's confusing that yielding a tuple expands to the block arguments
<RX14>
people should be force to use each do |{key, value}| to avoid special casing
Raimondii has joined #crystal-lang
<asterite>
what's the problem? :-)
<RX14>
it's just weird and obscure
<RX14>
and confusing
<FromGitter>
<jmoriau> @djdarkbeat_ did/could you try with a NamedTuple instead of a Hash something like {version: String, message: Int} (notice the : not =>)
<RX14>
special casing yielding a tuple into expanding block args is ugly and i hate it
<djdarkbeat_>
no because the packing of the packet is proprietary, mices several vendor hardware, endianness, bitstrings, UTF8 all in one. I have to be very eplicit about each element I’m grabbing.
<RX14>
djdarkbeat_, then why do you want to use Hash, it has the same limitations
<FromGitter>
<jmoriau> I meant using this {version: Int16, message_type: Int16, sequeunce_number: Int32} instead of {:version => Int16, :message_type => Int16, :sequeunce_number => Int32}
<FromGitter>
<jmoriau> @djdarkbeat_
Raimondi has quit [Ping timeout: 240 seconds]
<FromGitter>
<jmoriau> -+
<djdarkbeat_>
I am not up on the distinctions of the Tuple in crystal versus the hash short syntax from Ruby.
<FromGitter>
<jmoriau> @djdarkbeat_ try it, should work
<djdarkbeat_>
is it correct there is no hash short syntax in Crystal?
<djdarkbeat_>
that it is a named tuple instead?
<FromGitter>
<jmoriau> {version: Int16, message_type: Int16, sequeunce_number: Int32} this is a NamedTuple
<FromGitter>
<jmoriau> {:version => Int16, :message_type => Int16, :sequeunce_number => Int32} this is a Hash
<RX14>
a StaticTuple can be thought of an immutable hash
<RX14>
you should be able to use a StaticTuple instead of a Hash in your usecase
<RX14>
and be faster
<RX14>
and cleaner imo
<djdarkbeat_>
Hmm. I have a component of my bytes for the instrument readings that makes the packet dynamic in length but I see your point. I can use the static tuple for everythign except the readings segment.
<asterite>
what's a hash short syntax?
<djdarkbeat_>
{this: 2, that: 4}
<FromGitter>
<jmoriau> the ':' notation instead of the arrow
<djdarkbeat_>
the Ruby 1.8 to 1.9 leap
<asterite>
oh, we use that for NamedTuple
<djdarkbeat_>
right
<djdarkbeat_>
and that’s what threw me a bit
soveran has joined #crystal-lang
<RX14>
but for your usecase f using it as something to map on to unpack an IO you can use a NamedTuple and it should be the same
Raimondii is now known as Raimondi
soveran has quit [Remote host closed the connection]
soveran has joined #crystal-lang
<asterite>
depending on what you need the data for, I would use structs with fields, or records. Hashes are (ab)used in Ruby, and in Crystal you can't easily abuse them
<asterite>
or just plain variables
<asterite>
(but that's just my opinion)
mark_661 has quit [Quit: Leaving.]
<FromGitter>
<acterhd> Hello have you atomics and simd support?
<djdarkbeat_>
what’s the deal with initializing Hash
<FromGitter>
<acterhd> i.e. you have no parallelism?
<djdarkbeat_>
but I sense the thinking is a bit different in crystal
<RX14>
acterhd, nope not yet, but we will before 1.0
<RX14>
djdarkbeat_, yes because the compiler has to know whaat you're doing
<RX14>
you might need to use macros here i'm not sure
<RX14>
but using a hash is wrong here
<FromGitter>
<acterhd> how you made IRC in gitter?
<RX14>
custom bot written in crystal
pawnbox has quit [Remote host closed the connection]
<RX14>
acterhd, btw parallelism isn't so important in crystal because it's just so fast
<FromGitter>
<acterhd> I want in crystal write path tracer
<RX14>
well
<FromGitter>
<acterhd> so need more threads
<djdarkbeat_>
So make my output a named tuple
<RX14>
you can write it now and it'll be parallel in a few months...
<RX14>
djdarkbeat_, yes
<FromGitter>
<acterhd> and will SIMD support?
<FromGitter>
<acterhd> for JS it have
<RX14>
i think it's kinda possible
<RX14>
you could write it yourself using the asm literal
<RX14>
or bind to llvm intrinsics maybe
<FromGitter>
<acterhd> Can Crystal builded to webassembly?
<RX14>
no
<RX14>
technically yes
<RX14>
but not
<RX14>
not without a large amount of effort
<FromGitter>
<acterhd> what is bigint?
<djdarkbeat_>
well I’m going to have to keep my eye on this for sure, we’re aggregating live transit data from UDP streams. Rubys not going to keep up.
<RX14>
libgmp arbitrary size integer acterhd
<RX14>
djdarkbeat_, crystal might be 100x faster for that already due to evented io
<RX14>
even without parallelism
<RX14>
on IO bound, bit fiddling workflows crystal can be much much much faster
<djdarkbeat_>
That’s great news.
<RX14>
libevent + fibers makes any IO much faster on crystal than ruby
<RX14>
well, concurrent IO
<RX14>
if you perform any blocking IO when processing the udp packet it can start processing another udp packet while the first operation blocks#
<RX14>
thats's more useful on tcp
<RX14>
but probably still useful on udp
<FromGitter>
<acterhd> i want write path tracing for create new image format, different than all in the world
<FromGitter>
<acterhd> .dotx
<FromGitter>
<acterhd> would be good if will opengl
<asterite>
djdarkbeat_: out of curiosity, what protocol do you need to handle?
pawnbox has joined #crystal-lang
snsei has quit []
djdarkbeat_ has quit [Quit: djdarkbeat_]
dannluciano has joined #crystal-lang
snsei has joined #crystal-lang
dannluciano has quit [Ping timeout: 244 seconds]
willl has joined #crystal-lang
nakilon has joined #crystal-lang
nakilon has quit [Ping timeout: 276 seconds]
tomchapin has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
Oliphaunte has quit [Remote host closed the connection]
soveran has quit [Remote host closed the connection]
soveran has quit [Remote host closed the connection]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 250 seconds]
emancu has joined #crystal-lang
Oliphaunte has joined #crystal-lang
djdarkbeat_ has joined #crystal-lang
Oliphaunte has quit [Ping timeout: 250 seconds]
dannluciano has joined #crystal-lang
<djdarkbeat_>
I’m handling UDP packets with a proprietary structure of mixed type data of GPS strings, bitpacked sensor values and numerical instrument readings.
<djdarkbeat_>
asterite I’m handling UDP packets with a proprietary structure of mixed type data of GPS strings, bitpacked sensor values and numerical instrument readings.
dannluciano has quit [Ping timeout: 252 seconds]
<RX14>
djdarkbeat_, what do you do with the data? write it to a DB?
Oliphaunte has quit [Remote host closed the connection]
dannluciano has joined #crystal-lang
dannluciano has quit [Ping timeout: 265 seconds]
nakilon has joined #crystal-lang
Oliphaunte has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
paulcsmith_ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
adam^ is now known as adam12
emancu has quit []
nakilon has quit [Ping timeout: 260 seconds]
ssvb has quit [Ping timeout: 260 seconds]
Raimondii has joined #crystal-lang
ssvb has joined #crystal-lang
Raimondi has quit [Ping timeout: 240 seconds]
<FromGitter>
<jwoertink> Anyone here familiar with `guard`?
<FromGitter>
<jwoertink> I'm trying to use it with kemal to auto-restart the server when one of the files change, but when it tried to reboot, I get a `Error binding TCP server at 0.0.0.0:3000: Address already in use (Errno)` error
Raimondii is now known as Raimondi
<FromGitter>
<sdogruyol> Ugh, you have to stop the process first
dannluciano has joined #crystal-lang
<FromGitter>
<jwoertink> I've never really used guard before, but I'm using `guard-process`
<FromGitter>
<jwoertink> and have my `Guardfile` setup with `guard 'process', name: 'crystal app.cr', stop_signal: 'KILL', command: 'crystal app.cr'`
<FromGitter>
<sdogruyol> And sleep 0.1 or something to make sure it stops
<FromGitter>
<sdogruyol> I have to try it myself but i am going to sleep for now.
<FromGitter>
<jwoertink> sleep 0.1?
<FromGitter>
<jwoertink> lol
<FromGitter>
<sdogruyol> Haha
<FromGitter>
<sdogruyol> Nice one :+1:
dannluciano has quit [Ping timeout: 276 seconds]
<FromGitter>
<acterhd> why no float like 1.0f?
<BlaXpirit>
acterhd, what's that supposed to do if 1.0 is already a float?
<FromGitter>
<jwoertink> `1.0.class #=> Float64`
<FromGitter>
<acterhd> 1.0f.class can be float32
<FromGitter>
<jmoriau> I thought float literals were always Float64 ?
<FromGitter>
<acterhd> also, will cool if crystal can be played in browser
<FromGitter>
<acterhd> and will language instead of js
<FromGitter>
<jwoertink> Use Opal if you want the syntax