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
alex`` has joined #crystal-lang
gangstacat has joined #crystal-lang
<raz> hmm. i may be last to the part, but today i realized something. lucky is basically to crystal what rails is to ruby.
<raz> i.e. it uses every dirty trick and language magic to make web dev less painful.
<raz> coming from rails it's kinda like upgrading from an idea that didn't quite work out, to a new version of that idea on a much more solid foundation (albeit less mature)
<FromGitter> <Daniel-Worrall> As kemal is to sinatra
<raz> yeh but kemal leaves a bit of a bad aftertaste with the global stuff (i feel like it's likely gonna be superseded by one of the cleaner alternatives soon)
<FromGitter> <Blacksmoke16> kemal is essentially just a fancy router
<raz> on lucky i'm not really decided yet. so far it feels damn good. it's dirty macros galore, but the straightjacket that is crystal (errors at compile rather at runtime, yay!) realllllly helps.
<FromGitter> <Daniel-Worrall> Removing the global pollution is in the works, but the developer has been quite irl busy
<FromGitter> <Blacksmoke16> athena is also getting pretty slick, im a bit biased tho :P
<FromGitter> <Blacksmoke16> not as mature as lucky/amber tho
<raz> yeh, i'm def not hating on kemal (have used it in almost every crystal app). it's great - the global pollution is really the only wart for me.
<raz> yea haven't looked a athena yet (ought to soon). dabbled with amber some, but it's kinda too railsy to me. not taking advantage of crystal the way lucky does.
<FromGitter> <Blacksmoke16> https://athena-framework.github.io/athena/Athena/Routing/Controller.html gives you the jist of things
<FromGitter> <Blacksmoke16> is an example controller and comments and such
<raz> hm yea, doesn't look bad at a glance (but also not quite "woah, wait wot" like lucky ;))
<FromGitter> <Blacksmoke16> lucky deff has it beat for server rendered html
<FromGitter> <Blacksmoke16> that hasnt been a focus
<FromGitter> <Blacksmoke16> what made you say "whoa, wait wot"? :p
<raz> yeh, i mean options are great in any case. all of them are a breath of fresh air
<raz> mainly the type-safe SQL, well, type-safe everything
<raz> and the "write your html as crystal"
<FromGitter> <Blacksmoke16> indeed, been focusing on the framework/core parts mainly as REST api framework
<raz> yeah a lighter weight api-only framework would def also be great
<raz> prob wouldn't use lucky for something small, it's quite a beast
<FromGitter> <Blacksmoke16> benchmarks i did was like 10-20k less than kemal in terms of requets/sec
<FromGitter> <Blacksmoke16> requests
<raz> *shrug*
<raz> so you mean it's only 500 times faster than anyone needs rather than 600 times? :P
<FromGitter> <Blacksmoke16> idk whats up with lucky in https://github.com/the-benchmarker/web-frameworks, they down at 23k :(
<FromGitter> <Blacksmoke16> (dont mind athena, is an old version that got broken when the repo migrated to docker containers since it doesnt have the right env var anymore so is writing logs to files and shit)
<FromGitter> <Blacksmoke16> waiting on crystal `0.32.1` in alpine to update it
<raz> as long it's not ruby-slow that isn't a big deal in practice
<FromGitter> <Blacksmoke16> yea for sure, just has to be fast enough
<raz> 23k/s per server is unlikely to become a bottleneck ;)
<FromGitter> <Blacksmoke16> ouch lol, rails is like 3k
<FromGitter> <Blacksmoke16> didnt realize it was *that* bad
<raz> yea, and that's still plenty for pretty much any app
<raz> rails problem is less the performance and more the uncontrollable memory leakage
<raz> i guess vanilla rails isn't to blame for that. but then you add gems and stuff. i have yet to see a real world rails app that doesn't leak like a sieve
<FromGitter> <Blacksmoke16> i come from a non ruby background, so been taking a bit diff approach
<FromGitter> <Blacksmoke16> has been nice, combining the things i like from each framework
<FromGitter> <Blacksmoke16> that i worked with*
<raz> yea, really interesting stuff coming up on crystal. also love the rate at which it happes
<raz> still discovering new gems almost every week
<FromGitter> <Blacksmoke16> have to see what is around a year from now
alex`` has quit [Ping timeout: 268 seconds]
<FromGitter> <watzon> @straight-shoota where would you say marionette belongs in the shardbox catalog?
<FromGitter> <watzon> I was thinking maybe testing, but while it can be used for testing it's not really testing related. I just can't think of a category that fits better.
mistergibson has joined #crystal-lang
<FromGitter> <grkek> Wouldn't it be nice to have an auto resolver for the class name definitions to the stdlib of crystal / lib's found in the lib folder, What I mean is that it would be perfect for the vs code crystal plugin just to click on the class with Ctrl + Click which opens the local file which contains the class or just redirects you to the crystal API :^), might even open the local docs of the crystal api, that would be
<FromGitter> ... nice as well if not having internet is a problem there might already be a local version of the API but yeah you get the picture.
<FromGitter> <watzon> So goto definition
<FromGitter> <grkek> yeah
<FromGitter> <grkek> goto definition
<FromGitter> <grkek> for the extension would be nice ?
<FromGitter> <watzon> Well yeah, and it's on the roadmap for Scry, but that project hardly gets any love
<FromGitter> <grkek> Scry ?
<FromGitter> <watzon> I wouldn't expect a good language server with that implemented until post v1
<FromGitter> <grkek> can you link me that
<FromGitter> <grkek> Oh yeah I remember now how much pain it is to write a plugin for vscode
<FromGitter> <watzon> It is a pain
<FromGitter> <watzon> But less so than with Sublime at least
<FromGitter> <grkek> Oh sublime is horrific
<FromGitter> <watzon> Yes. Yes it is.
yukai has quit [Ping timeout: 240 seconds]
_ht has joined #crystal-lang
_ht has quit [Remote host closed the connection]
alex`` has joined #crystal-lang
<repo> raz: i felt exactly the same way as you about lucky
<repo> i've been a rails dev for a few years but also migrated away from it for almost every project. Usually built something on top of sinatra or hanami. With crystal i'm still looking for something that's modular enough and easy enough to set up. I have some issues with the way lucky presumes the directory structure. Which makes all their generators pretty much useless to me. Maybe more their
<repo> namespacing than directory structure.
<repo> but they're definitely going in the right direction
<repo> currently i'm giving Athena a go. I really like it for it's modularity and that it doesn't care how i structure my project. I use it together with crecto.
sagax has quit [Ping timeout: 260 seconds]
<raz> hmm yup, rails apps always get muddled and nasty in the end. and then you have to update to the next major version, stuff breaks in funny ways...
<raz> haven't yet had a problem with lucky's dir structure. i generally try to not go against the grain with that type of "all-in" framework, that tends to be a recipe for headache ;)
HumanGeek has quit [Ping timeout: 240 seconds]
sagax has joined #crystal-lang
HumanGeek has joined #crystal-lang
<FromGitter> <faustinoaq> @grkek Hi, I'm using crystal again, I was the author of crystal-vscode plugin. The current version has many workarounds, using two backends, the most sophisticated one is Scry, but we still need to fix some protocol mismatches to make it work flawlessly.
<FromGitter> <faustinoaq> I'm testing crystal-vscode and incredibly the WSL tweak I did to make it work on windows, still works to check syntax error at least.
<FromGitter> <faustinoaq> 😅
<repo> raz: that's true. Idk it's just personal preference maybe but TopLevelNamespace::Controllers::Users is much cleaner to me than UsersController in global namespace
<repo> especially since it mirrors the directory structure
<repo> (yes, i always have src/top_level_namespace/)
<repo> it's unnecessarily limiting the choices for your model names
<repo> i ran into this once with lucky and i only used it in like two pet projects
<raz> repo, yep i agree, not a fan of that either (same as with kemal)
<raz> but ultimately i've learned to avoid wrestling with frameworks over largely cosmetic decisions like that
<raz> that way lies madness.... you monkeypatch it or actively go against the grain in other ways, it comes back to bite you (none of the examples work anymore, updates break etc.)
<raz> in practice i've found namespace conflicts to be exceedingly rare, so for a monster like lucky i'm even willing to tolerate it
<raz> since for most apps where lucky is involved, lucky pretty much *is* the app ;)
<raz> i think the namespace issue is a bigger one in kemal (as that one more of a webserver-mixin than an all-encompassing framework)
Andriamanitra has joined #crystal-lang
alex`` has quit [Ping timeout: 265 seconds]
alex`` has joined #crystal-lang
duane has joined #crystal-lang
_ht has joined #crystal-lang
alex`` has quit [Ping timeout: 268 seconds]
alex`` has joined #crystal-lang
_ht has quit [Remote host closed the connection]
_ht has joined #crystal-lang
sagax has quit [Remote host closed the connection]
duane has quit [Ping timeout: 265 seconds]
<FromGitter> <grkek> @repo have you tried Grip :) ?
<FromGitter> <grkek> @faustinoaq yeah I got it to work as well but go to definition would be really nice
<FromGitter> <grkek> https://github.com/grrkek/grip
<FromGitter> <grkek> try it out :)
<FromGitter> <grkek> whopse
<FromGitter> <grkek> https://github.com/grkek/grip
<FromGitter> <grkek> I added an extra R :)
<FromGitter> <omidathari> Hi all ⏎ I am trying to write an event driven serial port program that listens on a read fiber while the main loop performs the transmitting asynchronously. ⏎ In the following program the Read Fiber blocks the main program loop and hence does not allow any transmission. The Read fiber receives data correctly. ⏎ If I set the blocking attribute to false and provide a timeout, then the main loop
<FromGitter> ... executes but the of course the Read fiber continuously times out and performs as a polling function which was not my intention. ⏎ Is this a bug? Any help is appreciated. ... [https://gitter.im/crystal-lang/crystal?at=5e31d2dabfe65274eabd2f06]
sagax has joined #crystal-lang
<FromGitter> <grkek> Try using psatebin or user ``` on both ends
duane has joined #crystal-lang
<FromGitter> <christopherzimmerman> I've been trying to add Crystal's parallelism to my library, but I must be doing something very wrong, since my benchmarks are vastly slower when using fibers, and even slower when I compile with `-Dpreview_mt`. I based this code (https://gist.github.com/christopherzimmerman/d6ee39ae8665f4cf5735f467557d3e94) off the blog post on matrix multiplication, but I must be missing something.
<FromGitter> <Blacksmoke16> building with release?
<FromGitter> <christopherzimmerman> Yea
<FromGitter> <Blacksmoke16> how many workers you using?
<FromGitter> <christopherzimmerman> Usually just the default, but tried with 8 as well.
<FromGitter> <christopherzimmerman> I've been basing everything off this repo (https://github.com/bcardiff/crystal-benchmarks)
<FromGitter> <christopherzimmerman> For build options and such
<FromGitter> <Blacksmoke16> :shrug:
antoszka has joined #crystal-lang
<antoszka> Hi guys, is there an equivalent for Rubys quoted-printable pack/unpack in Crystal?
<antoszka> as in: foo.unpack('M')[0]
<FromGitter> <tenebrousedge> you can do similar things, yes
<FromGitter> <Blacksmoke16> not in the same way tho
<FromGitter> <Blacksmoke16> mainly the newer comments
<antoszka> ok, thanks
<FromGitter> <tenebrousedge> right, IO has options
<antoszka> Yeah, that's cool, though I don't thinnk IO specifically has the quote-printable template (M).
<antoszka> I wouldn't want to reimplement it by hand as it's pretty complex
<antoszka> I think I'll just stick to Ruby for this task – it's not very performance intensive, so I should be good
<antoszka> either way, thank you :)
<FromGitter> <Blacksmoke16> got an example of it?
<FromGitter> <Blacksmoke16> https://carc.in/#/rb
<antoszka> yes, it's actually a trivial mail reformatting task:
<antoszka> splits the mail into headers + body
<antoszka> and "unfolds" the body to *not* use quoted printable
<antoszka> I can then do some other operations on the body
<FromGitter> <Blacksmoke16> working example*
<antoszka> that paste is wrong, btw, gimme a sec
<FromGitter> <Blacksmoke16> 👍
<antoszka> Here's a working one (different paste service, cause carc.in eats data): https://paste.q3k.org/paste/efGnU48L#F6SZGvnH5E53Wnfl3IeUk3MTDfm-qsFpd/URHPvhuF/
<antoszka> the e-mail has been redacted to just two headers and a short body
<antoszka> but it shows the workings → headers stay intact, body is decoded from quoted-printable
<FromGitter> <Blacksmoke16> 👍 gotcha thanks
<FromGitter> <Blacksmoke16> mm, am i missing something? doesnt seem to print anything when i run it
<FromGitter> <Blacksmoke16> diff ruby version maybe?
<FromGitter> <straight-shoota> @Blacksmoke16 It's probably just a paste service and doesn't run the code like carc.in. You need to execute it locally
<antoszka> yeah
<FromGitter> <Blacksmoke16> well yea i did
<antoszka> here's an updated paste
<antoszka> with the script output
<antoszka> it basically just decodes quoted-printable body
<antoszka> removes the `=` multiline trick
fifr has joined #crystal-lang
<FromGitter> <Blacksmoke16> https://repl.it/repls/RustyThoughtfulNasm
_ht has quit [Quit: _ht]
<FromGitter> <Blacksmoke16> regex doesnt seem to match on there or locally (mac)
<antoszka> repl.it probably changes the newline chars
<antoszka> so it's not \x0a\x0a anymore
<antoszka> (the delimiter between headers and body)
<FromGitter> <Blacksmoke16> ah good call
<antoszka> anyway, I think you see the point now ;)
<FromGitter> <straight-shoota> It works with `\s\s`
<antoszka> ack
sagax has quit [Read error: Connection reset by peer]
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/8h26 well that not what i was expecting ha
<antoszka> :)
<antoszka> it eats up the `eml` var anyway
<antoszka> like it did for me :)
<antoszka> anyway, I think I won't be wasting your time anymore
<FromGitter> <Blacksmoke16> locally is the same thing
<antoszka> was just curious if I could compile a nice crystal programme for this particular task
<FromGitter> <Blacksmoke16> oh nvm i see the problem
<antoszka> will stick to ruby for now and keep learning crystal for other stuff ;)
<antoszka> thanks!
<antoszka> if you find a solution I'll peek here later on
<FromGitter> <Blacksmoke16> there is like https://crystal-lang.org/api/master/String.html#dump_unquoted(io:IO):Nil-instance-method but im not sure if thats what you want
<FromGitter> <straight-shoota> No, that's entirely different
<FromGitter> <straight-shoota> => https://en.wikipedia.org/wiki/Quoted-printable
<FromGitter> <Blacksmoke16> ah interesting
<FromGitter> <Blacksmoke16> yea i dont have any idea
<FromGitter> <straight-shoota> There's no implementation of quoted-printable encoding in Crystal's stdlib. But some email shards might provide that.
<antoszka> nvm, thanks for the input ;)
Human_G33k has joined #crystal-lang
<antoszka> this is pretty urgent for me, so I don't really have the time to experiment with random shards
<FromGitter> <straight-shoota> Btw. a basic implementation is quite simple: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e320493bfe65274eabe9989]
<FromGitter> <straight-shoota> https://carc.in/#/r/8h2i
HumanGeek has quit [Ping timeout: 240 seconds]
<antoszka> yeah, but there's more to quoted printable then just the lined endings
<antoszka> oh, actually it does more
<antoszka> sorry
<antoszka> still, not sure how much of the spec/corner cases it covers
<FromGitter> <straight-shoota> Yes, it's not complete
<FromGitter> <Nicolab> Hello, ⏎ ⏎ My first Crystal shard : https://github.com/Nicolab/crystal-validator \o/ ⏎ ⏎ Freshly published, now 😃 ... [https://gitter.im/crystal-lang/crystal?at=5e3209adea9ba00b8491db24]
<FromGitter> <Nicolab> `crystal spec` and `crystal docs` are really great tools!
<FromGitter> <kinxer> @Nicolab Congrats on your first published shard! I'm not quite there yet, myself... Most of my Crystal is proprietary to my work right now.
<FromGitter> <Nicolab> @kinxer Thanks! I'm doing the opposite :) Now that I've made my hand with a Shard. I'm going to do the backend of a project for the company I work for.
<FromGitter> <Nicolab> In fact, I have a little started working the backend in Crystal. ^^
yukai has joined #crystal-lang
<FromGitter> <elorest> Is it possible to make `gets` on File be blocking so that it yields and waits for more input?
<FromGitter> <elorest> File inherits from FileDescriptor which has instance methods for #blocking and #blocking=(v)
<FromGitter> <elorest> `f.blocking = true` doesn't seem to change anything though.
<FromGitter> <kinxer> What are you trying to do? Trying to emulate `tail -f`?
<FromGitter> <elorest> That's similar to my goal as a proof of concept.
<FromGitter> <kinxer> Hm... But you're just generally trying to continue to get data from the end of a file? And if the read position is already at the end of the file, you want it to wait until the file becomes larger?
<FromGitter> <elorest> Yes.
<FromGitter> <kinxer> How often should it check whether the read position is still at the end of the file?
<FromGitter> <elorest> I'm actually trying to solve an issue I'm having with reading serial ports. With UDP/TCP and other file decriptor readers gets, read_byte etc, blocks until data is available which lets me switch fibers and wait for content.
<FromGitter> <elorest> Opening a FD serial port as a file however doesn't block but just hangs and waits.
<FromGitter> <kinxer> Can you `peek` and `sleep` if there's no data?
<FromGitter> <elorest> I don't want to check every so often I just want it to block like stdlib gets or most other IO gets.
<FromGitter> <elorest> @phortx Yeah. That's pretty much what I'm doing it just seems like a hack.
<FromGitter> <Blacksmoke16> @Nicolab ⏎ ⏎ > Not exposed by default, must be imported
<FromGitter> <kinxer> Hm... Why are you using `File` for reading file descriptors?
<FromGitter> <Blacksmoke16> whats the reasoning? if you dont use it it wouldnt be included in the binary anyway
<FromGitter> <Blacksmoke16> `name.id.chars[0] == ':' ? name[1..-1].id : name.id` im pretty sure `name.id` would work no?
<FromGitter> <Blacksmoke16> > is is a macro, no overhead during the runtime ⏎ ⏎ I'm not sure that's entirely accurate, the macro just expands to the same `Valid.xx` logic so in the end would be exactly the same runtime performance at a cost of very slightly slower compile times
<FromGitter> <Nicolab> @Blacksmoke16 "Not exposed by default, must be imported" Did I make a mistake in my English?
<FromGitter> <Blacksmoke16> no it makes sense, but whats the reasoning for just now including it by default?
<FromGitter> <Blacksmoke16> not*
<FromGitter> <elorest> @kinxer How would you interact with a COM port? Opening it as a File seems pretty standard...
<FromGitter> <Nicolab> Yes the same runtime performance, is not a wrapper or other
<FromGitter> <Nicolab> @Blacksmoke16 to avoid polluting the scope when not in use.
<FromGitter> <Blacksmoke16> fair enough
<FromGitter> <kinxer> @elorest Let me take a sec to admit that I'm trying to help debug but have no experience with the kind of file descriptor communication you're doing (e.g. I just had to look up "COM port"). However, my point was that if you're opening file descriptors that aren't files, it seems to me that `IO::FileDescriptor` is more likely to match what you're looking for.
<FromGitter> <Nicolab> @Blacksmoke16 "is" seem to me a little short for exposing it by default
<FromGitter> <Nicolab> @Blacksmoke16 `name.id.chars[0] == ':' ? name[1..-1].id : name.id` If I remember correctly, it wrote down the symbol (with `:`) instead of the method name.
<FromGitter> <Blacksmoke16> yea and putting in the `Valid` or `Validator` namespace would kinda defeat the purpose of having it short
<FromGitter> <Blacksmoke16> it shouldnt
<FromGitter> <elorest> @kinxer File inherits from IO::FileDescriptor. I was trying to follow this https://stackoverflow.com/questions/51069578/crystal-lang-accessing-serial-port
<FromGitter> <Blacksmoke16> `.id` should convert a `StringLiteral` or `SymbolLiteral` to its raw value
<FromGitter> <Blacksmoke16> i.e. `"name" => name` or `:name => name`
<FromGitter> <Nicolab> @Blacksmoke16 Ok thanks, I'm updating :)