<FromGitter>
<dscottboggs_gitlab> so then would author_id be a column on User or on another table?
<FromGitter>
<Blacksmoke16> in the `jobs` table
<FromGitter>
<Blacksmoke16> so like this would be used like `Job.match(OwnsJobs.new user)`
<FromGitter>
<Blacksmoke16> where user comes from db or something idk
<FromGitter>
<Blacksmoke16> which would be like select * from jobs where (author_id = 1321)`
<FromGitter>
<Blacksmoke16> assuming that user's id is 1321
<FromGitter>
<Blacksmoke16> `BelongsToUser` would be a better name
<FromGitter>
<dscottboggs_gitlab> idk that just seems problematic to me unless you made the matchers subclasses of the things they're matching on like `Jobs::BelongsToUser`
<FromGitter>
<Blacksmoke16> hm yea good point
<FromGitter>
<Blacksmoke16> could get into trouble adding blocks to things they not supposed to go on
<FromGitter>
<dscottboggs_gitlab> like you've got this struct that seems like a standalone filter but it depends on the column `author_id` in a table that has nothing obviously to do with it
<FromGitter>
<dscottboggs_gitlab> yeah exactly
<FromGitter>
<Blacksmoke16> exactly
<FromGitter>
<Blacksmoke16> :p
<FromGitter>
<dscottboggs_gitlab> haha
<FromGitter>
<dscottboggs_gitlab> I see why this pattern is controversial. It's powerful but it can be dangerous if not done right
<FromGitter>
<Blacksmoke16> what could i do to prevent that tho
<FromGitter>
<dscottboggs_gitlab> oh nothing, that's not your responsibility
<FromGitter>
<dscottboggs_gitlab> you are familiar with and want to use this pattern and that's fine,
<FromGitter>
<Blacksmoke16> maybe if an ORM had a deep enough suport for this you could raise a compile time error if you used one on something that doesnt have that col
<FromGitter>
<Blacksmoke16> or some sort of registration thing where you whitelist specs that a class is allowed to take
<FromGitter>
<Blacksmoke16> :0
<FromGitter>
<Blacksmoke16> remember how you were doing splat generics?
<FromGitter>
<dscottboggs_gitlab> I'm just saying I recognize how it could be dangerous but if you know what you're doing with it (or use it in a well-tested ORM or other abstraction) it can be really great
<FromGitter>
<dscottboggs_gitlab> yes, why?
<FromGitter>
<Blacksmoke16> what if i did something like
<FromGitter>
<Blacksmoke16> Why you would you have to? Isn't that what the GC is for
<FromGitter>
<iambudi> what is the best way in crystal to implement expire time while waiting response from server?
<FromGitter>
<iambudi> is delay() recommended?
<FromGitter>
<dscottboggs_gitlab> delay seems perfect to me
<FromGitter>
<proyb6> @Blacksmoke16
<FromGitter>
<proyb6> I see the memory went up from 1MB to 100MB+ when benchmark with wrk and memory wonโ GC
<FromGitter>
<dscottboggs_gitlab> why won't it GC?
<FromGitter>
<proyb6> Let me try Kemal, current using onyx rest
<FromGitter>
<Blacksmoke16> Hmm, dunno
<FromGitter>
<Blacksmoke16> Probably a bug
<FromGitter>
<Blacksmoke16> Should try Athena ;)
<FromGitter>
<staleo> Hi guys! I remember theres been a service with 4-letter io domain, where ppl could quickly run a piece of crystal code, but i cant remember the url. Sort of abbreviation, or something. Anyone?
gangstacat has quit [Remote host closed the connection]
sp3ncer has joined #crystal-lang
sp3ncer has left #crystal-lang [#crystal-lang]
<FromGitter>
<proyb6> I see, it looks like the folks still need a permanent solution to free memory
<FromGitter>
<proyb6> Meanwhile, calling ```GC.collect``` 5 or more times rapidly will free up memory usage while the app is idle
<FromGitter>
<dscottboggs_gitlab> > calling GC.collect 5 or more times rapidly โ โ On one hand that sounds like a huge hack...what if the GC implementation changes? Ouch... โ โ On the other, this really seems like an issue you're running into specifically because you're running a benchmark... which actually reflects accurately the choices Crystal has made around optimization of time vs memory. If a server were under the
<FromGitter>
... sort of load a benchmark puts it under, you'd want it to hold onto some memory for a little while so that it doesn't have to wait to ask for more. But in most situations, after a while, the GC would release that memory anyway. [https://gitter.im/crystal-lang/crystal?at=5c4d41819221b9382dcace79]
<FromGitter>
<proyb6> @dscottboggs_gitlab Not sure when it will release the memory and would stave other services require a large amount of memory as well.
<FromGitter>
<dscottboggs_gitlab> I wonder if there's a way to increase the frequency of collections besides manually calling #collect...
<FromGitter>
<dscottboggs_gitlab> no I don't think so
<FromGitter>
<proyb6> I've used GC_FREE_SPACE_DIVISOR and increase it, not that I can effectively free when the benchmark is pushing the limits
<FromGitter>
<dscottboggs_gitlab> true
<FromGitter>
<dscottboggs_gitlab> I suppose if you really need that memory under extreme load, even at the expense of performance, then your only option is to use GC.collect manualy, because regardless of the GC it isn't going to be able to free up resources with the benchmark banging on it
_whitelogger has joined #crystal-lang
oz has joined #crystal-lang
<FromGitter>
<proyb6> Maybe, only reverse proxy are able to handle that for now and seriously need folks to evaluate Immix.
<FromGitter>
<proyb6> On the other hand, manually managing memory need more tutorials
rohitpaulk has joined #crystal-lang
blassin has quit [Quit: Ping timeout (120 seconds)]
blassin has joined #crystal-lang
rohitpaulk has quit [Remote host closed the connection]
<FromGitter>
<girng> @proyb6 i've had the same questions you had 7+ months ago or so
<FromGitter>
<mavu> I just tested GPIOs on a pi using crystal -> wiringPi, just switching a pin high and low in a loop, to see how fast it could go in crystal vs. C. โ surprisingly, my scope can't tell the difference, both clock in at about 15mHz. I find that pretty neat :)
<FromGitter>
<mavu> out of curiosity, I did a quick check with the node.js binding of wiringPi and that is so all over the place that my scope is unable to display a frequency. โ But that was not really fair, because I used a OnOff instead of the wiringPi directly. Maybe I'll try the ruby binding next
ua has joined #crystal-lang
<mps>
mavu: what board you use
<FromGitter>
<mavu> Raspberry pi 3, but I have others around here somewhere. You think it would make a big difference (beyond being a bit slower in c and crystal)?
_whitelogger has joined #crystal-lang
<mps>
mavu: with aarch64 (arm64) OS on it?
<mps>
actual question is what OS you have installed on it?
<FromGitter>
<mavu> debian stretch on this one, but it will be updated next week.
<mps>
arm64 version?
<FromGitter>
<mavu> Sorry, rasbian stretch. I'm so used to answering debian to everything .. :)
<mps>
no problem, it is debian in the base, at the end
<mps>
I had a hope that I'll hear from you that it is arm32 and that the you managed to get crystal working on arm32 :)
<FromGitter>
<r00ster91> When I do `llvm-config --version`, it gives me "6.0.0", when I run `crystal --version`, it shows "LLVM: 4.0.0". How do I make Crystal use 6.0.0?
<mps>
r00ster91: rebuild it with llvm6
<FromGitter>
<r00ster91> do you mean I should uninstall crystal and install it again? will try
<mps>
no, rebuild, i.e. recompile with llvm6 installed
<mps>
from source, I mean
<FromGitter>
<r00ster91> but I didn't build Crystal myself. I installed it with the package
<mps>
which distribution
<FromGitter>
<r00ster91> Ubuntu 18.04
<mps>
uh, strange that they built crystal with ancient llvm. I can't help with ubuntu because never used it
<FromGitter>
<r00ster91> oh no does that mean I have to build it myself
<mps>
let me look to debian stretch, wait a minute or two
<FromGitter>
<mavu> I had to build crystal myself too.
<mps>
uhm, debian does not have crystal. I'm astound.
<FromGitter>
<mavu> But mainly because the 'inofficial' debian arm package is outdated
<FromGitter>
<mavu> it is not oto hard to build yourself though.
<FromGitter>
<mavu> but the 0.27 has a bug you need ot patch if you want to run on arm.
<mps>
mavu: you mean crystal on arm32? If you have pointer/url how to build crystal on arm32 please post it here. I would like to have it in Alpine armv7 packaged
<FromGitter>
<mavu> also, for some reason I don't remember I built with llvm-3.9 (I think I found a comment somewhere saying thats a good idea and just went with it, because I needed to Get-things-done_(tm)
<FromGitter>
<mavu> the second one is probably an older one, but I don't have physical access to it at the moment to check.
<mps>
interesting, will look what and how raspbian people did it packaged
<mps>
yes, armv6 is older architecture, better say older features on arm
<FromGitter>
<mavu> again, i compiled the crystal compiler myself, no official or unofficial package used.
<mps>
from the source on raspbian?
<FromGitter>
<mavu> followed the links above, cross compiled crystal itself on x86_64 for raspi. linked in place.
<FromGitter>
<mavu> I'll have to document my steps some time next week anyway, for work. so I can make a forum post about it then. (no promises though, I have to battle CSS next week and CSS makes me cranky.)
<mps>
please, could you paste link again, I'm on the irc not gitter
<FromGitter>
<mavu> and this: crystal-lang/crystal#7039 โ keep in mind you need to patch the crystal source before you cross-comple it.
<FromGitter>
<mavu> good luck :)
<mps>
patching source is everyday duty in Free/Opensource world :) no problem for me
<mps>
thank you again for links and infos
rohitpaulk has joined #crystal-lang
<FromGitter>
<r00ster91> when I `make`, I get `/mnt/c/Users/r00ster/Desktop/make/crystal/src/llvm/pass_registry.cr:11: undefined reference to `LLVMInitializeInstCombine'` :/
<FromGitter>
<r00ster91> I tried master and 0.27.0
<FromGitter>
<proyb6> @girng I saw your thread at Rust forum on Godot, yeah
<FromGitter>
<girng> @proyb6 yeah. i think opyrpin and others basically told me (and what is boiled down to) is the GC will free some stuff, like sockets n whatnot. but other memory says around
<FromGitter>
<girng> you can test this on your VPS. load up 500, 1000+ connections, then see memory usage in crystal app rise, then disconnect them, it drops down
<mps>
r00ster91: do you have llvmX-libs installed on your build machine
<FromGitter>
<drum445> or is it better practice to pass through context?
<FromGitter>
<proyb6> @girng It less efficient to disconnect, as GC precludes control and predictability. We have to manage memory allocation/deallocation ourselves for critical services, it's hard.
<FromGitter>
<r00ster91> mps: LLVM_CONFIG is currently set to "llvm-config"
<FromGitter>
<r00ster91> and llvm-config works
<mps>
r00ster91: can't help over chat, but you can look at some build scripts, for example archlinux pkgbuild for crystal and try to adapt it to your case
<FromGitter>
<r00ster91> it seems to be a bug in llvm 6.0.0. will try to install llvm 6.0.1
<mps>
could be, I didn't tried to build with llvm6 yet, just with llvm5
<FromGitter>
<Blacksmoke16> @drum445 makes sense, cleaner too
rohitpaulk has quit [Ping timeout: 268 seconds]
tankf33der has joined #crystal-lang
<FromGitter>
<drum445> lovely, so just for my own ignorance, during compilation macros are placed in the code like they were there all along?
<FromGitter>
<Blacksmoke16> yea
<FromGitter>
<Blacksmoke16> which is why that works
<FromGitter>
<drum445> perfect, ta
<FromGitter>
<r00ster91> is anyone here on Ubuntu and installed LLVM 6.0.1?
<FromGitter>
<proyb6> @Blacksmoke16
<FromGitter>
<Blacksmoke16> Yes?
<FromGitter>
<proyb6> I have no idea how to use Athena without example :( but Iโm thinking if H2O (C) could be bind in Crystal since H2O.cr was proven in TechEmpower benchmark
<FromGitter>
<proyb6> Especially Kazuho is working on QUIC
<FromGitter>
<Blacksmoke16> did you checkout the docs?
<jemc>
when I make a mistake that affects a lot of tests in my test suite, it's really bothersome to have to scroll up past hundreds of failure messages to see any troubleshooting print statements that I added to the code
<jemc>
maybe I can monkey-patch the spec library, I guess
<FromGitter>
<Blacksmoke16> if you can find a way to tap into the error count, could maybe use a before each to call exit(1) if error count > x
gangstacat has quit [Remote host closed the connection]
gangstacat has joined #crystal-lang
<FromGitter>
<sdogruyol> @Blacksmoke16 I just checked athena, it looks really interesting ๐ I especially like the typed parameters
<FromGitter>
<Blacksmoke16> thanks man, the param conversion/route constraints are also pretty neat
<FromGitter>
<sdogruyol> it's great to see annotations in action
<FromGitter>
<sdogruyol> they're really powerful
<FromGitter>
<Blacksmoke16> indeed, it worked quite well
<FromGitter>
<sdogruyol> I'd like to give it a try when I have time :)
<FromGitter>
<Blacksmoke16> sounds good :) any questions/issues let me know
fanta7531 has quit [Quit: fanta7531]
<FromGitter>
<sdogruyol> Sure ๐ Keep up the good work @Blacksmoke16
return0e has quit [Ping timeout: 272 seconds]
return0e has joined #crystal-lang
<FromGitter>
<dscottboggs_gitlab> @r00ster91 I am on ubuntu but mine says LLVM 6.0.0
fanta7531 has joined #crystal-lang
jemc has quit [Ping timeout: 250 seconds]
jemc has joined #crystal-lang
<FromGitter>
<dscottboggs_gitlab> do we have some sort of a standard Generator type or do you just have to make it from scratch?
livcd has quit [Ping timeout: 250 seconds]
<FromGitter>
<r00ster91> @dscottboggs_gitlab Oh. I'm looking for someone who has LLVM 6.0.1 because then he might be able to tell me how he installed that version. Because you can't `make` your own Crystal with LLVM 6.0.0 because of a regression in that release.
<FromGitter>
<dscottboggs_gitlab> oh I see...are you on 18.04 or 18.10?
<FromGitter>
<r00ster91> 1) 04
<FromGitter>
<dscottboggs_gitlab> just a sec
<FromGitter>
<r00ster91> sure
<FromGitter>
<bararchy> Our product just passed 60k LOC not incl shards
<FromGitter>
<bararchy> ๐
<FromGitter>
<dscottboggs_gitlab> both debian testing and ubuntu 18.10 moved on to llvm 7.0 rather than 6.0.1
<FromGitter>
<r00ster91> i really like the background of that website
<mps>
bararchy: I read your interview in "Programming Crystal" :)
<FromGitter>
<bararchy> Cool :) tbh I didn't even knew it was there until @sdogruyol told me
<FromGitter>
<bararchy> Hahaha
<FromGitter>
<j8r> @bararchy I remember! Does NeuraLegion is a Crystal supporter? :)
<mps>
you explained in fine words how crystal could be used, enjoyed reading it
<FromGitter>
<bararchy> @j8r not yet officially unless you count the massive amount of open source shards we release. Its my aim for 2019 to start support Crystal via NeuraLegion
<FromGitter>
<r00ster91> @mavu hmmm I installed it with `sudo apt-get install llvm-6.0` but `llvm-config-6.0 --version` gives me 6.0.0
<FromGitter>
<r00ster91> oh in "testing"? Do you know how I could access that?
return0e has quit [Ping timeout: 244 seconds]
<FromGitter>
<r00ster91> oooh but llvm-5.0 is also available on Debian! And that version is sufficient! Thank you so much, mavu
JuanMiguel has joined #crystal-lang
<FromGitter>
<girng> @bararchy 60k loc? what's the compile time on that just curious
return0e has joined #crystal-lang
JuanMiguel has quit [Client Quit]
<FromGitter>
<sam0x17> would it be possible using fibers to have a single-process crystal program that has clients connect and blocks for some arbitrary amount of time while still being able to serve other clients? or is that impossible without parallelism?
<FromGitter>
<drum445> @bararchy awesome stuff, does it compile in a reasonable amount of time?
<FromGitter>
<bararchy> @drum445 @girng I'll do benchmarks and will.let you know
<FromGitter>
<mavu> @r00ster91 No problem , happty to help. In case you need 6.0.1, you need to add testing repository to your /etc/apt/xources.list. โ You can net it up in a way that your standard distribution has precedence, and only if you manually specify something else, like apt-get install -t testing whatever_package it will pull that from testing (in this case)
<FromGitter>
<mavu> @sam0x17 Blocks how? I *think* if it blocks on waiting for IO, Crystal automagically lets other fibers run while one waits.
<FromGitter>
<r00ster91> thank you sooo much! actually one error was left with 5.0.1 but now all the errors are fixed! you are my savior
<FromGitter>
<mavu> You are welcome :)
jemc has joined #crystal-lang
ashirase has quit [Ping timeout: 246 seconds]
ashirase has joined #crystal-lang
<FromGitter>
<sam0x17> @mavu blocks manually before responding to the request -- I'm developing a distributed lock daemon
<FromGitter>
<sam0x17> so if a key is locked, other clients connecting trying to acquire a lock on that key will block until that key is released
<FromGitter>
<sam0x17> what I'm picturing is like a do while loop with Fiber.yield in it that loops until the key is unlocked
<FromGitter>
<mavu> @sam0x17 if you can yield, I don't see a problem with concurrency BUT I'm very much not an expert here. Please get some answers from people who actually know what they are saying , and not just throwing around educated guesses :)
<FromGitter>
<sam0x17> the problem I'm running into is it seems like things like kemal will block incoming web requests until the current one is finished. I don't know if that is by design or because of limitations
<FromGitter>
<sam0x17> and that's regardless of whether I Fiber.yield in a response
<FromGitter>
<domgetter> If I get a `UInt8*` from a C lib, what is the proper way of printing it out as a string?
<FromGitter>
<ankush981> Hello, noob question. Given that we have properties like `property age` in a class, this allows us to mutate the instance properties as freely as in a dynamic language like PHP and Python. What's the advantage of all this trouble? ๐
<FromGitter>
<Blacksmoke16> that is just syntax to define a getter/setter for an instance var of the given type
<FromGitter>
<ankush981> So, the idea is that you use getters and setters on properties you want to be mutable from outside, and not on those that you don't?
<FromGitter>
<ankush981> My question was, I guess, about the need for getters/setters
<FromGitter>
<Blacksmoke16> well if you dont define a getter/setter it cant be accessed/set from the outside
<FromGitter>
<Blacksmoke16> i.e. `@age : Int32`
<FromGitter>
<ankush981> ah, I see, I see
<FromGitter>
<ankush981> my bad
<FromGitter>
<ankush981> no, hold on
<FromGitter>
<Blacksmoke16> got a playground link?
<FromGitter>
<sam0x17> so this works, I'm able to serve "fast" requests while still serving a "slow" request concurrently: โ โ ```code paste, see link``` โ โ I could probably do it with a channel too [https://gitter.im/crystal-lang/crystal?at=5c4e226413a2814df6d8c8e9]
DTZUZO_ has joined #crystal-lang
<FromGitter>
<dscottboggs_gitlab> how do you bind to C++ functions?
<FromGitter>
<dscottboggs_gitlab> or does crystal not interface with c++ stuff, only C?
<FromGitter>
<j8r> it's possible, there are Qt bindings
<FromGitter>
<dscottboggs_gitlab> I know that's what I'm looking at to try to figure it out but I think @Papierkorb did some weird stuff to get it to work
<FromGitter>
<j8r> TIL websockets are obsolete. With HTTP/2 we can use SSE (server sent events)
<oprypin>
dscottboggs_gitlab: yes, it's not possible to support c++, it doesn't have a well defined binary interface. you have to go through C. perhaps a simpler example is https://github.com/oprypin/crsfml/tree/sources/voidcsfml
<FromGitter>
<dscottboggs_gitlab> @oprypin yes, that is a good example of what I was thinking of.