ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.32.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
Nicolab has quit [Ping timeout: 258 seconds]
ur5us has joined #crystal-lang
martinium has joined #crystal-lang
MasterdonX has quit [Read error: Connection reset by peer]
MasterdonX has joined #crystal-lang
martinium has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
martinium has joined #crystal-lang
DTZUZO_ has quit [Ping timeout: 265 seconds]
DTZUZO has joined #crystal-lang
martinium has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
zorp_ has quit [Ping timeout: 268 seconds]
alexherbo26 has joined #crystal-lang
alex`` has quit [Ping timeout: 265 seconds]
alexherbo2 has quit [Ping timeout: 268 seconds]
alexherbo26 is now known as alexherbo2
alex`` has joined #crystal-lang
<FromGitter> <sudomaxime> Hey there, still learning Crystal, I'm coming from JS, Rust and Go, so I'm not used to the ruby-like syntax. I've seen online that it's basically the same syntax than Ruby. Would you reccomend that I take a quick ruby course or it's going to be a waste of time ?
<FromGitter> <sudomaxime> I'm reading Kemal source code and there's a bunch of things I can't quite grasp
<FromGitter> <Blacksmoke16> its a lot of macros
<FromGitter> <Blacksmoke16> id read thru https://crystal-lang.org/reference if you havent already
<FromGitter> <watzon> @sudomaxime the ruby like syntax makes it fairly easy to port things from Ruby, but Rubyists do tend to rely a lot on metaprogramming that's either impossible or impractical in Crystal. That being said when I found Crystal I was basically looking for "compiled Ruby" and it does the job. It wouldn't be a terrible thing to at least know where to find answers to Ruby questions since a lot of them will apply to
<FromGitter> ... Crystal as well.
ryanprior has joined #crystal-lang
<ryanprior> I would like to read a file at compile time and use its text as a string, without the file needing to be available at runtime. I tried using `my_string = {{read_file "my_file_path"}}` but that fails at runtime if the file isn't available. Is there a standard way to do this?
<FromGitter> <Blacksmoke16> that would be the way to do it
<FromGitter> <Blacksmoke16> would include the file's contents within the binary
<ryanprior> Hmm, let me try to cook up a simple program then and see if I can figure out what I'm doing wrong
<FromGitter> <Blacksmoke16> do remember when you do `crystal my_app.cr` that it builds a temp binary and runs it
<FromGitter> <Blacksmoke16> i..e if you have the file there and do `crystal build my_app.cr` then delete the file, then do `./my_app` it'll work fine
<ryanprior> I made a simple test app and saw that's true. But when I try to do it with my actual use case it doesn't work.
<FromGitter> <Blacksmoke16> doesnt work how?
<FromGitter> <Blacksmoke16> doesnt build?
<ryanprior> It builds, and when the file is in the correct place it runs fine too, but then if you move the binary it says "Unhandled exception: Error opening file" when run
<FromGitter> <Blacksmoke16> sure you dont have another `File.open/read` somewhere?
<ryanprior> Nope, if I interpolate the file by hand into a here-doc it compiles and runs fine without the file.
<FromGitter> <Blacksmoke16> got some code to share?
<ryanprior> I don't have it in source control yet but could pastebin it if you'd like
<FromGitter> <Blacksmoke16> that would work
<ryanprior> https://paste.debian.net/hidden/5e278975/ there's the source file I'm working on now
<ryanprior> I'm focusing on lines 11-20. If I uncomment out that here-doc, it works as I want; if I try to use the macro instead, it's failing at runtime after I move the file.
<FromGitter> <Blacksmoke16> and you're testing this by building then running the binary?
<ryanprior> yep, then I move the grammar file and run again and it fails
<FromGitter> <Blacksmoke16> what commands are you using to do this?
<ryanprior> I looked around in some other source files and saw that I was reading the grammar file to print a debug message in another source file. Darn me!
<ryanprior> That's another reason to get this into source control. A `git diff` would have saved me time & embarrassment here. Thank you for your encouragement!
<FromGitter> <Blacksmoke16> that would do it :p
<FromGitter> <Blacksmoke16> np
ryanprior has quit [Remote host closed the connection]
ur5us has quit [Ping timeout: 260 seconds]
ua has quit [Ping timeout: 265 seconds]
Nicolab has joined #crystal-lang
ht_ has joined #crystal-lang
livcd has joined #crystal-lang
return0e has joined #crystal-lang
ht_ has quit [Remote host closed the connection]
Yxhuvud has joined #crystal-lang
yukai has quit [Ping timeout: 240 seconds]
Nicolab has quit [Quit: Leaving.]
DTZUZO has quit [Read error: Connection reset by peer]
flaviodesousa has joined #crystal-lang
flaviodesousa has quit [Remote host closed the connection]
Nicolab has joined #crystal-lang
vegai has left #crystal-lang ["User left"]
Nicolab has quit [Quit: Leaving.]
ua has joined #crystal-lang
return0e has quit [Ping timeout: 265 seconds]
zorp_ has joined #crystal-lang
zorp_ has quit [Read error: Connection reset by peer]
Nicolab has joined #crystal-lang
<FromGitter> <absolutejam_gitlab> any recent Crystal projects I can check out?
<FromGitter> <absolutejam_gitlab> Just out of curiosity
<FromGitter> <absolutejam_gitlab> not written any Crystal in forever, would be nice if there was some new hotness
<FromGitter> <j8r> not a new hotness, some will know for sure: https://github.com/Redocly/redoc
<FromGitter> <absolutejam_gitlab> ^ where's the Crystal?
<FromGitter> <j8r> It would be so sick to integrate it with https://github.com/icyleaf/swagger
<FromGitter> <j8r> sorry, just dreaming :)
duane has quit [Ping timeout: 240 seconds]
alexherbo29 has joined #crystal-lang
duane has joined #crystal-lang
alex`` has quit [Ping timeout: 265 seconds]
alexherbo2 has quit [Ping timeout: 240 seconds]
alexherbo29 is now known as alexherbo2
alex`` has joined #crystal-lang
HumanGeek has joined #crystal-lang
Human_G33k has quit [Ping timeout: 240 seconds]
<FromGitter> <Blacksmoke16> i rewrote athena if that counts
<FromGitter> <absolutejam_gitlab> haha you did?
<FromGitter> <absolutejam_gitlab> Lemme see
<FromGitter> <Blacksmoke16> event listener approach versus `HTTP::Handler`
<repo> Blacksmoke16: oh nice! you're done!
<FromGitter> <Blacksmoke16> merged in the big part of it yea, want to do the view layer feature next before releasing it as currently it only supports JSON
<FromGitter> <absolutejam_gitlab> ART/AED?
<FromGitter> <Blacksmoke16> alises to each component, `ART => Athena::Routing`
<FromGitter> <Blacksmoke16> less typing
<FromGitter> <Blacksmoke16> since crystal doesnt have like es6 imports or PHP `use` statements was a decent workaround
<FromGitter> <Blacksmoke16> mainly since i namespace stuff so names could get quite long
duane has quit [Ping timeout: 265 seconds]
<repo> only JSON is totally fine :)
<FromGitter> <Blacksmoke16> JSON will be the default, but dont want to prevent someone from using xml/text whatever
<repo> Blacksmoke16: could you add an example to ParamConverters how to use the annotation for post requests?
<repo> or is it exactly the same as for GET?
<FromGitter> <Blacksmoke16> its the same yea
<repo> so ParamConverter(param: "some_param_name_which_i_can_use_in_the_method_head", ...)
<repo> is (param: "foo", ...) the same as ("foo", ...)
<repo> i see both being used
<FromGitter> <Blacksmoke16> concept is a route action must return a `Response` object, if your action does, then it doesnt dispatch the `View` event, otherwise it does to convert the action response value into a `Response`
<FromGitter> <Blacksmoke16> yes, depends if you like named or positional more
<repo> ok
<repo> very very nice
<repo> i will definitely give it a try in my next api project
<FromGitter> <Blacksmoke16> param maps to the name of an argument for a given action
<FromGitter> <Blacksmoke16> i.e. `def some_method(some_param_name_which_i_can_use_in_the_method_head : MyObj, ...`
<FromGitter> <Blacksmoke16> :p
<repo> yeah exactly
<FromGitter> <Blacksmoke16> 👍 currently working on updating the blog repo i have with the new stuff, once thats done, want to finish view layer, and fix any bug that come up in the blog
<FromGitter> <Blacksmoke16> finally write some new blog posts, and prob call (this version) done
<repo> what about databases? should the DI component be used to share the db connection/repository?
<FromGitter> <Blacksmoke16> framework we use at work uses the `Repository` approach
<FromGitter> <Blacksmoke16> so you inject an `EntityManager`
<FromGitter> <Blacksmoke16> then do like `$this->em->getRepository(User::class)->someQuery();`
<FromGitter> <Blacksmoke16> injected repo could be for like slave/master as well
duane has joined #crystal-lang
<repo> right
<FromGitter> <Blacksmoke16> while in crystal most ORMs have the connection and model tightly coupled, so prob doesnt make sense to use DI to share that
<FromGitter> <Blacksmoke16> i.e. you do `model.save` versus `@em.persist(model)`
<repo> not in crecto :)
<FromGitter> <Blacksmoke16> oh?
<FromGitter> <absolutejam_gitlab> Does crecto use changesets like Ecto?
<repo> yeah
<FromGitter> <absolutejam_gitlab> Big fan of that approach
<repo> same
<FromGitter> <Blacksmoke16> deff makes supporting like master/slave connections easier
<repo> how do you handle conversion errors for params? if i define a param as Int32 and the param is "foo" will this result in a 500 error or a 400?
<repo> or 4xx
<FromGitter> <Blacksmoke16> 422 iirc
<repo> nice
<repo> sounds very well designed
<FromGitter> <Blacksmoke16> you have to manually handle them in param converters tho. :shrug:
<repo> i'm pretty hyped right now :) Now you'll just need a flashy logo and landing page to compete :D
<repo> yeah but that's fine imho
<FromGitter> <Blacksmoke16> > *<repo>* sounds very well designed ⏎ ⏎ Thanks :p i like to think so ha
<FromGitter> <Blacksmoke16> i really like the event listener versus `HTP::Handler` approach
<repo> what was your reason for it?
<FromGitter> <Blacksmoke16> you/external shards could define a listener and register it with DI, give it a specific tag, and it'll just get sucked up
<FromGitter> <Blacksmoke16> thought it was a pain to have to do like `ART.run(handlers: [MyHandler.new, CorsHandler.new, ...])`
<repo> ah yeah
<repo> awesome
<FromGitter> <Blacksmoke16> plus combined with DI you can do pretty cool stuff by injecting other services into the listeners
<FromGitter> <Blacksmoke16> just is more flexible/testable imo
<repo> yeah def!
<repo> any support for websocket planned?
<FromGitter> <Blacksmoke16> havent really thought about it yet tbh
<FromGitter> <Blacksmoke16> i dont really know much about them so would have to play around with it
<repo> yeah
<repo> i think it's a minor thing
<repo> i'd mostly use athena for apis i think
<FromGitter> <Blacksmoke16> for sure, deff can be a future enhancement
<repo> not that i'd write anything else :D
<FromGitter> <Blacksmoke16> is what i made it for, should also be fairly easy to add in templates
<repo> i think i'll have a chance to give it a go real soon for a little project at work
<repo> generators would also be nice to have
<FromGitter> <Blacksmoke16> 👍 be sure to lock to a commit if you start before `0.8.0` is releasd
<repo> will do!
<FromGitter> <Blacksmoke16> like to generate a controller?
<repo> yeah
<repo> or a service, and so on
<FromGitter> <Blacksmoke16> after web sockets maybe 😉
<repo> heh
<FromGitter> <irlcatgirl> @thedracle Sorry for the delay in my reply, it looks like a very old version of Crystal, is there anyway you can migrate to a newer version?
Nicolab has quit [Quit: Leaving.]
DTZUZO has joined #crystal-lang
<FromGitter> <grkek> @absolutejam_gitlab https://github.com/grkek/grip here godspeed mate
ht_ has joined #crystal-lang
Nicolab has joined #crystal-lang
FromGitter has quit [Remote host closed the connection]
FromGitter has joined #crystal-lang
Nicolab has quit [Quit: Leaving.]
JuanMiguel has joined #crystal-lang
duane has quit [Ping timeout: 268 seconds]
ht__ has joined #crystal-lang
ht_ has quit [Ping timeout: 272 seconds]
ht__ is now known as ht_
ur5us has joined #crystal-lang
JuanMiguel has quit [Quit: This computer has gone to sleep]
DTZUZO has quit [Ping timeout: 268 seconds]
alex`` has quit [Ping timeout: 260 seconds]
alexherbo2 has quit [Ping timeout: 272 seconds]
Nicolab has joined #crystal-lang
alexherbo2 has joined #crystal-lang
alex` has joined #crystal-lang
alex` is now known as Guest25175
alexherbo20 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 265 seconds]
alexherbo20 is now known as alexherbo2
Guest25175 has quit [Ping timeout: 268 seconds]
alexherbo2 has quit [Client Quit]
alexherbo2 has joined #crystal-lang
alexherbo2 has quit [Client Quit]
alexherbo2 has joined #crystal-lang
HumanGeek has quit [Ping timeout: 268 seconds]
f1refly has joined #crystal-lang
alex`` has joined #crystal-lang
HumanG33k has joined #crystal-lang
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
duane has joined #crystal-lang
ht_ has quit [Quit: ht_]
JuanMiguel has joined #crystal-lang
<FromGitter> <Nicolab> Six hours with no messages in the channel, it's working around here! :D
<f1refly> Not sure if thats too good of a sign
JuanMiguel has quit [Quit: This computer has gone to sleep]
<FromGitter> <Blacksmoke16> Were q minute early
<FromGitter> <Blacksmoke16> A
<FromGitter> <Nicolab> > If you sleep... and you dream you're asleep... you have to wake up twice! ⏎ > -- <cite>Jean-Claude Vandamme</cite>
<FromGitter> <Nicolab> 🐒
yukai has joined #crystal-lang
<FromGitter> <bew> Not necessarily