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
ur5us has quit [Ping timeout: 240 seconds]
<FromGitter> <watzon> It would be nice if aliases could have generics
ur5us has joined #crystal-lang
sagax has quit [Remote host closed the connection]
<FromGitter> <tenebrousedge> hmmm
<FromGitter> <Blacksmoke16> can they not?
<FromGitter> <watzon> Apparently not
<FromGitter> <oren> i asked a question yesterday. how can i find if anyone answered it?
<FromGitter> <Blacksmoke16> scroll up :S
<FromGitter> <Blacksmoke16> or ask it again ha
<FromGitter> <oren> i tried hiting the search icon but searching for my name didn't show anything meaningful
<FromGitter> <Blacksmoke16> search on here is πŸ’©
<FromGitter> <Blacksmoke16> theres also an unofficial discord server just as an fyi
Vexatoast has joined #crystal-lang
Vexatos has quit [Ping timeout: 246 seconds]
sagax has joined #crystal-lang
commavir has quit [Remote host closed the connection]
commavir has joined #crystal-lang
Flipez has quit [Quit: Ping timeout (120 seconds)]
Flipez has joined #crystal-lang
<FromGitter> <HCLarsen> @oren if they answered you by name, there'd be an orange @ in the upper right corner of the window.
ur5us has quit [Ping timeout: 240 seconds]
livcd has quit [Ping timeout: 260 seconds]
darkstardevx has joined #crystal-lang
return0e_ has joined #crystal-lang
return0e has quit [Ping timeout: 260 seconds]
return0e has joined #crystal-lang
return0e_ has quit [Ping timeout: 265 seconds]
livcd has joined #crystal-lang
ur5us has joined #crystal-lang
_ht has joined #crystal-lang
flaviodesousa has joined #crystal-lang
flaviodesousa has quit [Remote host closed the connection]
flaviodesousa has joined #crystal-lang
_ht has quit [Quit: _ht]
flaviodesousa has quit [Quit: KVIrc 4.9.3 Aria http://www.kvirc.net/]
alexherbo2 has joined #crystal-lang
ur5us has quit [Ping timeout: 240 seconds]
<FromGitter> <636f7374> After a day of conception / thinking, a day of design / debugging, Tomato.cr has been initially completed.
<FromGitter> <636f7374> Tomato.cr - SOCKS5 Proxy (https://github.com/636f7374/tomato.cr)
<FromGitter> <636f7374> @wontruefree πŸ˜€πŸ˜‹
<FromGitter> <636f7374> I might make VPN (IPSec) and TUNTAP, but I should use Rust, TUNTAP part can be tricky in Crystal.
<FromGitter> <636f7374> Writing in Rust may be more reliable and stable, then I want to try Rust (m-labs / smoltcp: a smol tcp / ip stack).
<FromGitter> <636f7374> smoltcp is a standalone, event-driven TCP/IP stack that is designed for bare-metal, real-time systems. Its design goals are simplicity and robustness. Its design anti-goals include complicated compile-time computations, such as macro or type tricks, even at cost of performance degradation. ⏎ ⏎ smoltcp does not need heap allocation at all, is extensively documented, and compiles on stable Rust 1.28 and
<FromGitter> ... later. ⏎ ⏎ smoltcp achieves ~Gbps of throughput when tested against the Linux TCP stack in loopback mode. [https://gitter.im/crystal-lang/crystal?at=5e428ac1d4daaa26c197adc3]
<FromGitter> <636f7374> Waiting for my good news.
<FromGitter> <confact> @straight-shoota I saw that you are one of the collaborators to the crystal libgit2 repo. Do you know a way to do something similar to `git log` with path filter, like `-- path`?
<FromGitter> <j8r> How can I turn `Time.measure` (https://github.com/crystal-lang/crystal/blob/master/src/time.cr#L353) to a Proc?
<FromGitter> <Blacksmoke16> prob should be changed to just `&`
<FromGitter> <Blacksmoke16> considering its not doing anything with the `block` var
<FromGitter> <dscottboggs_gitlab> `&->Time.measure`, right?
<FromGitter> <tenebrousedge> no it needs a signature
<FromGitter> <dscottboggs_gitlab> right, of course
<FromGitter> <dscottboggs_gitlab> `&->Time.measure(Proc(Nil))`?
<FromGitter> <j8r> no :/
<FromGitter> <dscottboggs> Damn
<FromGitter> <tenebrousedge> I don't think that's a thing
<FromGitter> <j8r> ok, thanks, I will find another way
<FromGitter> <dscottboggs_gitlab> what about ⏎ ⏎ ```->(&action) { Time.measure { action.call } }``` [https://gitter.im/crystal-lang/crystal?at=5e42a6e9c900d747abfa597c]
<FromGitter> <j8r> try it πŸ˜‰
<FromGitter> <j8r> no, I don't think there is a way
<FromGitter> <j8r> I got something
<FromGitter> <j8r> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e42a7fff3718e705df65d9f]
<FromGitter> <dscottboggs> Nice!
<FromGitter> <j8r> Too bad we can only transform method to procs, but not class methods
leavengood has quit [Quit: bye]
<FromGitter> <Blacksmoke16> pretty sure you can
<FromGitter> <Blacksmoke16> i did that with original version of athena
<FromGitter> <j8r> I finally just calculate the `Time::Span` anyway, and let the user eventually process the `Time::Span` as they wish
return0__ has joined #crystal-lang
return0e has quit [Ping timeout: 260 seconds]
<FromGitter> <bajro17> I follow this repo for long time https://github.com/the-benchmarker/web-frameworks
<FromGitter> <bajro17> can someone tell me what is reason first crystal framework appear on 16. place
<FromGitter> <bajro17> It is toro
<FromGitter> <waghanza> @bajro17 what do you mean by reason ? ⏎ It just figures I've found πŸ˜› (but still not *production-grade*)
<FromGitter> <bajro17> how can I measure every process program make to see what is slowest
<FromGitter> <waghanza> follow the guidelines on `README` an *DM* if any trouble
<FromGitter> <waghanza> on use https://gitter.im/which_is_the_fastest/Lobby channel
<FromGitter> <bajro17> also this nim surprise me
<FromGitter> <bajro17> super fast
<FromGitter> <bajro17> but same problem like crystal so hard to find any tutorials
<FromGitter> <waghanza> yeah, because this is not a *mature* language
<FromGitter> <waghanza> I mean not `1.0`, yet
<FromGitter> <bajro17> nim have version 1.0
<FromGitter> <bajro17> but still not popular
<FromGitter> <bajro17> I have even feeling that crystal is more popular then nim
<FromGitter> <waghanza> ah sorry I was thinking that you spoke of `crystal`
<FromGitter> <bajro17> yes crystal is amazing
<FromGitter> <waghanza> `nim` competes `rust` ⏎ `crystal` competes `go`
<FromGitter> <bajro17> crystal cant compete with GO
<FromGitter> <waghanza> at least for inspiration (`crystal` take inspiration from `go`)
<FromGitter> <bajro17> I think its impossible
<FromGitter> <waghanza> why ?
<FromGitter> <bajro17> because google make it
<FromGitter> <bajro17> if crystal have same amount of users and developers like go
<FromGitter> <waghanza> I speak only on technical ideas, not popularity
<FromGitter> <bajro17> I think crystal in short time will be even better then this
<FromGitter> <bajro17> I was trying to promote crystal
<FromGitter> <bajro17> make some tutorials on yt
<FromGitter> <bajro17> but I finish with 14 subscribers :D
<FromGitter> <bajro17> And I do it 2 years ago ahahhaha
woodruffw has quit [Ping timeout: 265 seconds]
woodruffw has joined #crystal-lang
<FromGitter> <watzon> Crystal is actually faster than Go in many benchmarks. I think it competes just fine for the most part.
<FromGitter> <watzon> A lot of Crystal was actually based on Go, like the concurrency model
<FromGitter> <ImAHopelessDev_gitlab> Hello
<FromGitter> <ImAHopelessDev_gitlab> i've been using the sh*t out of enums lately
<FromGitter> <ImAHopelessDev_gitlab> in godot, and in crystal
<FromGitter> <waghanza> @watzon probably, my figures does not say that, but their not goodly computed (I'm working on that)
<FromGitter> <watzon> There is already a large benchmarking repo that takes both Go and Crystal into account. https://github.com/kostya/benchmarks
<FromGitter> <watzon> @ImAHopelessDev_gitlab enums are very helpful
<FromGitter> <ImAHopelessDev_gitlab> @watzon yeah they are. i used to just try to remember integers and map them to their functionality in my head. but it got quite hard to remember
<FromGitter> <ImAHopelessDev_gitlab> over time, now, having a string representation of it makes it very easy
<FromGitter> <watzon> Wait until you learn about symbol autocasting
<FromGitter> <watzon> Assuming you don't know about it already
<FromGitter> <ImAHopelessDev_gitlab> never heard of it, but i probably i've seen it in the wild before?
<FromGitter> <watzon> Maybe. Basically it just allows you to use an enum as a parameter to a function, but rather than the enduser having to actually use the full enum itself, they can use a symbol
<FromGitter> <ImAHopelessDev_gitlab> is it like syntax sugar on top of enums?
<FromGitter> <watzon> For instance: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e42ef5945000661fcb47c75]
<FromGitter> <watzon> Yeah basically just some syntactic sugar
<FromGitter> <watzon> Really helpful for larger enums
<FromGitter> <ImAHopelessDev_gitlab> ohh
<FromGitter> <ImAHopelessDev_gitlab> i've seen that in some code blacksmoke showed me long time ago. and i got triggered because the lowercase symbol, and how we can't do :Bar
<FromGitter> <ImAHopelessDev_gitlab> or.. maybe that's in the case when thing, can't remember
<FromGitter> <watzon> That's just the way symbols are meant to be written. They should always be snake case.
<FromGitter> <watzon> So the enum `FooBarBaz` would be `:foo_bar_baz`
<FromGitter> <ImAHopelessDev_gitlab> yeah that really triggers me
<FromGitter> <watzon> :shrug:
<FromGitter> <watzon> Just the way the language is meant to work. Stylistically you should never really have uppercase symbols.
<FromGitter> <ImAHopelessDev_gitlab> i capitalize all my enum values too... lol don't know if that's normal but i liek it
<FromGitter> <watzon> Well enum values are constants, so they should be capitalized
<FromGitter> <watzon> Technically symbols are constants of a sort as well, but... They're also kind of strings so :shrug:
<FromGitter> <ImAHopelessDev_gitlab> every letter for me
<FromGitter> <ImAHopelessDev_gitlab> I_MONSTER_SPEED
<FromGitter> <watzon> I think the convention is to do UpperCamelCase, but it's really up to you. The UPPER_SNAKE_CASE is more of a C convention.
<FromGitter> <ImAHopelessDev_gitlab> Yeah, that's the term, UPPER SNAKE CASE
<FromGitter> <ImAHopelessDev_gitlab> My fav ;D
<FromGitter> <Blacksmoke16> i remember seeing something that did like `UPPER_SNAKE_CASE` for constant, `UpperSnakeCase` for types, and `Uppser_Snake_Case` for enum members
<FromGitter> <Blacksmoke16> so you can tell what "type" of const it is by just looking at it
<FromGitter> <watzon> Hmm that's not bad
<FromGitter> <Blacksmoke16> but meh
<FromGitter> <watzon> I don't like using a bunch of different styles if I can avoid it. Mostly I'll do UPPER_SNAKE_CASE for constants and UpperCamelCase for types and enums.
<FromGitter> <Blacksmoke16> thats what i end up doing as well
<FromGitter> <ImAHopelessDev_gitlab> that's what i do
<FromGitter> <watzon> @Blacksmoke16 any idea how to take a type `T` and figure out if it's a subclass of something else? For instance, `Number`/
<FromGitter> <ImAHopelessDev_gitlab> https://github.com/AregevDev/raylib-cr that's pretty interesting
<FromGitter> <kinxer> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e42f92445000661fcb49edb]
<FromGitter> <watzon> Aha! Good one
<FromGitter> <kinxer> I happened to run into this recently while I was trying to figure a good way to implement saturating arithmetic in Crystal.
<FromGitter> <kinxer> It was based on a forum question by @ImAHopelessDev_gitlab, actually.
<FromGitter> <kinxer> But I couldn't figure out a really good way to do it.
<FromGitter> <Blacksmoke16> yea, https://crystal-lang.org/api/master/Crystal/Macros/TypeNode.html#%3C(other:TypeNode):BoolLiteral-instance-method these would do that
<FromGitter> <kinxer> It really is wonderful how readable macros can be in Crystal. Metaprogramming is always going to be somewhat arcane, but Crystal still manages to avoid it being too bad.
<FromGitter> <watzon> As long as they're not nested. Nested macros can get a bit messy.
* FromGitter * ImAHopelessDev_gitlab Girng has exited the chat
* FromGitter * watzon wave's bye
<FromGitter> <ImAHopelessDev_gitlab> πŸ˜‚
ur5us has joined #crystal-lang
<sorcus> Blacksmoke16: Nice :-)
<FromGitter> <Blacksmoke16> :)
gangstacat has quit [Quit: Ĝis!]
_whitelogger has joined #crystal-lang
alexherbo22 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 246 seconds]
alexherbo2 has joined #crystal-lang
_ht has joined #crystal-lang
alexherbo22 has quit [Ping timeout: 265 seconds]
DTZUZU has quit [Quit: WeeChat 2.7]
DTZUZU has joined #crystal-lang
gangstacat has joined #crystal-lang
_ht has quit [Remote host closed the connection]
return0__ has quit [Ping timeout: 272 seconds]
<FromGitter> <dburnsii> Hey, I have some issues with nil checks with UnixSockets, but could definitely apply to a more general case.
<FromGitter> <Blacksmoke16> oh?
<FromGitter> <dburnsii> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e43347663c15921f47288a9]
<FromGitter> <Blacksmoke16> and whats the error?
<FromGitter> <dburnsii> I would expect that `if` statement to evaluate to true only if the socket is not nil, but I get a compile time error on the `gets`, saying `(compile-time type is (UNIXSocket | Nil))`
<FromGitter> <kinxer> Does the error still happen if you don't have the `spawn` block?
<FromGitter> <636f7374> Why put accept in initialize (construct).
<FromGitter> <dburnsii> It doesn't, but I'll need to spawn a fiber for the application I'm writing. This is just a stripped down version of what I've written
<FromGitter> <dburnsii> I get if the spawn has it's own context and doesn't know if `client` is or is not nil, but the following code has the same problem:
<FromGitter> <dburnsii> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e4335d3ecfa4461c0546849]
<FromGitter> <Blacksmoke16> make a struct to encapsulate the logic?
<FromGitter> <636f7374> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e4335ed45000661fcb536ea]
<FromGitter> <636f7374> This is SOCKS5 Simple Server, you can refer to.
<FromGitter> <kinxer> Would that work?
<FromGitter> <636f7374> `next` more clear.
<FromGitter> <dburnsii> Okay, so I'm not sure what you mean by making a struct to encapsulate the logic?
<FromGitter> <dburnsii> What exactly is `server.process`?
<FromGitter> <636f7374> Okay, so I'm not sure what you mean by making a struct to encapsulate the logic? = Bad design
<FromGitter> <636f7374> You can delete that line.
<FromGitter> <636f7374> That is only for SOCKS5 Server `next unless context = server.process client`.
<FromGitter> <636f7374> 🚧 WIP - Crystal SOCKS5 Client with Server (https://github.com/636f7374/tomato.cr)
<FromGitter> <636f7374> `if ...` -> `unless ...`, `.nil?` -> `next`.
<FromGitter> <dburnsii> So @636f7374 I think that solves my problem, save for the `server.process` call. So I guess my question is, why does `if !client.nil?` not set the type of `client` in the branch, but `next unless` does?
<FromGitter> <dburnsii> Thanks for helping me so quickly by the way guys
<FromGitter> <wontruefree> @636f7374 Awesome !! I might migrate my project to use this instead
<FromGitter> <636f7374> why does if !client.nil? not set the type of client in the branch, but next unless does? If you use fiber, it will have this problem (nil).
<FromGitter> <636f7374> So you need to use `unless`.
<FromGitter> <636f7374> @wontruefree :)
<FromGitter> <dburnsii> So I notice that `client` is created and initialized within the `spawn` in the code you wrote. So my assumption is that I won't have this issue as long as I use a variable created within the spawn. Interesting how that works, but I can work with that. Thanks again.
<FromGitter> <636f7374> :)