<FromGitter>
<meltheadorable> PHP’s global functions have historically been a mess, it seems like they’ve been trying to clean it up and make it less necessary to rely on them over the years, i don’t really care for the language but I’m also not really interested in spending a lot of time disparaging it, I’m glad I don’t have to write it in my day job most of the time
<FromGitter>
<watzon> It's up there in my top 5 least favorite languages
<FromGitter>
<meltheadorable> JS continues to be a mess and I’m disappointed that the scope of webassembly was reduced to remove aspirations of letting it interact with the DOM directly, because it means javascript still has to be the target for any language hoping to drive a browser
<FromGitter>
<meltheadorable> used to be excited about the possibility webassembly would free us from that
<FromGitter>
<meltheadorable> but it’ll only be useful within a canvas now
<rkeene>
Many of the W3C examples use Tcl as the language of the web :-D
<FromGitter>
<dscottboggs_gitlab> how does one create a variable in macro-land? Like `{% some_var = [:a, :b, :c] %} {% for x in some_var %}"do something with {{x}}"{% end %}`
<FromGitter>
<Blacksmoke16> y es
<FromGitter>
<dscottboggs_gitlab> yes, as in I did it right?
<FromGitter>
<dscottboggs_gitlab> Oh I know what I did
<FromGitter>
<Blacksmoke16> looks fine yea
<FromGitter>
<dscottboggs_gitlab> needed to wrap it in `{% begin %}` and `{% end %}`
<FromGitter>
<Blacksmoke16> that would do it
<FromGitter>
<Blacksmoke16> prob not helpful for you, but will be some new methods on annotations coming up
<FromGitter>
<Blacksmoke16> `.args` returns a tuple of positional args on the annotation
<FromGitter>
<Blacksmoke16> and `named_args` returns a namedTuple of named args on the annotation
<FromGitter>
<dscottboggs_gitlab> can we do `@[Annotate arg: "value"]` yet?
<FromGitter>
<Blacksmoke16> hm?
<FromGitter>
<Blacksmoke16> without the paren?
laaron has joined #crystal-lang
<FromGitter>
<dscottboggs_gitlab> yeah
<FromGitter>
<Blacksmoke16> dont think so
* FromGitter
* dscottboggs_gitlab grumbles
<FromGitter>
<Blacksmoke16> :shrug:
<FromGitter>
<Blacksmoke16> this makes positional args much more useful tho
<FromGitter>
<Blacksmoke16> before you only could access them directly, i.e. `ann[idx]`
<FromGitter>
<dscottboggs_gitlab> was there at least a size so you could use a `for..in` macro loop?
<FromGitter>
<Blacksmoke16> nope
<FromGitter>
<dscottboggs_gitlab> jeeze
<FromGitter>
<dscottboggs_gitlab> TBF though, crystal has an amazing macro system. I tried to write my first macro in rust today and was shocked at how terrible it was
<FromGitter>
<dscottboggs_gitlab> Just gave up on it after looking into it for a while
<FromGitter>
<Blacksmoke16> `(0...initializer.args.size)` is the hack i was using before this new feature
<FromGitter>
<meltheadorable> why do annotations have an `end` if they don’t have a body
<FromGitter>
<dscottboggs_gitlab> because they could have a body in the future maybe? Idk, that's a pretty good point
<FromGitter>
<Blacksmoke16> i remember there being talk of future features of them
<FromGitter>
<Blacksmoke16> like being able to define the fields and such
<FromGitter>
<meltheadorable> that would be useful i think
<FromGitter>
<Blacksmoke16> oo another idea i just thought of
<FromGitter>
<Blacksmoke16> can iterate over key/value pairs now as well. should be able to cleanup CrSerializer a bit now
<FromGitter>
<Blacksmoke16> before you had to manually specify the fields to read off of
<FromGitter>
<dscottboggs_gitlab> that should be nice
<FromGitter>
<Blacksmoke16> indeed
<FromGitter>
<meltheadorable> ✨
<FromGitter>
<Blacksmoke16> I lied, no it won't help much
<FromGitter>
<Blacksmoke16> Still need to have a list of annotations to read off the Ivar
<FromGitter>
<watzon> Has anyone figured out a good way to cast a Hash of one type to another type?
<FromGitter>
<dscottboggs_gitlab> it's actually not too hard to write out HTTP requests by hand. You just have to remember to use MS line endings in it
<FromGitter>
<absolutejam_gitlab> Are macros limited to only the select few functions? Or do I have to use `run` and make another crystal executable to get full crytsal support?
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
<FromGitter>
<bew> @absolutejam_gitlab yes and yes
<FromGitter>
<absolutejam_gitlab> hm, poop
<FromGitter>
<absolutejam_gitlab> I'm trying to build in an Alpine container but it's failing to find my relative shard
<FromGitter>
<absolutejam_gitlab> trying to build within `/app/`
<FromGitter>
<absolutejam_gitlab> switched it to git, still saying that it can't find it
<FromGitter>
<absolutejam_gitlab> after a `shards install` etc.
<FromGitter>
<absolutejam_gitlab> oh, I don't think `shards install` is doing anything...
<FromGitter>
<absolutejam_gitlab> `bake_file "foo", {{ system("cat ./assets.tar.gz").stringify }}` works fine locally but gets `Syntax error in expanded macro: macro_140320976575216:1: invalid hex escape` in alpine
<FromGitter>
<Blacksmoke16> you could prob just use the `read_file` macro method
<FromGitter>
<Blacksmoke16> vs system at
<FromGitter>
<absolutejam_gitlab> Did not see that one...
<FromGitter>
<absolutejam_gitlab> haha
<FromGitter>
<absolutejam_gitlab> jesus
<FromGitter>
<Blacksmoke16> :p
<FromGitter>
<absolutejam_gitlab> ugh, I am having no joy getting my binary to work across machines
<FromGitter>
<absolutejam_gitlab> I really thought it'd be simpler
<FromGitter>
<tenebrousedge> @watzon silent passthrough proxy? nginx will do that
<FromGitter>
<absolutejam_gitlab> the lasto ne is `libpcre.so.1`
<FromGitter>
<absolutejam_gitlab> am I right in thinking a statically compiled binary (From Alpine) will not work on non-alpine boxes?
<FromGitter>
<Blacksmoke16> it *should* work on all linux based OS of the same arch afaik
<FromGitter>
<Blacksmoke16> but i could be wrong...
<FromGitter>
<absolutejam_gitlab> if i compile it in alpine container with `--static` on my arch machine and run it on my machine, it works
<FromGitter>
<absolutejam_gitlab> but if I scp to an ubuntu host, it segfaults
<livcd>
glibc vs musl ?
<FromGitter>
<absolutejam_gitlab> Tried symlinking libpcre.so.3 to .1 and then I get `/lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found `
<FromGitter>
<absolutejam_gitlab> 😢
<FromGitter>
<absolutejam_gitlab> and this is building on Ubuntu, which I didn't wanna have to do
<FromGitter>
<tenebrousedge> symlinking? Isn't that what `LD_PRELOAD` is for?
<FromGitter>
<absolutejam_gitlab> Honestly, I have no idea about compilation
<FromGitter>
<straight-shoota> > if i compile it in alpine container with `--static` on my arch machine and run it on my machine, it works ⏎ but if I scp to an ubuntu host, it segfaults
<FromGitter>
<straight-shoota> This should usually work without issues, as long as it is fully statically compiled and doesn't use any libraries that don't work well when compiled statically (like openssl)
<FromGitter>
<straight-shoota> The boehm error seems to indicate an issue with libgc
<FromGitter>
<straight-shoota> Is that literally the only thing printed?
<FromGitter>
<absolutejam_gitlab> It doesn't do an awful lot outside of stdlib
<Stephie>
i wish glibc static linking wasn't cursed
<Stephie>
it's just NSS stuff, which uses dlopen
<Stephie>
and NSS is a terrible idea
sz0 has quit [Quit: Connection closed for inactivity]
<FromGitter>
<r00ster91> is there anything wrong with this websocket creation `HTTP::WebSocket.new("localhost", "", port: 8080, tls: true)`? This websocket creation ends in an infinite loop. I think I've found a bug
duane has joined #crystal-lang
<Stephie>
are you sure the infinite loop is during the constructor?
<FromGitter>
<r00ster91> this loop is never being exited
<FromGitter>
<r00ster91> maybe it's WSL-related
rohitpaulk has quit [Remote host closed the connection]
<FromGitter>
<r00ster91> can anyone on wsl reproduce this
<FromGitter>
<dburnsii> Hey all, I'm really new to Docker but just pulled the latest docker image, anyone know the command I have to run to get it to start compiling?
<FromGitter>
<tenebrousedge> to start compiling what?
<FromGitter>
<kniknoo> A docker image itself is basically a vm, are you meaning to open fresh image and compile the compiler into it?
<FromGitter>
<dburnsii> Well I grabbed this: https://hub.docker.com/r/crystallang/crystal , that should have the source on it already shouldn't it? There's a Dockerfile listed that looks like it has the make command along with a few other operations
<FromGitter>
<Blacksmoke16> you would want to make a volume to get your project directory into the container, then could execute it within there
<FromGitter>
<Blacksmoke16> something like
<FromGitter>
<Blacksmoke16> `docker run crystal -v ./:/app crystal /app/src/my_app.cr`
<FromGitter>
<Blacksmoke16> but it would prob be easier to develop locally?
<FromGitter>
<kniknoo> Oh, is it not possible to just work from a shell in a docker image?
<FromGitter>
<tenebrousedge> you can, it's not ideal
<FromGitter>
<tenebrousedge> better to mount the local folder in the docker image
<FromGitter>
<kniknoo> (I could see why WSL users might want to try this)
<FromGitter>
<dburnsii> Hm, I see what you're saying. The only reason I opted for the Docker image was because of clashing LLVM versions on my arch machine.
<FromGitter>
<kniknoo> I'm always once to isolate thoughts via VM images. If you're just starting out on Crystal and you're worried about the clash, it might be a way to roughly do what you're trying to do with docker.
<FromGitter>
<tenebrousedge> @kniknoo if you're working inside the docker image then you are probably only going to have `nano` or `vim` available for editing, at most
<FromGitter>
<kniknoo> Understood... I admittedly have done most writing in my life on nano... :D
<FromGitter>
<Blacksmoke16> oh you could do like
<FromGitter>
<kniknoo> These here gui editors are new and neat to me. :D
<FromGitter>
<absolutejam_gitlab> Not implemented yet by looks
<FromGitter>
<absolutejam_gitlab> There's an issue
<FromGitter>
<dburnsii> So @Blacksmoke16 , what do I specify for the `crystal_image_name`? `crystal` and `crystallang/crystal` don't seem to be working
<FromGitter>
<kniknoo> This is something I look forward to learning about. I am correct in my assumption that I could use sockets to talk between languages? Or is there a smarter way to approach that?
<FromGitter>
<absolutejam_gitlab> I don't know if there's an official one, is there?
<FromGitter>
<absolutejam_gitlab> You could throw together an alpine image like I have
<FromGitter>
<absolutejam_gitlab> Between processes so
<FromGitter>
<absolutejam_gitlab> Yeah if both of them have a common interface, eg json, protobuf
<FromGitter>
<tenebrousedge> `docker exec` presupposes that you have a running docker container
<FromGitter>
<tenebrousedge> so if `docker ps` does not list anything...
<FromGitter>
<tenebrousedge> @kniknoo you should check out Atom or VSCode. Do you know vim?
<FromGitter>
<absolutejam_gitlab> @Blacksmoke16 it's a http rest interface over a socket tho
<FromGitter>
<absolutejam_gitlab> I can make it over http but not the default
<FromGitter>
<absolutejam_gitlab> And id rather not add http layer...
<FromGitter>
<absolutejam_gitlab> Kakoune is best editor
<FromGitter>
<absolutejam_gitlab> Im a shill
<FromGitter>
<kniknoo> That's what I was thinking for a VM. I'm going to play around with my alpine install a bit. Two things I'd like to accomplish are a simple minimalist iso for people on WSL and and rolling-releases and a working portable ARM image I can provide.
<FromGitter>
<kniknoo> I am aware of vim. It would be easier to pull me into emacs world I think. I have been meaning to try out atom to see what it's all about.
<FromGitter>
<Blacksmoke16> @dburnsii do a `docker images`
<FromGitter>
<dburnsii> Is it the `image_id` I want?
<FromGitter>
<tenebrousedge> kakoune looks very interesting, but you can get vim keybindings in a lot of places
<FromGitter>
<Blacksmoke16> that would prob work yea
<FromGitter>
<tenebrousedge> atom is fine, lots of good plugins, but slow and memory-heavy
<FromGitter>
<tenebrousedge> emacs lost the editor wars
<FromGitter>
<absolutejam_gitlab> It's like Inversed vim
<FromGitter>
<absolutejam_gitlab> And I love it
<FromGitter>
<absolutejam_gitlab> dw in vim to delete word
<FromGitter>
<absolutejam_gitlab> wd in Kakoune and it you the selection
<FromGitter>
<absolutejam_gitlab> Anyway, less pushing form. Me
<FromGitter>
<absolutejam_gitlab> Can't type on mobile
<FromGitter>
<dburnsii> So a `docker ps -a` shows that it starts up, but it looks like it exits right away
<FromGitter>
<Blacksmoke16> @dburnsii one sec, let me try it. was going off memory
<FromGitter>
<kniknoo> One of my considerations is that I could never imagine myself using the key-bindings. I see what people do with shortcuts and I can't even imagine getting to a point where I'd think like that.
<FromGitter>
<tenebrousedge> modal editors are kinda the opposite of shortcuts
<FromGitter>
<kniknoo> I do have a vim book that's been waiting around to be read, perhaps that would help me think in that way.
<FromGitter>
<tenebrousedge> I'd try spacevim
<FromGitter>
<tenebrousedge> @absolutejam_gitlab does Kakoune have an equivalent to the vim-tutorial?
<FromGitter>
<Blacksmoke16> will put you into a shell within the container, with your current directory mapped to `/app` in the container
<FromGitter>
<Blacksmoke16> thus you any files you add/remove from that dir will be synced between container and host
<FromGitter>
<Blacksmoke16> and in container can just do `crystal my_app.cr`
<FromGitter>
<Blacksmoke16> backticks around pwd
<FromGitter>
<dburnsii> There it is, awesome, thank you so much
<FromGitter>
<Blacksmoke16> np
<FromGitter>
<absolutejam_gitlab> So therr is an official image?
<FromGitter>
<absolutejam_gitlab> I didn't even look
<FromGitter>
<absolutejam_gitlab> P
<FromGitter>
<Blacksmoke16> yes
<FromGitter>
<jwoertink> Is there a way to do `Spec.before_each` but only within a specific group of specs? So not on every single spec, but for just a small group of them?
<FromGitter>
<jwoertink> Also, has anyone come up with a way to focus specs? Like with RSpec how you can add `describe "whatever", :focus`
<FromGitter>
<jwoertink> so when you run your spec suite, it only runs those specific blocks
<FromGitter>
<kniknoo> Without referencing the phrase "billion dollar mistake" could someone point me to a resource about the dangers of nil and how to anticipate and account for it in crystal code. I keep eventually getting myself out of the weeds but it's without a strategy right now.
<FromGitter>
<Blacksmoke16> @jwoertink no
<FromGitter>
<Blacksmoke16> @kniknoo the compiler does it for you
<FromGitter>
<Blacksmoke16> it prevents doing stuff like
<FromGitter>
<tenebrousedge> @kniknoo beyond that, it's hard to give suggestions without seeing how you're approaching things. Do you have any example code?
<FromGitter>
<kniknoo> Gotcha on that Kai... Hmmm. So it's actually going to be REALLY common for me to be basing things on probabilities when I get to art projects. That example is exactly why I asked.
<FromGitter>
<kniknoo> Oh, ok. The if var strategy looks perfect for what I'm asking.
<FromGitter>
<Blacksmoke16> `try` is also helpful, but really it all depends on the context of what you're doing
<FromGitter>
<Blacksmoke16> are multiple ways to handle it
<FromGitter>
<tenebrousedge> I don't like `if`s <_<
<FromGitter>
<kniknoo> Okie doke. This is partly for my understanding and party so I can boil down the strategies for their essence. I feel like, for better or worse, Ruby taught me to love the nil for its truthiness.
<FromGitter>
<tenebrousedge> o__o?
<FromGitter>
<kniknoo> or, falseyness
<FromGitter>
<kniknoo> Oh... ok. So that's why it keeps working out when I whittle things down to ternary? Is that running on the same concept as the if var?
<FromGitter>
<kniknoo> Ok, I `play`ed around with that and it makes sense now. You can tell I got into programming from a weird trajectory. So many basics I don't know and obscure things I do. :D
<FromGitter>
<kniknoo> Ok, so like, .not_nil! on a gets is so that it will raise an exception to handle if there's no input? That bit kind of confuses me.
<FromGitter>
<Blacksmoke16> `not_nil!` raises an exception if its called on something that is nil
<FromGitter>
<kniknoo> Ok, so in the case of gets, it's just like an assurance that something will come of it? I think of gets as assuring a string will come in, but I may totally misunderstand that part.
<FromGitter>
<Blacksmoke16> youd have to test it
<FromGitter>
<kniknoo> Ok. I need to fiddle a bit it sounds like. Thank you!
<FromGitter>
<kniknoo> Wait, maybe this answers it... a blank input is a Nil prior to being converted to "" by gets and that's where the issue lies?
<FromGitter>
<kniknoo> FFS, I don't even know what I was reading now. Something early on that made me think that gets always had to be followed by .not_nil.
<FromGitter>
<kniknoo> Thank you for humoring my derpy questions. :)
return0e_ has joined #crystal-lang
return0e has quit [Ping timeout: 248 seconds]
<FromGitter>
<watzon> `not_nil!` is rarely necessary I've found. `try` and `to_s` make pretty good replacements depending on the scenario.
<FromGitter>
<watzon> `try` especially. That thing is a life saver.
<FromGitter>
<kniknoo> Ok cool. That makes sense.
alex`` has quit [Ping timeout: 246 seconds]
alex`` has joined #crystal-lang
<oprypin>
@kniknoo: it is true though. `gets` can return nil
<oprypin>
that's where not_nil comes in
<oprypin>
nil is not for an empty input in the normal sense. empty string serves that fine
<oprypin>
it's for EOF, which happens for piped input or if u just press Ctrl+D
<oprypin>
or just use read_line which has an exception instead of nil
lucasb has quit [Quit: Connection closed for inactivity]
<FromGitter>
<kniknoo> *click* THANK YOU!!!
<FromGitter>
<kniknoo> Those cases make it make more sense now.
<FromGitter>
<tenebrousedge> `else` should be avoidable
<FromGitter>
<absolutejam_gitlab> I like that way the most
<FromGitter>
<watzon> Lol
<FromGitter>
<kniknoo> Well, that seems like a good reason to use ternary heavily, IMO
<FromGitter>
<bararchy> @kniknoo yeha... it and `spawn` don't play nicely
<FromGitter>
<watzon> Does anyone know if it's possible to add a handler to a HTTP::Server instance after it's been initialized?
<FromGitter>
<kniknoo> I haven''t really understood spawn yet.
<FromGitter>
<absolutejam_gitlab> I do miss pattern matching a little
<FromGitter>
<absolutejam_gitlab> But the way my functions are composed is generslly not like how I'd do it in elixir so I don't think I'd lrscfisallg use it as much a si
<FromGitter>
<absolutejam_gitlab> As I think
<FromGitter>
<absolutejam_gitlab> Jesus where is autocorrect today
<FromGitter>
<absolutejam_gitlab> These fat thumbs need supervision
<FromGitter>
<kniknoo> Oh I thought you were breaking into a Welsh idiom...
<FromGitter>
<absolutejam_gitlab> I just try and hit 60% accuracy and rely on autocorrect
<FromGitter>
<watzon> That would overwrite other handlers, but I suppose that may be what I have to do
<FromGitter>
<Blacksmoke16> would prob have to keep a reference of the old ones
<FromGitter>
<kniknoo> *Avoids making silly Cthulhu joke*
<FromGitter>
<j8r> I bet there will have lots of user feedbacks due do shards 0.9.0 perf issue. More than 8 deps without setting the version will eat all the memory and crash.
<FromGitter>
<watzon> Probably because I'm not sending anything
<FromGitter>
<Blacksmoke16> whats the goal?
<FromGitter>
<dscottboggs_gitlab> In what way does it not work?
alex`` has quit [Ping timeout: 248 seconds]
<FromGitter>
<watzon> Right now marionette doesn't have the ability to capture headers and modify them. In order to do that you have to proxy requests and responses and modify them in the proxy.
<FromGitter>
<watzon> Right now it doesn't seem to be proxying
<FromGitter>
<watzon> It seems to be capturing, but not forwarding
<FromGitter>
<Blacksmoke16> would the block cleanup after the block executes
<FromGitter>
<Blacksmoke16> which would reset the objs since they prob passed by reference
<FromGitter>
<bajro17> @watzon where is that lib for facebook pictures I cant find it
<FromGitter>
<Blacksmoke16> imagine a pointer to an array or something?
<FromGitter>
<dscottboggs_gitlab> > would the block cleanup after the block executes ⏎ ⏎ Probably not, from what I've seen of discussions about it, the GC doesn't kick in for a while after memory isn't needed anymore
<FromGitter>
<watzon> It looks like a pointer to the `TagDirective` struct
<FromGitter>
<watzon> Tried running it and setting Firefox to use it
<FromGitter>
<Blacksmoke16> can you just new up C structs like normal?
<FromGitter>
<Blacksmoke16> or are they just more representing types in C land?
DTZUZU has joined #crystal-lang
<FromGitter>
<dscottboggs_gitlab> There should be a way to initialize structs, but I can't rememeber what it is. Does `.new` with named arguments work?
<FromGitter>
<dscottboggs_gitlab> hang on I'll check
<FromGitter>
<dscottboggs_gitlab> OH I rememember, I'll provide an example