RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.27.0 | 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
Raimondi has quit [Ping timeout: 240 seconds]
marmotini_ has joined #crystal-lang
<FromGitter> <theretromaniac> Is anybody here, newbie like me to crystal or no newbie, who has free time to work with me some ideas?
<FromGitter> <theretromaniac> Open source of course. If anyone pm me.
<FromGitter> <Blacksmoke16> mm i love macros
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c37fa0b5aa04d46c58f4619]
<FromGitter> <theretromaniac> 👍
marmotini_ has quit [Ping timeout: 240 seconds]
gangstacat has quit [Ping timeout: 245 seconds]
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
Raimondi has joined #crystal-lang
spacemanspam has joined #crystal-lang
DTZUZO has quit [Ping timeout: 244 seconds]
DTZUZO has joined #crystal-lang
DTZUZO has quit [Ping timeout: 250 seconds]
DTZUZO has joined #crystal-lang
spacemanspam has quit [Read error: Connection reset by peer]
_whitelogger has joined #crystal-lang
marmotini_ has joined #crystal-lang
marmotini_ has quit [Remote host closed the connection]
marmotini_ has joined #crystal-lang
marmotini_ has quit [Ping timeout: 246 seconds]
marmotini_ has joined #crystal-lang
<FromGitter> <j8r> I need to benchmark if a case/when is more efficient than a Hash. I would say yes
gangstacat has joined #crystal-lang
laaron has quit [Remote host closed the connection]
marmotini_ has quit [Ping timeout: 258 seconds]
laaron has joined #crystal-lang
DTZUZO has quit [Ping timeout: 244 seconds]
livcd has quit [Remote host closed the connection]
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
<FromGitter> <bew> @j11m is the callback called from a different thread than the one running crystal fibers etc..? That would explain your problem i think
<FromGitter> <talbergs> @maiha can we talk?
<FromGitter> <talbergs> @maiha can we talk?
ashirase has quit [Ping timeout: 272 seconds]
marmotini_ has joined #crystal-lang
DTZUZO has joined #crystal-lang
ashirase has joined #crystal-lang
<mps> malkomalko: I'm on the mid of reading this book. Well, not impressed but it is ok. I expected more from it because it is named "Programming Crystal"
<FromGitter> <proyb6> Saw another benchmark which is unheard of
<FromGitter> <proyb6> Last tested Go is faster than Crystal by 3 seconds
<FromGitter> <j8r> @proyb6 thanks
<FromGitter> <j8r> GO/C/C++/Crystal are close
<FromGitter> <j8r> what's strange is Rust/Nim, they are much slower
<FromGitter> <theretromaniac> I will give julia a try 😂
<FromGitter> <Sija> @vladfaust thanks for the tip about buildkite, that stuff looks rad!
<FromGitter> <vladfaust> Yeah, @Sija. The only con is that they don’t have publicly readable pipelines yet, however, this feature is in private beta now and I’m sure it will be available to everyone soon 👍
chemist69 has joined #crystal-lang
<FromGitter> <proyb6> @j8r
<FromGitter> <proyb6> I was more concern if both Crystal could be faster here, we haven’t fell off the chair yet
<FromGitter> <j8r> Does someone succeed to connect to an IPv6 database with crystal-mysql? I can execute `mysql -u root -h ::1 --port=4000` but `DB.open "mysql://root@[::1]:4000" {}` returns `Unhandled exception: getaddrinfo: Temporary failure in name resolution (Socket::Error)`
mps has quit [Ping timeout: 250 seconds]
<FromGitter> <j8r> but it works with @localhost :|
<FromGitter> <yxhuvud> @proyb6 I'm more wondering why crystal seems to have bad precision. Do we have the equivalent of the fast-math compilation optimization flag set?
<FromGitter> <j8r> and with localhost I have `Can not prepare DDL statements` :(
<FromGitter> <j8r> for `db.exec "CREATE DATABASE test_db"`
spacemanspam has joined #crystal-lang
mps has joined #crystal-lang
Raimondi has quit [Ping timeout: 240 seconds]
<FromGitter> <vladfaust> I would be happy if the language had busyloop detection. Have to disable the codebase method-by-method to find out where it is :(
<FromGitter> <proyb6> @yxhuvud
<FromGitter> <proyb6> Love to know it too
<FromGitter> <vladfaust> TIL `Channel.send` blocks :thinking:
<FromGitter> <j11m> @bew That was it. I was able to prove it by looking at the pthread ID in the C Callback.
<FromGitter> <j8r> what can be the causes of `Can not prepare DDL statements`?
<FromGitter> <j8r> (I pass an URI to DB.open to fix the IPv6 parsing issue, mysql don't want brackets)
<jokke> hey
<jokke> how can i make a relative symlink in crystal?
<jokke> i have two absolute paths
<jokke> one being the source and the other the target
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/0.27.0/File.html#symlink(old_path,new_path)-class-method prob that?
spacemanspam has quit [Read error: Connection reset by peer]
marmotini_ has quit [Ping timeout: 258 seconds]
<FromGitter> <j8r> my db doesn't seems to support `PREPARE`, and crystal-db use it :(
<jokke> yeah but that's not relative
<jokke> there's a -r flag in ln
<FromGitter> <Blacksmoke16> ah, welp
<rkeene> `ln` doesn't need any "-r" flag; A symlink is just a file with the destination as the contents and a special mode
<FromGitter> <j8r> jokke you can `split('/')` and perform operations
<jokke> yeah i guess
<jokke> rkeene: it does
<FromGitter> <j8r> but the best would be to wait for `Path`
<jokke> rkeene: there are use cases for the -r flag
<jokke> oh Path is in the making?
<FromGitter> <j8r> there is a PR
<FromGitter> <l3kn> @j8r @proyb6 All the programs are compiled without optimizations, with `--release` or `-O3` C, crystal and rust run at the same speed
<FromGitter> <straight-shoota> yeah #5635
<jokke> j8r: cool!
<FromGitter> <straight-shoota> But it only provides a generic API for handling paths. Not direct file system integration.
<FromGitter> <straight-shoota> And I'm not sure if that should even be added to the Path type. This still needs to be debated. The next step is to get `Path` merged. Maybe soon.
<FromGitter> <straight-shoota> Anyway, I don't think "wait for `Path`" would be best
Yxhuvud has joined #crystal-lang
<jokke> yeah no but it could have some method like #relative_to(other)
<FromGitter> <j8r> 🎉`db.unprepared("CREATE DATABASE test_db").exec`
<FromGitter> <straight-shoota> jokke, yes the inverse of `#expand`. It should definitely be added, but is not yet included in the current PR.
<FromGitter> <straight-shoota> @j8r What database are you using that doesn't support prepared statementsß
<FromGitter> <straight-shoota> ?
<FromGitter> <j8r> https://github.com/pingcap/tidb (even when setting `run-ddl = true`)
<FromGitter> <j8r> @straight-shoota
chemist69 has quit [Ping timeout: 260 seconds]
<FromGitter> <straight-shoota> It says `Easily replace MySQL with TiDB [...] without changing a single line of code in most cases`. That would be a very bold statement if it doesn't support prepared statements...
marmotini_ has joined #crystal-lang
<FromGitter> <j8r> maybe I need to setup their TiKV... I've only ran the standalone tidb-server binary
<FromGitter> <j8r> or perhaps configuring their `prepared-plan-cache`
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
mps has left #crystal-lang [#crystal-lang]
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
<FromGitter> <proyb6> @l3kn Thank for filing an issue in that repo, forgot about the missing optimization part!
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
<FromGitter> <proyb6> @l3kn On macOS, Crystal and C don't run at the same speed which golang is almost the same speed as C in optimization build.
marmotini_ has quit [Ping timeout: 244 seconds]
marmotini_ has joined #crystal-lang
<FromGitter> <girng> is it possible to limit floats to 2 decimals without converting them to a string `"%0.2f" % floatvalue`?
<FromGitter> <girng> for example, when increasing a float value in my game loop per tick by a percentage.. it will be 5.9999999 then 6.12333333 or whatever, instead of just 5.9 and 6.1
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/0.27.0/Number.html#round(digits=0,base=10)-instance-method ?
<FromGitter> <greenbigfrog> Any idea why the comparsio isn't working here? https://gist.github.com/greenbigfrog/89e2edffaed65d8b0b9ae064c1ee3ea3
<FromGitter> <girng> @Blacksmoke16 THANK YOU
<FromGitter> <r00ster91> @greenbigfrog what error do you get?
<FromGitter> <greenbigfrog> none. the `unless ex == DB::PoolRetryAttemptsExceeded` isn't working. ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c38e40783c7e3776553c6a6]
<FromGitter> <greenbigfrog> ```pp ex ⏎ pp ex == DB::PoolRetryAttemptsExceeded``` [https://gitter.im/crystal-lang/crystal?at=5c38e4d29289cc7aa75a9dcf]
<FromGitter> <r00ster91> replace `rescue ex` by `rescue ex : DB::PoolRetryAttemptExceeded`
<FromGitter> <r00ster91> this will only catch this kind of error
<FromGitter> <girng> is it okay pass a class to a method? like, a large one with a lot of the property macros? does everything get copied or is it a reference?
<FromGitter> <r00ster91> but `ex.is_a?(DB::PoolRetryAttemptExceeded)` would work too @greenbigfrog
<FromGitter> <greenbigfrog> I want to catch all, but only send a discord message if it's not a RetryAttemptExceeded
<FromGitter> <greenbigfrog> thanks
<FromGitter> <greenbigfrog> why is exception equality not determined via message?
<FromGitter> <r00ster91> you could determine exception equality with `ex.message == "Pool retry attempts exceeded` too. Or do you mean something else?
<FromGitter> <greenbigfrog> I'm using `is_a?` now ⏎ ⏎ But I'm wondering why `Exception` doesn't have this method, instead of using `Reference#==` ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c38e89d2e25e453d767c7ec]
<FromGitter> <girng> https://play.crystal-lang.org/#/r/5z22/edit does this confirm classes are passed by reference?
<FromGitter> <Blacksmoke16> well they are
<FromGitter> <Blacksmoke16> structs are not
<FromGitter> <Blacksmoke16> i.e. if you change it to a struct, it would still be -0
<FromGitter> <girng> okay thank goodness. cause i have over 45 properties on my Client class. and i have some methods that get some data from the class object to build a string, or whatever
<FromGitter> <girng> i can't imagine copying all the data, i think reference is better right
<FromGitter> <Blacksmoke16> not sure tbh
spacemanspam has joined #crystal-lang
<FromGitter> <Blacksmoke16> afaik, correct me if im wrong, is better to use structs when the data is immutable as it allocates memory in a more efficient location
<FromGitter> <girng> yeah my data is mutable so i chose a class
<FromGitter> <kingsleyh> evening :)
<FromGitter> <Blacksmoke16> o/
<FromGitter> <girng> o/
<FromGitter> <kingsleyh> I'm super excited about Crystal
<FromGitter> <girng> :D
<FromGitter> <kingsleyh> Pity there's no Crystal jobs that pay like my job does - I had this same problem with Ruby but after 10 years of waiting its still not there! This time ill have to drop my salary to take a low paid Crystal job when it starts getting popular or ill miss out on all the fun!!
<FromGitter> <rishavs> guys, to use `Digest::SHA1.hexdigest`, do i need to require something?
marmotini_ has quit [Ping timeout: 250 seconds]
<FromGitter> <kingsleyh> probably need to do something like `require "digest/*"`
marmotini_ has joined #crystal-lang
<FromGitter> <kingsleyh> @rishavs ^^
<FromGitter> <kingsleyh> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c38f95754d8bb07ccd5a779]
<FromGitter> <greenbigfrog> Any ideas why I'd get `undefined method 'query_all?' for DB::Database` at one place, but it works at a other? And also, `query_all` works just fine
<FromGitter> <girng> is it losing the db connection perhaps?
marmotini_ has quit [Ping timeout: 258 seconds]
<FromGitter> <kingsleyh> is query_all? even a method?
<FromGitter> <girng> yeah a query method
<FromGitter> <girng> i just use `query_all` without the `?` in my code
<FromGitter> <kingsleyh> I dont see `query_all?` anywhere in the API http://crystal-lang.github.io/crystal-db/api/0.5.1/
<FromGitter> <kingsleyh> only `query_all`
<FromGitter> <girng> oh yeah there is none for the `?`
marmotini_ has joined #crystal-lang
<FromGitter> <kingsleyh> so maybe @greenbigfrog made a typo? as the error says `query_all?`
<FromGitter> <girng> possibly. he does say it works at a other location so hmm...
<FromGitter> <kingsleyh> maybe his particular db driver implements `query_all?` and it works there - but when it's running in the scope of the base - it doesn't exist - or something like that
<FromGitter> <girng> good point
<FromGitter> <kingsleyh> since it really doesn't exist in the base
<FromGitter> <kingsleyh> @Girng - I'm going to be streaming my godot development on Twitch over here if you feel like hanging out while I'm streaming and giving me godot tips ;) https://www.twitch.tv/guardiansofaxum
marmotini_ has quit [Ping timeout: 250 seconds]
<FromGitter> <girng> lol i'll check it out
<FromGitter> <girng> i followed
<FromGitter> <greenbigfrog> should work at both locations. Pushing in a moment
<FromGitter> <rishavs> thanks @kingsleyh
<FromGitter> <girng> NICE. `round(2)` is a life savior
<FromGitter> <kingsleyh> thanks @girng :)
<FromGitter> <kingsleyh> I'll give you a shout out in my streams :)
<FromGitter> <girng> LOL :D
mps has joined #crystal-lang
<FromGitter> <domgetter> I'm having a weird issue with cross compiling my sdl/opengl wrapper to windows from WSL. I can get triangles on the screen just fine, but if I put my triangle-drawing-code in a block, then it stops working if I declare certain variables outside the block. https://gist.github.com/domgetter/19bb6e405d8f7d9a8eabecc178bee819
<FromGitter> <domgetter> I can get it all to work simply by not using the block version of the method I wrote, so I have a workaround, but I would like to know why it's doing this. Is it possibly a cross compiling bug? I know that's a WIP, so if it's a bug, what do you think I should do to notify or report the issue?
spacemanspam has quit [Read error: Connection reset by peer]
spacemanspam has joined #crystal-lang
spacemanspam has quit [Read error: Connection reset by peer]
powerbit has joined #crystal-lang
<FromGitter> <fridgerator> The one in coin.cr doesn't have a `?`
<FromGitter> <theretromaniac> biggest bugs is always a question mark…
<FromGitter> <theretromaniac> or a comma
<FromGitter> <greenbigfrog> > Any ideas why I'd get `undefined method 'query_all?' for DB::Database` at one place, but it works at a other? And also, `query_all` works just fine ⏎ sorry. this was a follow up to this
devil_tux has quit [Ping timeout: 260 seconds]
Raimondi has joined #crystal-lang
Raimondi has quit [Ping timeout: 240 seconds]
<FromGitter> <swordglowsblue> Hey there, just wondering if there's some way to get a list of all compile-time flags that a Crystal source was compiled with? I know about the `flag?` macro method, but I'd like to see what flags show up where, and you kind of have to know that for `flag?` to be useful.
<FromGitter> <swordglowsblue> For example, it'd be nice to be able to have code that is only compiled when run with `crystal spec`.
<FromGitter> <Blacksmoke16> im pretty sure you can already do it
<FromGitter> <Blacksmoke16> `crystal spec -D my_flag`
<FromGitter> <swordglowsblue> Yes, I know how to set flags. If there's a way to see in macro code exactly what flags are set (without knowing ahead of time in order to use `flag?`), I'd like to know of it.
<FromGitter> <Blacksmoke16> sorry im not sure i follow
<FromGitter> <Blacksmoke16> you can set flags to anything at compile time so it doesnt really matter which are set
<FromGitter> <swordglowsblue> I'd like to, for any given compilation, print out a list of flags that are set.
<FromGitter> <Blacksmoke16> oh, like that you compiled the binary with?
<FromGitter> <swordglowsblue> At compile time, preferably, but yes.
<FromGitter> <Blacksmoke16> mm dont think there is a way to get that atm
<FromGitter> <swordglowsblue> Alright, thanks =)
<FromGitter> <Blacksmoke16> still not sure why you would need that tho :p
<FromGitter> <swordglowsblue> Mostly just curious what different commands compile with. Purely academic.
<FromGitter> <Blacksmoke16> like in your own program or crystal stdlib
<FromGitter> <swordglowsblue> As in command line options, like `crystal run` vs `crystal spec` and such.
<FromGitter> <Blacksmoke16> oh
<FromGitter> <Blacksmoke16> just do `crystal --help`
<FromGitter> <Blacksmoke16> tada
<FromGitter> <swordglowsblue> You still misunderstand me lol, sorry
<FromGitter> <swordglowsblue> I'm interested in what compile-time flags (as in, visible to `flag?`) are set by different subcommands.
<FromGitter> <Blacksmoke16> ah, as in what they pass in under the hood?
<FromGitter> <swordglowsblue> Yeah
<FromGitter> <Blacksmoke16> they're mostly used for OS differences afaik
<FromGitter> <Blacksmoke16> like depending on if os is 32 or 64bit
<FromGitter> <Blacksmoke16> afaik spec/run dont pass any on their own
<FromGitter> <swordglowsblue> I expected as much, but I figured it would at least make for an interesting question, and potentially be useful if they did.
<FromGitter> <Blacksmoke16> could maybe just search for `flag?` in the stdlib and see the examples that are used
<FromGitter> <swordglowsblue> Yeah. It's not important, was just wondering. Thanks for the help!