<FromGitter>
<mwlang> which is actually what I think I would do myself.
<FromGitter>
<mtsmmp_gitlab> is there a way:
<FromGitter>
<mtsmmp_gitlab> 1) to escape having to call Config.new (like Config was already initilized on require)
deavmi has quit [Ping timeout: 256 seconds]
<FromGitter>
<mtsmmp_gitlab> 1) to get the properties like this -> config.name instead of config["name"]
deavmi has joined #crystal-lang
<FromGitter>
<mtsmmp_gitlab> @mwlang can you show me an example of what this constrain method does
<FromGitter>
<mtsmmp_gitlab> @mwlang yo? :D
<FromGitter>
<dscottboggs_gitlab> > to get the properties like this -> config.name instead of config["name"] ⏎ ⏎ it depends on whether you know the string `name` at compile- or run-time
<FromGitter>
<mtsmmp_gitlab> @dscottboggs_gitlab got it
<FromGitter>
<dscottboggs_gitlab> wow, cool, I expected to have to explain what I meant by that lol
<FromGitter>
<mtsmmp_gitlab> =(
<FromGitter>
<dscottboggs_gitlab> not because of you in particular!
<FromGitter>
<dscottboggs_gitlab> I just don't expect people to necessarily know what compile-time or runtime are in a forum for a language targeted at rubyists lol
<FromGitter>
<dscottboggs_gitlab> > is there a way to escape having to call Config.new (like Config was already initilized on require) ⏎ ⏎ so, I recently was confronted with this exact problem, and....I'm not exactly proud of this or sure it's the best way to do things, but this is how I handled it... ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5f3f41f2a8c17801766199c3]
iwq has quit [Ping timeout: 260 seconds]
<FromGitter>
<mtsmmp_gitlab> the difficulty for me is that i come from a nodejs background and everything is new yet. i have 0 ruby experience too
iwq has joined #crystal-lang
<FromGitter>
<dscottboggs_gitlab> that's alright. TBH I don't think ruby experience is a huge advantage for Crystal. I feel like it's more like a better Go or runtime-GC'd rust than ruby-like
<FromGitter>
<mixflame> Ok in the last few days in my backend I have built bad word filtering, bad link filtering, serverless server and global user ban, almost done with these apple requirements lol
<FromGitter>
<dscottboggs_gitlab> > is there a way to escape having to call Config.new (like Config was already initilized on require) ⏎ ⏎ so, I recently was confronted with this exact problem, and....I'm not exactly proud of this or sure it's the best way to do things, but this is how I handled it... ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5f3f43b6a05e464346db15f5]
<FromGitter>
<dscottboggs_gitlab> > apple requirements ⏎ ⏎ ugh that sucks. Thanks for your work in making Crystal Apps work on iOS but I don't envy you
<FromGitter>
<mixflame> lol np
<FromGitter>
<mixflame> it's actually a crystal server paired with a swift OS X app
<FromGitter>
<dscottboggs_gitlab> > swift OS X app ⏎ ⏎ oh, I see. Still, I don't envy you 😆
<FromGitter>
<mtsmmp_gitlab> > that's alright. TBH I don't think ruby experience is a huge advantage for Crystal. I feel like it's more like a better Go or runtime-GC'd rust than ruby-like ⏎ ⏎ i thought it was a major advantage
<FromGitter>
<mtsmmp_gitlab> > > is there a way to escape having to call Config.new (like Config was already initilized on require) ⏎ > ⏎ > so, I recently was confronted with this exact problem, and....I'm not exactly proud of this or sure it's the best way to do things, but this is how I handled it... ⏎ > ⏎ > ``` ... [https://gitter.im/crystal-lang/crystal?at=5f3f4542a8c178017661a198]
<FromGitter>
<dscottboggs_gitlab> > i thought it was a major advantage ⏎ ⏎ on it's face, you'd think so. The syntax is so close that some Crystal programs wiill run in the ruby interpreter. But the type system in Crystal is so much like C/C++/Rust/Go that it's not even close to ruby when you really get into writing Crystal on a day-to-day basis.
<FromGitter>
<mwlang> For me, Ruby doesn't help all that much with the static type stuff (as you can tell by my various questions here), but it's been a huge advantage to me quickly taking up Crystal. I'm especially able to find the rough equivalents for Crystal based on my StdLib of Ruby and all that meta-programming definitely helped me figure out how to write macros in Crystal and actually think of them like I might think of
<FromGitter>
<mwlang> I love that I can think structurally and conceptually like Ruby and approach problems with more or less the same approach I would in Ruby from design perspective.
<FromGitter>
<mwlang> sorry, @mtsmmp_gitlab -- wasn't ignoring ya earlier, just had my head down in code and all notifications off.
<FromGitter>
<mtsmmp_gitlab> no problem mate
<FromGitter>
<mwlang> I only have a few weeks of Crystal under my belt, so by no means an expert here.
<FromGitter>
<mtsmmp_gitlab> i just started days ago
<FromGitter>
<mwlang> entirely different beast from NodeJS, so I'd say you're doing quite well already.
<FromGitter>
<mtsmmp_gitlab> i can say without a doubt that today i worked like 8 or 10 hours on this crystal project
<FromGitter>
<mtsmmp_gitlab> long time since that happens man
<FromGitter>
<mwlang> its the excitement of seeing and doing something new and seeing how ridiculously fast the programs run.
<FromGitter>
<mwlang> I've got algos that take 20 minutes in Ruby running in just under a couple minutes in Crystal.
<FromGitter>
<mwlang> I still can't get over that huge speed boost.
<FromGitter>
<mtsmmp_gitlab> yep... im creating a simple blog generator because on nodejs i use hexo and i have some spam blogs with thousands of pages
<FromGitter>
<mtsmmp_gitlab> what is happening is that hexo is slowing down a lot on the generation
<FromGitter>
<mtsmmp_gitlab> and it takes up like 4gb of my memory, like what the fuck
<FromGitter>
<mtsmmp_gitlab> (on the generation)
<FromGitter>
<mwlang> sounds crazy
<FromGitter>
<mtsmmp_gitlab> i thought about switching to huGO
<FromGitter>
<mwlang> well, I'm off to bed. have fun!
<FromGitter>
<mtsmmp_gitlab> but out of nowhere decided to code everything myself on crystal
<FromGitter>
<mtsmmp_gitlab> cool, have a good night
<FromGitter>
<mattrberry> And why does it fail on `bus` but not `cartridge`?
dostoyevsky has quit [Client Quit]
dostoyevsky has joined #crystal-lang
woodruffw has joined #crystal-lang
<FromGitter>
<naqvis> @mattrberry you are passing instance of uninitialized object
<FromGitter>
<naqvis> during constructor phase `self` shouldn't be valid and shouldn't be available
<FromGitter>
<naqvis> object is not yet instantiated/constructed
sorcus has joined #crystal-lang
<FromGitter>
<mattrberry> Is there a way to achieve a similar effect of objects with references to each other from the initialize method so that I dont have to do it independently at a later point?
<FromGitter>
<grkek> and why does it redirect to shards.io?
<FromGitter>
<grkek> shards.info*
<FromGitter>
<Blacksmoke16> the real question is how did you find that :S
<FromGitter>
<wyhaines> @grkek It's not redirecting to shards.io. ⏎ ⏎ The DNS for it points to the same IP address as shards.io. ⏎ ⏎ It was registered in 201, and it was still operating until sometime last year. ... [https://gitter.im/crystal-lang/crystal?at=5f3fd9b459ac794e02b88d77]
Seich has quit [Ping timeout: 272 seconds]
Seich has joined #crystal-lang
zorp_ has quit [Ping timeout: 272 seconds]
zorp_ has joined #crystal-lang
<FromGitter>
<j8r> @Blacksmoke16 haha lol
<FromGitter>
<grkek> @Blacksmoke16 I was searching for shards
<FromGitter>
<grkek> and it popped up
<FromGitter>
<j8r> @grkek maybe it was the first domain name
Elouin7 has joined #crystal-lang
<FromGitter>
<grkek> Maybe they just decided to rename shards.info to that
<FromGitter>
<grkek> I released Grip 1.0.0
<FromGitter>
<grkek> v
<FromGitter>
<j8r> it popped having installed some random things a site asked?
<FromGitter>
<grkek> Use the more than sign multiple times
<FromGitter>
<dscottboggs_gitlab> I don't see how that's an "exploit"
<FromGitter>
<grkek> I wonder what happens if you type /me multiple times
<FromGitter>
<dscottboggs_gitlab> @grkek is there anything significant for the release other than adding some tests and `crystal: 1.0.0` ?
* FromGitter
* grkek /me /me /me /me /me
<FromGitter>
<grkek> Updated the websocket handler
<FromGitter>
<grkek> renamed couple of classes idk
<FromGitter>
<grkek> not much to be honest
<FromGitter>
<dscottboggs_gitlab> I like the websocket API of inheriting from a controller and overloading `#on_ping` etc
<FromGitter>
<dscottboggs_gitlab> @Blacksmoke16 does Athena have decent websocket support?
<FromGitter>
<Blacksmoke16> 😬
<FromGitter>
<Blacksmoke16> no
<FromGitter>
<grkek> It doesn't even have
<FromGitter>
<grkek> websocket support
<FromGitter>
<grkek> I think
<FromGitter>
<dscottboggs_gitlab> oooof
<FromGitter>
<Blacksmoke16> it doesnt, idk anything about them soooo yea...
<FromGitter>
<Blacksmoke16> its a TODO :P
<FromGitter>
<grkek> I can help? but I don't know the weird annotation magic
<FromGitter>
<grkek> @dscottboggs_gitlab thank you mate ;)
<FromGitter>
<grkek> Did you like the way the exceptions are handled?
<FromGitter>
<dscottboggs_gitlab> yeah I was just about to say I might be able to work up a PR for that, from what I remember of looking at the Kemal source code it was pretty simple to do
<FromGitter>
<Blacksmoke16> main problem would be those implementations are based on `HTTP::Handler` which athena doesnt use
<FromGitter>
<grkek> > .> sorry that is what kemal uses
<FromGitter>
<dscottboggs_gitlab> why does that smell bad @j8r ?
<FromGitter>
<j8r> this means two grip can't be on a same app
<FromGitter>
<dscottboggs_gitlab> oh
<FromGitter>
<grkek> Why would one want to do that?
<FromGitter>
<j8r> same as kemal
<FromGitter>
<grkek> Why would you want to have 2 apps in the same project?
<FromGitter>
<j8r> a reverse proxy for instance
<FromGitter>
<dscottboggs_gitlab> IMO it doesn't matter why. Someone will want to do something weird with your code someday so designing for flexibility is better
<FromGitter>
<Blacksmoke16> fwiw, can any framework do that atm?
<FromGitter>
<dscottboggs_gitlab> couldn't you just put instance in a module class method and then include the module in each "app" running in your app?
<FromGitter>
<j8r> @dscottboggs_gitlab is quite right, that's also not a good practise overall
<FromGitter>
<Blacksmoke16> separate apps meaning separate routes as well i assume?
<FromGitter>
<Blacksmoke16> i mean are we talking about having two apps with separate routes running on the diff ports, or the same app running on separate ports?
<FromGitter>
<dscottboggs_gitlab> different routes
<FromGitter>
<grkek> The second one is possible
<FromGitter>
<grkek> @Blacksmoke16
<FromGitter>
<grkek> the first one is not possible in Grip ATM
<FromGitter>
<j8r> yes two different apps, in the same binary, which can be an advantage
<FromGitter>
<Blacksmoke16> same for athena. I think it would be doable as i have some abstractions that could allow for it but atm :shrug: is prob low priority compared to other stuff that could be done
<FromGitter>
<grkek> @dscottboggs_gitlab The exception handling gives is done by matching over the exceptions and rendering different views for each and every error code, so basically you get more control over them.
<FromGitter>
<grkek> @j8r I still see it as an optional improvement
<FromGitter>
<dscottboggs_gitlab> oh ok. that's a good way to do it.
<FromGitter>
<j8r> that's sure not very common
<FromGitter>
<grkek> Ill show an example and youll understand what I mean
<FromGitter>
<grkek> since this will give more details to the error
<FromGitter>
<grkek> for example generic 401 will just go and render 401
<FromGitter>
<Blacksmoke16> ok, so what would happen if you did `raise IncorrectPassword.new "Invalid Password"` and didnt have a `when Bakuriani::Exceptions::Users::IncorrectPassword`?
<FromGitter>
<dscottboggs_gitlab> I agree this example is good @j8r
<FromGitter>
<grkek> it will render
<FromGitter>
<grkek> 500 with the invalid password
<FromGitter>
<grkek> text
<FromGitter>
<dscottboggs_gitlab> I feel like this is a problem with Crystal though, having both inheritance and mixins, and doesn't that come from ruby?
<FromGitter>
<grkek> since that exception doesn't belong to the library it needs to be mapped
<FromGitter>
<grkek> you can just return 401 and raise the error
<FromGitter>
<grkek> would do the same
<FromGitter>
<j8r> That was a question @dscottboggs_gitlab , because I did with both inheritance and composition 😅
<FromGitter>
<grkek> but you would need the context
<FromGitter>
<grkek> if you returned a response with an 401
<FromGitter>
<grkek> or raised an error
<FromGitter>
<grkek> or whatever else
<FromGitter>
<grkek> it would go to the 401 handler
<FromGitter>
<naqvis> because from examples its obvious that for one to write `Controller`, they need to inherit from `Controller` and then use mixin for specific http or ws functionality
<FromGitter>
<j8r> @naqvis but, how can you then include them if they are classes/structs?
<FromGitter>
<Blacksmoke16> then could add whatever context you wanted to this type
<FromGitter>
<Blacksmoke16> the framework should ideally handle all that boilerplate
<FromGitter>
<naqvis> if going with mixin approach, then replace inheritance with inclusion in my above sentence
<FromGitter>
<grkek> @Blacksmoke16 If you look at the structure you can see that my database layer is in a different module
<FromGitter>
<j8r> @naqvis not sure to see the advantage though?
<FromGitter>
<grkek> @Blacksmoke16 I want to handle raised exceptions from the database layer
<FromGitter>
<j8r> using inheritance differentiate controllers features vs base object, it should be clearer?
<FromGitter>
<grkek> how would you do that?
<FromGitter>
<naqvis> only advantage i see is consistency from user perspective
<FromGitter>
<Blacksmoke16> like around the `call_next` in the handler?
<FromGitter>
<grkek> I don't use call_next
<FromGitter>
<grkek> the endpoint is the deadend to the request
<FromGitter>
<grkek> for the http controllers
alexherbo2 has quit [Remote host closed the connection]
<FromGitter>
<Blacksmoke16> so theres nothing in between the request coming into the application and the controller action?
<FromGitter>
<Blacksmoke16> something has to handle calling the right thing
<FromGitter>
<grkek> It is
<FromGitter>
<grkek> the router
<FromGitter>
<grkek> basically its kemal
<FromGitter>
<grkek> but object oriented
<FromGitter>
<grkek> with a slapped on routing sugar
<FromGitter>
<Blacksmoke16> fair enough
<FromGitter>
<grkek> the exceptions are handled when they are default defined by the library
<FromGitter>
<grkek> if they are not defined they go to the 500 handler
<FromGitter>
<grkek> if you define an exception in your app and register it you need to route it as well so it doesnt go to 500 again
<FromGitter>
<grkek> and it goes to the appropriate error code
<FromGitter>
<grkek> that is why the raise function is overloaded so you can specify the error and the response code at the same time
<FromGitter>
<grkek> and since you do not have the context with which you can specify the error code you need to match over the errors so you can define the proper error code for the proper exception
<FromGitter>
<Blacksmoke16> i think we just have diff views on how it should work. All im saying is why shouldnt the error class be tied to the code?
<FromGitter>
<grkek> it sounds verbose, looks verbose but provides cleaner and better structure
<FromGitter>
<grkek> It is tied to the code
<FromGitter>
<grkek> the grip code
<FromGitter>
<grkek> everything else you define other than grip code
<FromGitter>
<Blacksmoke16> but its not if you have to manually give the code