bjz_ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
splitty_ has quit [Read error: Connection reset by peer]
splitty_ has joined #crystal-lang
gk_-1wm has joined #crystal-lang
gk_-1wm has left #crystal-lang [#crystal-lang]
bjz has joined #crystal-lang
<FromGitter>
<mosop> jokke, try --link-flags "-Wl,-Bstatic `gpgme-config --libs` -Wl,-Bdynamic”. Sometimes I encounter the weird ‘_end’ error. On that case, I always do static link.
akwiatkowski has joined #crystal-lang
akwiatkowski has quit [Ping timeout: 260 seconds]
snsei has joined #crystal-lang
splitty__ has joined #crystal-lang
BlaXpirit_ has joined #crystal-lang
badeball_ has joined #crystal-lang
dostoyev1ky has joined #crystal-lang
stnly_ has joined #crystal-lang
A124 has quit [Disconnected by services]
A124 has joined #crystal-lang
VectorGraphics has joined #crystal-lang
rkeene_ has joined #crystal-lang
tatey has quit [Ping timeout: 260 seconds]
BlaXpirit has quit [Ping timeout: 260 seconds]
miketheman has quit [Ping timeout: 260 seconds]
rkeene has quit [Ping timeout: 260 seconds]
stnly has quit [Ping timeout: 260 seconds]
adam12 has quit [Ping timeout: 260 seconds]
g3funk has quit [Ping timeout: 260 seconds]
CompanionCube has quit [Ping timeout: 240 seconds]
yopp has quit [Ping timeout: 240 seconds]
badeball has quit [Ping timeout: 240 seconds]
dostoyevsky has quit [Ping timeout: 240 seconds]
splitty_ has quit [Ping timeout: 240 seconds]
swav has quit [Ping timeout: 240 seconds]
BlaXpirit_ is now known as BlaXpirit
miketheman_ has joined #crystal-lang
yopp has joined #crystal-lang
miketheman_ is now known as miketheman
tatey has joined #crystal-lang
adam- has joined #crystal-lang
CompanionCube has joined #crystal-lang
swav has joined #crystal-lang
manveru has quit [Ping timeout: 240 seconds]
ome has quit [Ping timeout: 240 seconds]
g3funk has joined #crystal-lang
ome has joined #crystal-lang
manveru has joined #crystal-lang
snsei has quit [Remote host closed the connection]
ome has quit [Excess Flood]
ome has joined #crystal-lang
tatey_ has joined #crystal-lang
adam| has joined #crystal-lang
CompanionCube has quit [Ping timeout: 260 seconds]
adam- has quit [Ping timeout: 260 seconds]
samis has joined #crystal-lang
braidn_ has joined #crystal-lang
g3funk has quit [Ping timeout: 240 seconds]
tatey has quit [Ping timeout: 240 seconds]
tatey_ is now known as tatey
samis is now known as CompanionCube
Philpax_ has quit [Ping timeout: 268 seconds]
VectorGraphics has quit [Ping timeout: 240 seconds]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
VectorGraphics has joined #crystal-lang
pawnbox has quit [Ping timeout: 268 seconds]
zaiste has joined #crystal-lang
VectorGraphics has quit [Quit: Leaving]
Qchmqs has joined #crystal-lang
triangles has quit [Ping timeout: 240 seconds]
_whitelogger has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox_ has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
akwiatkowski has joined #crystal-lang
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
Raimondii has joined #crystal-lang
soveran has quit [Ping timeout: 240 seconds]
Raimondi has quit [Ping timeout: 268 seconds]
Raimondii is now known as Raimondi
<FromGitter>
<crisward> @Rinkana try the run extension in VSCode, you can highlight a line of code, right click and run. It can be occasionally quite useful. Have you found anything which formats on save like the sublime plugin?
elia has joined #crystal-lang
<FromGitter>
<Rinkana> @crisward no i haven't found anything like that. But i guess i'ts just using the built-in formatter
elia has quit [Quit: Computer has gone to sleep.]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
<FromGitter>
<crisward> @Rinkana probably... It does it by default in sublime, I really like it. Shame neither of the crystal extensions for vscode seem to offer it. I really like the git tools in vsc.
<FromGitter>
<molovo> I use guardian (https://github.com/f/guardian) to trigger a compile, format, spec run and doc generation whenever the source changes. That works really well and is separate from the editor
<FromGitter>
<crisward> @molovo I was doing that, but vscode kept saying I had a conflict when I tried to save, something about the file has changed on disk, would your like to overwrite, it was very annoying. Not tried it for a while, they may have fixed it.
bjz has joined #crystal-lang
bjz has quit [Client Quit]
bjz has joined #crystal-lang
<FromGitter>
<crisward> Vscode seems to have fixed that. I'm using sentry to rebuild my app on save, I'll add it to that.
<RX14>
the latter is with a clean ~/.cache/crystal
<jhass>
I wonder how much just crystal allocates, that whether there should focus on optimizing crystals own representations of stuff or how it uses LLVM
<RX14>
hmm
<jhass>
also how do we compare against say go compiling go?
<jhass>
mh, given the GC warns that kinda hints at the former
<RX14>
thats only a 4mb alloc jhass
<RX14>
it's both
<RX14>
as I said
<RX14>
crystal uses 2gb ram
<RX14>
llvm takes up the rest
<jhass>
mh
<jhass>
btw nightly.crystal-lang.org is probably going down quite soon (and currently broken anyway I think) as the server is not mine and being repurposed
<FromGitter>
<sdogruyol> ugh that's sad
<RX14>
we'll have nightlies on jenkins soon enough I hope
<jhass>
RX14: so if you can't reach the responsible folk I can repoint the cname target to your CI or so
pawnbox has quit [Remote host closed the connection]
<jabb>
also, is there a way to break out of an outer loop while i'm in a yielding block? :D
<RX14>
jabb, typically i'd say at that point you want to refactor your code
<jabb>
right now i have a main loop, with a function that polls for an event and calls a block. in the block i'd like to quit the loop
<RX14>
return from the function
soveran has joined #crystal-lang
pawnbox has joined #crystal-lang
soveran has quit [Ping timeout: 268 seconds]
snsei has joined #crystal-lang
kubaxvx has joined #crystal-lang
snsei has quit [Remote host closed the connection]
<jabb>
i have a couple what seem to be run away processes on mac
<jabb>
utilizing 95% cpu
<jabb>
crystal-run-main.tmp
<FromGitter>
<rishavs> hi guys. i need some help with implementing oauth. i have a simple webapp using Kemal, with crud operations. I have added the google login js into my frontend. what do i do next? I have an d token but know how do i use that to authenticate and authorise the user. can someone give me the broad pointers?
<FromGitter>
<Rinkana> You need to save the token you get somewhere. It is used to communicate to the servers the token was from. With that token you can do requests on behalf of that user.
<FromGitter>
<rishavs> in that example, "some_access_token" is where i put in the token id i got from the browser, right?
<FromGitter>
<Rinkana> Correct
<FromGitter>
<rishavs> so, i dont ad any more code at all? the oauth lib handles everything like failed auth ?
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has joined #crystal-lang
<FromGitter>
<Rinkana> It seems that the std-lib OAuth2 only adds authentication headers. You still need to parse the result yourself (and so check if it was valid)
snsei has joined #crystal-lang
soveran has quit [Remote host closed the connection]
snsei has quit [Remote host closed the connection]
<FromGitter>
<tekjar> Hi. How do I intialize an existing repo into a crystal lib?
<FromGitter>
<Rinkana> @tekjar what do you mean?
triangles has joined #crystal-lang
<FromGitter>
<tekjar> @Rinkana I'll create my repo from github ui and clone it. Now I want to do crystal init on this repo
<jabb>
curious, what's the advantage to gitter over irc?
<RX14>
it's easier to set up, essentially
<RX14>
and you can paste multiple lines
<RX14>
although thats dumb
<RX14>
damn, even using --threads=1 I can't compile even std_spec with 4gb ram
mooe has joined #crystal-lang
mooe has left #crystal-lang [#crystal-lang]
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
<FromGitter>
<tekjar> Hi. How do I convert a `String` to `Slice(UInt8)` ?
<RX14>
@tekjar use to_slice on the string
<FromGitter>
<tekjar> RX14: Thanks alot
<FromGitter>
<tekjar> I was searching for `Slice(UInt8)` in the `String` documentation
<RX14>
yeah unfrtunately most methods don't have return types annotated
<RX14>
would potentially be possible to suss out some simple return types for the docs in the future
<FromGitter>
<tekjar> Yep. Helps newcomers like me to not bother you guys much :)
<FromGitter>
<tekjar> One last question for the day
<FromGitter>
<tekjar> How do I create tagged unions in crystal?
<BlaXpirit>
tekjar, i don't get it
<BlaXpirit>
or rather havent heard of this term
<FromGitter>
<tekjar> BlaXpirit : Something similar to rust's enums
<BlaXpirit>
... could you provide a direct explanation?
<BlaXpirit>
oh well, looking at it
<FromGitter>
<tekjar> I'll try
<BlaXpirit>
no, i don't think there is anything similar
<FromGitter>
<tekjar> Ohhhh
<BlaXpirit>
there's just unions which have data but no names and enums which have names but no data
<FromGitter>
<tekjar> Ohh. I can get away with unions I guess
<BlaXpirit>
you can put tuples in unions
<BlaXpirit>
hm i wonder...
<BlaXpirit>
tekjar, could try unions of namedtuples but it can get annoying to work with https://carc.in/#/r/1ob4
<FromGitter>
<tekjar> I've never written crystal code before apart from some hello world progs. Can you please point me to an example ?
<FromGitter>
<tekjar> Thanks. I'll try that
<BlaXpirit>
tekjar, and for a simpler example that someone might actually write :| https://carc.in/#/r/1ob5
<FromGitter>
<tekjar> Rust's way is to create enums and pattern match against the cases to extract its contents (also making sure that user handles all the cases). Do we have any such plans for crystal?
<BlaXpirit>
tekjar, yeah unions make you consider all cases. but crystal usually avoids big unions and people never even think about needing tagged unions
<FromGitter>
<tekjar> Oh cool thanks. I'll do that
<BlaXpirit>
well, until the C bindings section, anyway
<FromGitter>
<tekjar> Your last example link is redirecting to empty page though :)
<RX14>
technically, crystal's unions are tagged unions
onionhammer has joined #crystal-lang
<RX14>
just tagged with the type
<FromGitter>
<schoening> If I have two arrays and I pop one item off the first one and insert it into the second one, there is not gonna be any GC, right? Just moving around reference "pointers" ?
<RX14>
so typically you would just create a class/record/something for every possiblity, then stick them in a union
<RX14>
@tekjar ^
<RX14>
@schoening there can be
<RX14>
you're decreasing the size of one, and increasing the size of another
<RX14>
if there's not enough space to grow the other one it will call realloc
<RX14>
and *may* get moved around
<FromGitter>
<tekjar> Ohh. Sounds cool
<BlaXpirit>
schoening, if these are Reference types, yeah, the objects have no reason to be collected because you keep a reference to them in the process of moving
<BlaXpirit>
RX14 is talking about possible reallocation of memory for the array of pointers
<jabb>
there isn't a huge amount of info on the docs on how the gc keeps track of stuff. do pointers not hold ownership of the data?
<jabb>
what if i pass stuff to C, which expects an object to remain allocated
<RX14>
@tekjar I guess doing what I said is a bit awkward but crystal programs tend not to grow that way, if you know what I mean
<FromGitter>
<schoening> I was thinking about this today: I hope I am right in that an array *removing* elements from an array wont cause realloc? ⏎ @RX14, @BlaXpirit thanks for the answers :) I rather have a realloc than a lot of GC action I think :D preferably neither ofc
<RX14>
removing elements can cause a realloc
<FromGitter>
<schoening> Damn.
<RX14>
wait, no it can't
<BlaXpirit>
do arrays actually shrink? I'm not sure
<FromGitter>
<schoening> Whew :p
<FromGitter>
<schoening> That would kinda suck. Better safe than sorry I hope. If it got big once, it might again
bjz has joined #crystal-lang
<RX14>
concat, push, unshift
<RX14>
it should resize when it gets smaller
<RX14>
i consider that a bug
<RX14>
don't rely on it
<RX14>
jabb, GC is a rather complicated topic, but essentially it scans the whole heap, looking for numbers which looks like pointers
<FromGitter>
<schoening> I thought those things work like an "object pool" and they got an actual size that does not shrink back and a "fake" @size that is increased / decreased with those functions. But I haven't looked at the source code! That was just a wild guess.
<RX14>
and if they point to an allocation, it's considered as visible
<jabb>
i'm aware :P i'm curious about crossing the C barrier and which objects actually keep a reference so the GC holds onto it
<RX14>
well calling a C function is usually fine as the references are on the stack
<RX14>
however there are a few issues with C and the GC
<jabb>
right, not seeing any reference to those. don't want to do something bad :P
<jabb>
i expect objects on the heap coming from C are not accounted for, but passing an object to C which expects it to last awhile...?
<jabb>
also, are there any weak references?
<RX14>
there's WeakRef(T)
<BlaXpirit>
jabb, well you need to have at least one variable pointing to an object so it's not collected, for C to be able to use it
<RX14>
it's not in the docs
<jabb>
ahh, just found it
<RX14>
jabb, except 99% of the stuff that you pass into C is on the stack
<RX14>
so it's not a huge issue
<BlaXpirit>
jabb, only GC.alloc or whatever it's called is accounted for
<jabb>
RX14: stuff on stack could go out of scope no?
<BlaXpirit>
if memory is allocated by C, the GC does not track it, at least not intentionally
<RX14>
what do you mean?
<RX14>
the GC doesn't work on the stack...
<RX14>
that just wouldn't work
<BlaXpirit>
jabb, yes, i think you understand the situation but RX14 might be understanding your question differently
<RX14>
pointers on the stack always count, the stack will never be GCed
<BlaXpirit>
if u create something, give it to C code which keeps the pointer, and say exit the function, there will be breakage
<jabb>
int a def: foo = 5; c_function_that_keeps_passed(pointerof(foo))
<RX14>
as long as you don't pass a pointer to a *crystal* object to a *C* function you're ok
<jabb>
BlaXpirit: gotcha
<RX14>
well yeah thats just dangling pointers
<RX14>
C 101
<jabb>
right
<jabb>
what about
<RX14>
if you're using C bindings you still have to follow C rules
<jabb>
can a C struct be allocated on the heap?
<jabb>
a crystal C struct
<RX14>
well technically yes
<RX14>
but it involves a manual GC.malloc
<jabb>
gotcha
<RX14>
and some pointer fudging
<RX14>
so typically no
<jabb>
and i would have to keep a reference for as long as C needs that
<BlaXpirit>
or array of 1 item
<RX14>
or that BlaXpirit lol
<BlaXpirit>
jabb, yes, usually in an instance variable
<jabb>
makes sense
<RX14>
typically the GC/C issue comes when you're passing a callback to C
<jabb>
a closure?
<RX14>
and want to pass in some sort of "payload data" as a void*