<FromGitter>
<bajro17> Random.new.rand(-20..20) use this
<FromGitter>
<codenoid> okay, how to determine the minimum distance of the number that comes out , for example with a distance of 2, first out the number 3, then number 6 then number 9
<FromGitter>
<codenoid> *Builtin Way :D
<FromGitter>
<Blacksmoke16> but then its not a random number?
qard has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
illy_ has quit [Remote host closed the connection]
illy_ has joined #crystal-lang
kosmonaut has quit [Ping timeout: 245 seconds]
kosmonaut has joined #crystal-lang
return0e has quit [Ping timeout: 240 seconds]
return0e has joined #crystal-lang
flaviodesousa has joined #crystal-lang
<FromGitter>
<bew> I got bored,and I'm trying to install crystal on my phone using the app Termux (provides apt and some binaries), but I'm hitting this error: Skipping acquire of configured file 'main/binary-aarch64/Packages' as repository 'https://dist.crystal-lang.org/apt crystal InRelease' doesn't support architecture 'aarch64'
<FromGitter>
<bew> Anyone knows this?
<FromGitter>
<bew> (When doing apt update, after adding the key and the deb line in sources.list)
return0e_ has joined #crystal-lang
return0e has quit [Ping timeout: 240 seconds]
<FromGitter>
<faustinoaq> @bew I tried it before unsuccessfully 😅 Did you try to cross compile it?
<FromGitter>
<bew> Naa don't want to cross compile :p
ashirase has quit [Ping timeout: 276 seconds]
<FromGitter>
<faustinoaq> ok 😄 I just was able to install crystal in my raspberry pi
<FromGitter>
<bew> Now I'm installing a Arch-like system (over termux), will see how it work out when it finishes decompressing
<FromGitter>
<aisrael> Hi! what's the status of #5324 (timezone support)? It's not in 0.24.2 yet, right?
<FromGitter>
<straight-shoota> 1) 24.2 is just a bugfix release
<FromGitter>
<straight-shoota> will be in the next one
<FromGitter>
<aisrael> Thanks. Can't wait (good thing we don't need it urgently yet [can always do the TZ conversion client-side])
<FromGitter>
<straight-shoota> you could build with stdlib from master if you need it
<FromGitter>
<straight-shoota> but I hope we see a new release soon
<FromGitter>
<Sjoerrdd> Good morning
<f1refly>
Hello
Sjoerd_ has joined #crystal-lang
<Sjoerd_>
Hello
Sjoerd_ has quit [Client Quit]
<FromGitter>
<straight-shoota> hi
<FromGitter>
<girng> hello
<FromGitter>
<Sjoerrdd> Am I the only one with issuess installing Crystal on Windows?
<f1refly>
What issues are you facing?
<FromGitter>
<Sjoerrdd> the keyserver doesn't respond
<f1refly>
are you using a (company) firewall by any chance?
<f1refly>
i think i've had this issue too
<FromGitter>
<Sjoerrdd> Maybe my school is using a firewall
<f1refly>
most likely, yes
<f1refly>
can you access a keyserver with your browser?
<FromGitter>
<straight-shoota> I've had issues with the keyserver as well, but it eventually worked
<FromGitter>
<Sjoerrdd> Thanks!
<FromGitter>
<Sjoerrdd> The Dutch goverment blocks it at schools
<f1refly>
i think gpg.mit.edu is currently unavailable anyways
<FromGitter>
<straight-shoota> googling for keys.gnupg.net unavailable shows there are frequently issues with this
<FromGitter>
<straight-shoota> you might try updating to gpg2
<f1refly>
you can manually search for the key on a different server, download it and import it with gpg from file
<FromGitter>
<Sjoerrdd> I switched from wifi network, now it works
<FromGitter>
<straight-shoota> it's really weird
<FromGitter>
<buraktutanlar> Hi everybody, I have a question, I don't know if this is discussed at somewhere public, I couldn't find easily. Why is a private function accessible from a subclass?
<Groogy>
`A private method can only be invoked without a receiver, that is, without something before the dot`
<f1refly>
Why wouldn't it? The subclass inherits the function from it's parent, hence making it accessible
<FromGitter>
<buraktutanlar> Doesn't `protected` already make the function accessible from the subclass? How would I be sure that a function only accessible in the class that it is defined?
<Groogy>
You don't really in Crystal?
<Groogy>
I mean you could make a top-level method that's private I guess?
<Groogy>
would make it only available in that file
<Groogy>
Protected means that you can do other.protected_method
<Groogy>
as logn as you are the same type
<Groogy>
it's like friends in C++
<Groogy>
sort off
<f1refly>
'protected' means it can be accessed from everything in the same namespace in crystal
<f1refly>
in the same module for example
<FromGitter>
<buraktutanlar> I just started reading language specs because it mentions OOP as a language focus. After OOP experience in Java, I was expecting to see some class scope privates. Interesting..
<Groogy>
Well Java is the C++ family, Crystal comes from Ruby which is an entirely different branch of OOP :P
<FromGitter>
<buraktutanlar> then let me read some about encapsulation in Ruby..
<Groogy>
Eh don't think they work the same actually. my point was more that a lot in Crystal is going to be alien to you if you come from like C++ or Java
<Groogy>
actually they might work the same actually, ages ago since I worked in Ruby, visibility worked differently back then
<Groogy>
`To think of this, protected actually reminds me of the "internal" accessibility modifier in C# or "default" accessibility in Java (when no accessibility keword is set on method or variable): method is accessible just as "public", but only for classes inside the same package.`
return0e_ has quit [Ping timeout: 255 seconds]
return0e has joined #crystal-lang
<FromGitter>
<buraktutanlar> Yeah, it is alien to me currently, but I will check it, I need to give it a try :) thanks!
<RX14>
in crystal we tend to trust other people a lot more
<RX14>
there's no point to having restrictions against calling a private method from a subclass becuase you can always monkey patch around it
return0e has quit [Ping timeout: 245 seconds]
<Groogy>
ah yeah since the classes are all open
return0e has joined #crystal-lang
<FromGitter>
<yxhuvud> in any case crystal doens't follow the lead of ruby when it comes to protected. I disagree with the logic of how it works as I find it very confusing
<Groogy>
D do add a bunch of new visibilities that are quite useful
<Groogy>
public, protected and private works as expected but then adds package and.. antoher one I don't remember I think
Papierkorb has joined #crystal-lang
Papierkorb has left #crystal-lang ["Konversation terminated!"]
<FromGitter>
<plainas> Please don't see this as a flamewar, I'n not really a seasoned C programmer, what's the status of static compilation? Is people using it? Does it generally works?
<Groogy>
Yes?
<Groogy>
Do you mean in Crystal or do you mean other compilers?
<FromGitter>
<j8r> yes it works, but it's recommended to do so in a Docker Alpine image (maybe there is one official?)
<FromGitter>
<plainas> I guess the question is how reliable and what's the state of compiling with a static flag? I don't see many people doing it/talking about it. I do the whole docker image from scratch, but I fin that a bit of unnecessairy overhead for what it could be just an executable for a given arch
shalmezad has joined #crystal-lang
<RX14>
--static only works on alpine linux
<RX14>
because glibc is stupid
<RX14>
same for macos
<FromGitter>
<PlayLights_twitter> I had to do use static libs on heroku
<FromGitter>
<buraktutanlar> > **<RX14>** there's no point to having restrictions against calling a private method from a subclass becuase you can always monkey patch around it ⏎ ⏎ You are right, but personally I like languages restricting a bit because otherwise I am finding myself spending too much time on reviewing PRs to see if the person is shooting himself/herself in the leg.
<FromGitter>
<buraktutanlar> > **<Groogy>** D do add a bunch of new visibilities that are quite useful ⏎ ⏎ Actually D's visibility attributes are quite similar to C++/Java, but they have different behaviours depending on the scope, if it is module or class, and this complicates the situations too much sometimes.
<FromGitter>
<plainas> how do go lang does it? Does go use llvm too?
<RX14>
no
<RX14>
go doesn't use any C at all
<RX14>
go wrote it's own stdlib
<RX14>
because they can
<RX14>
because they're google
<FromGitter>
<plainas> I see
<RX14>
s/stdlib/libc/
<FromGitter>
<plainas> as in $$$
<RX14>
as in time
<RX14>
which makes it so so easy to deploy
<FromGitter>
<plainas> I am not too familiar with these things. Where do most problems arise? libs being placed a differing locations in the filesystems across linux distros? or about their ABIs not being exactly the same?
<RX14>
but it's not really possible for crystal... yet
<RX14>
@plainas it's just that people have "always" dynamically linked
<RX14>
and they're "always" just built from source
<RX14>
and not moved binaries between distributipons
<RX14>
honestly in crystal do the same
<FromGitter>
<plainas> Ok, I got all confused now
<FromGitter>
<plainas> what's allways just build form source?
<RX14>
all the applications and libraries
<RX14>
because it's all open source
<RX14>
why not just build it
<RX14>
instead of move the binary about
<FromGitter>
<plainas> For developers yes, but for it facilitates distribution for non tech savy users of the final product
<FromGitter>
<plainas> but I am curious about 'yet', and really that is what I asked initially.... Is crystal planning to remove its dependency on C libraries?
<RX14>
of course but we're talking about traditional linux
<RX14>
no users are using it
<RX14>
@plainas no we're not planning
<RX14>
but it's possible
<RX14>
and we might do it
<RX14>
it's a long way off
<FromGitter>
<plainas> I see
<FromGitter>
<plainas> It would be cool to distribute apps as single compiled binaries
<FromGitter>
<plainas> I find Kemal nicer to use than any other frameowork in any other language. Certainly many things useful for average joe could be built with it
<FromGitter>
<plainas> I put them all in a folder like this: ```ldd bin/$PROJECT_NAME | tr -s '[:blank:]' '\n' | grep '^/' | xargs -I % sh -c 'mkdir -p $(dirname dependencies%); cp % dependencies%;'```
<FromGitter>
<plainas> then copy the contents from that folder to / on my dockerfile.
<FromGitter>
<plainas> but of course, this needs docker
<FromGitter>
<j8r> you have a replicable build environment this way
<FromGitter>
<plainas> yes
<FromGitter>
<plainas> in fact I my dockerfile is just copying these libs plus my app. based on 'SCRATCH'
<FromGitter>
<j8r> why scratch?
<FromGitter>
<j8r> the simpler is to make a Dockerfile that install system deps, your app and build statically
<FromGitter>
<j8r> and of course, a mount point to retrieve the binary
<FromGitter>
<ddrscott> I see a Dockerfile in the root project, too.
<FromGitter>
<j8r> I think I will create one for Alpine Linux (to compile statically) soon
<FromGitter>
<ddrscott> I'm going to go down that path for a bit.
<FromGitter>
<ddrscott> Thanks for the responses. The first contribution is always the hardest.
hightower2 has joined #crystal-lang
hightower3 has quit [Ping timeout: 240 seconds]
flaviodesousa has quit [Ping timeout: 276 seconds]
Creatornator has joined #crystal-lang
<FromGitter>
<Sjoerrdd> Hi
<FromGitter>
<Sjoerrdd> I'm playing around with Amber Framework
<FromGitter>
<Sjoerrdd> Do you guys know that?
<FromGitter>
<Sjoerrdd> Because I've some issue
<FromGitter>
<Sjoerrdd> I want to return a model with the entries, but I don't know how to do that, and can't find it in the documentation. does somebody know it?
<FromGitter>
<bmulvihill> I would ask @faustinoaq
<FromGitter>
<bmulvihill> @ddrscott I use mac, I believe i just did `brew install crystal-lang` then `brew link llvm --force`
<hightower2>
Sjoerrdd: you mean you want to retrieve all records from a table/model?
<FromGitter>
<Blacksmoke16> using granite that would be like `Model.all`
<hightower2>
Right
<FromGitter>
<Sjoerrdd> @hightower2
<FromGitter>
<Sjoerrdd> I've a post, with many comments
<FromGitter>
<Sjoerrdd> So i wanna retrieve the post with all comments
<FromGitter>
<Blacksmoke16> if you setup your relation it would just be like `Post.comments`
<FromGitter>
<Blacksmoke16> where `Post` is a specific post
<FromGitter>
<Blacksmoke16> like `post = Post.first`
<FromGitter>
<girng> i have a quesiton about memory usage @straight-shoota can i ask it ?
<FromGitter>
<straight-shoota> Fire away!
<FromGitter>
<straight-shoota> I just came on :D
<FromGitter>
<straight-shoota> wow, awesome news to get a full time dev
<FromGitter>
<girng> basically.. i have a class called "player" which gets created everytime a new player joins the game. i append this player class to my players array. however, when a player leaves the server, that player class gets removed from my players array. which works nice. ⏎ ⏎ except, if i load up a lot of these ( i did some stress testing ), say 500 players or so, my memory in my task manager does not go baack down.
<FromGitter>
... but, my players array is empty. do i have a memory leak somewhere maybe?
<FromGitter>
<j8r> if the class is little enough, you can try with a struct, this might help
<FromGitter>
<simaoneves> @girng as far as i know, when crystal asks memory to the operating system, it's never able to return it, it keeps it forever, regardless if it is using it or not
<FromGitter>
<girng> oh ok, so i prob don't have memory leak. if i keep references to that obj / my players array clean i should be fine then?
<FromGitter>
<Sjoerrdd> Just another simple question
<FromGitter>
<bararchy> @girng its part of the standard work of Linux programs, its cheaper to keep memory and reuse it then reask for new mem allocation from OS, ruby does the exact same thing
<FromGitter>
<Sjoerrdd> I'm a laravel developer, and in laravel we've something like `$post->with('comments')` is there a similar thing in Amber? (now it only returns the post, or the comments, but not both in one array)
<FromGitter>
<straight-shoota> @girng probably, yes. you can use `GC.stats` to look at Crystal's internal memory usage. This way you can see if it really keeps using too much memory
<FromGitter>
<straight-shoota> but keep in mind that it might take some time for the GC to clean up... or it might never if you don't need the memory
<FromGitter>
<girng> @bararchy so the only way i could run out of memory is if a large ddos attack were to happen right? but that's kinda would happen to any server wouldn't it?
<FromGitter>
<girng> what if i survive a large ddos attack and have my memory high, what do i do then?
<FromGitter>
<girng> @bararchy ya looks like not plausible / good idea. thx. i guess if ddos happens and memory is still high when only few player online.. i could just restart the server lol
<FromGitter>
<j8r> you can have a queue system that will reduce the impact of the ddos
<FromGitter>
<j8r> but other players will be impacted :/
<FromGitter>
<bararchy> @girng Blizzard uses a cluster of server farms for each world zone, also Sony and they still get DDOSed down once in a while
<FromGitter>
<bararchy> In other words, leave this issue to the IT department and people who handle HA and DR
<FromGitter>
<PlayLights_twitter> Blizzard servers are amazing, you can play with people in asia with 0 lag (from US)
<FromGitter>
<PlayLights_twitter> ea servers are more slow than a turtle
<FromGitter>
<ddrscott> @bew `make clean` did the trick! Thanks
<FromGitter>
<bew> Perfect :)
commavir_ has quit [Quit: leaving]
commavir has joined #crystal-lang
rohitpaulk has joined #crystal-lang
duane has quit [Remote host closed the connection]
duane has joined #crystal-lang
Nik736 has joined #crystal-lang
Nik736 has quit [Client Quit]
rohitpaulk has quit [Ping timeout: 245 seconds]
<FromGitter>
<Sevensidedmarble> Does anyone know if the any of the projects on crystal to ruby bridges/extensions are being actively worked on?
<FromGitter>
<Sevensidedmarble> The one I saw that seemed the most mature hadn't had any commits in a while, and said some big things like floats didn't work
<FromGitter>
<Sevensidedmarble> Does anyone know of an actively developed one?
ua_ has joined #crystal-lang
<FromGitter>
<Sevensidedmarble> The maintainer also claimed the crystal team has plans for developing their own tooling for ruby extensions is that true?
<txdv>
what do plans mean to you?
ua has quit [Ping timeout: 255 seconds]
<txdv>
I can have many plans, yet no time in my life to fullfill them
<FromGitter>
<straight-shoota> I don't think there are any plans and it is actually not really feasible to do
duane has quit [Ping timeout: 240 seconds]
<FromGitter>
<Sevensidedmarble> What's the feasibility issue?
<FromGitter>
<straight-shoota> Ruby extensions are dynamic libraries
<FromGitter>
<straight-shoota> Compiling crystal to a dynamic library is technically possible, but has huge problems because Crystal has it's own runtime
<FromGitter>
<straight-shoota> Crystal assumes it is the king of everything in it's process
<FromGitter>
<girng> if i link to c, can i manage memory?
DTZUZO has quit [Ping timeout: 265 seconds]
DTZUZO has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 265 seconds]
Creatornator has joined #crystal-lang
<FromGitter>
<Sevensidedmarble> Does the same not apply to C?
duane has joined #crystal-lang
rohitpaulk has joined #crystal-lang
DTZUZO has quit [Ping timeout: 265 seconds]
shalmezad has quit [Quit: 5:00PM, later]
<FromGitter>
<girng> mormons just showed up atmy door, that was akward.
<FromGitter>
<girng> i had to ask for a business card to close the conversation they gave me a pamphlet :D
<FromGitter>
<Sjoerrdd> lol
<FromGitter>
<girng> i was coding in crystal, add properties to my class. then 1 second later, i answer the door and am asked why i don't go to church anymore lol
<FromGitter>
<girng> my brain is like wtf is going on, i need to go back to coding
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Creatornator has joined #crystal-lang
relyks has joined #crystal-lang
DTZUZO has joined #crystal-lang
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]