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: 260 seconds]
<raz> The supported date range is 0001-01-01 00:00:00.0 to 9999-12-31 23:59:59.999_999_999 in any local time zone.
* raz scratches head
<raz> what's with the pessimism there, do we really think crystal won't be used after 9999
<FromGitter> <randiaz95> clear
<FromGitter> <randiaz95> ls
<FromGitter> <randiaz95> lol, nvm about those random bash commands.
<FromGitter> <Daniel-Worrall> Returning a nil should be on accessing data, returning a Boolean should be if the method is an adjective
<raz> nil is generally a pain in the rectangle and should be avoided altogether where possible tho
<FromGitter> <j8r> also, having a method ending with `?` remind `T?`, which is `T | Nil`
<FromGitter> <j8r> unions, in general
<FromGitter> <j8r> better to avoid when possible
ur5us has joined #crystal-lang
<raz> yup, coming from ruby you quickly end up sprinkling many of those nasty little not_nil!'s across your code
<raz> then you learn to avoid them for most cases. that's about the time when you really fall in love with crystal <3
<raz> i'm still astonished by the elegance of how it all clicks together once you get the hang of it. i'm old enough to remember not just the early Go but also the early Java days. how they both struggled to make certain basics solid. and how terribly wrong they went each in their respective ways (XML hell, 'if err' hell, GOROOT, maven, to name just a few).
Nicolab has quit [Quit: Leaving.]
<raz> somehow crystal avoided all of that. early on i was convinced there must be at least one huge wart that i'll eventually run into. but i've yet to find it. the dev experience (coming from mainly ruby) is so good, it's almost uncanny.
<FromGitter> <Blacksmoke16> id be happy if there was a release dedicated to bugs
<raz> like, to fix bugs? are there any? (i'm not trolling, i haven't run into a single one so far)
<FromGitter> <Blacksmoke16> lucky you :/
<raz> got a sample? i'm curious
<raz> i avoid macros. but otherwise i think i'm prob a relatively heavy crystal user nowadays
<FromGitter> <Daniel-Worrall> Just take a look at the issue tracker
<FromGitter> <Blacksmoke16> third one is the more painful one :/
* raz emits a sigh of relief
<FromGitter> <Blacksmoke16> mainly around generics
<raz> well, tbh these don't look painful to me at all (from a glance). as log as the compiler barfs out in the compile phase nothing bad happens. annoying, but i suppose it'll be addressed.
<FromGitter> <Blacksmoke16> not *painful*, just annoying to workaround
<raz> this looks like a scary one to me (weird OpenSSL hangs at runtime).
<raz> but (from a glance) it seems to be related to MT enabled, so... hopefully not relevant when it's not
<raz> "annoying to workaround" isn't really relevant to me. if something advanced doesn't work right yet, pfft, i'll just not use it.
<raz> the feature set that i needed so far has been amazingly solid. very much unlike the early'ish java and Go days, where spurious segfaults and such were a very serious concern
<raz> also, SCNR. if you think working around these generics bugs is painful. have you tried implementing it in Golang? :P
<FromGitter> <Blacksmoke16> nope :p
dwdv has quit [Ping timeout: 265 seconds]
dotism has joined #crystal-lang
<dotism> I'm working through the pragprog book and am having difficulty parsing the instructions of a particular problem. Would anyone be interested in helping me work through it?
<FromGitter> <andrewc910> Hey is the keyword debugger removed in 0.32? I keep trying to use it but regardless if it's a tiny script or in Amber I get "Program received and didn't handle signal TRAP (5)"
<FromGitter> <andrewc910> Do I need any extra packages for it? Running Ubuntu 19.04
<FromGitter> <andrewc910> Or what's the best way to debug? I'm use to pry. I'm seeing something about vscode and some package in the docs. Is this the most useful way to debug currently?
dotism has quit [Remote host closed the connection]
ur5us has quit [Ping timeout: 260 seconds]
_whitelogger has joined #crystal-lang
<FromGitter> <stnluu_twitter> is it possible to produce an AST tree at run time?
<FromGitter> <stnluu_twitter> like, I have a txt file that is valid Crystal syntax. are there built-in APIs I can use to produce an AST tree without writing my own?
ur5us has joined #crystal-lang
ur5us has quit [Remote host closed the connection]
ur5us has joined #crystal-lang
ur5us has quit [Ping timeout: 260 seconds]
<FromGitter> <stnluu_twitter> > Seems to work with `->(hash : Hash(String, Int32), key : String) { hash[key] = hash.size }` ⏎ ⏎ @halfdan does it work with a `do end` block too?
<FromGitter> <stnluu_twitter> i suspect it has something to do with the different `new` overloads. { } always binds to the right most thing
return0e has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
<FromGitter> <bew> @stnluu_twitter the whole compiler can be require-d if you need it, you can get the parser and parse the crystal file
dwdv has joined #crystal-lang
<sorcus> Happy New Year everyone.
_whitelogger has joined #crystal-lang
<sorcus> j8r: i'm too, but later i'll be sleeping. :-D
<FromGitter> <iambudi> Hi, In VSCode with vscode-crystal-lang, is there a way to turn off focus stealing to output tab from Terminal or Problem Tab panel when Scry throws error?
<FromGitter> <iambudi> cc @faustinoaq
alex`` has joined #crystal-lang
alexherbo2 has joined #crystal-lang
vegai has joined #crystal-lang
_whitelogger has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 258 seconds]
alexherbo2 has joined #crystal-lang
alex`` has quit [Ping timeout: 258 seconds]
alex`` has joined #crystal-lang
alexherbo21 has joined #crystal-lang
alex`` has quit [Ping timeout: 268 seconds]
alexherbo2 has quit [Ping timeout: 258 seconds]
alexherbo21 is now known as alexherbo2
alex`` has joined #crystal-lang
Human_G33k has joined #crystal-lang
HumanG33k has quit [Ping timeout: 260 seconds]
<FromGitter> <grkek> Still in 2019 where I am :D
<FromGitter> <j8r> Still in 2018 here... ho wait
<FromGitter> <grkek> Still in 1 here
<FromGitter> <grkek> holy shit they are nailing a guy
<FromGitter> <grkek> lmao
<FromGitter> <grkek> wtf
<FromGitter> <j8r> I hope it will be a big year 2020 for Crystal
<FromGitter> <j8r> 2019 needs a survey
<FromGitter> <grkek> prolly
<FromGitter> <grkek> crystal so far
<FromGitter> <grkek> has only been getting better for me
<FromGitter> <rishavs> :D
<FromGitter> <j8r> haha I love your response - I think you might like having some sort of Windows support :)
<raz> why do so many people want crystal on their wintendo. i mean, i'd kinda like it on my apple watch too, but these are not places where real work happens ¯\_(ツ)_/¯
<FromGitter> <stnluu_twitter> lulz ok bro
<FromGitter> <Blacksmoke16> its mainly for being able to distribute your app for windows
<FromGitter> <Blacksmoke16> versus doing dev on windows
<FromGitter> <Blacksmoke16> windows is still the most used OS so yea
<FromGitter> <GaryMiller> The conclusion here is that Windows has the highest desktop market share among operating systems. Most Windows users prefer Windows 10, making it the most popular OS. ⏎ ⏎ Unsurprisingly, Mac comes second, with MacOS Mojave being the most popular among Apple users. ⏎ ⏎ Google’s Chrome OS might not be the most used OS, not by a longshot, but it does dominate the educational statistics. ...
JuanMiguel has joined #crystal-lang
JuanMiguel has quit [Remote host closed the connection]
JuanMiguel has joined #crystal-lang
<FromGitter> <Daniel-Worrall> I can dev for Crystal fine on Windows with WSL. The main thing I want from Windows support is distribution
<FromGitter> <Daniel-Worrall> In the next 2 years, I'd love some better IDE support, like goto definition would be amazing, especially when using shards
<raz> dunno. i don't mind windows support. just hope it won't take too many resources from the core language progress.
JuanMiguel has quit [Client Quit]
<FromGitter> <andrewc910> Is window support the next major release?
<FromGitter> <andrewc910> And what's up with web assembly and Crystal? I saw the issues discussing it back in 2016. Using full stack crystal would be awesome
<FromGitter> <Daniel-Worrall> Windows support is slow, but the desire is there. No word on if/when it will work on stdlib
<FromGitter> <Daniel-Worrall> I don't know much about web assembly, but wouldn't it be impossible to write crystal code that compiles to web assembly?
<FromGitter> <Daniel-Worrall> Sure, you could build a web assembly compiler in crystal, but that's not the same
<FromGitter> <Blacksmoke16> pretty sure it would just a diff cross-compile target
<FromGitter> <Blacksmoke16> since llvm supports it
<FromGitter> <Daniel-Worrall> oh it does? Hm.
<FromGitter> <Blacksmoke16> rust can so yea
<FromGitter> <Daniel-Worrall> LLVM 8 has default support for it, before it was experimental
JuanMiguel has joined #crystal-lang
JuanMiguel has quit [Quit: Saliendo]
<FromGitter> <andrewc910> What's llvm? Sorry coming from ruby.
<FromGitter> <Blacksmoke16> is what ultimately creates the binaries for crystal
<FromGitter> <Blacksmoke16> crystal compiler complies the crystal code to (llvm-ir?) which llvm then uses to compile the native binary
<FromGitter> <watzon> Yup. If you watch the Chicago Crystal meetup that @asterite
<FromGitter> <Blacksmoke16> can add `--emit llvm-ir` to your `crystal build` to see what that looks like
<FromGitter> <watzon> LLVM is basically another language that languages can compile to, that then compiles to machine code. It's heavily optimized so it's very fast.
<FromGitter> <jwoertink> So I had a typo in my URL, and the parser raised a strange error that threw me off. I'm curious what others thoughts are on this error message, and if there might be a bug in the parser with this, or if it's fine as is. https://play.crystal-lang.org/#/r/8bg2
<FromGitter> <Blacksmoke16> it prob thinks the port is `localhost:6379/1` since the domain is an empty string
<FromGitter> <jwoertink> That's what I'm thinking. Maybe it says at character 9 since that's what comes before the DB
<FromGitter> <Blacksmoke16> character 9 would be the `l` in localhost (assuming 0 indexed)`
<FromGitter> <jwoertink> but I would have thought it would say bad port at character "l" (for local)
<FromGitter> <jwoertink> OOHHHH
<FromGitter> <jwoertink> hahaha
<FromGitter> <jwoertink> ok, that actually makes way more sense
<FromGitter> <jwoertink> just a coincidence that there was a 9 in the string
<FromGitter> <Blacksmoke16> still could be improved, `invalid port: 'localhost:6379/1'`
<FromGitter> <Blacksmoke16> :shrug:
<FromGitter> <jwoertink> Yeah, that would be a nicer error message
<FromGitter> <jwoertink> Is it worth opening an issue about?
<FromGitter> <Blacksmoke16> my as well
<FromGitter> <watzon> Yeah URI parsing is weird
<FromGitter> <jwoertink> cool. thanks
<FromGitter> <grkek> So basically building llvm ir for windows == windows support ?
<FromGitter> <andrewc910> That makes sense! Thanks for the explaination above llvm. I got another question for y'all.
<FromGitter> <andrewc910> I have vscode set up for debugging. The vanilla task template is command: shards build --debug. I need to debug a test. Changing the command to 'crystal spec --debug' caused an error. What are some good tasks to keep on hand?
<FromGitter> <andrewc910> Oh NVM about the crystal spec. I was accidentally passing in the current directory as an argument. However, I would appreciate seeing everyone's favorite tasks!
<FromGitter> <Blacksmoke16> `--order random`
<FromGitter> <Blacksmoke16> when running your specs
<FromGitter> <stnluu_twitter> @andrewc910 @grkek Kind of, but not quite. One of the very amazing thing about Crystal is it abstracts things from the developers. Currently, it does so via a lot of syscalls to the OS', which is pretty much hardcoded for POSIX. For example, all of the IO we do is "async" via epoll/kqueue. On Windows, this would have to work via IO completion ports, which is a little different.
<FromGitter> <stnluu_twitter> So for baisc things like classes, object, usual code, yes. For many other things, it'll require more resources to support making the right syscalls
<FromGitter> <stnluu_twitter> @bew is there any documentation for it? I scrolled around and saw people using "compiler/crystal/parser" but didn't find it mentioned anywhere in the official API doc.
<FromGitter> <ImAHopelessDev_gitlab> @dotism yes just post it here ;D
alexherbo2 has quit [Ping timeout: 265 seconds]
alex`` has quit [Ping timeout: 258 seconds]
<FromGitter> <plambert> If I define: `foo : NamedTuple(id: Int32, name: String?)` can I later assign a tuple missing one of the keys (name in this case), and have it default to nil?
<FromGitter> <randiaz95> I think you have to do NamedTuple(id: Int32, name: String?)|nil
<FromGitter> <plambert> I don't mean `foo = nil`
<FromGitter> <plambert> I mean `foo = {id: 21}` without specifying `name: ...`
<FromGitter> <plambert> And have the result be the same as `foo = {id: 21, name: nil}`
<FromGitter> <stnluu_twitter> https://play.crystal-lang.org/
<FromGitter> <stnluu_twitter> :)
<FromGitter> <Blacksmoke16> I'm going to go with no
<FromGitter> <watzon> @plambert nope, with a NamedTuple you always have to supply all of the fields. Maybe you should think about using a `record` instead?
<FromGitter> <watzon> ```record Foo, id : Int32, name : String? = nil```
<FromGitter> <watzon> ```foo = Foo.new(32) ⏎ # => Foo(id: 32, name: nil)``` [https://gitter.im/crystal-lang/crystal?at=5e0bbbeed31dba03fdd7e388]
<FromGitter> <andrewc910> Can we debug tests with the debug flag? I have breakpoints in my tests and my tasks.json is running "crystal spec --debug'" but I can't seem to hit my breakpoints
<FromGitter> <Blacksmoke16> debug support is 😐 atm
<FromGitter> <andrewc910> I'm not use to brand new programming languages 😭 Just trace the code one line at a time then?
<FromGitter> <Blacksmoke16> pp is your friend :p
<FromGitter> <randiaz95> print that badboy
<FromGitter> <randiaz95> before and after
alexherbo2 has joined #crystal-lang
early has quit [Quit: Leaving]
alexherbo2 has quit [Ping timeout: 258 seconds]
<FromGitter> <Blacksmoke16> so think imma refactor my validation shard a bit
<FromGitter> <Blacksmoke16> internally at least
<FromGitter> <btihen> @stnluu_twitter & @randiaz95 - I have two versions of using channels and fibers at: https://github.com/btihen/crystal_channels - It works pretty well. I next want to figure out how to create multiple TCP or windows (one for each user). I realized when doing the chat room - using one thread works well - but compiliing with multiple cores - outputting to one screen gets jumbled again. I'll happily learn more
<FromGitter> ... about multiple connections (I assume I need to use TCP sockets) - could I also use OS sockets?
<FromGitter> <stnluu_twitter> who is doing the output to screen?
<FromGitter> <stnluu_twitter> remember yesterday, we discussed about ideally, there's a "room" object that keeps track of all the users, and does the job of broadcasting the message–instead of each user keeping track of all the other users?
<FromGitter> <stnluu_twitter> ideally, this "room" object should be the one doing the output to screen, aka only one fiber doing the output.
<FromGitter> <stnluu_twitter> @watzon ooh. how is a record different from a struct?
<FromGitter> <watzon> It's just a simplified syntax for creating a Struct with a default initializer
<FromGitter> <Blacksmoke16> also defines getters and some ways to copy it
<FromGitter> <watzon> You can also do ⏎ ⏎ ```record Foo, name : String, id : Int32 do ⏎ def do_something ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5e0bc11cb4ed68096e0d4a28]
<FromGitter> <stnluu_twitter> nice!
<FromGitter> <stnluu_twitter> didnt see this in the doc
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/toplevel.html#record(name,*properties)-macro
<FromGitter> <watzon> Yeah there are a lot of things like this that aren't well documented
<FromGitter> <watzon> I don't think it's in the Book at all
early has joined #crystal-lang
<FromGitter> <btihen> @stnluu_twitter - I am doing what you suggested. I just did a short-cut and run everything within a module. And so it all outputs to the screen where I kick off the module. So for parellelism - I guess I need to start the room as a server and each user needs to spin off its own window? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e0bc3df07a1a67d1d8e9e28]
<FromGitter> <btihen> @stnluu_twitter - each `user` outputs to their own `stdout` - but I only create one stdout.
<FromGitter> <btihen> @stnluu_twitter - hmmm - yes if room did all the output then it would work - I was trying to simulate where the room re-broadcasts to everyones - phone or something like that - where the client does the actual output in a 1-many scenaraio
<FromGitter> <btihen> Anyway, I need to sleep - but thought I would post the repo as we discussed and if any of the code would be helpful for explaining channels to others - I would be happy to post it someplace helpful. I'll look at the TCP and socket docs tomorrow.
<FromGitter> <stnluu_twitter> this is awesome!
alex`` has joined #crystal-lang
<FromGitter> <btihen> @stnluu_twitter If you're referring to the channels repo - I am certainly glad for your ideas and clarifications yesterday. feel free to comment on or suggest changes.
<FromGitter> <btihen> Happy new year!
<FromGitter> <btihen> Thanks for crystal.
<FromGitter> <stnluu_twitter> happy new year!
<FromGitter> <stnluu_twitter> it's still the 31st where i am :D
ur5us has joined #crystal-lang
return0e has quit [Ping timeout: 258 seconds]
return0e has joined #crystal-lang
oprypin has quit [Quit: Bye]
oprypin has joined #crystal-lang