<FromGitter>
<kaukas_gitlab> @vladfaust, it's a great introduction for rubyists. But the devil is in the details. It is quite likely that Rails devs would look for alternatives when their Rails app is big and slow (whatever that means). By then it makes no sense to rewrite everything. Instead you want to optimise the "core parts". The only way Crystal could help is as a standalone app (somehow network-based), and that's not
<FromGitter>
... convenient. E.g. Rust can be used to write Ruby extensions (https://crates.io/crates/rutie) (not super elegant but possible) which allows to gradually improve the most painful parts only, and then later possibly take over the whole app. Crystal can not do that yet, not without MT support and a good binding shard.
<FromGitter>
<kaukas_gitlab> In comparison, Sorbet is very gradual and you do not *have* to infect your files with `T::Sig`s, `.rbi`s are supposed to be auto-generatable, so largely out-of-sight.
<FromGitter>
<vladfaust> It doesn't matter. The main goal is to raise the language awareness
<FromGitter>
<kaukas_gitlab> Yes, I guess awareness is important. More eyes means more hands to fix problems. That said, the thoughts above are from a person who actually tried to use Crystal in a Ruby app, and failed. Since you are comparing Ruby+Sorbet to Crystal the details on how to integrate (not as a lib) and what performance to expect (problematic compile times) could be relevant for any non-green field project.
alexherbo29111 has joined #crystal-lang
alexherbo2911 has quit [Ping timeout: 245 seconds]
<FromGitter>
<jackturnbull> Howdy folks. Does anyone know if iterating over Postgres result-sets is thread (or fiber) safe? I'm setting an ID cache outside of the ResultSet `each` block and I'm expecting there to be an ID in an array for the second row, but there isn't. I'll not drop my full code but I've got something like; ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ So it appears that the first push of the ID into the cache
<FromGitter>
<jackturnbull> Am I missing something fundemental?
<FromGitter>
<jackturnbull> I had posted a message but I've solved my own issue, so I'll remove it to save clutter, but for anyone that did see it; *user error, incorrectly resetting my cache on first iteration*
<FromGitter>
<Blacksmoke16> i think that's what he wanted?
<FromGitter>
<j8r> it's not a good idea to monkey patch the stdlib
<FromGitter>
<Blacksmoke16> oh well
<FromGitter>
<yxhuvud> It would definitely make sense as a lib though. There are a couple of lapack bindings, but doing a full lapack/BLAS implementation is a lot of work, and it is largely orthogonal to having a nice and workable API against a matrix.
<z64>
i don't know about INT, but thats what docker does - it sends TERM to give the app a chance to do a graceful cleanup, and after a long timout period, kills it
<jokke>
yeah except if you start it with docker run and hit ctrl-c
<jokke>
then it seems to send an INT
<z64>
yes, if you're attached, it will behave like a normal terminal and send sigint. but for production, you need to handle `TERM` sent by the docker daemon
<wakatara>
I am getting what would be strange behaviour moving over from ruby to crystal. I am trying to sort an array of hashes and using a .sort_by{|h| [h.date, h.habit]} but this is causing a weird error: no overload matches 'String#<=>' with type (String | Time)
<wakatara>
What I"m trying to do is do a bilevel sort where I get things sorted by date and then by the string habit, but I'm assuming I'm doing it wrong in Crystal land.
<wakatara>
Can anyone give me an idea of the correct way to do this? (again, I'm sorting an array of hashes one of which has a Time type, the other a String - in case hat was not obvious)
<FromGitter>
<jwoertink> You could go `h.date.to_s("%Y-%m-%d")` or whatever
<wakatara>
jwoertink: I had assumed that would not work because the system is translating the read file from the %Y-%m-%d fromat into something like @date=2019-04-29 00:00:00.0 +07:00 Local in the Struct. Why does that work?
<wakatara>
(it does seem to compile without error... just curious though, since I would never have thought of that.
<FromGitter>
<jwoertink> @nsuchy I replied to your post. Also, another idea is maybe go through the bug label issues, and look to see if that bug is still reproducible in the latest release on different systems. That could be a bit time consuming, but might help close out some old issues no longer relevant
<FromGitter>
<jwoertink> My guess was that your overload error was because of the Union. I figured 2 String objects would work.
<FromGitter>
<jwoertink> But that was purely a guess lol
<Yxhuvud>
wakatara: the type of [h.date, h.havit] is Array(String|Time). Try to change it to {h.date, h.habit}
<Yxhuvud>
that at least has a chance of working :)
<Yxhuvud>
Tuples have positional typing, arrays do *not*.
<wakatara>
Yxhuvud: Ah, yes, {h.date, h.habit} works
<wakatara>
Thank you. I think I need to read up on why both seemed to work, but the second seems to work properly. POints for jwoertink though since it certainly _seemed_ plausible what he was saying. Lol.
<Yxhuvud>
what he was saying was true, just not the efficient and clean solution :)
<wakatara>
It's kinda cool that both work, but I would not have thought of the first one but was going for the first one just from more idiomatic ruby.
<wakatara>
One other niggling thing: I am writing a CLI app. When I use a `results = get` for command line input, I am being asked for it on a new line rather on the same line after after the prompt.
<wakatara>
I'm gathering there is an easy way round it in Crystal but just don't know the idiom. Does anyone?
<z64>
wakatara: check how you are printing the prompt. if its using `puts`, a newline will be written at the end. using `print "foo"` will omit this newline
alexherbo2 has joined #crystal-lang
<wakatara>
z64: thank you!
wakatara has quit []
olbat[m]2 is now known as olba4
olba4 is now known as olba6
rohitpaulk has joined #crystal-lang
alexherbo22 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 258 seconds]
<Yxhuvud>
that behaviour is the same in ruby, FWIW.
olba6 is now known as olbat[m]
<FromGitter>
<mwlang> what's the correct way to cast to a specific type from a NamedTuple? For example, I need to convert to Symbol from a NamedTuple that contains Float64 and Symbol values.
<FromGitter>
<mwlang> @pivot_kind = options.fetch(:pivot_kind, :traditional) => instance variable '@pivot_kind' of Indicators must be Symbol, not (Float64 | Symbol)
<FromGitter>
<mwlang> I've largely just been tacking on .to_f64 or .to_i32, or .to_s and so on, but starting to wonder if this is the idiomatic way to do it.
<FromGitter>
<kinxer> @vladfaust Lack of Windows support is the barrier of inconvenience that keeps me from programming in Crystal at home. I work primarily on Linux at my job, and that's where I was exposed to the language and have been using it, but my personal desktop is Windows 7, and it's just not convenient for me right now to add another computer or Linux partition to my home setup.
<FromGitter>
<lsymonds> @kinxer Can you not use Cygwin? Or upgrade to Windows 10 (if possible) and use WSL?
<FromGitter>
<lsymonds> Granted it's not ideal to do that
alexherbo223 has joined #crystal-lang
<FromGitter>
<kinxer> I mean, there are certainly workarounds. That's why I described it as a barrier of inconvenience. I could certainly use Cygwin or Windows 10 ($$$), or I could even set up a Linux VM using Vagrant and a shared directory (something I use heavily at work) and run my code from that.
alexherbo22 has quit [Ping timeout: 252 seconds]
<FromGitter>
<kinxer> It's just that my personal motivation to work on Crystal side projects (which is, of course, not something the language can fix) isn't great enough to overcome the inconvenience.
<FromGitter>
<kinxer> Which is why I've recently just been doing side stuff in Python, since it's easy to write in (for the little stuff I'm using it for) and has native Windows support. Of course, it's slow.
rohitpaulk has quit [Ping timeout: 246 seconds]
rohitpaulk has joined #crystal-lang
return0e has quit [Ping timeout: 268 seconds]
return0e has joined #crystal-lang
<FromGitter>
<watzon> Is it possible to run `HTTP.get` through a SOCKS proxy?
<FromGitter>
<straight-shoota> No, it's currently tied to a TCP transport
<FromGitter>
<straight-shoota> But there are plans to change that
<RX14>
@straight-shoota if there's any PR that just needs a second review that i've missed in the past few months (just cleaned out my github inbox) please let me know
<FromGitter>
<j8r> @mwlang very often, there is a better way than using `Symbol` and `NamedTuple`
<FromGitter>
<j8r> The idiomatic way is to used records
rohitpaulk has quit [Remote host closed the connection]
<FromGitter>
<mwlang> Makes no sense: @pivot = ((high.to_f64 + low.to_f64 + close.to_f64) / 3.0).to_f64 => Can't infer the type of instance variable '@pivot' of Pivot
<FromGitter>
<mwlang> trying to figure out where the compiler is failing to infer correct type, so I appended #to_f64 on everything and still get the error.
<z64>
@mwlang the compiler currently doesn't know the return type of the expression that makes a call like that (it doesn't know what `.to_f64` returns yet, etc) - see this more basic example https://carc.in/#/r/6uvz
<z64>
in this case you have to add an annotation, `@pivot : Float64` in the type body somewhere
lucasb has quit [Quit: Connection closed for inactivity]
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
<FromGitter>
<bew> This is pretty cool: https://carc.in/#/r/6uw4 aka being able to override any system behavior with fake ones (here, for the system ENV)
<FromGitter>
<bew> this could be used to fake everything in specs very easily! (filesystems, stdin/out, time, env)
<FromGitter>
<bew> I'm loving this, will start a shard I think
Liothen has quit [Ping timeout: 248 seconds]
_whitelogger has quit [Ping timeout: 248 seconds]
sz0 has quit [Quit: Connection closed for inactivity]
laaron has quit [Remote host closed the connection]