ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.22.0 | Fund Crystal's development: http://is.gd/X7PRtI | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Logs: http://irclog.whitequark.org/crystal-lang
early has quit [Quit: Leaving]
early has joined #crystal-lang
zipR4ND has quit [Ping timeout: 268 seconds]
Kug3lis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 268 seconds]
Raimondii is now known as Raimondi
txdv has quit [Ping timeout: 240 seconds]
<oprypin> bew, is it because that initialize method is never inherited in the first place?
<oprypin> i think it would work with any other method name
<oprypin> just that initialize is magic - always 'protected' or something
txdv has joined #crystal-lang
_whitelogger has joined #crystal-lang
<FromGitter> <bew> Even if it's always protected, it should be accessible from childs classes
marciogm has quit [Ping timeout: 260 seconds]
marciogm has joined #crystal-lang
dckrx has joined #crystal-lang
mark_66 has joined #crystal-lang
dckrx has quit [Client Quit]
pwned has joined #crystal-lang
Kug3lis has joined #crystal-lang
yogg-saron has joined #crystal-lang
bjz has joined #crystal-lang
bjz has quit [Client Quit]
bjz has joined #crystal-lang
Winty has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<Winty> hey guys. i'm trying to learn crystal and i can't get this program to compile: https://pastebin.com/VTv6yYPh it fails on line 20 because @tail is nil, but on line before i'm ensuring that it's not nil so where's the problem?
<Papierkorb> Winty: @instance variables don't "work" with the nil check, as in a multithreaded program, it could be changed in between setting it to non-nil back to nil
<Papierkorb> Winty: Instead, in line 19, do `if tail = @tail`, and then use that local variable `tail` in the following two lines
<Winty> ok thx
<Papierkorb> err, only in the following line. You still need to set `@tail`...
bjz has joined #crystal-lang
<Winty> it works even without setting @tail = tail after i modify tail variable. so tail is reference to @tail and not copy? (tail = @tail)
<Papierkorb> Yep, `class` is always heap allocated and thus you pass around references to it
<Papierkorb> btw, line 2/3 in your snippet, you can also write `property next : Node(T)?`, you don't have to split the @instance variable definition and property macro call
<Papierkorb> Otherwise, at least put a space before the colon, per convention
<Winty> :D ok thanks for the help
<Papierkorb> Line 6 isn't needed. A nilable variable defaults to `nil`. You can also make this explicit, e.g. replacing line 3 by `property next : Node(T)? = nil`, or `@next : Node(T)? = nil`
<Papierkorb> Line 2 could also be omitted, by using `def initialize(@val : T)` instead on line 5. That'll tell Crystal that @val will always be a T. "Good enough" for the compiler :)
<Winty> yeah i just like having all fields at the top of the class for better readability
<FromGitter> <bew> Winty: https://carc.in/#/r/21d3 :)
<Papierkorb> I do so too, just directly use `property`(or getter or setter), so it's also clear what a user of your class can do with those (if at all)
<Papierkorb> Winty: ^
<FromGitter> <bew> the definition of `<<` allows you to write `puts LinkedList{"Another", "Syntax with", true, "types"}` https://carc.in/#/r/21d7
<jokke> hi
<jokke> what's the equivalent of ruby's foo.method(:foobar) in crystal?
<jokke> i want to pass a method of an object to a block
<jokke> or rather to a method expecting a block
<RX14> jokke, ->foo.foobar ?
<jokke> ah m(
<RX14> well, if you want to pass it to a block you need &->foo.foobar
<jokke> of course
<jokke> thanks :D
<RX14> although, I think it's way way cleaner just to call the method in the block
<RX14> and it likely has a performance advantage
<FromGitter> <bew> ah? why?
<jokke> alright
<RX14> @bew procs generate a function pointer whereas using blocks emits a normal call
<RX14> llvm might be able to optimise it but i'm not sure
<FromGitter> <bew> Optimisation, ok !
sz0 has joined #crystal-lang
bjz_ has joined #crystal-lang
bjz has quit [Ping timeout: 246 seconds]
<crystal-gh> [crystal] RX14 opened pull request #4426: Add warnings to MD5 and SHA1 hash documentation (master...feature/digest-doc-fix) https://git.io/v9h9h
bjz has joined #crystal-lang
Winty has quit [Ping timeout: 260 seconds]
bjz_ has quit [Ping timeout: 240 seconds]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
gewo has quit [Ping timeout: 240 seconds]
gewo has joined #crystal-lang
gewo has quit [Ping timeout: 260 seconds]
yogg-saron has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
gewo has joined #crystal-lang
yogg-saron has joined #crystal-lang
gewo has quit [Ping timeout: 246 seconds]
gewo has joined #crystal-lang
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 268 seconds]
Raimondii is now known as Raimondi
yogg-saron has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
yogg-saron has joined #crystal-lang
yogg-saron has quit [Client Quit]
yogg-saron has joined #crystal-lang
yogg-saron has quit [Client Quit]
<FromGitter> <bigtunacan> Has anyone done a standard webserver interface for Crystal web frameworks yet?
<FromGitter> <bigtunacan> Essentially a Ruby/Rack equivalent?
<FromGitter> <aolko> no cancan :(
<FromGitter> <fridgerator> @bigtunacan like https://crystal-lang.org/api/0.22.0/HTTP/Server.html ?
<FromGitter> <bigtunacan> Forgive me if I'm wrong; I'm new to Crystal
<FromGitter> <bigtunacan> But that seems more equivalent to this https://ruby-doc.org/stdlib-2.4.1/libdoc/net/http/rdoc/Net/HTTP.html
<FromGitter> <bigtunacan> Seems like that is an HTTP library that can be built on, but I don't see how it provides a standardized interface for external app servers.
snsei has joined #crystal-lang
yogg-saron has joined #crystal-lang
yogg-saron has quit [Client Quit]
yogg-saron has joined #crystal-lang
yogg-saron has quit [Client Quit]
<FromGitter> <fridgerator> quoting someone from earlier "Crystal has HTTP::Server and HTTP::Handler wich is a different concept, but the handlers are somewhat similar to Rack middleware."
<FromGitter> <fridgerator> I don't have much experience with bare rack, so I'm probably not the best person answer the question
<FromGitter> <drujensen> Hi @bigtunacan Kemal and Kemalyst both use the http::handers in a middleware stack
<FromGitter> <drujensen> they are interchangable
<FromGitter> <drujensen> there is implementations of http::handlers for several different tasks in the middleware stack just like Rack
<FromGitter> <drujensen> you can remove, add or replace to the stack your own handlers
<FromGitter> <drujensen> I believe Amber is doing this as well
<FromGitter> <bigtunacan> But then HTTP::Server IS the app server?
<FromGitter> <drujensen> but would need to verify
<FromGitter> <drujensen> right, we are using the HTTP::Server implementation
<FromGitter> <drujensen> and adding handlers to it
<FromGitter> <drujensen> chaining them
<FromGitter> <drujensen> it’s pretty simple to create your own
<FromGitter> <drujensen> in Kemalyst, all the controller methods are just http::handlers that get added to the call stack
<FromGitter> <bigtunacan> How difficult does it become to take Kemal off of HTTP::Server and just swap that out for "Super Scalable More Awesome App server"?
<FromGitter> <bigtunacan> Is it just like flipping a switch; or are you tightly coupled to HTTP::Server?
<FromGitter> <drujensen> checking...
<FromGitter> <drujensen> i think we are just inheriting from it so if it supports the http::handlers, you could just swap it out
<FromGitter> <drujensen> if the “super scalable” support http::handlers
<FromGitter> <bigtunacan> Gotcha; ok
<FromGitter> <bigtunacan> I just clone Kemal so I can take a look at how that's layering on
<FromGitter> <drujensen> ok. yeah, so you will see the `start` method simply spins up an HTTP::Server and adds the handlers
<FromGitter> <drujensen> you could replace that with your own
yogg-saron has joined #crystal-lang
<FromGitter> <drujensen> you can take any Kemalyst::Handler and use it in Kemal or vise versa
yogg-saron has quit [Client Quit]
<FromGitter> <drujensen> here is an example of basic auth handler
<FromGitter> <drujensen> you just need to implement the `call(context)` and inside that `call_next(context) to be compliant
<FromGitter> <drujensen> the `context` can be reopened to add stuff that you need in future handlers
<FromGitter> <bigtunacan> Very nice; similar to the Rack middleware; like you said
<FromGitter> <drujensen> and include `include HTTP::Handler`
<FromGitter> <drujensen> in your class
<FromGitter> <drujensen> if anyone is interested in helping, we could use a `warden` http::handler. ;-)
<FromGitter> <bigtunacan> :)
<FromGitter> <straight-shoota> @bigtunacan With ruby/rack you are usually using an appserver executable (like puma, unicorn etc.) do run your application code. In crystal the binary usually binds directly to a port or listens to a socket. That's what `HTTP::Server`does and it invokes the appropriate handlers. It could be replaced by another implementation if you would need something else and still use the same handlers.
<FromGitter> <johnjansen> just a reminder, that there is a growing list of wants / needs outside of StdLib, over here https://github.com/johnjansen/crystal-libraries-needed/issues
<FromGitter> <johnjansen> add anything you dream up
<FromGitter> <bigtunacan> @johnjansen Yeah; I'm very familiar with the Rack workings.
<FromGitter> <bigtunacan> That's is what so nice about it.
<FromGitter> <johnjansen> thats a general list @bigtunacan, not directed at you ;-)
<FromGitter> <bigtunacan> Someone comes along and builds a faster appserver and you just drop it in
<FromGitter> <bigtunacan> Sorry, that was supposed to be @straight-shoota
<FromGitter> <bigtunacan> Picked you by accident in the auto-completer @johnjansen
<FromGitter> <johnjansen> no worries ;-) … BTW @bigtunacan you should take a look at the benchmarks over here http://kemalcr.com
<FromGitter> <bigtunacan> Yeah; I've looked at the benchmarks already.
<FromGitter> <bigtunacan> Compared to Sinatra; it's super fast.
<FromGitter> <bigtunacan> Overall I'm impressed by it.
<FromGitter> <bigtunacan> I was just wondering more what happens in the future.
<FromGitter> <bigtunacan> In the early Ruby days there wasn't Rack and the app servers were non standard and slow
<FromGitter> <fridgerator> robots
<FromGitter> <bigtunacan> Moving Rails to Rack initially was a big undertaking
<FromGitter> <johnjansen> also @bigtunacan this is kinda interesting http://blog.seraum.com/crystal-lang-vs-nodejs-vs-golang-vs-http-benchmark
<FromGitter> <bigtunacan> Well damn
<FromGitter> <bigtunacan> If those specs are right; why are people using Go ;)
<FromGitter> <johnjansen> crystal is too young
<FromGitter> <fridgerator> not backed by google
<FromGitter> <bigtunacan> Probably true on both accounts
<FromGitter> <bigtunacan> Go definitely has the Google machine behind it.
<FromGitter> <bigtunacan> But I kind of hate working with it. Love Ruby; want better performance.
<FromGitter> <bigtunacan> That's why I'm here :)
<FromGitter> <johnjansen> so im looking forward to seeing something faster ;-)
<FromGitter> <fridgerator> same here @bigtunacan
<FromGitter> <johnjansen> haha, no pressure ;-)
<FromGitter> <jwoertink> @bigtunacan I had a similar thought of taking kemal and replacing the HTTP::Server with something not built in to crystal. I started writing https://github.com/jwoertink/haywire.cr to handle doing that
<FromGitter> <jwoertink> And as long as it had the same interface as the built in server, I think it wouldn't be too difficult to switch out
Kug3lis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <drujensen> @jwoertink At the Code Camp, Juan Wajnerman originally tried using the libuv library instead of libevent
<FromGitter> <drujensen> but the callbacks became problematic. May want to reach out and ask.
<FromGitter> <drujensen> He didn’t go into details
<FromGitter> <jwoertink> oh yeah? That might be part of some of the issues I'm running in to too
<FromGitter> <jwoertink> On a side note, is it me, or does it seem like the crystal updates are slowing down?
<FromGitter> <jwoertink> For a while there it was like 5~6 commits a night, but now it's like 1 every other day
<FromGitter> <drujensen> yeah, i know the code camp was draining some time
<FromGitter> <drujensen> but should start to pickup again??
<FromGitter> <drujensen> not sure
<FromGitter> <jwoertink> I figured maybe that was it
snsei has quit []
snsei has joined #crystal-lang
snsei has quit [Client Quit]
snsei has joined #crystal-lang
splitty_ has joined #crystal-lang
snsei has quit [Remote host closed the connection]
mark_66 has quit [Remote host closed the connection]
Kug3lis has joined #crystal-lang
<crystal-gh> [crystal] bcardiff pushed 1 new commit to master: https://git.io/v9jHf
<crystal-gh> crystal/master 2a71284 Chris Hobbs: Add range access methods to BitArray (#4397)...
<crystal-gh> [crystal] bcardiff pushed 1 new commit to master: https://git.io/v9jHn
<crystal-gh> crystal/master af61a81 at_grandpa: Fix benchmark.cr documentation. (#4421)
<crystal-gh> [crystal] bcardiff pushed 1 new commit to master: https://git.io/v9jH7
<crystal-gh> crystal/master 3364f3b Akzhan Abdulin: Extend known HTTP default status messages by RFC 2518, RFC 5842, RFC 2324 etc. (#4419)...
<crystal-gh> [crystal] bcardiff closed pull request #4420: More documentation for Exception class. (master...doc-Exception-class-more) https://git.io/v9AG6
zipR4ND has joined #crystal-lang
joaumg has joined #crystal-lang
<joaumg> Is there a way to use `YAML.parse` to parse a string into a user defined struct ? From `yaml_spec.cr` I only see native types...
<crystal-gh> [crystal] bcardiff pushed 1 new commit to master: https://git.io/v9j7s
<crystal-gh> crystal/master d62caee Akzhan Abdulin: Documentation for HTTP.rfc1123_date. (#4418)
<FromGitter> <l3kn> @joaumg: You can use the YAML.mapping macro to do that https://crystal-lang.org/api/0.19.4/YAML.html#mapping-macro
<crystal-gh> [crystal] bcardiff pushed 1 new commit to master: https://git.io/v9jdI
<crystal-gh> crystal/master deef66c O_o: Select: fix case when select send executed before select receive, fixed #3862 (#3899)
<crystal-gh> [crystal] bcardiff pushed 1 new commit to master: https://git.io/v9jFl
<crystal-gh> crystal/master 96169cc Chris Hobbs: Fix WebSocket negotiation (#4386)...
<Majost> What is the equivalent to rubygems.org for crystal?
<FromGitter> <drujensen> I think the closest we have is http://awesome-crystal.com
<FromGitter> <fridgerator> http://crystalshards.xyz/
<RX14> @bcardiff thanks for merging all those PRs!
pwned has quit [Remote host closed the connection]
Ven has joined #crystal-lang
Ven is now known as Guest50345
zipR4ND has quit [Ping timeout: 240 seconds]
Kug3lis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Guest50345 has quit [Ping timeout: 240 seconds]
<FromGitter> <bigtunacan> @drujensen Oh lord
<FromGitter> <bigtunacan> I see you created this repo less than an hour ago
<FromGitter> <bigtunacan> https://github.com/drujensen/crack
<FromGitter> <bigtunacan> LOL
<FromGitter> <bigtunacan> That is exactly the name I had in mind...
Ven_ has joined #crystal-lang
<FromGitter> <drujensen> @bigtunacan lol. I was thinking of standardizing the http::handlers. two things I want are a standard way of configuring a handler and a standard pattern for modifying the HTTP::Server::Context
<FromGitter> <drujensen> do you want to own this?
<FromGitter> <bararchy> Anyone is security orianted here and want's to give a hand here -> https://github.com/bararchy/sslscanner ?
<FromGitter> <drujensen> I will transfer to you if your interested in working on it
<FromGitter> <bigtunacan> @drujensen I am interested in working on it, but I'm also a total noob to Crystal
<FromGitter> <bigtunacan> So I would rather not run point yet
Ven_ has quit [Ping timeout: 240 seconds]
<FromGitter> <drujensen> no better way to learn… lol. ok.
<FromGitter> <drujensen> i will add you as a contributor if your interested
<FromGitter> <bigtunacan> That would be good
<FromGitter> <drujensen> invited
<FromGitter> <bigtunacan> Thanks
<FromGitter> <drujensen> @bararchy not my cup of tea.
<FromGitter> <bigtunacan> My interest in that Rack like abstraction layer is that I was thinking I would do YAWFP
<FromGitter> <bigtunacan> (Yet Another Web Framework Port)
<FromGitter> <bigtunacan> ;)
<FromGitter> <drujensen> lol, awesome!
<FromGitter> <bigtunacan> I was thinking of trying to do a Hanami style port
<FromGitter> <bigtunacan> hanamirb.org
<FromGitter> <drujensen> not familiar…lookking...
<FromGitter> <bigtunacan> It's much smaller and more modular than Rails
<FromGitter> <bigtunacan> Very testable
<FromGitter> <bigtunacan> But unlike Sinatra/Kemal it isn't just the barebones, "Here is a REST end point; now go!"
<FromGitter> <drujensen> lol, looks like Kemalyst..
<FromGitter> <drujensen> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=591de76000efc2bb3e7f46ed]
<FromGitter> <bigtunacan> Somewhat
<FromGitter> <drujensen> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=591de7c533e9ee771cbe6db3]
<FromGitter> <drujensen> although I’m using inheritance
<FromGitter> <bigtunacan> It has some unique traits.
<FromGitter> <bigtunacan> Yeah; that's one of the big ideas pushed by Hanami
<FromGitter> <bigtunacan> No inheritance; everything should be composition
<FromGitter> <drujensen> nice. i like it
<FromGitter> <drujensen> the http::handlers moved that way as well
<FromGitter> <bigtunacan> The model layer is different as well
<FromGitter> <drujensen> used to be base class
<FromGitter> <bigtunacan> Models are essentially 2 pieces
<FromGitter> <bigtunacan> entity + repository
<FromGitter> <bigtunacan> entity is your business logic
<FromGitter> <bigtunacan> repository is your actual data request layer
<FromGitter> <fridgerator> @bigtunacan check out - https://github.com/Crecto/crecto
<FromGitter> <fridgerator> the repo usage is more like phoenix - ecto than hamani though
<FromGitter> <fridgerator> but its similar
<FromGitter> <drujensen> take a look at https://github.com/Crecto/crecto
<FromGitter> <drujensen> it uses that approach
<FromGitter> <bigtunacan> I'll have a look
Ven_ has joined #crystal-lang
<FromGitter> <drujensen> you could just include Crecto with Kemal and add your own set of handlers. create some generators and your off and running.. thats what i did. :-)
<FromGitter> <drujensen> @fridgerator lol, just noticed your post
<FromGitter> <fridgerator> ;)
<RX14> what exactly is crystal's HTTP::Handler missing?
<FromGitter> <drujensen> @RX14 I wouldn’t say its missing anything per say. It’s more of a convention.
<FromGitter> <drujensen> so if your handler needs something in the HTTP::Server::Context
<RX14> oh yeah extending HTTP::Server::Context is something that needs doing
<RX14> I think a simple component system could do the job
<FromGitter> <drujensen> say `params` hash, this should be done with the handler
<FromGitter> <drujensen> another pattern i use in kemalyst is configuring each handler separately
<FromGitter> <drujensen> so for example, the session handler needs a `secret`
<FromGitter> <drujensen> the static handler needs a `directory` where files will be searched
<RX14> that's easy using the stdlib's handler system...
<FromGitter> <drujensen> the log handler...
<RX14> I think it'd be best to architect these changes as an experiment on top of the stdlib
<RX14> aimed at being able to be merged if it works well
<FromGitter> <drujensen> i agree
<FromGitter> <drujensen> would be nice to have a standard for this stuff
<FromGitter> <drujensen> but `crack` is such a perfect name for a crystal project. ;-)
Ven_ has quit [Ping timeout: 246 seconds]
Ven has joined #crystal-lang
Ven is now known as Guest74863
TheLemonMan has joined #crystal-lang
pduncan has quit [Ping timeout: 272 seconds]
Guest74863 has quit [Ping timeout: 240 seconds]
Ven_ has joined #crystal-lang
Ven_ has quit [Ping timeout: 240 seconds]
Ven_ has joined #crystal-lang
zipR4ND has joined #crystal-lang
Ven_ has quit [Ping timeout: 260 seconds]
Ven has joined #crystal-lang
Ven is now known as Guest71934
Guest71934 has quit [Ping timeout: 240 seconds]
Ven_ has joined #crystal-lang
Ven_ has quit [Ping timeout: 246 seconds]
Ven_ has joined #crystal-lang
bjz has joined #crystal-lang
Ven_ has quit [Ping timeout: 260 seconds]
Ven_ has joined #crystal-lang
joaumg has quit [Quit: Leaving]
Ven_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
zipR4ND has quit [Read error: Connection reset by peer]
zipR4ND1 has joined #crystal-lang
sagax has quit [Quit: Konversation terminated!]
<crystal-gh> [crystal] RX14 opened pull request #4428: Add limits to HTTP request parsing (master...feature/http-limits) https://git.io/vHeyZ
bjz has quit [Ping timeout: 260 seconds]
bjz_ has joined #crystal-lang
bjz_ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
go|dfish has quit [Ping timeout: 240 seconds]
<crystal-gh> [crystal] RX14 opened pull request #4429: Add | as a string delimiter (master...feature/pipe-string-delimiter) https://git.io/vHeQV
greengriminal has joined #crystal-lang