ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.23.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
bmcginty has joined #crystal-lang
<FromGitter> <kazzkiq> Locally the benchmark results are ~1800 req/s, at production server ~1200 req/s
<FromGitter> <kazzkiq> fun fact is that my local machine is like 10x faster, and has 8 cores vs 1 from VM. Still, the results seem pretty close, which is weird
<FromGitter> <kazzkiq> @fridgerator Yes, the benchmarks run all locally (both on my machine and in remote VM, via ssh)
<FromGitter> <picatz> @kazzkiq you bring up an interesting question, I'm also rather curious.
<FromGitter> <picatz> Benchmarking / performance tuning can be a tricky business sometimes.
<FromGitter> <picatz> In some cases, the database itself can actually be the bottleneck for those kinds of things.
<FromGitter> <kazzkiq> I tried using built-in connection pool (as described in the docs (https://crystal-lang.org/docs/database/connection_pool.html)), but it changed nothing
<FromGitter> <picatz> Well, if the database can only serve up X amount of requests, it won't matter if crystal itself is using a pool ( someone can feel free to correct me ).
<FromGitter> <picatz> I dunno really, though. It'd take some sciencey: try, hypothesize, repeat kinda stuff.
<FromGitter> <picatz> Are you able to share the application / make a demo of something similar by chance?
<FromGitter> <picatz> If ya' had a Vagrantfile or something to show your case, it'd be much easier to help diagnose the issue. I'm not sure why I'm so interested :P
<FromGitter> <kazzkiq> Yep. And that's the odd part. If my 8 core i7 Macbook can't serve more than 1800 simple queries from a table with a dozen rows, then how the heck people use "medium-sized" VMs to serve thousands upon thousands of requests/second?
<FromGitter> <kazzkiq> This doesn't seem right. But I'm no DBA, so I might be overlooking something.
<FromGitter> <picatz> At one point or another I'd imagine you'd need to scale out your application / databases to be able to handle the load.
<FromGitter> <picatz> I've been in a (lucky?) situation where I've never needed to handle a high amount of traffic for anything I've built.
<travis-ci> crystal-lang/crystal#7daf14b (master - Consistently store documentation when reopening (#4908)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/270581434
<FromGitter> <kazzkiq> If your app have an average of 1000+ req/s you're probably not concerned about throwing money into servers or paying people to fix your database. The real problem is that the internet does not work on averages. There are peaks. Someone famous might tweet your link, or a blog can talk about you, then *bam*, suddenly you've got 10k requests/sec from to-be customers who are mad because your service is feeling slow
<FromGitter> <picatz> I think that sort of goes beyond the possibility of any language to handle, right?
<FromGitter> <picatz> That's sort of dealing with the full stack.
<FromGitter> <kazzkiq> I once had a peak of 5000% in visits on one of my static websites. Turned out a japanese (!!) jQuery blog posted it, out of nowhere
<FromGitter> <kazzkiq> Two days later, back to normal
<FromGitter> <picatz> Any application deployed on a single VM will eventually reach its limits.
<FromGitter> <kazzkiq> Definitely. There isn't silver bullet. But I just find odd that the limit for MySQL is so low, even with such simple database
<FromGitter> <picatz> Have you benchmarked other DBs?
<FromGitter> <picatz> If it's not just MySQL, I'd also be curious.
<FromGitter> <picatz> I almost never use MySQL :P
<FromGitter> <picatz> ( No hate, just stating something, I guess lol )
<FromGitter> <kazzkiq> I didn't. No idea how would it perform on other databases.
<FromGitter> <kazzkiq> NoSQL makes no sense for this project, and a good alternative (PostgreSQL) was out of reach, so I just had to stick with good ol' MySQL for the MVP 😄
<FromGitter> <picatz> lolol
<FromGitter> <picatz> *Just make your own in-memory ( inb4 key-value store ) DB with Crystal.*
ragmaanir has quit [Quit: Leaving]
<FromGitter> <faultyserver> does Crystal have anything like C++'s move constructor?
<FromGitter> <faultyserver> I seem to recall hearing something like defining `def initialize(other : self)` acted like a move constructor, but I have no idea where or if that was even a thing
<FromGitter> <faultyserver> actually, more interested in a copy constructor, not necessarily a move
<watzon> Wtf is a move constructor?
<FromGitter> <picatz> I'm google'n that right now 😹
<FromGitter> <picatz> C++ documentation is dense asf
<FromGitter> <faultyserver> http://en.cppreference.com/w/cpp/language/move_constructor for the lazy :)
<FromGitter> <faultyserver> short version: Move assignment operators typically "steal" the resources held by the argument (e.g. pointers to dynamically-allocated objects, file descriptors, TCP sockets, I/O streams, running threads, etc.), rather than make copies of them, and leave the argument in some valid but otherwise indeterminate state
<FromGitter> <faultyserver> even shorter: the constructor essentially destructs the other object to create itself
<FromGitter> <faultyserver> my use case is closer to references than anything else, but I'm thinking a copy constructor might be necessary.
<watzon> Thank you for the shorter shorter version. That makes sense to me
<FromGitter> <picatz> Makes sense to me too. Just loaded up Crystal play.
Philpax__ has joined #crystal-lang
<FromGitter> <faultyserver> The basics of my situation are that I have a Hash of `Value`s, where `Value` is an abstract base class. I want to be able to obtain a reference to an entry in the hash using a key. Then elsewhere I want replace that entry with a new `Value`, without having to know the key.
<FromGitter> <faultyserver> so nvm, I guess copy constructors are actually the opposite of what I want :)
<FromGitter> <picatz> 😅 Ok then.
<FromGitter> <faultyserver> I think what I'm trying to achieve is similar to this: https://carc.in/#/r/2n1q
<FromGitter> <faultyserver> But that fails because `can't take address of h["hi"]`
<FromGitter> <picatz> Curious why you wouldn't just access the hash to change the value of the "hi" key like`h["hi"] = [3, 4, 5]`
<FromGitter> <picatz> What's the advantage of using the pointerof thing?
<FromGitter> <confin234> How good is Crystal's RAM management? Is it on par with something like Rust?
<FromGitter> <confin234> @picatz Also I love your profile picture
<FromGitter> <picatz> Thanks! 😊
<FromGitter> <picatz> I'm not a crystal RAM management master: but I'd imagine it'd be more about the application in question.
<FromGitter> <picatz> I've never had an issue with memory problems with Crystal.
<FromGitter> <picatz> Jruby will easy my memory all day long though. Was messing with that today.
<FromGitter> <confin234> I've been coming up with an idea to take the code of Firefox OS and turn it into something new, like maybe adding Android app support and giving it a better UI. One with lots of blurring like Apple
<FromGitter> <picatz> *With lots of blurring like Apple* 😹
<FromGitter> <confin234> I've been trying to think of a good way to somehow make the RAM usage of the Android apps that it would be using much lower. The only way I could think of would be to convert the Android app's code to Crystal. Then I realised, how the heck will I be able to convert all of the code to Crystal? Maybe a bot of some kind? I guess I could make one and leave me to sift through the errors, and maybe the FOSS
<FromGitter> ... community if they can help.
<FromGitter> <picatz> Not terribly sure myself. Never done any android development before.
<FromGitter> <picatz> Open Source does tend to help though :D
<FromGitter> <confin234> Yeah, I really believe in open source. I want to use it for all of my projects. It saves so much time and work! After all, I can't be doing my projects around the clock!
<FromGitter> <confin234> Not to mention that the open source community is one of the kindest places on the internet that I've been to. Since all the trolls are too stupid to even know what binary is, we all get along really well, we all respect all the noobs (because we know that sometime soon they will be one of us,) and we all work together to achieve a common goal, a better future. That's not something I would put a price on!
<FromGitter> <picatz> Yeah. A supportive community helps things get done. 👍
<FromGitter> <picatz> Whoa
<FromGitter> <picatz> I just noticed
<FromGitter> <picatz> In Crystal play that it counts the ammount of times that object is called or something.
<FromGitter> <confin234> What's the link to Crystal Play? I've kept trying to google it but I couldn't find it so I just stuck with repl.it .
<FromGitter> <picatz> I'm using the crystal play launched from the command line
<FromGitter> <picatz> `crystal play`
<FromGitter> <picatz> There's also: https://carc.in/#/cr
<FromGitter> <picatz> Which is a bit different, but easy to share.
<FromGitter> <confin234> Thanks!
<FromGitter> <faultyserver> @picatz from earlier: that hash was a very basic example. As I mentioned, it could be arbitrarily nested in any of a number of different collection types.
<FromGitter> <faultyserver> It's in an AST visitor for assignments like `object.member.sub_member = new_value`
<FromGitter> <faultyserver> where the left hand side could feasibly be any expression that results in a storable value (i.e., `lvalues` in C++ )
<FromGitter> <faultyserver> the real answer is probably that `.sub_member =` should really be a method call like it is in Ruby/Crystal, but I'm not sure if that's the approach I want to take atm
<FromGitter> <picatz> I can only get this to work thus far: https://carc.in/#/r/2n1x
<FromGitter> <faultyserver> hmmm, it's *some* progress
<FromGitter> <picatz> I'm just having fun with it at this point, not exactly sure if I'll figure out your case.
<FromGitter> <picatz> pointerof is unsafe in crystal land
<FromGitter> <picatz> But you seem to be able to do that on an object that's being nested like how you showed.
<FromGitter> <picatz> I don't know, I'm going to keep hacking on this.
<FromGitter> <faultyserver> good luck :)
rohitpaulk has joined #crystal-lang
<FromGitter> <picatz> I've managed this: https://carc.in/#/r/2n1y
<FromGitter> <picatz> Pointer the thing before putting it into the hash, maybe? 😓
<FromGitter> <picatz> Not sure if making it a pointer will work before hand for you. Seems to work, I think sortof? ⏎ https://carc.in/#/r/2n1z
<FromGitter> <faultyserver> it'd be *possible*, but not really practical :/
<FromGitter> <faultyserver> thanks for looking into it, though :)
<FromGitter> <picatz> Curious what makes it not practical?
<FromGitter> <picatz> I dunno really why I would do something like this at all. Maybe if I was doing some weird, weird abstraction thing.
<FromGitter> <faultyserver> it's basically a weird abstraction, yeah
<FromGitter> <faultyserver> to use pointers beforehand would mean changing things in a bunch of places and having to do `.value` *all over the place*
<FromGitter> <picatz> Well, it's one more call than just accessing the `hash["key"]` normally.
<FromGitter> <picatz> I'd honestly argue that's a fair tradeoff, since that's what's the object needs to have being `Pointer` object, right?
<FromGitter> <faultyserver> maybe? idk honestly
<FromGitter> <picatz> I do recognize it's a bit ugly, sure. I think Pointers are ugly. It's my first time ever using them in Crystal too lol.
<FromGitter> <faultyserver> yeah, that and kind of seems inefficient. Like a pointer to something that's already basically a pointer (inheriting from `Reference`)
<FromGitter> <picatz> Plus, if you're going to update a hash... like, how do you not know it's key?
<FromGitter> <picatz> Unless you're doing something based just on the values -- like, why use a pointer to a hash key,value when you can just use the hash's native api to access that exact key,value
<FromGitter> <picatz> Pointers would seem like something to save space with, I guess? Like, if already exists just point to the thing in memory or something?
<FromGitter> <picatz> Like, perhaps you could have multiple hashes and they all share a pointer for a common key,value pair thing. Then I could see a use case for a pointer with a hash. And in which case, I think again the value method call is a fair tradeoff.
<FromGitter> <faultyserver> well, afaik, that's what Reference types are already
<FromGitter> <faultyserver> > A reference type is passed by reference: when you pass it to methods, return it from methods or assign it to variables, a pointer is actually passed.
<FromGitter> <faultyserver> so I just feel like that extra layer shouldn't be necessary...
<FromGitter> <faultyserver> as for why I don't know the key, here's the exact code for the situation https://github.com/myst-lang/myst/blob/master/src/myst/interpreter/visitors/assignment.cr#L2-L15
<FromGitter> <faultyserver> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=59a8cd9c66c1c7c47702549f]
<FromGitter> <faultyserver> that's some ....uh.... interesting highlighting...
<FromGitter> <picatz> Looks *perfect*
<FromGitter> <faultyserver> anyway, `node.target` is the whole `object.member.sub_member` construct
<FromGitter> <picatz> *We've gone too deep for me to understand what's going on anymore.*
<FromGitter> <faultyserver> yeah, that's kind of the problem for me too :)
<FromGitter> <picatz> That's where I'm like, the `.value` thing works? Cool.
<FromGitter> <faultyserver> basically, it's recursing through a tree
<FromGitter> <picatz> I think you need it too for that hash, right? Like, you're saying you just want the object, right?
<FromGitter> <picatz> The object of the Pointer class requires the `.value` call to access its underlying value.
<FromGitter> <faultyserver> yeah, so if `@symbol_table` was a `Hash(String, Pointer(Value))`, it might work
<FromGitter> <picatz> Wait, sorry.
<FromGitter> <picatz> I'm confused a bit. Why would `Hash(String, Pointer(Object))` change things?
<FromGitter> <faultyserver> right now it's just a `Hash(String, Object)`
<FromGitter> <faultyserver> the code there is my current hacky workaround that *doesn't* support nested values on the left hand side
<FromGitter> <faultyserver> e.g., `object.member = value` doesn't work
<FromGitter> <faultyserver> only `object = value` does
<FromGitter> <faultyserver> and that's where the problem is
<FromGitter> <faultyserver> in reality, I need to `recurse(node.target)`, at which point I don't have access to `target.name`, and would only be able to `stack.pop` to get whatever value is returned from recursing down
<FromGitter> <picatz> ( I mean this in the best way ) : Wtf are you trying to accomplish with this.
<FromGitter> <faultyserver> it's a programming language interpreter
<FromGitter> <faultyserver> .....I realize now my examples like `object.member = value` probably haven't been making any sense without that context
<FromGitter> <picatz> It was.. interesting 😂
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter> <codenoid> hi, how to do this in crystal, :/ http://cpp.sh/8fntb
<FromGitter> <faultyserver> do what exactly? Treat `long`s as `string`s?
<FromGitter> <faultyserver> or just read a stream of bytes as a string?
<FromGitter> <codenoid> returning an "Hello world" without write a "Hello world"
<FromGitter> <codenoid> and explanation :shipit:
<FromGitter> <faultyserver> still not really sure what you mean...
<FromGitter> <faultyserver> return or output?
<FromGitter> <codenoid> yes
<FromGitter> <codenoid> output
<FromGitter> <faultyserver> okay....
<FromGitter> <faultyserver> so, `long msg[] = {8031924123371070792, 560229490};` defines a series a bytes that is equivalent the series of bytes in the string `"Hello world!"`
<FromGitter> <faultyserver> and because it's an array in C/C++, it's really just a pointer, the actual type doesn't matter here
<FromGitter> <faultyserver> then `printf` with the `%s` flag just expects a pointer as an argument, then reads byte-by-byte and outputs the corresponding character for each one, stopping when it hits a null terminator `\0` or `00`
<FromGitter> <faultyserver> all of which begs the question: what are you actually trying to do? Take a byte stream and output the characters it represents?
<FromGitter> <codenoid> first thanks for your explanation in C++, then how do that in crystal ?
<FromGitter> <faultyserver> do what? You wouldn't do that in Crystal
<FromGitter> <faultyserver> there's no real reason to
<FromGitter> <faultyserver> unless you have some other context that's forcing you to do it
<FromGitter> <faultyserver> otherwise, just do `puts "Hello world!"`
<FromGitter> <codenoid> > so, `long msg[] = {8031924123371070792, 560229490};` defines a series a bytes that is equivalent the series of bytes in the string `"Hello world!"` ⏎ but can crystal do like that ?
<FromGitter> <faultyserver> ....yeah, but why?
<FromGitter> <faultyserver> that's obfuscation for no real reason
<FromGitter> <faultyserver> if you just want the series of bytes from a String (which is what that array represents), you can do `"Hello world!".to_slice`
<FromGitter> <codenoid> me and my friends are playing cryptography :D
<FromGitter> <picatz> Security by obscurity no worky ( with very few exceptions ).
<FromGitter> <sdogruyol> Morning everyone
<FromGitter> <elorest> Good evening.
<FromGitter> <picatz> Evening 😂
<FromGitter> <sdogruyol> 😄
<FromGitter> <sdogruyol> 7 am in İstanbul
<FromGitter> <elorest> 10 PM in Utah.
<FromGitter> <picatz> 12 PM in Michigan.
snsei has joined #crystal-lang
rohitpaulk has joined #crystal-lang
snsei has quit [Remote host closed the connection]
<FromGitter> <sdogruyol> wow :D
rumenzu has joined #crystal-lang
alex`` has joined #crystal-lang
<watzon> What part of Utah are you in elorest?
<FromGitter> <elorest> Provo.
<watzon> Ahh nice. I just moved from there about 2 years ago
<FromGitter> <elorest> Oh nice. Where do you live now.
<watzon> BYU, UVU, or the U?
<watzon> I’m in Arizona now
<FromGitter> <elorest> I actually went to SUU. Graduated 2006 though.
<FromGitter> <elorest> Moved to Provo 3 years ago.
<FromGitter> <elorest> Google fiber is awesome.
<FromGitter> <sdogruyol> how's the speed
<FromGitter> <sdogruyol> Gbit?
<FromGitter> <elorest> Yeah.
<watzon> Ahh very nice haha. I wish Phoenix had Google Fiber already. Couldn’t afford it when I was there
<FromGitter> <elorest> 1Gb Up and Down.
rohitpaulk has quit [Ping timeout: 260 seconds]
<watzon> That’s so ridiculously wonderful
rohitpaulk has joined #crystal-lang
<FromGitter> <sdogruyol> and how's the uptime?
<FromGitter> <elorest> Seems good. One time they said it was out at 2AM for a few minutes so they gave me like 10 dollars back on my bill.
<FromGitter> <elorest> I didn’t notice though.
<watzon> If Cox did that I’d never pay for internet
<FromGitter> <elorest> Yeah when I lived in St George it would go out everynight.
<Yxhuvud> how much do you have to pay for it?
<FromGitter> <elorest> $70
<Yxhuvud> I pay about $12 a month for my Gbit connection, but then, I can't opt out of it without moving due to it being a communal solution for everyone living in my house
<Yxhuvud> Stockholm is amazing in some ways :D
<FromGitter> <elorest> That’s cool. Where do you live?
<FromGitter> <elorest> Yeah.
<FromGitter> <elorest> America mostly doesn’t have fast internet.
<vegai> I wonder if Crystal should have a mailing list with easier accessibility than google groups
<vegai> like I Discourse forum?
<watzon> Yes. Yes it should
<watzon> Google Groups is such a freaking eyesore
<FromGitter> <sdogruyol> I pay $20 for 16mbit
<FromGitter> <elorest> Well I better go to bed.
<FromGitter> <elorest> Have a good day/night
<watzon> I pay $50 for 30mbit 😭
<txdv> i pay 15eu for 300mbit
<txdv> they even have 1gb for 20eu
<txdv> hmm
<FromGitter> <sdogruyol> :D
<FromGitter> <sdogruyol> Speed is good but I prefer stable / more uptime
<txdv> I have from time to time a disconnect on freenode
Tuxified has joined #crystal-lang
Tuxified has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mark_66 has joined #crystal-lang
<FromGitter> <krypton97> We got a very good and cheap internet here too. I kinda wished for more highways than that 😄
rohitpaulk has quit [Ping timeout: 264 seconds]
<ShalokShalom> Papierkorb: hi there
<ShalokShalom> bindgen is for other languages as well?
<ShalokShalom> or only for Crystal
<FromGitter> <sdogruyol> for Crystal i guess
Tuxified has joined #crystal-lang
<txdv> @krypton97 where are you from?
<FromGitter> <sdogruyol> reminded me of crane // cc @RX14 :)
Tuxified has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <sdogruyol> Having something like ```crane update stable``` would be lovely
DTZUZO has quit [Ping timeout: 240 seconds]
DTZUZO has joined #crystal-lang
<FromGitter> <krypton97> Romania @txdv
<txdv> the country with the best internet
<FromGitter> <krypton97> I think Japan was 1st
<FromGitter> <krypton97> is*
<txdv> more like south korea
Groogy has quit [Disconnected by services]
Groogy_ is now known as Groogy
<Groogy> Morning!
Groogy2 has joined #crystal-lang
<FromGitter> <sdogruyol> morning
brunto has joined #crystal-lang
brunto has quit [Client Quit]
<FromGitter> <krypton97> I don't know what's wrong with the return, but when I try to assign the result of this function to a variable I get void value expression
<FromGitter> <krypton97> def next ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ err: void value expressoon [https://gitter.im/crystal-lang/crystal?at=59a91ce9ee5c9a4c5f204d78]
<FromGitter> <krypton97> Doing rn = next throws error, but doing rn = self.next won't
<FromGitter> <bew> can you carcin? @krypton97
DTZUZO has quit [Quit: WeeChat 1.9]
<FromGitter> <jose-rodrigues> @krypton97 isn't next a reserved keyword?
<FromGitter> <bew> oh yes, that's why I think
<FromGitter> <krypton97> is it?
<FromGitter> <krypton97> O so I guess if I say self.next it won't be takken as a reserved keyword
<FromGitter> <krypton97> right?
<FromGitter> <jose-rodrigues> Dunno try to rename it and see
<FromGitter> <krypton97> Next is a private method for a lcass
<FromGitter> <krypton97> with self.next I got no errors
<FromGitter> <bew> yes, by specifying a receiver `self.` you can use keywords as method names
<FromGitter> <krypton97> nice
<FromGitter> <krypton97> thanks
Tuxified has joined #crystal-lang
<Groogy> donno if that's good praxis though
<crystal-gh> [crystal] RX14 closed pull request #4898: correct and use simple sample in FormData::Builder doc (master...fix-variable-name-in-formdata-builder-comment) https://git.io/v5ch1
<FromGitter> <jose-rodrigues> For fun and profit: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=59a92bc5bac826f0546bc897]
rohitpaulk has joined #crystal-lang
Yxhuvud has quit [Read error: Connection reset by peer]
<travis-ci> crystal-lang/crystal#4d9aed0 (master - correct and use simple sample in FormData::Builder doc (#4898)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/270757934
saadq has quit [Ping timeout: 255 seconds]
bmcginty has quit [Ping timeout: 240 seconds]
saadq has joined #crystal-lang
bmcginty has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter> <codenoid> hi, how to convert BSON to JSON ? :/
ShalokShalom_ has joined #crystal-lang
ShalokShalom has quit [Ping timeout: 240 seconds]
<FromGitter> <codenoid> BSON from mongocr clash with https://github.com/jeromegn/bson.cr ,
<travis-ci> crystal-lang/crystal#4d9aed0 (master - correct and use simple sample in FormData::Builder doc (#4898)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/270757934
rohitpaulk has joined #crystal-lang
ShalokShalom_ is now known as ShalokShalom
<FromGitter> <veelenga> Sorry, but someone had to do this 😄
<FromGitter> <krypton97> @codenoid paste some bson here to see it's format
<FromGitter> <krypton97> its*
<FromGitter> <krypton97> 😄
<FromGitter> <codenoid> ```code paste, see link```
<FromGitter> <krypton97> okey, that won't be too hard
<FromGitter> <codenoid> *simple way please with current crystal method, (if there are)
<FromGitter> <krypton97> [ ⏎ { ⏎ "_id": { ⏎ "$oid": "59a92b7f383af240c95212b2" ⏎ }, ... [https://gitter.im/crystal-lang/crystal?at=59a93b9cba0f0f6e3806c566]
<FromGitter> <krypton97> I think you have to build it
<txdv> why is crystal so bad in the techempower benchmark?
<FromGitter> <codenoid> but it still readed as BSON
<FromGitter> <krypton97> Did u read the entire doc? Mongo should provide a function to return json
<FromGitter> <codenoid> or i use .read(JSON) (?)
<FromGitter> <codenoid> or / ?
<FromGitter> <krypton97> @txdv I've ran it on my local machine and it's not bad at all
<FromGitter> <krypton97> But I'm very interested run some bench against java
<FromGitter> <krypton97> @codenoid I haven't used mongo with crystal, let me check the docs
<FromGitter> <krypton97> Do u have a node js background? :)
<FromGitter> <krypton97> Mongo is pretty popular there and also very easy to use with it
<FromGitter> <krypton97> Wait, your BSON is a valid json
<FromGitter> <krypton97> If you stringify it you got it
Tuxified has quit [Ping timeout: 264 seconds]
<FromGitter> <krypton97> https://jsonlint.com/
<FromGitter> <krypton97> Applying `to_s` on that BSON gave me a valid json string, but be aware that there shouldn't be spaces between keys and columns
<travis-ci> crystal-lang/crystal#4d9aed0 (master - correct and use simple sample in FormData::Builder doc (#4898)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/270757934
<FromGitter> <codenoid> yes, thank @krypton97 for your help, but when i check it, why web socket (cr) just support sending as String and Bytes :/ ,
<FromGitter> <codenoid> `crystal-lang/0.23.1/src/http/web_socket ᐅ vi protocol.cr`
<FromGitter> <krypton97> what do you mean?
<FromGitter> <krypton97> I don't get it
<FromGitter> <codenoid> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=59a944c9bc46472974e5a87c]
<FromGitter> <codenoid> approved data type for Web Socket
<FromGitter> <krypton97> are you looking to send that json over socket?
<FromGitter> <codenoid> yes, but nvm
<FromGitter> <krypton97> there should be a way to convert that
<FromGitter> <codenoid> actually, I'm trying to edit it to suit my wishes :D
<FromGitter> <krypton97> 👍
<FromGitter> <sdogruyol> @krypton97 check round 15 preview
<FromGitter> <sdogruyol> Previously crystal using only one of 48 cpu cores.
<FromGitter> <krypton97> Isn't the code optimized to use all the cores?
<FromGitter> <krypton97> well, multiply it by 48 and we got it 😄
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
Tuxified has joined #crystal-lang
<FromGitter> <faustinoaq> @krypton97 as @sdogruyol said, see https://www.techempower.com/benchmarks/previews/round15/ ⏎ ⏎ I think preview 3 should show a faster Kemal, because serve_static is disabled now.
<FromGitter> <krypton97> I've seen it. Isn't crystal supposted to beat java in terms of speed?
<FromGitter> <sdogruyol> There are lots of factors here
<FromGitter> <sdogruyol> Not just raw crystal speed
<FromGitter> <krypton97> go-fasthttp is doing pretty well
maxpert has joined #crystal-lang
maxpert has quit [Remote host closed the connection]
<FromGitter> <faustinoaq> > Isn't crystal supposted to beat java in terms of speed? ⏎ ⏎ I think parallelism is the key here. Crystal would be faaster that Java on single core, but on multiples cores (TechBench has at least 80 cores) we are forking processes (https://github.com/TechEmpower/FrameworkBenchmarks/blob/master/frameworks/Crystal/amber/setup.sh#L9) managed by operative system, so context change is slow. Languages like
<FromGitter> ... Go and Java handle parallelism quite well. ⏎ ⏎ I hope we can see some progress (https://github.com/crystal-lang/crystal/wiki/Threads-support#random-notes) on Crystal parallelism before this year end. [https://gitter.im/crystal-lang/crystal?at=59a95824ee5c9a4c5f216747]
rohitpaulk has quit [Quit: Ping timeout (120 seconds)]
rohitpaulk has joined #crystal-lang
snsei has quit [Remote host closed the connection]
Tuxified has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
kubaxvx__ has quit [Quit: WeeChat 1.6]
kubaxvx has joined #crystal-lang
<FromGitter> <jose-rodrigues> @faustinoaq Do you know if there is any plans to update the `thread-support` branch to less us play with the feature?
<FromGitter> <faustinoaq> Nop, but I think core crystal team at Manas.tech is working on something. Just not ready yet. WDYT @mgarciaisaia ?
snsei has joined #crystal-lang
<FromGitter> <jose-rodrigues> @faustinoaq Ho ! You wake up my curiosity :D
<RX14> @faustinoaq i doubt it's parallelism that makes java faster
<FromGitter> <mgarciaisaia> Have you seen the hammok-driven development talk by Rich Hakey? https://github.com/matthiasn/talk-transcripts/blob/master/Hickey_Rich/HammockDrivenDev.md
<RX14> java's networking libraries have had a *lot* of thought and effort put in to themn
<RX14> and they are highly optimised
<RX14> i doubt crystal will beat them any time soon
<FromGitter> <mgarciaisaia> We're about to. There are good news coming, but they're not here *yet*.
<FromGitter> <crisward> JS Array.filter in crystal ? I know I should know it.... can't seem to spot in docs
<RX14> select?
<FromGitter> <crisward> Thanks
<FromGitter> <fridgerator> @mgarciaisaia good news?
<FromGitter> <mgarciaisaia> @fridgerator I think "good" is an understatement
<FromGitter> <mgarciaisaia> I'm pretty much excited about that, at least
<FromGitter> <fridgerator> 1) o
<FromGitter> <crisward> It's documented under enumerable..
<FromGitter> <faustinoaq> > Ho ! You wake up my curiosity ⏎ ⏎ @jose-rodrigues New year resolutions (https://crystal-lang.org/2016/12/29/crystal-new-year-resolutions-for-2017-1-0.html) is a good reading. Well, I think Crystal could be ready at end of 2018, because parallelism and Windows support are big issues yet. see: Roadmap for 1.0 (https://groups.google.com/forum/#!topic/crystal-lang/BEQSAUAZ_pE) ⏎ ⏎ If we could delay
<FromGitter> ... Windows and parallelism, I think crystal is almost done for production. Maybe we can publish a beta before that, alpha stage is a bit confusing for newcomers 😅 [https://gitter.im/crystal-lang/crystal?at=59a9636066c1c7c47704d324]
<RX14> @mgarciaisaia i told martin i'd believe the news when it was confirmed though!
<FromGitter> <fridgerator> what is the news?
<FromGitter> <mgarciaisaia> Of course! I'm on the same page, @RX14. *I'm excited* about that, but that doesn't mean *you* should too :)
<crystal-gh> [crystal] RX14 pushed 1 new commit to master: https://git.io/v5BCn
<crystal-gh> crystal/master 842548e TSUYUSATO Kitsune: Allow assignment to class var when fit this class var types of ancestors (#4871)...
maxpert has joined #crystal-lang
<7JTAB68NV> [crystal] RX14 closed pull request #4653: Additions to Big arithmetics (master...bigfloat-frexp) https://git.io/vQ0eO
<crystal-gh> crystal/master d1960a5 Akzhan Abdulin: Additions to Big arithmetics (#4653)...
<crystal-gh> [crystal] RX14 pushed 1 new commit to master: https://git.io/v5BCP
rohitpaulk has quit [Ping timeout: 246 seconds]
maxpert has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
<RX14> i like how merging pace has picked up recently
<RX14> feels good to merge some progress every day
<hightower3> ++
<rumenzu> hi everyone
<FromGitter> <bew> @mgarciaisaia you're spreading mystery about thoses upcoming news :P
<FromGitter> <fridgerator> how soon can we expect the news?
<FromGitter> <mgarciaisaia> Yeah. I know I shouldn't - sorry about that ¯\\_(ツ)\_/¯
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
<FromGitter> <bew> RX14 yes it's good to see progress! I bet it has something to do with your promotion, as you're always there to push things ;)
<RX14> there was plenty of time where i was on the core team where it was slower than this....
<FromGitter> <schoening> When is the next release comming 😃
<FromGitter> <bew> true, but in a bigger timeline I think my statement is true though (we were not talking about the same timeline I think ^^)
<RX14> when it feels like the right time
<FromGitter> <bew> @schoening I'm waiting for it too, lot of cool things merged!
<FromGitter> <schoening> Horray! 😍
<travis-ci> crystal-lang/crystal#842548e (master - Allow assignment to class var when fit this class var types of ancestors (#4871)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/270834563
<rumenzu> what would be the simplest way to explore all subnodes of a given AST node?
<FromGitter> <schoening> Would I be right in thinking that parallelism is more difficult than windows support ?
Tuxified has joined #crystal-lang
<FromGitter> <sdogruyol> @schoening well both takes a lot of effort for sure
<RX14> @schoening perhaps, but windows support is getting more attention at this point
<travis-ci> crystal-lang/crystal#d1960a5 (master - Additions to Big arithmetics (#4653)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/270835508
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
<travis-ci> crystal-lang/crystal#842548e (master - Allow assignment to class var when fit this class var types of ancestors (#4871)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/270834563
snsei has quit [Remote host closed the connection]
<crystal-gh> [crystal] RX14 pushed 1 new commit to master: https://git.io/v5BzO
<crystal-gh> crystal/master dca2887 Sergio Gil Pérez de la Manga: Document Array#shift? (#4886)
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter> <krypton97> any frontend developers here? Thinking to switch from react to vue, but in doubts
<FromGitter> <crisward> For anyone doing web stuff that's not using crinja, I suggest you check it out. Runtime templates are sooo much quick when developing in crystal. You can also wrap your crystal method calls so you can call things from inside your template. Really cool. It's also not any slower to render than `slang`, well not when you take into account all the other stuff going on. I'm sure some benchmarks could prove me wrong.
<FromGitter> <krypton97> templating is not enough
<FromGitter> <crisward> @straight-shoota Nice work.
<travis-ci> crystal-lang/crystal#dca2887 (master - Document Array#shift? (#4886)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/270859799
<FromGitter> <crisward> @krypton97 ?
<FromGitter> <krypton97> For a complex project where you wanna add charts as well, templates won't be enough
rohitpaulk has joined #crystal-lang
<watzon> krypton97 I've used both react and vue. Between the two I'd go with vue, but I'd still choose Angular over either
<FromGitter> <crisward> Front end js you mean? We're using React for that. We use Riot.js too for custom tags. Never used vue.
<watzon> Vue is a lot easier and lighter weight though
<FromGitter> <crisward> Preact?
<FromGitter> <crisward> Even lighter
<watzon> Can't say I've ever used it. I kinda hate react, and that new license doesn't help matters
<FromGitter> <crisward> Personally I wouldn't bother learning another front end framework until custom elements land in all the browsers. I think vanilla.js may well become the new norm.
* FromGitter * maxfierke whispers "ember.js" or "glimmer.js" ...
<watzon> There's always Elm
<watzon> Lol. Ember. Haven't heard that name whispered in a while
Tuxified has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <krypton97> there's inferno too that replicates react and seems faster
<FromGitter> <kazzkiq> Angular is only good only for huge projects. It helps with organization and prevents messy code (most of the time).
<FromGitter> <kazzkiq> But it comes as a cost, and the cost is that it generally weights 1MB+ *in production*. Unbearable for PWAs or small projects. Its simply too heavy (in terms of resources).
<travis-ci> crystal-lang/crystal#d1960a5 (master - Additions to Big arithmetics (#4653)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/270835508
snsei has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 260 seconds]
Yxhuvud has joined #crystal-lang
Philpax__ has quit [Ping timeout: 240 seconds]
mark_66 has quit [Remote host closed the connection]
maxpert has joined #crystal-lang
<FromGitter> <fridgerator> I use vue a lot, it's great
snsei has quit [Remote host closed the connection]
maxpert has quit [Ping timeout: 248 seconds]
<crystal-gh> [crystal] bew opened pull request #4909: Remove useless loc in Signal (master...signal-remove-useless-loc) https://git.io/v5Bi5
DTZUZO has joined #crystal-lang
rumenzu has quit []
<crystal-gh> [crystal] bew opened pull request #4910: Print spec arg errors to stderr (master...spec-errors-on-stderr) https://git.io/v5B1e
<RX14> can anyone else replicate a spec failure on master? `bin/crystal spec spec/compiler/crystal/tools/init_spec.cr`
<RX14> preferably someone on archlinux as obviously it doesn't fail on travis
<FromGitter> <bew> no error for me (arch too)
<FromGitter> <bew> ah wait, didn't re-built
<FromGitter> <bew> still no error
<RX14> what does `(echo "foo" >2) 2>&1 >/dev/null` print for you?
<FromGitter> <bararchy> RX14 , you need that tested on HEAD ?
<FromGitter> <mgarciaisaia> Worked for me in OSX if that helps in some way
<RX14> oops
<RX14> what does `(echo "foo" 1>&2) 2>&1 >/dev/null` print for you?
<RX14> because to me, "2>&1 >/dev/null" should always print nothing
<FromGitter> <mgarciaisaia> `foo`
<RX14> you redirect stderr to stdout
<RX14> and then redirect stdout to dev null
<RX14> to me it prints nothing
<FromGitter> <mgarciaisaia> I think the order matters there
<RX14> yeah but for you it prints foo
<RX14> for me it prints nothing
<FromGitter> <bew> RX14 ah that's my code ^^ it prints `foo` on stderr, then redirect on stdout and close the original stdout
<FromGitter> <mgarciaisaia> If you swap it to `(echo "foo" 1>&2) >/dev/null 2>&1` it prints nothing
<RX14> oh wait nvm
<FromGitter> <bew> it's a weird bash thing iirc
<RX14> it does print foo for me
<RX14> but i get these spec failures
<RX14> i was trying out my crystal::system IO refactor
<RX14> and kept getting these errors
<RX14> but they seem to be on master too
<RX14> which is weird
<FromGitter> <bew> I have a clean of this spec file in https://github.com/crystal-lang/crystal/pull/4691/files
<FromGitter> <bew> but not merged yet
<RX14> yeah but
<RX14> its broken specs
<RX14> and i don't know why
<RX14> can anyone replicate this result? https://gist.github.com/RX14/cecf34263285bd41f02390df32ee3b27
<RX14> same for me in /bin/sh too
<RX14> given that, why does it work at all?
<RX14> oh
<FromGitter> <krypton97> guys, guys hold up all
<RX14> i solved it
<FromGitter> <krypton97> https://sample.goby-lang.org/
<FromGitter> <krypton97> Go + Ruby => Goby
<FromGitter> <krypton97> O.o
<RX14> @bew the problem is that https://github.com/crystal-lang/crystal/commit/ffb748fc182d61222bc780d6dfa9605ce3351b63 breaks specs when you havent compiled your own compiler
<RX14> try make clean deps
<RX14> and then run the spec again
<RX14> if your compiler is 0.23.1 it won't have the patch to print to STDERR
<RX14> essentially you can't reply on bin/crystal being the built compiler
<RX14> but this spec does do that
<FromGitter> <bew> Ooh... I see..
<RX14> i assume you can replicate?
<FromGitter> <bew> Not on my computer right now
<FromGitter> <bew> I'm not on my computer right now
<RX14> oh
<FromGitter> <bew> I will try in a hour if no one already did it
rohitpaulk has joined #crystal-lang
<FromGitter> <bew> I just left work, but I'll try in the train if I find somewhere to sit!
<crystal-gh> [crystal] RX14 closed pull request #4909: Remove useless loc in Signal (master...signal-remove-useless-loc) https://git.io/v5Bi5
<RX14> well i'm 99% and I can replicate it on my PC
<RX14> so it's not really worth the effort
<FromGitter> <bew> Yeah and I understand the problem.. how should we do that then? Remove the spec, release, re-add the spec?
<RX14> perhaps
<FromGitter> <vonKingsley> just curious, is the only way to get call stack line numbers on OSX by calling dsymutil --flat on the executable, or should this happen automatically when I use the --debug flag?
<FromGitter> <bew> Can you open an ossue RX14 so we can find a way, an discuss with others? (I'll do it later if you don't have time)
snsei has joined #crystal-lang
<FromGitter> <bew> issue*
<RX14> i mean
<RX14> its been since july
<RX14> and now it's september
<RX14> and nobody has noticed
<RX14> so maybe we should just ignore it
snsei has quit [Ping timeout: 255 seconds]
<FromGitter> <bew> Ahahah well.. you can mention this in the issue, or I will if you don't ˆˆ it's aways a bad idea to ignore sth like that imo!
<FromGitter> <bew> Unless everyone is ok to ignore it
<travis-ci> crystal-lang/crystal#dca2887 (master - Document Array#shift? (#4886)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/270859799
RandomCrystal125 has joined #crystal-lang
<RandomCrystal125> heya, is there a special reason that crystal does not support postfix increment ( eg. a++ )
<crystal-gh> [crystal] RX14 opened pull request #4912: Add Crystal::System::FileHandle (master...feature/io-crystal-system) https://git.io/v5BQ5
<FromGitter> <drosehn> I'm not part of the decision-making, but I don't miss it. It doesn't give you anything that a good compiler would do with 'a += 1'.
<RandomCrystal125> so just a design decision
<FromGitter> <drosehn> And one reason I don't miss it is that ruby doesn't have it. Neither does python.
rohitpaulk has quit [Ping timeout: 240 seconds]
<RandomCrystal125> so many things to get used to design wise coming from C :D
<RandomCrystal125> another question. most flow-control operators don´t use {} but basically only end. however some like .each dont. is there a specific reason for that? and if it is design, what is the design idea behind it
<RandomCrystal125> for me it just feels like inconsitency in the syntax
<FromGitter> <drosehn> `val++` and `++val` are used in C, but a new language can do quite well without them, IMO. And from my many days of C programming, some programmers get into trouble when they use them "to save a few keystrokes" while they're also using C macros (`#define`s). So personally I usually avoid them in C, too.
<FromGitter> <drosehn> <shrug>
<RandomCrystal125> yeah i mean, i don´t really mind the ++ thing, was just curious. the {} thing though i really am wondering
claudiuinberlin has joined #crystal-lang
<RX14> RandomCrystal125, .each isn't a control operator, it's a method which takes a block
<RX14> typically we do most our control frow through wordy sumbols
<RX14> do/end if/else/end etc
<RX14> without braces
<Yxhuvud> RandomCrystal125: each is not a flow control operator! It is just a regular method (that happens to take a block)
<RX14> there's 2 places where we use C-style braces in the language
<RX14> one of them is procs, which are very rarely used
<RX14> the other is a shorthand syntax for blocks
<Yxhuvud> (I should probably read what other people write now and then)
<RX14> often you want to write a block on a single line
<RX14> and instead of using `bar.map do |foo| foo.bar end`, which is quite visually messy
<RX14> we allow a shorthand of `bar.map { |foo| foo.bar }` which is easier to parse visually
<RX14> but the {} syntax is (almost) exactly equivalent to do/end
<RX14> I really need to get around to making it equivalent
<RX14> so I can reopen that formatter PR I made
<Yxhuvud> .. and then the shorthand has a shorthand of its own bar.map &.bar.
<RandomCrystal125> while i get that they are techincyally methods and not control flows, but for me .times .each really feel like control flows. but ok, so everything that kidna works in blocks but isn´t really a control flow uses {}....i think i can get used to that :D
<RX14> no
<RX14> it's purely a one line or two think
<RX14> if you use multi-line use do/end
<RX14> if it's a single line use {}
<RX14> if course you can use {} on multiple lines
<RX14> but it's discouraged
<RandomCrystal125> aaab
<RandomCrystal125> now i got it :D
<RX14> it's simply do that the do/end syntax doesn't look ugly on 1 line
<RandomCrystal125> that does make sense to me
<RX14> because when you have multiple blocks on 1 line
<RX14> do/end gets very messy
<RandomCrystal125> yeah, i can imagine that :D
<RX14> rest of the time we use do/end and the "ruby style"
<RX14> perhaps adding a do/end proc syntax would be cool
<RX14> hmm
<Yxhuvud> I'm not certain it is worth the trouble considering how seldom people actually do procs
<RX14> my consistency :(
<RandomCrystal125> it is interesting that (100).times do |i| works, it is nice that you can get the number (though would that be discouraged or ok)
<RandomCrystal125> sorry for the beginner questions, just playing around with it a bit to get into it
<Yxhuvud> it is ok, but it is quite seldom necessary. Internal iterators (ie putting the iterations in methods) tend to do away with a lot of the need to get numbers like that
<Yxhuvud> and for the times you need it for an index, then #with_index is usually nicer.
maxpert has joined #crystal-lang
<RandomCrystal125> #with_index ?
<RX14> i rarely use iterators personally
<RX14> RandomCrystal125, you arely use #times because most of the time you're iterating over a collection or array
<RX14> so you just use #each
<RX14> and when you are dealing with indexes you typically want to do special things involing #upto, #downto or #step
<RX14> not a sinle #times
<RandomCrystal125> yeah makes sense. i mean i was just doing fizzbuzz, probably one of the only times you´d use it :D
<RX14> yeah lol
<RandomCrystal125> but it is nice to understand the different ways to loop through stuff
<FromGitter> <bew> Without using for ;)
<RX14> our only loop constructs are while and until
<Yxhuvud> RandomCrystal125: https://crystal-lang.org/api/0.23.1/Iterator.html#with_index%28offset%3AInt%3D0%29-instance-method
<RX14> the rest is methods with blocks
<RX14> building on those two
<Yxhuvud> I can really recommend reading through the methods in Enumerable, Indexable and Iterator. Lots of useful gems can be found there.
maxpert has quit [Ping timeout: 240 seconds]
<RX14> why not each_with_index though...
<RX14> i rarely use iterators
<RX14> very rarely
<Yxhuvud> RX14: I guess it is my ruby heritage showing. with_index is more flexible so I tend to use only that and ignore the specialized methods.
<RandomCrystal125> RX14 i also meant iterating through arrays and such, loops maybe was a bad term to use
<RX14> as long as you're aware how we use these methods in crystal
<RX14> just wanted to amke sure
<RandomCrystal125> anyway, thanks for the help, cya
RandomCrystal125 has quit [Quit: Page closed]
<travis-ci> crystal-lang/crystal#d1960a5 (master - Additions to Big arithmetics (#4653)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/270835508
snsei has joined #crystal-lang
<travis-ci> crystal-lang/crystal#e2b2685 (master - Remove useless loc (#4909)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/270904048
<crystal-gh> [crystal] RX14 closed pull request #4910: Print spec arg errors to stderr (master...spec-errors-on-stderr) https://git.io/v5B1e
snsei has quit [Remote host closed the connection]
Tuxified has joined #crystal-lang
snsei has joined #crystal-lang
hightower4 has joined #crystal-lang
hightower3 has quit [Ping timeout: 264 seconds]
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
RockyBalboa has joined #crystal-lang
snsei has quit []
snsei has joined #crystal-lang
RandomCrystal125 has joined #crystal-lang
snsei has quit [Client Quit]
<RandomCrystal125> how excatly would i handle an argument error? in java i would for example have try catch. i understood that in crystal i have rescue, but i don´t really understand how to use it.
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<RandomCrystal125> if for example i had the code " x = x.nil? ? 0 : x.to_i "it could have an argument error (if x were "a3" for example). how would i catch and deal with that? :/
snsei has joined #crystal-lang
<FromGitter> <bew> You can read a lot on crystal syntax and usage in the docs => https://crystal-lang.org/docs/
<RandomCrystal125> i did read the docs, but i didn´t understand them. wich is why i came here to ask for an explanation
<FromGitter> <bew> You can read about error handling https://crystal-lang.org/docs/syntax_and_semantics/exception_handling.html
<RandomCrystal125> i am aware of that
<FromGitter> <bew> No problem', it was just in case!
<RandomCrystal125> dw, no offense taken
<RandomCrystal125> i realise how i can raise my own exception and then deal with that, i assumed that i would have to put it in a begin ... rescue.... block, but i got compile errors when i did
<FromGitter> <bew> What did you tried? Can you show in carc.in ?
Tuxified has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <bew> https://carc.in write your code, run and give the link here
<RandomCrystal125> i mean not carc, but seemed to be the same...i hope there is no difference :P
maxpert has joined #crystal-lang
<FromGitter> <bew> yes it's the same ;)
<RandomCrystal125> running it without the begin rescue it does compile, but ofc it would crash if you would input something that isn´t a number
<FromGitter> <bew> The issue here is the type of x line 7, it could be an Int32, a String or a Nil. Explanation: `gets` return value is a String or Nil, then in the begin/end block you try to convert it to an Int32. The thing is, if your conversion fail, `x` will can still be a String or Nil!
claudiuinberlin has joined #crystal-lang
<FromGitter> <oesgalha> You can pass a block to the `to_i`method to handle an invalid string
<RandomCrystal125> well the nil case i "catch" with the if. but if the conversion would fail it raises an argument error. how do i rescue that error.
<RandomCrystal125> how would i pass such a block?
<FromGitter> <oesgalha> "a3".to_i { 0 }
<FromGitter> <oesgalha> Since "a3" is not a valid integer string this expression returns what is inside the block: zero
<FromGitter> <oesgalha> https://crystal-lang.org/api/0.23.1/String.html#to_i%28base%3AInt%3D10%2Cwhitespace%3Dtrue%2Cunderscore%3Dfalse%2Cprefix%3Dfalse%2Cstrict%3Dtrue%2C%26block%29-instance-method
<FromGitter> <bew> https://play.crystal-lang.org/#/r/2ndq Nice, didn't know that!
<RandomCrystal125> https://play.crystal-lang.org/#/r/2ndr i mean, that is one poop line....but hey it works, and if it works it ain´t stupid ^^
<RandomCrystal125> though i guess since the { 0 } would also handle the nil type i can shorten it to not use the if....if i understood it correctly
<watzon> Dafuq
<watzon> That is awesome
<RandomCrystal125> i know....i have a tendency to overcomplicate stuff
<FromGitter> <bew> randomCrystal123, well, x is 0 https://play.crystal-lang.org/#/r/2nds
<FromGitter> <bew> but it's cool, yeah ;)
<RandomCrystal125> yeah, since the online repl can´t use gets.
<RandomCrystal125> " x = x.nil? ? 0 : x.to_i { 0 } " is just a more complicated version of " x = x.to_i { 0 } " though xD
<RandomCrystal125> but awesome, handling with exceptions in a block feels super fluid....i like this language more and more
<RandomCrystal125> ~with~
<FromGitter> <bew> You can 'fake' I/O stuff with in memory IO: https://carc.in/#/r/2ndw
<FromGitter> <peterschols> @konovod ☝️ August 29, 2017 12:11 PM (https://gitter.im/crystal-lang/crystal?at=59a53dc576a757f808f52da5) have you heard of any updates on the atom-ide-crystal issue? I'd love to use Atom for Crystal development.
<RandomCrystal125> well blocks are nice. but how would i elegantly report that error. lets say if the input is "a3" and i would want to put the message "Invalid, only use numbers". i can´t do that with a block since that is only a "default" return. so i would have to actually catch the argument error
<FromGitter> <bew> well, you can raise in the block, like `"a3".to_i { raise "Invalid, only use numbers" }`
<RandomCrystal125> ah...got it
<FromGitter> <peterschols> Anyone here using Atom with atom-ide-crystal and running into issues with the latest version of Atom? See https://github.com/crystal-lang-tools/atom-ide-crystal/issues/23
maxpert has quit [Remote host closed the connection]
<FromGitter> ... shared earlier could be changed to use begin/rescue: ⏎ https://play.crystal-lang.org/#/r/2nex [https://gitter.im/crystal-lang/crystal?at=59a9c041bac826f0546e8c65]
<FromGitter> <oesgalha> randomCrystal123 you could also use `x.to_i?`. If x is an invalid string, this will return nil, so you can check it later and report the error: ⏎ https://crystal-lang.org/api/0.23.1/String.html#to_i%3F%28base%3AInt%3D10%2Cwhitespace%3Dtrue%2Cunderscore%3Dfalse%2Cprefix%3Dfalse%2Cstrict%3Dtrue%29-instance-method ⏎ ⏎ Handling excpetions is more expensive than an if check. But here is how the code you
<FromGitter> <eliasjpr> Can’t sleep at night waiting for the reveal of the news
<FromGitter> <eliasjpr> @mgarciaisaia :shipit:
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
<travis-ci> crystal-lang/crystal#e2b2685 (master - Remove useless loc (#4909)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/270904048
<RandomCrystal125> @oesgalha since nil also gets returned if the input is just empty i would want to differenciate there. so i found a solution i am quite happy with.
<travis-ci> crystal-lang/crystal#e2b2685 (master - Remove useless loc (#4909)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/270904048
<RandomCrystal125> wich is pretty similar to your code, now that i look at yours :D
<FromGitter> <bew> randomCrystal125 I made a little example (with tests!) for you https://carc.in/#/r/2nf3 :)
DTZUZO has quit [Read error: Connection reset by peer]
<FromGitter> <totakaro> @krypton97 Goby is interpreted, needs a VM and doesn't have types.
<RandomCrystal125> uuuh using testing on the playground...i didn´t think about that
<RandomCrystal125> thanks for the help, awesome community
RockyBalboa has quit [Quit: Lost terminal]
<FromGitter> <bew> you're welcome ;)
sifi has joined #crystal-lang
<travis-ci> crystal-lang/crystal#d74c3f3 (master - Print spec arg errors to stderr (#4910)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/270945215
<FromGitter> <krypton97> Wished the std http lib looked something like this
<FromGitter> <krypton97> require "http/server" ⏎ require "file" ⏎ require "json" ⏎ server = HTTP::Server.new(3000) ⏎ ... [https://gitter.im/crystal-lang/crystal?at=59a9c997bc46472974e83cdf]
<FromGitter> <sdogruyol> Use Kemal @krypton97 :)
<FromGitter> <krypton97> 👍 yup
<FromGitter> <krypton97> btw, would local scoping be better for kemal?
<FromGitter> <krypton97> wouldn't*
<FromGitter> <krypton97> like instead of get "/" do .. to be Kemal.get "/" do..
<oprypin> how is that local
<FromGitter> <bew> @krypton97 stdlib stuff must stay generic & simple enough so that you can build any kind of framework on top of it. You're describing a library, that could use the stdlib (like Kemal!)
<FromGitter> <krypton97> seems legit
DTZUZO has joined #crystal-lang
alex`` has quit [Quit: WeeChat 1.9]
maxpert has joined #crystal-lang
maxpert has quit [Remote host closed the connection]
claudiuinberlin has quit [Quit: Textual IRC Client: www.textualapp.com]
<FromGitter> <MatthewBennington> Is there an easy way to download & access the api documentation offline?
DTZUZO has quit [Read error: Connection timed out]
<FromGitter> <krypton97> check github
DTZUZO has joined #crystal-lang
<FromGitter> <krypton97> should be there
<FromGitter> <bew> no need for github, you can generate the docs with `make doc`
<FromGitter> <MatthewBennington> @bew I don't understand, sorry.
<FromGitter> <bew> you can download the source code of the crystal compiler (on github), then write the command `make doc` in it to generate the API documentation and be able to onsult it offline
<FromGitter> <MatthewBennington> hmm, that's what I thought, but make is giving me an error. My LLVM install might be messed up
Tuxified has joined #crystal-lang
<FromGitter> <bew> just run `make doc`, not `make`
<FromGitter> <MatthewBennington> Yeah, that's giving me an error
<FromGitter> <bew> whats your error?
<FromGitter> <MatthewBennington> This fixed it for me
<FromGitter> <MatthewBennington> Thanks
<travis-ci> crystal-lang/crystal#d74c3f3 (master - Print spec arg errors to stderr (#4910)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/270945215
<travis-ci> crystal-lang/crystal#dca2887 (master - Document Array#shift? (#4886)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/270859799
<FromGitter> <faustinoaq> > Is there an easy way to download & access the api documentation offline? ⏎ ⏎ @MatthewBennington If you need offline docs, then devdocs is your best friend http://devdocs.io/crystal/
<travis-ci> crystal-lang/crystal#d74c3f3 (master - Print spec arg errors to stderr (#4910)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/270945215
snsei has quit [Remote host closed the connection]
Tuxified has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <fridgerator> @sdogruyol are you around?
<FromGitter> <fridgerator> nvmd, its 2am there
<crystal-gh> [crystal] bew opened pull request #4915: Refactor tool init specs (master...refactor-init-spec) https://git.io/v5RE5
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 240 seconds]
RandomCrystal125 has quit [Ping timeout: 260 seconds]