return0e has quit [Remote host closed the connection]
<FromGitter>
<sam0x17> is there some trick I could use to "dump" the current heap and stack state, and "load" that state on a subsequent execution of the program? (looking for a way to hack better repl-like functionality into the language). .NET languages have a per-object way of doing this for example. Maybe some ugly low-level call to the GC plus some ugly thing that gets/sets the stack?
<FromGitter>
<tenebrousedge> now that's an interesting idea
<FromGitter>
<sam0x17> for my purposes, I think it would actually be most useful on a per-object basis
<FromGitter>
<sam0x17> but it gets tricky when objects have references to objects
<FromGitter>
<sam0x17> in the mean time, I've been literally using database migrations where I used to use my production rails repl on a real in production service xD
<FromGitter>
<tenebrousedge> I reaaaaally miss not having `pry` in Crystal
<FromGitter>
<sam0x17> right, and I don't care if it's slow as molasses -- I expect that
<FromGitter>
<sam0x17> rust managed to get a real repl working (some googler did it)
<FromGitter>
<tenebrousedge> you have `icr` right?
<FromGitter>
<sam0x17> yeah icr is dangerous af
<FromGitter>
<sam0x17> re-runs everything up to that point
<FromGitter>
<sam0x17> imagine that in a database / web service context
<FromGitter>
<sam0x17> xD
<FromGitter>
<tenebrousedge> it's useful for "does this stdlib method work the way I think it does?"
<FromGitter>
<sam0x17> totally
<FromGitter>
<sam0x17> but I have crystal eval (or whatever it is) for that
<FromGitter>
<Blacksmoke16> whats the use case for having a repl in a prod env? something like the rails console
<FromGitter>
<sam0x17> exactly that
<FromGitter>
<Blacksmoke16> for doing one off command and stuff?
<FromGitter>
<sam0x17> yup
<FromGitter>
<tenebrousedge> I've had to do debugging that way too, when I couldn't reproduce something any other way
<FromGitter>
<Blacksmoke16> gotcha
<FromGitter>
<sam0x17> there are workable solutions right now, but I want to make it nicer
<FromGitter>
<sam0x17> something like loop over all locals in the current scope, serialize them, and then in a prelude on the next repl input prepopulate those locals using deserialization
<FromGitter>
<sam0x17> but in crystal when we talk about serialization it's usually sexy serialization / JSON stuff, not a memory dump, which is what it is in .NET
<FromGitter>
<sam0x17> might be able to do it by monkey-patching the GC when the repl is loaded
<FromGitter>
<Blacksmoke16> :shrug:
<FromGitter>
<sam0x17> I suppose I could do it from the ground up and just write a dump/undump routine for all the primitive types, and then have an automatic implementation for all complex types
<FromGitter>
<sam0x17> what will get tricky is when the language yells at me for not following whatever arbitrary initialization procedure some class uses
<FromGitter>
<sam0x17> for structs it would work 100%
<FromGitter>
<sam0x17> I think I just realized why it was easy in rust -- everything is a struct
<FromGitter>
<sam0x17> aha, I can use Pointer.new to basically get a memory dump of an object
<FromGitter>
<sam0x17> when I use `Bytes` and `Pointer(UInt8)` I get `Bytes[164, 0, 0, 0, 32, 0, 0, 0]`, which is closer, but then segfaults in the same place. I bet the `String` is crashing it since that's a reference
<FromGitter>
<sam0x17> yup, when I use some primitive instead of a String as the second field, everything works fine
<FromGitter>
<sam0x17> so now I have to have it recursively deal with references I suppose
<FromGitter>
<sam0x17> a start though, to be sure!!!
<FromGitter>
<sam0x17> actually, it isn't working with Int64 -- they come back zero
_whitelogger has joined #crystal-lang
<FromGitter>
<sam0x17> correction: only the first field will work, rest will get `1` as their value if they are an Int32
return0e has quit [Remote host closed the connection]
return0e has joined #crystal-lang
_whitelogger has joined #crystal-lang
return0e has quit [Remote host closed the connection]
return0e has joined #crystal-lang
return0e has quit [Remote host closed the connection]
return0e has joined #crystal-lang
absolutejam4 has joined #crystal-lang
rohitpaulk has joined #crystal-lang
absolutejam4 has quit [Ping timeout: 265 seconds]
rohitpaulk has quit [Remote host closed the connection]
absolutejam4 has joined #crystal-lang
absolutejam4 has quit [Ping timeout: 240 seconds]
dwdv_ has joined #crystal-lang
return0e has quit [Remote host closed the connection]
return0e has joined #crystal-lang
<FromGitter>
<absolutejam_twitter> That's one of the things I love about elixir/the BEAM
<FromGitter>
<absolutejam_twitter> You can jump onto a repl of a running application and inspect all of the processes and state
MasterdonX has quit [Read error: Connection reset by peer]
MasterdonX has joined #crystal-lang
gangstacat has quit [Ping timeout: 246 seconds]
gangstacat has joined #crystal-lang
HumanGeek has quit [Ping timeout: 268 seconds]
HumanG33k has joined #crystal-lang
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
gangstacat has quit [Ping timeout: 276 seconds]
gangstacat has joined #crystal-lang
alexherbo2 has joined #crystal-lang
gangstacat has quit [Ping timeout: 246 seconds]
gangstacat has joined #crystal-lang
gangstacat has quit [Ping timeout: 252 seconds]
dom96 has quit [Ping timeout: 240 seconds]
dom96 has joined #crystal-lang
hypercore has joined #crystal-lang
<hypercore>
anyone running crystal or lucky on heroku?
<FromGitter>
<absolutejam_twitter> Isn't heroku hella expensive for what you get?
<FromGitter>
<tenebrousedge> they have a free tier
<FromGitter>
<tenebrousedge> they're relatively expensive, but it's easier to administrate, particularly on the small scale
<FromGitter>
<tenebrousedge> if I'm launching a service and want to scale quickly, heroku would likely be easier than k8s + traefik + whatever other infrastructure
<erdnaxeli>
<hypercore "anyone running crystal or lucky "> What is lucky? It's not the first time I heard about it here
<hypercore>
any idea what's causing this? doesn't happen when i run lucky locally
<hypercore>
there's no mix-manifest.json?
<hypercore>
in the .gitginore that lucky provides there's a line with "/public/mix-manifest.json", i've removed in and seeing if that works
<Yxhuvud>
absolutejam_twitter: no, while Heroku is kinda expensive, it the infrastructure you get for your money is good and it is *very* easy to work with.
<hypercore>
it depends how much you value the convenience, but in terms of an apples-to-apples comparison of price-to-performance, a VPS is far better value
<hypercore>
heroku will cost you potentially a 10x multiple of what you would pay using a VPS, if not more
<FromGitter>
<tenebrousedge> that depends on how complex your app is. If you're running a half-dozen different services on an equal number of VPSs, then Heroku is likely to be cheaper initially
<Yxhuvud>
Oh, sure. There are definitely companies for who the cost of doing ops is cheaper than letting heroku handle all that. And at some point you end up offloading some stuff to cheaper services.
<FromGitter>
<tenebrousedge> and at any level of complexity, as you scale Heroku becomes a much worse bargain. But there are worse problems to have
<hypercore>
can crystal/lucky run well on a $7 heroku instance?
<FromGitter>
<tenebrousedge> better than Ruby I'm sure
<FromGitter>
<tenebrousedge> probably there are more informed persons here than me
<hypercore>
ok, well thanks anyway for the help, i'm still pretty new to crystal so i could be missing something quite obvious
<FromGitter>
<sam0x17> anyone know how I can do a `sizeof` in a macro? I'm trying to instantiate a `StaticArray` to be the size of a type that I know at compile-time (I have the `TypeNode`)
<FromGitter>
<Blacksmoke16> couldnt you just do `sizeof({{@type}})`
<FromGitter>
<sam0x17> StaticArray wants a CONST
<FromGitter>
<sam0x17> not an Int32
<FromGitter>
<sam0x17> for the size
<FromGitter>
<sam0x17> and apparently sizeof is not CONST
<FromGitter>
<Blacksmoke16> then just do like `StaticArray({{@type}}, 3)`?
<FromGitter>
<sam0x17> I need to do something like `StaticArray(UInt8, sizeof(@type))`
<FromGitter>
<sam0x17> but that isn't CONST
<FromGitter>
<Blacksmoke16> got a playground link?
<FromGitter>
<sam0x17> I can set one up sec
<FromGitter>
<sam0x17> I'm gonna do a contrived simplification
<FromGitter>
<sam0x17> oh and basically all I'm trying to do is get the raw bytes for any primitive
<FromGitter>
<sam0x17> so anything that is `Value`
<FromGitter>
<sam0x17> I could actually put the static type inside a Tuple and get the data that way but I'd rather not
<FromGitter>
<sam0x17> witchcraft!!!
<FromGitter>
<sam0x17> thanks!
<FromGitter>
<sam0x17> I have zero understanding why that works but what I did didn't lol
<FromGitter>
<Blacksmoke16> er might want to make it `\{{@type}}` so it represents the type it was included in
<FromGitter>
<sam0x17> that would make sense
<FromGitter>
<sam0x17> tho it seems to be doing something anyway xD
<FromGitter>
<sam0x17> is there documentation anywhere for all the different like `{{}}` and `\{{}}` and `{% %}` thingys?
<FromGitter>
<sam0x17> I've just sort of picked up that `\{{}}` is what you need when stuff is is created in a later hook
<hypercore>
would you guys know why i get "remote: execution of 'lucky db.migrate' failed! /bin/bash: lucky: command not found" when using the heroku-crystal-buildpack to run lucky?
<FromGitter>
<Blacksmoke16> the way i look at it is the first is when you want to "insert" a value into the code like `{{@type}}`, adding the `\` escapes the expression so that it doesn't execute immediately, i.e. waits until after the included hook runs
<FromGitter>
<sam0x17> the lucky executable isn't in your PATH on that buildpack @hypercore
<FromGitter>
<Blacksmoke16> `{% %}` is what i use for control logic like if/for etc
<hypercore>
ah ok, do i have to add it manually or something? i thought buildpacks took care of this sort of thing for you
<FromGitter>
<sam0x17> you will probably have to modify the buildpack to ensure that the lucky executable is in PATH -- you might have to have the lucky executable be a second build target and then ensure that your app's bin directory is in PATH, or something
<FromGitter>
<sam0x17> this is probably one of those things where whoever maintains it didn't make sure the db migrate part is working
<FromGitter>
<sam0x17> so in theory yes, in practice no
<FromGitter>
<sam0x17> you should fork and submit a PR if there is a repo for it
<FromGitter>
<sam0x17> I had to do the same a few years ago for the amber build pack
<FromGitter>
<sam0x17> literally same issue
alexherbo26 has joined #crystal-lang
<FromGitter>
<sam0x17> thanks, @Blacksmoke16
<FromGitter>
<Blacksmoke16> if you have a lot of macro code within a hook you can also do like
<FromGitter>
<sam0x17> I've gathered that as well, just wish it was documented
<FromGitter>
<Blacksmoke16> :p didnt know it was a thing
<FromGitter>
<sam0x17> lolz
<FromGitter>
<sam0x17> its quite old
<FromGitter>
<sam0x17> @hypercore at a glance, it looks like it yeah, but then that begs the question why it isn't finding lucky already
<FromGitter>
<sam0x17> you might want to add a build step that just prints out `which lucky`
<FromGitter>
<sam0x17> and see if its actually finding it (I bet it isnt)
<FromGitter>
<sam0x17> and then when that doesn't work, try a build step that prints out `find -r / lucky`
<FromGitter>
<sam0x17> to see if it even is anywhere in what is getting deployed
<FromGitter>
<sam0x17> if a path comes back you then have the option of just calling it a day and using whatever that path is, or investigating further to have it properly included in PATH
<FromGitter>
<sam0x17> also, you might have some luck using apex's `up` instead of heroku
<FromGitter>
<sam0x17> I'm hosting all my crystal stuff using that now (puts it in lambdas!!!)
<FromGitter>
<sam0x17> their default crystal example breaks but its easy to fix and set up how you want -- I use kemal + a bunch of custom middleware generally
<hypercore>
oh cool, didn't know about apex
<FromGitter>
<sam0x17> unless you're google you'll probably be in free tier as well for lambda
<FromGitter>
<sam0x17> I was like mind = blown when I realized I could run a full web app in a lambda
<FromGitter>
<sam0x17> I can give you my up.json file that I use if you get stuck --- I had to do a bunch of workarounds because static compilation is annoying
<hypercore>
that'd be great, thanks
<hypercore>
and does that work exactly? i thought lambdas are simple little functions, i didn't realize you can use lambdas with a web framework
<hypercore>
*how does that work
<FromGitter>
<sam0x17> they are full vm's
<FromGitter>
<sam0x17> with a tiny environment
<FromGitter>
<sam0x17> by default they run usually a fork of nodejs / express
<FromGitter>
<sam0x17> but you can call unix executables
<FromGitter>
<sam0x17> so if you bundle things properly, you can call your crystal executable
<FromGitter>
<sam0x17> which is what up does (and my gcf.cr tool for google cloud functions -- dont use very old)
<FromGitter>
<sam0x17> so basically if you statically compile your crystal app, you can just directly run from the javascript
<FromGitter>
<sam0x17> if your dependencies are simple, you will have an easy time
<FromGitter>
<sam0x17> otherwise you will want to use a really good static compilation docker image, and make your build script something like: `docker run --rm -v $(pwd):/src -w /src durosoft/crystal-alpine:0.31.1 shards build`
dannyAAM has quit [Quit: znc.saru.moe : ZNC 1.6.2 - http://znc.in]
absolutejam4 has joined #crystal-lang
<FromGitter>
<SewerynKaminski> @Blacksmoke16 I have a struct with 3 Int32, and I need array of this as a constants
dannyAAM has joined #crystal-lang
<FromGitter>
<Blacksmoke16> got a playground link?
<FromGitter>
<SewerynKaminski> @Blacksmoke16 yes i have, the map magic is enought, thx
<FromGitter>
<Blacksmoke16> 👍
absolutejam4 has quit [Ping timeout: 240 seconds]
absolutejam4 has joined #crystal-lang
<FromGitter>
<sam0x17> also I think someone earlier mentioned they needed cheap and/or free postgresql hosting? these guys are great https://www.elephantsql.com/plans.html
<FromGitter>
<absolutejam_gitlab> so I went with pug.js
<FromGitter>
<absolutejam_gitlab> seems much nicer so far
<FromGitter>
<absolutejam_gitlab> speaks to my yaml engineer heart
<FromGitter>
<absolutejam_gitlab> Where's the data classes link that was posted yesterday?
<FromGitter>
<absolutejam_gitlab> That might be a good option for @SewerynKaminski
<FromGitter>
<absolutejam_gitlab> or using structs/`record`
<FromGitter>
<absolutejam_gitlab> I was looking for the same kinda thing after playing with Go & Elixir struct literals (eg. `Foo{bar: "Baz"}`)
<FromGitter>
<tenebrousedge> maybe an `enum` too, if that would make sense
<FromGitter>
<tenebrousedge> it has `from_values` already
<FromGitter>
<Blacksmoke16> `from_value`*
<FromGitter>
<ImAHopelessDev_gitlab> Enums in Crystal are a facade. You are forced to capitalize the first letter of the enum value, but then are screwed in a case when statement. Because only the lowercase shorthand notation is available (the best kind). Which doesn't match the actual value of the Enum itself (causes ambiguity)
<FromGitter>
<ImAHopelessDev_gitlab> Not short-handly you can't
<FromGitter>
<absolutejam_gitlab> seems like a non-issue
<FromGitter>
<absolutejam_gitlab> You're not calling a method, you're accessing a constant
masterdonx2 has joined #crystal-lang
<hypercore>
hello y'all, made some progress with the buildpack deployment, now i get this error (https://paste.ubuntu.com/p/8TXpqPsQm2/) "Failed to raise an exception: END_OF_STACK"
<FromGitter>
<absolutejam_gitlab> it'd be nice if you could leverage the compiler to help you catch exceptions in some form
<FromGitter>
<absolutejam_gitlab> as in, actual exception types
<FromGitter>
<ilanpillemer> I am also adding methods to Nil so I dont have to keep doing Nil checks
<FromGitter>
<Blacksmoke16> You can add type restrictions to rescue blocks
<FromGitter>
<absolutejam_gitlab> Golang gives you multiple return values, one of which is normally an error. elixir usually gives you pattern matching on `{:ok, foo}` or `{:error, foo}`
<FromGitter>
<absolutejam_gitlab> Yeah, but even perhaps a warning
<FromGitter>
<Blacksmoke16> So they only handle exceptions of that type
<FromGitter>
<ilanpillemer> the last one in Go as the error
<FromGitter>
<absolutejam_gitlab> 'method food can throw SomeException but no catch block matches`
<FromGitter>
<ilanpillemer> and 1.13 lets you wrap errors now
<FromGitter>
<absolutejam_gitlab> Well yeah, I just meant there's not always an error returned but it's idiomatic
<FromGitter>
<ilanpillemer> and context as first
<FromGitter>
<absolutejam_gitlab> even as much as generated documentation I guess
<FromGitter>
<absolutejam_gitlab> and yeah @Blacksmoke16, I mean the compiler hinting towards that
<FromGitter>
<Blacksmoke16> ah ok
<FromGitter>
<ilanpillemer> hmm.. you can’t `case self`?
alexherbo261 has joined #crystal-lang
<FromGitter>
<tenebrousedge> can you `case self.dup` ?
<FromGitter>
<Blacksmoke16> could always make a macro to do it for you
<FromGitter>
<absolutejam_gitlab> Yeah but it's not as nice
alexherbo261 has quit [Ping timeout: 276 seconds]
<FromGitter>
<Blacksmoke16> 😬
<FromGitter>
<absolutejam_gitlab> What's the benefit of using a module in this case?
<FromGitter>
<Blacksmoke16> why not just do `case @@token`?
<FromGitter>
<ilanpillemer> when I was started writing it, I did not know yet if there would be things that didnt need `@@token`
<FromGitter>
<absolutejam_gitlab> I generally sway to using modules vs. classes if I'm just using the class (not instances), but this seems like an anti-pattern
<FromGitter>
<Blacksmoke16> ah, fair enough
<FromGitter>
<ilanpillemer> I have been swaying towards modules
<FromGitter>
<Blacksmoke16> not really any diff than doing everything at the top level
<FromGitter>
<absolutejam_gitlab> But if I'm using a module (vs class instances), I wouldn't share state
<FromGitter>
<absolutejam_gitlab> or I'd share state in a specific way
<FromGitter>
<ilanpillemer> I just treated the module as the unit
<FromGitter>
<absolutejam_gitlab> I mean, if it's 'just because' then fair enough
<FromGitter>
<absolutejam_gitlab> I didn't know if you were doing it for a reason
<FromGitter>
<ilanpillemer> havnt been doing that much OO in ages
<FromGitter>
<ilanpillemer> so just defaulted to modules as a result
<FromGitter>
<absolutejam_gitlab> fair enough
<FromGitter>
<absolutejam_gitlab> Have you done any/much Elixir?
<FromGitter>
<ilanpillemer> no. played a big with Erlang about 18 months ago