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
<FromGitter> <Qwerp-Derp> @opensas Well of course it can be done just fine using JSON::Type, I'm not disputing that - I'm just asking why there's both `JSON::Any` and `JSON::Type` being used instead of only one standard type for JSON data?
hightower4 has joined #crystal-lang
hightower3 has quit [Ping timeout: 258 seconds]
_whitelogger has joined #crystal-lang
<FromGitter> <georgeu2000> @jose-rodrigues - Not really...
<FromGitter> <georgeu2000> I feel like the best way to learn Crystal is to use it without a framework...
Groogy has quit [Ping timeout: 240 seconds]
Groogy has joined #crystal-lang
Groogy2 has joined #crystal-lang
Groogy has quit [Ping timeout: 240 seconds]
DTZUZU has quit [Quit: WeeChat 1.9]
<FromGitter> <jwaldrip> anyone run into missing libssl and libcrypto on osx high sierra
<FromGitter> <elorest> yep
<FromGitter> <jwaldrip> give it to me isaac, whats the fix?
<FromGitter> <jwaldrip> nvm
<FromGitter> <jwaldrip> got it
snsei has joined #crystal-lang
pawnbox has joined #crystal-lang
_whitelogger has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
snsei has quit [Remote host closed the connection]
pawnbox has quit [Remote host closed the connection]
<Groogy2> @bew CLASS_DATA is for invariants
<Groogy2> they are only supposed tyo be run when you "leave the class"
<Groogy2> a method is allowed to break the internal state as long as when you leave the call to the object it becomes invalid again
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 248 seconds]
pawnbox has joined #crystal-lang
<FromGitter> <elorest> @jwaldrip I upgraded my work computer and it didn’t work so I’m just using my home computer for crystal right now.
snsei has joined #crystal-lang
sz0 has joined #crystal-lang
<FromGitter> <ekremkaraca> Morning guys
<Groogy_> Morning o/
Groogy_ is now known as Groogy
<FromGitter> <imonmyown> Morning!
<FromGitter> <bararchy> Morning :)
mark_66 has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
alex`` has joined #crystal-lang
<FromGitter> <OldhamMade> Morning everyone! Is there a way to get extended output when running specs? I'm hoping for something like the following: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=59d33f2cb20c642429b7c30e]
<FromGitter> <bew> run the specs with `--verbose`
<FromGitter> <OldhamMade> @bew that's not an option when running `crystal spec -h`, and adding the option doesn't change the output for me. I'm running `Crystal 0.23.1 (2017-09-08) LLVM 4.0.1`
<FromGitter> <schoening> To save a function + its arguments inside a hash for later use I have to use a proc correct?
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
<FromGitter> <schoening> Is it even possible to save a function + its context in crystal? Not having first class functions in 2017 is weeeeeird...
snsei has quit [Ping timeout: 258 seconds]
<FromGitter> <OldhamMade> also, is it possible to mark tests to be skipped?
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
<FromGitter> <jose-rodrigues> @georgeu2000 The crystal http library kinda "low level". You will need to write your own router then. You only have one entrypoint an a context (https://crystal-lang.org/api/0.23.1/HTTP/Server/Context.html)
<Papierkorb> schoening, have you .. tried it?
<FromGitter> <sdogruyol> morning everyone
<Papierkorb> Morning sdogruyol
<Papierkorb> Err, sdogruyol, how is one supposed to pronounce your nick?
<FromGitter> <sdogruyol> that's a good question
<FromGitter> <sdogruyol> people just call me sedo (which is literally abbrv for my first name)
<FromGitter> <sdogruyol> not sure how foreign people pronounce the nickname though :D
<FromGitter> <bararchy> Ssdoogruuol
<FromGitter> <bararchy> Kinda
<FromGitter> <bararchy> Hard to write pronounce with English latters haha
<FromGitter> <sdogruyol> lol
<FromGitter> <bararchy> Serdar is easier to say haha
<FromGitter> <sdogruyol> @bararchy that really feels like a Nigerian football player name
<FromGitter> <bararchy> LOL sorry hahah
<FromGitter> <sdogruyol> haha nope
<FromGitter> <bararchy> Serdar always remainds me of Serdakar (from dune)
<FromGitter> <sdogruyol> haha
<FromGitter> <sdogruyol> ahh sardaukar
<FromGitter> <sdogruyol> I really liked those from my childhood
<FromGitter> <bew> @OldhamMade try `crystal spec -- --verbose`
<FromGitter> <bew> The `--` argument will allow you to pass in arguments for the program, where arguments before are for the build.
<FromGitter> <ansarizafar> @Papierkorb I have written a basic Validator. I need expert opinion. Here is how I can validate args/parameters ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=59d350cc210ac269209f3ed6]
<Papierkorb> Looks like an ad-hoc validator approach. For that, I don't see much issues. I'd have a #in_range(Range) instead of a plain #max though. And a `required` should be the "default", an optional (if at all) should be the opt-in
<FromGitter> <OldhamMade> @bew ``` ⏎ KEMAL_ENV=test crystal spec -- --verbose ⏎ ......... ⏎ ⏎ Finished in 39.44 milliseconds ... [https://gitter.im/crystal-lang/crystal?at=59d3521ef7299e8f53a07670]
<FromGitter> <bew> Hmm let me try for a moment then
<FromGitter> <OldhamMade> sorry about this
<FromGitter> <bew> works for me.. (even without `--`)
ShalokShalom has quit [Ping timeout: 246 seconds]
sz0 has quit [Quit: Connection closed for inactivity]
<FromGitter> <crisward> `--` usually passes the flag down, so it would be passed to your app (I think), and ignored by crystal.
<FromGitter> <OldhamMade> @bew which version of crystal are you using?
<FromGitter> <bew> `Crystal 0.23.1 (2017-09-10) LLVM 5.0.0`
<FromGitter> <OldhamMade> is this something I can enable in code rather than on the terminal? it's something I'd like to switch on in general anyway
<FromGitter> <OldhamMade> I thought I may have been on an older version. so, it's something to do with my setup then...
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
unshadow has joined #crystal-lang
unshadow has quit [Client Quit]
<FromGitter> <ansarizafar> @Papierkorb Thanks for the feedback. It's just POC, I will add more validators later.
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 248 seconds]
pawnbox has joined #crystal-lang
<FromGitter> <Qwerp-Derp> Is there an Elixir chat on Gitter?
<FromGitter> <sdogruyol> probably @Qwerp-Derp
xiljin has quit [Ping timeout: 248 seconds]
pawnbox has quit [Remote host closed the connection]
ShalokShalom has joined #crystal-lang
<Papierkorb> Groogy: pm
<Papierkorb> pm'd you
xiljin has joined #crystal-lang
xiljin has quit [Ping timeout: 264 seconds]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
cyberarm has quit [Ping timeout: 258 seconds]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
cyberarm has joined #crystal-lang
ShalokShalom has quit [Ping timeout: 248 seconds]
ShalokShalom_ has joined #crystal-lang
ShalokShalom_ is now known as ShalokShalom
bazaar has quit [Quit: leaving]
bazaar has joined #crystal-lang
<crystal-gh> [crystal] bew opened pull request #5072: Add constructor with millisecond & nanosecond as named argument (master...time-new-milli-nano) https://git.io/vdWEf
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
<Papierkorb> @faustinoaq, did you try running hackintosh in a VM?
<Papierkorb> If yes, would you be willing to check what's missing for Qt5.cr to work OOTB there? With the recent bindgen and configuration changes, it should now be doable
<Papierkorb> In general, if anyone tried qt5.cr on a different OS than ArchLinux, I'd be interested to hear if it worked or did not.
<Papierkorb> Could `Regex::MatchData` be an Indexable(String) ?
<Papierkorb> Looks quite indexable to me :)
<FromGitter> <bew> 👍
<crystal-gh> [crystal] mverzilli closed pull request #5069: Fix for YAML spec failure with new nanoseconds precision (master...fix-yaml-spec-nanoseconds) https://git.io/vdCZm
<FromGitter> <imonmyown> @Papierkorb, I get an error on Ubuntu 17.04: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=59d3a82af7299e8f53a28982]
<Papierkorb> imonmyown, you're missing the `clang` dependency.
<FromGitter> <imonmyown> Which one?
<Papierkorb> I don't use Ubuntu, but `libclang-4.0-dev` looks like a promising candidate from https://launchpad.net/ubuntu/zesty/+source/llvm-toolchain-4.0
<FromGitter> <imonmyown> Yeah, I thought I need a dev version of it...
<Papierkorb> If that works out, lemme know. Want to compile a list of more useful installation steps
<FromGitter> <imonmyown> No, still no luck, same error
<Papierkorb> And on the long run, maybe use Docker or something to auto-test bindgen on various linux distros at least. No idea if there's a free CI for that
<FromGitter> <zyriuse75> i've a question i try to make a menu with crystal and i would the possibility than my user chose between 1...3 how i can do it ? my menu is
<Papierkorb> imonmyown, is `llvm-config` installed? Check `llvm-config --cxxflags --ldflags`
<FromGitter> <imonmyown> @Papierkorb, you're right man, it's missing
<Papierkorb> It's not required anymore, but it should exist in a full installation
pawnbox has quit [Quit: gotta go guys.]
<FromGitter> <imonmyown> Didn't help unfortunately :(
<FromGitter> <charlie-hadden> Papierkorb: Do you have a link to the project? I may get chance to compile and test on OSX before I head home for the day if that would be useful
<Papierkorb> To which project?
<FromGitter> <charlie-hadden> qt5.cr
<Papierkorb> charlie-hadden, Qt5.cr is at https://github.com/Papierkorb/qt5.cr and bindgen at https://github.com/Papierkorb/bindgen
<Papierkorb> charlie-hadden, that *will* fail on mac os. I don't own or have access to a Mac box, which complicates that a bit :)
<FromGitter> <charlie-hadden> Cool, no worries. I'll see what changes it needs to get it working. I was actually playing around with writing some qt bindings by hand just for the features I needed for a particular project. That was a horrible hack which involved C wrappers for everything though
<FromGitter> <charlie-hadden> Would be nice to have a proper library for it
<FromGitter> <zyriuse75> i've a question i try to make a menu with crystal and i would the possibility than my user chose between 1...3 how i can do it ? in ruby i know how to do it but in crystal 😟
<Papierkorb> What kind of menu do you mean? A CLI menu thing where it asks "Select one: _"?
<Papierkorb> How would you write that in Ruby?
<FromGitter> <zyriuse75> @FromIRC yes like you run your script and it will ask your name or other stuff
<Papierkorb> zyriuse75, How would you write that in Ruby?
<FromGitter> <zyriuse75> in ruby you just have to add
<FromGitter> <zyriuse75> case gets.strip ⏎ when "1"
<Papierkorb> Have you tried just doing that?
<FromGitter> <zyriuse75> yes
<Papierkorb> What does it say?
<FromGitter> <zyriuse75> and gets doesn't exist https://crystal-lang.org/docs/syntax_and_semantics/case.html
<Papierkorb> `#gets` does exist
<FromGitter> <zyriuse75> lol...
<FromGitter> <zyriuse75> all the time i tried with gets.strip
<FromGitter> <zyriuse75> if you take of strip it's okay
<FromGitter> <zyriuse75> :(
<FromGitter> <zyriuse75> sorry guy
<Papierkorb> zyriuse75, Read on in the docs you already linked. It has some chapter on Crystals type system, which forces you to consider all types something could return, unlike Ruby.
<Papierkorb> `#gets` returns `String | Nil`, so a string or nil. `String#strip` does exist, but `Nil#strip` doesn't. Hence why I asked you to tell us what it said.
<FromGitter> <zyriuse75> why there is not gets on doc ?
<Papierkorb> There sure is: https://crystal-lang.org/api/0.23.1/toplevel.html#gets%28%2Aargs%2C%2A%2Aoptions%29-class-method
<Papierkorb> You're looking at the book teaching crystal concepts, not the stdlib docs
<FromGitter> <zyriuse75> :( :( :(
<FromGitter> <zyriuse75> sorry again
<Papierkorb> Don't worry
<Papierkorb> Just have both links handy, they'll continue to be useful :)
hio has joined #crystal-lang
<hio> how mature is this thing?
<Papierkorb> "thing"?
<hio> crystal
<Papierkorb> Beta-y. Try it out, but not on a mission-critical project.
<Papierkorb> OTOH, some select companies are using it for just those. YMMV.
<Yxhuvud> well, if noone pushes the envelope then the kinks won't work themselves out :)
<hio> how FAST is it
<Papierkorb> That uppercasing is correct, but requires a few more A's, like this: It's FAAAAST
<Papierkorb> The average ruby program runs 3 to 10 times faster by just stupidly porting it in my experience.
<hio> ok but ruby is super slow, I need a comparison with c++
<FromGitter> <charlie-hadden> around about the same from what I've done with it
<Papierkorb> Depends on what you do. A few percent slower probably.
<hio> the compile times are okay for you?
<Papierkorb> Compared to what?
<hio> python
<Papierkorb> Python doesn't compile
<hio> exactly
<Papierkorb> Crystal is compiled etc., so comparing to an effective time of 0 doesn't make much sense
<FromGitter> <bew> then what's your question? Oo
<FromGitter> <charlie-hadden> Compile time is perfectly acceptable for everything I've used it for apart from one project but I've not had chance to look into why that is yet (it's not a very big project at the moment)
<hio> i need <1sec compile times
<Papierkorb> On what?
<hio> everything, why would i want to wait any longer
<FromGitter> <bew> to have a better language?
<Papierkorb> Even python takes longer than 1sec to load big libs lul
<Yxhuvud> python do compile in that it writes caches the parsed source code in .pyc files.
<travis-ci> crystal-lang/crystal#25392e1 (master - Fix for YAML spec failure with new nanoseconds precision): The build was fixed. https://travis-ci.org/crystal-lang/crystal/builds/282768024
<Papierkorb> Yxhuvud: Yes, but I consider that an implementation detail
<FromGitter> <jose-rodrigues> @hio aven in C++ you dont have this fast compilations
<Yxhuvud> C++ is notoriously slow in that department though
<Papierkorb> "Even in C++" is an understatement. Just pull in Boost or Clang or something and a single file takes multiple seconds alone
<hio> Sadly I cannot accept a language that compiles slowly, this is 2017
<Papierkorb> Your comparisons don't make any sense, so..
<Papierkorb> Or let me make a statement then: Buy a faster computer. This is 2017.
<Yxhuvud> becoming involved and help implement faster compilation is of course also an option.
<hio> Buying a faster computer does not scale
<hio> Your language will still compile slowly when I put more files in
<Papierkorb> Trolling doesn't scale either
<FromGitter> <jwaldrip> hio: you are comparing a interpreted language (python) to a compiled language (Crystal), the build time for Crystal will be slower because it IS compiled, but the runtime is MUCH faster than Python.
elia has joined #crystal-lang
<hio> jwaldrip, i understand but I want the best of both worlds
<Papierkorb> Then use something that compiles fast as it has no features, like Go
<FromGitter> <jwaldrip> Right. Go would be a good choice. It compiles fast, but that is because the language spec is simple.
<hio> it is too simple for me
<FromGitter> <jwaldrip> Crystal is cleaner and more understandable.
<FromGitter> <jwaldrip> And its compile times for development are acceptable by my standards. It pays off well as Crystal compiled out performs go in some benchmarks.
<FromGitter> <jwaldrip> There has yet to be an interpreted language that has been able to compete with compiled languages for runtime speed.
<FromGitter> <jwaldrip> (at least the modern ones)
<Yxhuvud> well, luajit is pretty fast.
<FromGitter> <bew> and the language is pretty simple too
<Yxhuvud> Yes, definitely.
<FromGitter> <jwaldrip> If you want fast build times, stick with Python/Ruby
* Papierkorb thinks of starting times of Rails apps
<Papierkorb> *shudder*
<FromGitter> <jwaldrip> luajit is fast... but still beat by Crystal, Go, Rust, etc.
<FromGitter> <jose-rodrigues> How fast does rust compile?
<FromGitter> <jwaldrip> hio: if you find a language that exists that is "as slick as ruby, fast as C, and compiles as fast as Go" you let us know.
<FromGitter> <jwaldrip> https://imgur.com/a/jQUav#xVgi2ZA
<FromGitter> <jwaldrip> @jose-rodrigues ^^
<hio> i just found it guys
<hio> you ready?
<adam12> Papierkorb: noo. i just got over having nightmares about that.
<FromGitter> <jwaldrip> Sure, what do you have hio?
<FromGitter> <jose-rodrigues> @jwaldrip thanks
<hio> it's SWIFT!
<FromGitter> <jwaldrip> I havent done much with swift yet. Any good use cases for doing web development in Swift?
<hio> i am looking into it, apparently there are plenty of web frameworks for it
<hio> the IDE situation for linux is bad, but im looking at appcode from jetbrains. i hope it works
<hio> it's probably not as fast as other guys though, but it ticks all the right boxes imo.
<FromGitter> <jwaldrip> Well let us know. I would be down to try it. Looks like windows support is third party though.
<Yxhuvud> It is certainly doing some things right - every release I see they added some feature that already exist in crystal :)
<hio> im downloading ubuntu 16.10 now, it really doesnt work with anything that isnt exactly supported
<FromGitter> <jwaldrip> https://vapor.codes/
<FromGitter> <jwaldrip> Looks like an interesting web framework for swift.
<FromGitter> <jwaldrip> @asterite looks like master is still failing. Where are we with the introduced time issues?
<hio> you made those benchmarks jwaldrip ?
<FromGitter> <jwaldrip> Which ones?
<FromGitter> <jwaldrip> I did now
<FromGitter> <jwaldrip> I did not. Pulled that from reddit
<hio> interesting why golang would slow down so much
<FromGitter> <asterite> master is passing
elia has quit [Quit: Computer has gone to sleep.]
<FromGitter> <jwaldrip> are you sure?
<FromGitter> <jwaldrip> ah nvm
<FromGitter> <jwaldrip> that was the last build
<FromGitter> <jwaldrip> go go gadget release!
mark_66 has quit [Remote host closed the connection]
mark_66 has joined #crystal-lang
alex`` has quit [Ping timeout: 240 seconds]
mark_66 has quit [Remote host closed the connection]
jwaldrip has left #crystal-lang [#crystal-lang]
RickHull has joined #crystal-lang
<FromGitter> <imonmyown> going back to compilation times anyone heard of jai by Jon Blow et al? This language's compiler shows some crazy compilation times. Whish we could have that for crystal too :)
<FromGitter> <imonmyown> But that would probably mean doing that from scratch and leaving llvm...
<FromGitter> <bew> didn't know, it quite interesting!
<FromGitter> <imonmyown> @bew I just hope that it would lead to something interesting crystal-wise :)
<FromGitter> <bew> that's fun https://www.youtube.com/watch?v=59lKAlb6cRg (on the jai lang)
<FromGitter> <mixflame> how do I install Crystal Dash docset for Dash/Zeal
<FromGitter> <bew> @imonmyown seems that jai compiles to C and then C is compiled.
<FromGitter> <imonmyown> @bew that's neat, didn't know that
<FromGitter> <georgeu2000> @jose-rodrigues - I already wrote a router: https://github.com/iAmPlus/rack-routing , haha.
<FromGitter> <georgeu2000> Maybe I'll convert it to Crystal.
<FromGitter> <imonmyown> @bew I wonder if that leaves generics possible for a scheme like that
<FromGitter> <georgeu2000> Besides, I don't like Sinatra DSL.
<FromGitter> <georgeu2000> I'll also check to see if there is a router already in Crystal.
<Papierkorb> There are probably around 5 to 10 router implementations, yes
<FromGitter> <georgeu2000> I see two on https://github.com/veelenga/awesome-crystal , but they implement Sinatra routing DSL.
<Papierkorb> there was also toro for a more roda-style, no idea if that's still maintained
<FromGitter> <georgeu2000> Yes, I see it: https://github.com/soveran/toro
<FromGitter> <OldhamMade> is there a standard practice for handling nil values in ecr templates? I've tried things like `<% if !thing.val.nil? %>`, can't seem to work around the errors
<FromGitter> <bew> @imonmyown I don't see why it wouln't be possible
<FromGitter> <imonmyown> @bew I agree with you after some thought
<FromGitter> <imonmyown> what about GC?
<FromGitter> <iamonkara> @will i saw your fantastic presentation http://bit.ly/2fMlqTd thanks for that. Would you have the list of deficiencies or features currently lacking in Crystal that you mentioned in this talk ?
alex`` has joined #crystal-lang
DTZUZO has quit [Ping timeout: 240 seconds]
<FromGitter> <jwaldrip> @georgeu2000 Check out orion for routing.
<FromGitter> <jwaldrip> https://github.com/obsidian/orion
<FromGitter> <jwaldrip> Its a rails'esk router, with inline middleware annotation.
<oprypin> OldhamMade, it's probably just like normal code
<oprypin> thing.val could return a different thing every time. you checked that it's not nil the first time, who says it'll be the same the second time
<FromGitter> <krypton97> has anyone tried this mini gui lib?
<FromGitter> <krypton97> https://github.com/wjakob/nanogui
<FromGitter> <krypton97> looks to be well mantained, but failed me to compile oO
<oprypin> krypton97, why
<oprypin> i mean why bring this up here?
<RickHull> watching Will Leinweber's intro talk. Here he talks about linking to postgres libpq: https://www.youtube.com/watch?v=GHPBMwrOV1w#t=19m
<RickHull> he says that he later rewrote it to speak the protocol natively and got a speed up. why would that be? I would expect having libpq do the work to be faster
<Papierkorb> Why?
<Papierkorb> libpq can't do magic
<RickHull> is it that the libpq API requires some extra operations that aren't needed when going native?
<RickHull> i would expect libpq to be closer to the metal, essentially
<RickHull> like when you need a speedup in python, you write the inner loop in C
<RickHull> in this case, it seems like the opposite
<Papierkorb> Wrapping into what? Ruby? Crystal?
<RickHull> I assume speaking the protocol natively means writing the postgres driver in Crystal
<FromGitter> <imonmyown> A very interesting Persistence/ORM solution (https://cdn.rawgit.com/permazen/permazen/master/permazen-language-driven.pdf) for Java (but the principles are language-agnostic)
<Papierkorb> I don't intend to watch the linked talk, hence me asking
<RickHull> I gave a timestamp so you only need about 60 seconds
<Papierkorb> RickHull: And, Crystal is fast. Really fast. There's not much reason to write something in C to "go faster" in 99% of the cases
<RickHull> yeah, that makes sense
<RickHull> I just don't understand where the speed up comes from, in a general sense
<Papierkorb> Especially when it comes to networking stuff, in which case Crystal is sleeping while the network lags
<Papierkorb> But everything being in Crystal has one big plus: LLVM can optimize everything
<Papierkorb> Especially method inlining, which isn't possible when binding to C
<Papierkorb> It could drag parts of the postgres driver into the ORM, or even further into user code, making the call path extremely efficient
<Papierkorb> libpq probably (?) doesn't use libevent, thus when binding to it, blocks the whole thread. a Crystal native implementation only blocks the fiber, which has probably the most drastic effect on total throughput of the application
<FromGitter> <OldhamMade> sorry guys, another "getting to grips with the language" question: how can I inspect what methods are on an object? coming from Python, I'm looking to do things like getattr, getattribute, obj.__dict__, etc.
<oprypin> OldhamMade, easier to forget about that, lol
<Papierkorb> OldhamMade, 'getattr' and friends don't make much sense outside of dynamic programming.
<FromGitter> <OldhamMade> @oprypin heh, I thought that might be the answer!
<FromGitter> <jwaldrip> @OldhamMade I find the easiest way is to just run Crystal docs
<FromGitter> <jwaldrip> `crystal docs`
<FromGitter> <jwaldrip> and see what is available
<FromGitter> <bew> it really depend on why do you need that
<FromGitter> <pawandubey> ☝️ October 3, 2017 12:08 PM (https://gitter.im/crystal-lang/crystal?at=59d3b60abbbf9f1a3819fcd2) ⏎ We load a million loc Rails app in 5secs. There's lots that can be done to optimize it.
<FromGitter> <bew> and when
<oprypin> OldhamMade, https://crystal-lang.org/api/master/Crystal/Macros/TypeNode.html `{% SomeType.resolve.methods %}` or something
<oprypin> {{
<FromGitter> <OldhamMade> @pawandubey I've been checking the docs, but as I have no Ruby background I'm not sure where to look
<FromGitter> <OldhamMade> concrete example: I want to load fixtures from CSV files, map them to objects, and store each object to a db with `obj.save`
<Papierkorb> That's not how you do it in Crystal.
<FromGitter> <OldhamMade> csv files *should* have cols that match attrs, if they don't I want to skip adding that attr on the object
<Papierkorb> You'd have the easiest time by using JSON or YAML, and then use JSON.mapping/YAML.mapping for the grunt work
<Papierkorb> Simply because there's apparently no CSV.mapping
<FromGitter> <pawandubey> If you want CSV, see how the JSON pull parser is implemented in core.
<oprypin> oh come on
<FromGitter> <OldhamMade> @pawandubey thanks, I'll take a look
<RickHull> OldhamMade: do you need to introspect on the objects at runtime? or can your code know the object attrs?
<oprypin> pawandubey, that's frankly not good advice to give to a beginner
<FromGitter> <pawandubey> @oprypin You are probably right.
<Papierkorb> Not considering the experience, implementing a pull parser for CSV sounds like complete overkill
<FromGitter> <pawandubey> Parsing CSV is hard.
<FromGitter> <pawandubey> The solution is to not do it.
<FromGitter> <OldhamMade> @oprypin I'm happy to look at anything if it gets me where I need to be. :D
<oprypin> OldhamMade, seems pretty easy https://crystal-lang.org/api/master/CSV.html#each_row%28string_or_io%3AString%7CIO%2Cseparator%3AChar%3DDEFAULT_SEPARATOR%2Cquote_char%3AChar%3DDEFAULT_QUOTE_CHAR%2C%26block%29-class-method
<FromGitter> <OldhamMade> @oprypin CSV parsing is done, it's the map-to-attr part I'm working through
<oprypin> `my_obj.aa, bb, my_obj.cc = row; my_obj.bb = bb.to_i`
<RickHull> CSV is such a terrible format, one of the worst accidents of history in data science
<FromGitter> <OldhamMade> my objects are defined with getters and setters for the attrs, but I have many objects and many CSV files; doing it manually could take a long time and the data is likely to change
<oprypin> OldhamMade, ok so hack up a quick macro. you can't really have schema config files if you want to keep it sane
<FromGitter> <pawandubey> You can use macros to automatically create objects.
<FromGitter> <bew> Maybe a dumb question, but what is a fixture? (at least in your case)
<RickHull> I wonder if something like a struct is a better way to organize data fields, rather than full fledged objects
<Papierkorb> No.
<Papierkorb> Absolutely, no
<FromGitter> <pawandubey> I think you can use the csv column names - cast them to symbols and try to use `respond_to?` to check if the object has that property?
<oprypin> but uh structs are full fledged objects
<Papierkorb> That's *not* what a struct is about RickHull
<oprypin> pawandubey, yeah cast them to symbols, right
<Papierkorb> lul
<FromGitter> <pawandubey> :shrug:
<oprypin> pawandubey, that would be the silver bullet, but alas, such magic is impossible
<Papierkorb> pawandubey, you're trying to smash ruby/python thinking into Crystal. Those languages are inherently different, their paradigms don't work here
<FromGitter> <OldhamMade> so there's really no way to do something like this? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=59d3e0bd177fb9fe7e34fe57]
<FromGitter> <bew> @OldhamMade not at runtime at least
<oprypin> OldhamMade, oh there is, if the obj already has defined fields
<Papierkorb> OldhamMade, Oh there is, it's called `Hash`
<Papierkorb> If you have (highly) dynamic schemas, use a dynamic data structure.
<FromGitter> <bew> 👍
<FromGitter> <OldhamMade> @bew in my case, fixtures = data used to pre-populate the a db during deployment
<RickHull> Papierkorb: I think of a struct as a composite data type with fields addressable by name rather than say an integer index
<RickHull> is it something different in Crystal?
<Papierkorb> RickHull: That's not a struct.
<Papierkorb> RickHull: that definition fits almost everything.
<Papierkorb> A struct is a structure. Nothing else. Fields are addressable by name, we just call them "getters"
<oprypin> OldhamMade, if you have a predefined object kind and predefined headers you expect, you can automatically generate code like {% for field in Type.dontrememberwhat %} obj.{{field.id}} = row[{{ field.stringify }}]
<FromGitter> <pawandubey> Struct is a value type as opposed to classes which are reference types
<FromGitter> <pawandubey> That's the definition
<RickHull> Papierkorb: I don't follow. I am talking about structs in general, like from C.
<Papierkorb> Yes. They're not dynamic.
<RickHull> they don't have methods, I wouldn't call them getters
<Papierkorb> They absolutely have methods
<Papierkorb> in C they may not have them, but in Crystal they sure have
<RickHull> structs come from C -- that's why I said "something like a struct"
<RickHull> apologies if I used the wrong terminology for this channel
<FromGitter> <ezrast> I think `NamedTuple` is the closest equivalent?
<FromGitter> <bew> RichHull don't worry, just that in Crystal `struct` is an object too (like a `class`) at the subtle difference that it's not allocated on the heap
<Papierkorb> Noooo
<Papierkorb> @ezrast
<Papierkorb> What's the obsession with tuple types.
<FromGitter> <pawandubey> I don't see any obsession?
<Papierkorb> Tuples come up almost every evening
<RickHull> bew: makes sense. I meant basically, like a less dynamic version of a hash
<RickHull> which should have less overhead
<FromGitter> <OldhamMade> ok, thanks everyone -- I'm going to have to rethink my approach using macros instead.
<FromGitter> <asterite> Macros? Just use a Hash
<RickHull> NamedTuple sounds about right, not sure. I think the motivation is to map the problem to the simplest concept with the least overhead
<FromGitter> <asterite> The solution is never "OK, I'll use macros"
<FromGitter> <bew> 😂
<FromGitter> <OldhamMade> speaking of macros, is there a way I can see the generated code before it's compiled?
<Papierkorb> `{{ debug() }}`
<FromGitter> <bew> with `{% debug() %}`
<FromGitter> <asterite> Or just use Ruby or Python, you have a dynamic problem, use a dynamic language
<FromGitter> <OldhamMade> thanks @Papierkorb & @bew
<FromGitter> <bew> Papierkorb: do you really want to paste `{{` the generated code?
<Papierkorb> bew, iirc, debug() doesn't return anything
<FromGitter> <OldhamMade> @asterite actually, it's just that I have a dynamic *brain* :)
<RickHull> OldhamMade: do you have a necessity to use an object interface to your DB, like an ORM?
<FromGitter> <bew> ah didn't thought about that
<Papierkorb> bew, Especially not itself, as that'd be quite recursive :P
<Papierkorb> And typing {{ is faster than {% lul
<FromGitter> <bew> Papierkorb: don't think it would be recursive, as the debug thing is not IN the generated code..
<FromGitter> <OldhamMade> @RickHull not specifically; I'm using custom objects which act a bit like an ORM, based on Topaz, and the CSV import is one way to ensure they're working correctly
<FromGitter> <OldhamMade> there's extra validation in there
<FromGitter> <franciscoadasme> hi everyone, crystal newbie here, is there a way to use type constraints for generics? something like: `struct Generic(T); ... end`, then `struct Generic(T < U); ... end` so the methods defined in the latter are only available for T if it's a subclass of or includes/extends U
<FromGitter> <OldhamMade> if it becomes crazy to use this approach, I'll just dump the data directly into the db
<FromGitter> <bew> yeah probably, I never type them, I always use snippets like md for macro debug, ms for macro statement (`{% ... %}`) and mp for macro that prints (`{{ ... }}`) :p
<RickHull> OldhamMade: http://docs.topazruby.com/en/latest/ ? seems... like a dramatic mixing of idioms and metaphors that one can easily get lost in
<FromGitter> <bew> currently not @franciscoadasme
<RickHull> if you are now adding Crystal to the mix
<FromGitter> <asterite> I had a CSV.mapping in a project, let me check if I can find the code
<FromGitter> <OldhamMade> @RickHull https://github.com/topaz-crystal/topaz
<FromGitter> <bew> @franciscoadasme see #934
<RickHull> ah, ok
<FromGitter> <bew> and #3298
<RickHull> OldhamMade: my very-much-outside view is that schema and data validation are critical, and dynamism should be avoided. However, Ruby and Python have popularized the dynamic approach. A static approach can work much more reliably and cleanly, as long as the handcuffs aren't too tight
<RickHull> you need robust error handling and an approach for handling unexpected fields
<FromGitter> <pawandubey> Generics seem to be a bit incomplete right now. I am also waiting on the feature to support type parameters for aliases. https://github.com/crystal-lang/crystal/issues/2803
<FromGitter> <OldhamMade> @RickHull yeah, I'm still getting to grips with the new concepts; having come from a fully dynamic world I'm falling back on familiar approaches. I'm already using macros to define obj attrs based on class definitions, it shouldn't take too much work to add something like a `.from_csv(...)` method.
<FromGitter> <franciscoadasme> @bew @pawandubey thanks for the info... I see there is still a lot to do for generics
<Papierkorb> pawandubey, what's missing? Specialization is on my wish list too, but if that'll ever be granted..
<FromGitter> <asterite> I have this: https://gist.github.com/asterite/a04cb8920175c4b0fae42d88c4cce40d but it's very rudimentary
<FromGitter> <pawandubey> @Papierkorb #2803 will reduce some lines of code for me and also it would make more sense type wise. It feels weird that a type alias can masquerade as a type alright but can't accept type params to pass into the constituent types. Also constraints on type parameters are a big thing as they catch errors earlier in the dev process (which I feel is the whole point of types). But they are only useful if they
<FromGitter> ... are supported properly, i.e. not like Java's type constraints.
<FromGitter> <OldhamMade> @asterite thanks! That's really helpful! :D
<oprypin> asterite, shouldn't `__{{key.id}}` be `%foo{key}` ?
<RickHull> dumb question from a rubyist: why do I see lots of "for x in y" rather than "y.each do |x|" ?
<Papierkorb> RickHull: that's macro code
<RickHull> ah, ok
<Papierkorb> No idea myself, but in macro code, there's no #each
<FromGitter> <asterite> That macro is really old, I just updated it to compile so it probably isn't idiomatic
elia has joined #crystal-lang
<FromGitter> <bew> that's because there's no block iirc in macros
<Papierkorb> bew, There are
p0p0pr37_ has joined #crystal-lang
p0p0pr37_ has joined #crystal-lang
<FromGitter> <bew> not with generated code inside the block at least
p0p0pr37 has quit [Ping timeout: 258 seconds]
p0p0pr37_ is now known as p0p0pr37
elia has quit [Quit: Computer has gone to sleep.]
elia has joined #crystal-lang
<FromGitter> <georgeu2000> @jwaldrip - Thanks
<FromGitter> <pawandubey> Is https://github.com/crystal-lang-tools affiliated to the crystal-lang org or are these independently developed?
<oprypin> pawandubey, unaffiliated
<FromGitter> <pawandubey> @oprypin Thanks
<FromGitter> <krypton97> @oprypi because I find this gitter one of the most active. I won't bother with c++ stuffs anymore..should've quit that language long time ago..
alex`` has quit [Ping timeout: 258 seconds]
elia has quit [Quit: Computer has gone to sleep.]
<Papierkorb> Is some random CDN down? The API docs are missing style sheets for me
<oprypin> Papierkorb, no, i dont know where you got that link from
elia has joined #crystal-lang
elia has quit [Client Quit]
hio has quit [Quit: Leaving]
rohitpaulk has joined #crystal-lang
<FromGitter> <hermanzdosilovic> Hey everyone! I am creator of https://judge0.com and after I saw Crystal I know it should be part of my https://api.judge0.com :D Enjoy on https://ide.judge0.com
<oprypin> hermanzdosilovic, syntax highlighting too?
rohitpaulk has quit [Ping timeout: 258 seconds]
<FromGitter> <hermanzdosilovic> yes!
<oprypin> which one
<FromGitter> <hermanzdosilovic> https://codemirror.net/mode/crystal/index.html
<oprypin> Crystal autoindent is very annoying (broken) in it
<oprypin> well it's pretty nice but we have https://carc.in/ which also saves the files
<FromGitter> <hermanzdosilovic> I plan to have the same feature in the near future :)
<oprypin> how do the logistics of running arbitrary code for free work?
<FromGitter> <hermanzdosilovic> I am not sure if I understand your question
<oprypin> hermanzdosilovic, well I provide some source code and your website compiles and runs it. you also seem to have an API for that. how did you decide that you want to provide these resources for free?
<FromGitter> <hermanzdosilovic> I don't care about money so much. I just made this and I wanted to share this with the world. Maybe I will follow some Freemium model but it would be just to cover my domain and beer :D
<RickHull> how much, typically, for a half liter of beer in a croatian bar?
* RickHull prepares to cry