RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.26.1 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
zorp has quit [Ping timeout: 244 seconds]
baweaver is now known as baweaver_away
<FromGitter> <noahlh> is it possible to create a Tuple from a range? i.e. start with `(0..5)` and end up with `{0,1,2,3,4,5}`?
<FromGitter> <bew> Not easily, it should be possible with macros though
<FromGitter> <noahlh> ahh i hadn't considered macros yet. ok so not built-in to the language - cool. that helps point me in the right direction.
<FromGitter> <noahlh> ty @bew !
<FromGitter> <codenoid> hi, can i do free memory check with just only crystal ?
DTZUZO has joined #crystal-lang
_whitelogger has joined #crystal-lang
zorp has joined #crystal-lang
_whitelogger has joined #crystal-lang
<FromGitter> <rishavs> @noahlh โŽ can you not do something like; โŽ โŽ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b8e11a6f5402f32aad4f7a9]
<FromGitter> <Timbus> That is a hash, my guy
<FromGitter> <Blacksmoke16> a tuple needs to be defined before runtime, so have to use a macro or statically define it
<FromGitter> <Blacksmoke16> since its immutable
<FromGitter> <Timbus> Are there mutable tuples/namedtuples in Crystal?
<FromGitter> <Blacksmoke16> that would prob be a hash
<FromGitter> <Timbus> Hm but each position would be typed
<FromGitter> <Timbus> So its a tiny bit different
<FromGitter> <Blacksmoke16> you could still define a type for your hash
<FromGitter> <Timbus> Guess then it's just a class
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/4vq9
<FromGitter> <Blacksmoke16> a class would prob be better in most cases tho yea
<FromGitter> <rishavs> ๐Ÿ˜†
Guest47999 has quit [Ping timeout: 260 seconds]
oz has joined #crystal-lang
<FromGitter> <rishavs> Is there a nicer way to write a code structure like; โŽ โŽ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b8e298bd8d36815e5d2d755]
<FromGitter> <rishavs> In JS, I would probably create an array of the functions and iterate through them, returning the value the moment any of them suceeded
<FromGitter> <Timbus> I guess you can just chain the functions using `||`, if its only a few
<FromGitter> <Timbus> methods*
<FromGitter> <rishavs> but wouldn't it run through each and every function in the chain?
<Yxhuvud> No, || shortcuts
<FromGitter> <f1refly_gitlab> It wouldn't. Besides, your proposed solution isn't too bad in my opinion
<Yxhuvud> also, you should read up on elsif and case statements.
baweaver_away is now known as baweaver
<FromGitter> <f1refly_gitlab> ```code paste, see link``` โŽ โŽ This is how you should construct your code [https://gitter.im/crystal-lang/crystal?at=5b8e2bdb58a3797aa3fd87ea]
<FromGitter> <rishavs> @yxhuvud case wouldn't work here and elsif would force me to use .try anyway. @f1refly_gitlab which solution? the array of functions? or just the if/else forest? โŽ Also, if I were to do โŽ โŽ ```code paste, see link``` โŽ ... [https://gitter.im/crystal-lang/crystal?at=5b8e2c0158a3797aa3fd88c8]
<FromGitter> <Timbus> it wouldn't
<FromGitter> <rishavs> Nice. I will try it out
<FromGitter> <rishavs> Thanks guys
<FromGitter> <f1refly_gitlab> The if/else forest you planted
<FromGitter> <Timbus> id save it for.. like small use cases
<FromGitter> <f1refly_gitlab> think of `||` as a shortcut for โŽ โŽ ```op = ( tmp= do0() ? tmp : ( tmp = do1 ? tmp : ( tmp = do2 : [...] ) ) )``` [https://gitter.im/crystal-lang/crystal?at=5b8e2cb0e5b40332ab404df1]
<FromGitter> <rishavs> Neat. I always thought it was a simple OR operation of sorts done with the values
ashirase has quit [Ping timeout: 250 seconds]
ashirase has joined #crystal-lang
<FromGitter> <f1refly_gitlab> Can someone here tell me what can be improved in the first function of this file?
<FromGitter> <f1refly_gitlab> It works, but i feel like it's a horrible solution
<FromGitter> <bajro17> @aminraeisi do you want we make one with crystal
<FromGitter> <bararchy> arch linux still don't have 26.1 package :(
<FromGitter> <bararchy> whos the brave soul to add `.to_h` for XML::Node ? ;)
<FromGitter> <bew> What would be the key?
<FromGitter> <bew> Maybe YOU can do a PR @bararchy ;)
<FromGitter> <bararchy> lol not brave enough
<FromGitter> <bararchy> XML::Serilizable hahah
<FromGitter> <bararchy> basicly the idea is having a more generic way to recurse around standard data structures
<FromGitter> <bararchy> we already treat YAML and JSON as "hash-like" objects, why not XML too ?
<FromGitter> <codenoid> hi, how i can check free memory in my computer with only crystal
<FromGitter> <Timbus> You have to ask the OS.. And its platform specific
<FromGitter> <bew> @bararchy don't forget that hash-like usage of a YAML or JSON doc is definitely not recommended
<FromGitter> <bew> You want sth like a XML::Any ?
<FromGitter> <bararchy> yeha
<FromGitter> <bararchy> `XML::Any`
<FromGitter> <bew> Have fun, I'm not touching any of that ๐Ÿ˜‚
<FromGitter> <codenoid> @Timbus Ubuntu 16.04
<FromGitter> <codenoid> btw, i want to run child process for a long time, โŽ better to use `fork` or `spawn`
<FromGitter> <Timbus> In theory, spawn is what you want.
<FromGitter> <Timbus> `fork` will give you a different process, and there's some tricky filehandle related issues. But sometimes it is quite useful, and you'll have real cooperative concurrency
<FromGitter> <codenoid> ups
<FromGitter> <codenoid> but i think `fork` is answer for my case
<FromGitter> <codenoid> bcoz sometime i will kill that child process
<FromGitter> <codenoid> ah i'll try
<FromGitter> <Timbus> For the meminfo, I guess the best way seems to be to read `/proc/meminfo`
<FromGitter> <Timbus> And in case you need it, `/proc/#{PID}/status` is probably useful for you, too
<FromGitter> <j8r> @Timbus https://github.com/crystal-community/hardware will do the parsing for you ;)
<FromGitter> <Timbus> Nice.
<FromGitter> <Timbus> I'll let @codenoid see that ^^
shalmezad has joined #crystal-lang
ua has quit [Read error: Connection reset by peer]
ua has joined #crystal-lang
Groogy1 has quit [Ping timeout: 240 seconds]
zorp_ has joined #crystal-lang
v2px__ has joined #crystal-lang
zorp has quit [Ping timeout: 245 seconds]
zorp_ has quit [Ping timeout: 260 seconds]
zolbatar has joined #crystal-lang
zolbatar has quit [Quit: zolbatar]
Groogy1 has joined #crystal-lang
<FromGitter> <MyrddinE> Quick noob question... I found the language specification reference, but I'm not seeing the library reference. Where can I find the Object hierarchy, Modules, and standard library documentation?
<FromGitter> <bew> All in https://crystal-lang.org/api
<FromGitter> <j8r> where is the language specification reference, there is a paper!?
<FromGitter> <bew> No he's talking about the language docs i guess
<FromGitter> <j8r> ๐Ÿ‘
DTZUZO has quit [Ping timeout: 240 seconds]
<FromGitter> <MyrddinE> Thank you kindly.
<FromGitter> <MyrddinE> (and yes, I was referring to the docs, https://crystal-lang.org/docs/overview/ )
<robacarp> @sdogruyol thanks for the mention in crystal-weekly :]
<FromGitter> <bew> Welcome to Crystal @MyrddinE ;)
<FromGitter> <rishavs> Heiyyyyoooo!! I just wrote my first library for crystal. Its simple and shitty, but does the work. :D โŽ https://github.com/rishavs/crog it fetches the open graph tags from any web page.
<FromGitter> <bew> Cool! Don't forget to populate the "Usage" section of the Readme!
<FromGitter> <rishavs> lol. i forgot that. updating now
<FromGitter> <rishavs> no specs though. will add them later
Groogy1 has quit [Ping timeout: 252 seconds]
<FromGitter> <j8r> I don't know who was the first to use the typical "Add this to your application's shard.yml:" - everyone, including me, use it ๐Ÿ˜†
<FromGitter> <j8r> @rishavs You could have `T?` types instead of `T | Nil` ๐Ÿ˜
<FromGitter> <rishavs> Thanks! I am still pretty bad when it comes to handling nils. bad JS habits and all ๐Ÿ˜†
DTZUZO has joined #crystal-lang
<robacarp> @j8r I always assumed that came from the Ruby "add this to your gemfile"
<FromGitter> <j8r> also i see lots of dev stuff remaining in https://github.com/rishavs/crog/blob/master/src/crog.cr like comments, the `page` variable etc
<FromGitter> <j8r> robacard yeah it can be, well observed (I don't come from Ruby). We could simply say `Add this to your shard.yml`... I will use this starting from now
<FromGitter> <j8r> but this will be more correct to say something like: โŽ โŽ > Add the dependency to your `shard.yml`:
<robacarp> yeah, or "Update your shard.yml: <diff>"
<robacarp> I have the diff on https://github.com/robacarp/mosquito/ . shard.yml has the distinct complexity that you can't just paste the shard name in wherever, so I wanted to make it a little more obvious what needed to happen
DTZUZO has quit [Ping timeout: 260 seconds]
DTZUZO has joined #crystal-lang
DTZUZO has quit [Ping timeout: 252 seconds]
DTZUZO has joined #crystal-lang
<RX14> @robacarp why didn't you contribute to sidekiq.cr
<RX14> i've had to use it in production recently and I found it lacking too
<RX14> well, a bit buggy actually
<RX14> and not suitable to very high concurrency jobs
<RX14> and it might have been leaking memory, didn't have time to track that down
<FromGitter> <vladfaust> Hm, RX14, I've seen you as an OSS guy
<FromGitter> <vladfaust> And now you propose to contribute into PAID SOFTWARE
<RX14> sidekiq is open source
<RX14> and sidekiq.cr
<FromGitter> <vladfaust> Or rly
<FromGitter> <vladfaust> https://sidekiq.org says that many essentials are paid
<RX14> well it's half open source
<RX14> i didn't pay for it
<FromGitter> <vladfaust> Why not using and promoting Resque then?
<FromGitter> <vladfaust> I beleive its integration with Crystal would be fairly simple
<RX14> because it doesnt have a crystal runner and because i didn't know it existed
<FromGitter> <vladfaust> Wow
DTZUZO has quit [Ping timeout: 244 seconds]
<FromGitter> <vladfaust> Resque is a very nice thing, I've used it in my Ruby projects
<RX14> and because the codebase i was porting didn't use it
<RX14> either way
<RX14> all of them would have eventually had the same problem for this usecase
<RX14> which is why i'm rewriting to use none of them
<FromGitter> <vladfaust> How do you organaize jobs then?
<robacarp> @RX14 I don't agree with the freemium model of open source
<robacarp> and it didn't have what I've always wanted from sidekiq ruby which is periodic jobs
<FromGitter> <vladfaust> @robacarp I do. It's wonderful when an OSS developer gets paid from companies for extra features
<robacarp> I'm not agaist getting paid to implement features, I'm against forking your project into a free and a paid version
<robacarp> if a company wants to sponsor a project, great, and that sponsorship should be available to everyone
<robacarp> er, the product of that sponsorship
<FromGitter> <vladfaust> That's a point of view
<FromGitter> <vladfaust> However, a developer would make much more when splitting. It's a hard job to find an ideal balance of what to split, and if it's found, it's great for many
<robacarp> As you said, that's a point of view.
<FromGitter> <vladfaust> ะัƒะท
<RX14> @vladfaust the whole model of submitting jobs doesn't suit this application
<FromGitter> <vladfaust> Got it
<RX14> more like kafka
<RX14> but i'm thinking on using redis streams
<FromGitter> <vladfaust> I got no experience in such things, Resque always was enough. Or bare cron
rohitpaulk has joined #crystal-lang
<robacarp> @rx14 you're looking for something more like event processing?
<RX14> not really
<RX14> its just fan-out message delivery
<RX14> many publishers pushing messages
<RX14> many subscribers
<RX14> and this is a federated system so high-letency and broken subscribers are exremely common
<RX14> job queues don't segregate each consumer
<robacarp> oh sure, yeah.
<RX14> and so they're vulnerable to one consumer backing up the whole system when their DNS fails and you're waiting 10 seconds for each job
<RX14> also, 600+ messages in per second and 130+ subscriptions, so 78000 deliveries per second :)
<RX14> sidekiq was not suitable
<robacarp> that doesn't sound like the right application for a worker cluster at all
<RX14> yeah, the ruby prototype I was copying used sidekiq for this
<RX14> so I copied the structure before doing the math
<RX14> and now i'm having to rewrite
<robacarp> I've used rabbitmq in the past for something that I think is similar, and had nothing bad to say about it. I've never used redis streams though
<RX14> for now i'm skimping on the consistency and going to do it all in-process
<RX14> and then i'll add streams once that's working
<RX14> because if even in-process can't keep up then redis has no hope
<FromGitter> <sdzyba> Take a look at NATS and NATS Streaming particularly. Mostly the same features as Kafka has but NATS has way simplier API while having about the same performance. It simply doesn't feel that bloated
<FromGitter> <sdzyba> ...that bloated as most of the Java software does and Kafka is no exception
<RX14> @sdzyba thanks i'll check it out
rohitpaulk has quit [Ping timeout: 245 seconds]
<RX14> oof, nats streaming protocol seems pretty hard to implement
<FromGitter> <r00ster91> am I understanding something wrong or why is the "b" option behind "r", "w" and "a" existing when it does nothing? https://github.com/crystal-lang/crystal/blob/master/src/crystal/system/file.cr#L32
<RX14> it's for binary mode, i.e. don't transform file line-endings
<RX14> and the text option isn't supported to it's a no-op
<RX14> i'm not sure whether we should keep it or not
<FromGitter> <r00ster91> oh ok
<RX14> also nats streaming seems terribly documented
<RX14> i'll think i'll go with redis for now, because redis's documentation is actually prefect
hightower2 has joined #crystal-lang
<FromGitter> <sdzyba> RX14, there is a ruby client for nats streaming: https://github.com/nats-io/ruby-nats-streaming
<RX14> this is #crystal-lang you know :P
<FromGitter> <sdzyba> that's exactly why I suggested a Ruby client, meaning it might be not that hard to port it to Crystal :)
<RX14> porting ruby code never really works out well
<RX14> it's never type-safe
<FromGitter> <sdzyba> well, still can be used as a reference, I believe. Go client might used as well in that case but, well, it is a too different programming paradigm
<RX14> yeah i'd use it as a reference but i'd rather not port a whole library
<RX14> so it's a bit moot because it'd be a lot of effort to use an under-documented solution anyway
<FromGitter> <DanielSokil> Why does Crystal compiler throw an error if nil is handled? โŽ โŽ ```code paste, see link``` โŽ โŽ Here `arguments.name` is checked if not `nil`. ... [https://gitter.im/crystal-lang/crystal?at=5b8ee75aac25fd11b5df2ccd]
<FromGitter> <r00ster91> try `if name = arguments.name` instead of `if arguments.name != nil` and use `name` in Scaffold.run
<FromGitter> <girng> dem local variables yummm
v2px__ has quit [Ping timeout: 260 seconds]
<FromGitter> <girng> is sodyreal still around? (the guy who did the websocket benchmark) can't remember his name
<FromGitter> <r00ster91> I guess you mean sdogruyol?
<FromGitter> <vladfaust> @sdogruyol
<FromGitter> <girng> yeah, his name doesn't popup on my gitter @ thing
<FromGitter> <girng> ty
<FromGitter> <vladfaust> He's got private contributions recently. I guess he's busy @ rainforest
ua_ has joined #crystal-lang
<FromGitter> <girng> interesting, i wish him the best very nice person
<FromGitter> <girng> he's the reason why i first sttarted to transition to crystal
<FromGitter> <girng> cause of websocket benchmark article
ua has quit [Ping timeout: 260 seconds]
shalmezad has quit [Quit: Leaving]
<FromGitter> <j8r> @DanielSokil like @r00ster91 said, you have to assign a variable to check if it's nillable. The compiler doens't *introspect* inside objects to check nillability. Also very often the `!= nil`can be dropped (unless the type is `Bool?`)
<FromGitter> <j8r> I think this check can only be done at the same variable level, or something like that (don't know the internals enough)
<FromGitter> <straight-shoota> Actually, `var != nil` doesn't work as a nil restriction either. You need to use `var.nil?` (or just `var` unless it's boolean). โŽ See https://crystal-lang.org/docs/syntax_and_semantics/if_var.html for details and limitations.
<robacarp> running in circles here today, aren't we
<FromGitter> <DanielSokil> @j8r Thanks.
<FromGitter> <DanielSokil> @straight-shoota Thanks.
hightower2 has quit [Ping timeout: 240 seconds]
moei has quit [Quit: Leaving...]
DTZUZO has joined #crystal-lang
hightower2 has joined #crystal-lang
daemonwrangler has joined #crystal-lang