lucasb has quit [Quit: Connection closed for inactivity]
Liothen has quit [*.net *.split]
Liothen has joined #crystal-lang
davic has quit [Ping timeout: 272 seconds]
davic has joined #crystal-lang
alex`` has quit [Ping timeout: 246 seconds]
<FromGitter>
<PlayLights_twitter> Yeah Iβm know, the worst is that nowadays there are bots scanning web apps to find all patterns of security problems
<FromGitter>
<mistergibson> I filter all my string inputs for SQL statements
sz0 has quit [Ping timeout: 252 seconds]
sz0 has joined #crystal-lang
<FromGitter>
<wrq_gitlab> is crystal likely to get ADTs in the next release? what is the progress with that?
<FromGitter>
<Blacksmoke16> ADTs?
<FromGitter>
<watzon> Abstract Data Types?
<FromGitter>
<wrq_gitlab> Algebraic Data Types
<FromGitter>
<wrq_gitlab> for a long time, there was discussion about case!, making regular case statements implement an exhaustiveness check
<FromGitter>
<wrq_gitlab> since there's already enums
<FromGitter>
<Blacksmoke16> mm bit out of my area of expertise
moei has joined #crystal-lang
moei has quit [Ping timeout: 252 seconds]
SukinoSenze[m] has joined #crystal-lang
return0e has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
return0e_ has joined #crystal-lang
return0e has quit [Ping timeout: 258 seconds]
<FromGitter>
<galvertez> hey guys polling opinions here - does serializing `Exception` or a child class of it as JSON sound like a bad idea?
<FromGitter>
<galvertez> this question presumes that the exception will be parsed and then (possibly, eventually) raised in another program
<FromGitter>
<galvertez> i can't come up with a good reason not to do it, but as i'm typing the code it feels... weird. like i'm doing something sinister or something
<FromGitter>
<tenebrousedge> semantically, an exception seems like a problem for a given program
<FromGitter>
<galvertez> you know what that's it
<FromGitter>
<galvertez> that's what makes it seem so weird to me
<FromGitter>
<galvertez> thank you, i couldn't put it into words.
<FromGitter>
<tenebrousedge> you're very welcome. But I might still advise collecting further opinions
<FromGitter>
<galvertez> yeah, i'm not done listening
<FromGitter>
<galvertez> just saying, that pretty accurately describes the nagging in the back of my head - basically, an exception more or less "belongs" to a specific runtime
<FromGitter>
<galvertez> and just because we have it as a datatype and thus can serialize it, doesn't mean that we should lol
<FromGitter>
<watzon> Those would be my thoughts as well
<FromGitter>
<watzon> Not everyone is going to want to serialize/deserialize exceptions in the same way
<FromGitter>
<galvertez> for a bit more context, i've been working on a jsonr rpc shard for like a year now and i keep waffling on how i want to handle failures. the idea of my implemantation is that it tightly integrates the client and the server, such that, both can use the same libraries and it is never upon the author to actually touch any JSON
<FromGitter>
<galvertez> i use a handler heavily influenced by stdlib's HTTP handler, and HTTP::Context. with simple HTTP, serializing an exception rarely makes sense. but i have been toying w/ the idea of having the client deserialize exceptions raised serverside, and raise them locally
<FromGitter>
<galvertez> specifically so that they can be handled with `rescue` as though both machines are actually one; i.e. delegation of runtime by the client to the server is as close to 1:1 as it can get
<FromGitter>
<galvertez> but the more i write the more i think "why am i doing this? it's ridiculous"
<FromGitter>
<galvertez> it gets even weirder when i realize this means the context has to have 3 type arguments - `Params`, `Result` and `Error` - it gets really hairy because it is borderline impossible to know ahead of time how many, and what kinds of exceptions are possible
<FromGitter>
<tenebrousedge> I feel like an exception is a valid response from a remote resource
laaron has joined #crystal-lang
<FromGitter>
<tenebrousedge> or at least should not be a stop-the-world problem
<FromGitter>
<galvertez> sure, but i wonder if it is actually valid to have the client try to parse those exceptions as actual types and then try to deal with them, given the expectation that clientside doesn't necessarily know serverside's possible runtime errors
<FromGitter>
<watzon> For something like JSON API, things like parsing and validation exceptions should throw, any other errors returned by the api should be handled by the developer
<FromGitter>
<galvertez> on the other hand, i guess i could just enforce that serverside swallows anything unaccounted for and then regurgitates it as https://www.jsonrpc.org/specification#error_object "Server Error"
<FromGitter>
<tenebrousedge> I feel like the application should receive a 50x error regardless of what is actually transferred
<FromGitter>
<galvertez> well so jsonrpc is not necessarily HTTP - the specification allows for it to run on a plain jane TCP server
<FromGitter>
<galvertez> and i want my shard to reflect that
<FromGitter>
<tenebrousedge> TCP errors are not application-level errors?
<FromGitter>
<galvertez> TCP doesn't throw HTTP codes, no
<FromGitter>
<galvertez> TCP's layer 4, HTTP is layer 7 so it's not quite the same
<FromGitter>
<tenebrousedge> right
<FromGitter>
<galvertez> i do think it would alright for anyone using the shard to have their HTTP server return a 50x if there's an error though
rohitpaulk has joined #crystal-lang
<FromGitter>
<tenebrousedge> I mean, so as long as you're implementing a HTTP or HTTP-based server, then I think this would be the best option. There is likely even some sort of applicable specification
<FromGitter>
<tenebrousedge> people may even follow it
<FromGitter>
<tenebrousedge> the jsonrpc docs seem mostly to describe errors with deserialization rather than deserialization of errors
<FromGitter>
<watzon> That's because individual programs are meant to handle errors in their own way
<FromGitter>
<galvertez> yeah, what @watzon said - the errors mentioned there are just the errors built into the specification. but developers are allowed to define their own error objects
<FromGitter>
<watzon> And should be able to decide what happens with those errors
<FromGitter>
<galvertez> 100%
<FromGitter>
<watzon> The client should only throw errors on deserialization and bad tokens
<FromGitter>
<galvertez> yea
<FromGitter>
<galvertez> i'm not just not sure if i want to extend the parallelism of shared libraries between server and client to include the `JSONRPC::Error` child classes - that is, if `JSONRPC::Error` inherits from `::Exception` whether it would be acceptable to raise one of those serverside, package it up, and then ship it off to the client for handling (no actual stacktrace necessary clientside, if the clientside dev knows
<FromGitter>
... what could go wrong)
<FromGitter>
<galvertez> maybe this is a question for version 2.0.0 lol
<FromGitter>
<watzon> Yeah I'd focus on the basics for v1
<FromGitter>
<galvertez> seriously. i've been debating myself about this on and off for nearly a year now
<FromGitter>
<galvertez> well thanks for the insight guys
rohitpaulk has quit [Ping timeout: 244 seconds]
return0e_ has quit [Ping timeout: 252 seconds]
return0e has joined #crystal-lang
return0e_ has joined #crystal-lang
return0e has quit [Ping timeout: 258 seconds]
<FromGitter>
<denolfe> Hello All, I'm not coming from Ruby-land, so I'm a little confused on how and when to use relative `require` statements? I'm not able to find a hard and fast explanation anywhere. I'm only familiar with how JS/TS does things, which is import everything you need in every file. Anyone care to explain or point me to a resource? Thanks!
<FromGitter>
<denolfe> Correct, I just ran into an odd scenario where it mattered *when* I did a require of a file that was doing a macro, so I was hoping someone could shed some light.
<FromGitter>
<watzon> And in Crystal you can import everything you need for every file, or just make sure that dependent files are imported before files than need them
<FromGitter>
<denolfe> Is it best practice to just import most things at your entrypoint then?
<FromGitter>
<watzon> I typically am just very explicit about it
<FromGitter>
<watzon> If a file depends on something I import it
rohitpaulk has joined #crystal-lang
<FromGitter>
<denolfe> Makes sense, thanks π
<FromGitter>
<watzon> The compiler doesn't care anyway, everything only really gets required once
rohitpaulk has quit [Ping timeout: 245 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 245 seconds]
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 258 seconds]
Raimondii is now known as Raimondi
hightower2 has quit [Ping timeout: 258 seconds]
<FromGitter>
<girng> hello
return0e_ has quit [Read error: Connection reset by peer]
<jokke>
if i run this i get an exception: Invalid encoding: UTF-8 (ArgumentError)
<jokke>
it doesn't seem to have anything to do with the static linking or scratch image. if i run it in the alpine image (no matter if statically linked or not) i get the same error
<jokke>
hm it works with the 0.27.0 tag of the image
SukinoSenze[m] has left #crystal-lang ["User left"]
sfcgeorge has joined #crystal-lang
sfcgeorge has quit [Client Quit]
sfcgeorge has joined #crystal-lang
gangstacat has quit [Ping timeout: 268 seconds]
gangstacat has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
alex`` has joined #crystal-lang
duane has quit [Ping timeout: 252 seconds]
devil_tux has joined #crystal-lang
alex`` has quit [Ping timeout: 258 seconds]
alex`` has joined #crystal-lang
duane has joined #crystal-lang
duane has quit [Ping timeout: 268 seconds]
duane has joined #crystal-lang
sfcgeorge is now known as sfcg[away]
sfcg[away] is now known as sfcgeorge
sfcgeorge is now known as sfcg[away]
devil_tux has quit [Ping timeout: 258 seconds]
sfcg[away] is now known as sfcgeorge
sfcgeorge is now known as sfcg[away]
devil_tux has joined #crystal-lang
devil_tux has quit [Ping timeout: 258 seconds]
sfcg[away] is now known as sfcgeorge
devil_tux has joined #crystal-lang
devil_tux has quit [Ping timeout: 252 seconds]
devil_tux has joined #crystal-lang
laaron has quit [Remote host closed the connection]
devil_tux has quit [Ping timeout: 252 seconds]
laaron has joined #crystal-lang
devil_tux has joined #crystal-lang
devil_tux has quit [Ping timeout: 252 seconds]
alex`` has quit [Ping timeout: 245 seconds]
alex`` has joined #crystal-lang
devil_tux has joined #crystal-lang
<FromGitter>
<jwoertink> Is there a way with crystal to see some under the hood stats with your running app like how many objects have been instantiated, or how much memory the app needed to build?
devil_tux has quit [Ping timeout: 245 seconds]
<FromGitter>
<jwoertink> Or like if you change a class to a struct, something that tells you if that was a bad idea, or if it actually improved your code?
<FromGitter>
<j8r> @jwoertink you can do `GC.stats`
<FromGitter>
<j8r> then judge on your own.
<FromGitter>
<jwoertink> Does that happen first thing when the app boots, or last thing before it shuts down?
<FromGitter>
<mmc1ntyre> I have YAML file that I'm using for some app specific settings. Let's say the key that I'm interested in is :foo. I have a class method that takes an argument subdomain. If I pass the string 'foo' to the method I want to be able to grab the value from the correct key in the YAML. Is this possible with crystal? If not is there another way to do this?
<FromGitter>
<Blacksmoke16> whats the structure of the yaml look like
<FromGitter>
<Blacksmoke16> one option is to using like `YAML.mapping` to instantiate objects from the yaml
<FromGitter>
<Blacksmoke16> other option would be to just use `YAML.parse` to get a hash representation of the data, and fetch it from there
<FromGitter>
<mmc1ntyre> I'm using YAML.parse...but the issue that I'm having is that I have different "subdomain" keys in the YAML...ie. :cloud, :rain, :forest. I want to be able to pass 'forest' into a method and get the correct YAML entry...my issue is how do I translate from a string to a symbol? In ruby I would normally just interpolate this by doing :"{subdomain}"....what is the crystal equivalent?
gangstacat has quit [Quit: Δis!]
<FromGitter>
<Blacksmoke16> > how do I translate from a string to a symbol? β β You cant afaik
<FromGitter>
<tenebrousedge> really?
<FromGitter>
<Blacksmoke16> but the bigger question, is `YAML.parse` making your keys symbols?
<FromGitter>
<Blacksmoke16> that doesnt seem right
<FromGitter>
<jwoertink> In ruby, if the keys begin with a colon, then they are parsed as Symbols. Not sure if crystal does the same
<FromGitter>
<watzon> So the opposite of a normal exclusive range
<FromGitter>
<Blacksmoke16> could then add another thing for DB.mapping
<FromGitter>
<vladfaust> Well, yes. Ideally, two sides should be able to be exclusive. I guess, it's four dots literal `1....3`
<FromGitter>
<Blacksmoke16> i.e. copy same block and just change the name, so the macro defines both
<FromGitter>
<naqvis> @Blacksmoke16 Thank you π π π
<FromGitter>
<watzon> Sounds like you're going to have to parse the range and build one yourself based on Postgres's rules
<FromGitter>
<vladfaust> What
<FromGitter>
<vladfaust> Crystal ranges do not support exclusive beginning
<FromGitter>
<watzon> Are you trying to make a Postgres range into a Crystal range or vice versa?
<FromGitter>
<vladfaust> Both, I guess
<FromGitter>
<watzon> Maybe you could roll your own `PostgresRange` that has compatibility for exclusive beginnings? You'd lose the syntactic sugar or Range literals,though.
<FromGitter>
<watzon> If it's worth it
devil_tux has joined #crystal-lang
<FromGitter>
<vladfaust> Yep, that what I've come to. Thanks!
<FromGitter>
<watzon> Have fun!
<FromGitter>
<vladfaust> :D
<FromGitter>
<dscottboggs_gitlab> can one get the path components of a class's name from `@type`? Like being able to get `Baz` or, better yet `[Foo, Bar, Baz]` from `Foo::Bar::Baz`?
<FromGitter>
<dscottboggs_gitlab> or do I have to do like `@type.id.gsub /::(\w+)$/, $1`?
<FromGitter>
<Blacksmoke16> :thinking:
<FromGitter>
<watzon> @dscottboggs_gitlab you're looking for the Path
<FromGitter>
<watzon> Crystal::Macros::Path
<FromGitter>
<Blacksmoke16> you want the values to be still of their class, not strings im assuming?
<FromGitter>
<watzon> It has a method `names`
<FromGitter>
<dscottboggs_gitlab> yeah I know but how do I get that from inside a class?
<FromGitter>
<dscottboggs_gitlab> @Blacksmoke16 it doesn't matter
<FromGitter>
<Blacksmoke16> non `!` raises, with it, just wraps
<FromGitter>
<vladfaust> Yes
<FromGitter>
<Blacksmoke16> i would have thought it would have been the other way around
<FromGitter>
<dscottboggs_gitlab> not raising is the dangerous option I guess
<FromGitter>
<Blacksmoke16> makes sense i guess
sagax has quit [Ping timeout: 252 seconds]
sagax has joined #crystal-lang
<FromGitter>
<cfsamson> Hi. I'm trying to cross compile from ubuntu to Windows following the "hello world" example in the wiki, but I run in to a funny issue that seems to stem from this line of code in `src/gc/boehm`: β β `````` [https://gitter.im/crystal-lang/crystal?at=5d15361e38c2bf757dcdf0f0]
<FromGitter>
<cfsamson> Has anyone tried to cross compile on the current version (0.29) and got it working?
mistergibson has joined #crystal-lang
<FromGitter>
<Blacksmoke16> i doubt it. prob be better off using the WSL
duane has quit [Ping timeout: 245 seconds]
<FromGitter>
<cfsamson> Yeah, that works, but I'm trying to work on the Fiber support for Windows, so I need to cross compile, but it would be great to get the "hello world" program working first :)
<FromGitter>
<Blacksmoke16> ah gotcha :P
<FromGitter>
<Blacksmoke16> are in uncharted waters haha
<FromGitter>
<Blacksmoke16> knowing nothing about that, i would say the windows is missing a require somewhere
<FromGitter>
<cfsamson> Me too. Not too familiar with Crystal.
<FromGitter>
<cfsamson> Yeah, but since I just followed the Wiki I would assume it worked on release build.
<FromGitter>
<Blacksmoke16> is no CI or anything for windows atm so ofc things prob break that go unnoticed
<FromGitter>
<cfsamson> Yes, that might be. This line might also be an issue β β ```{% unless flag?(:win32) %} β @[Link("pthread")] β {% end %}``` β β I'm not really sure what brings `Fiber` into scope... [https://gitter.im/crystal-lang/crystal?at=5d15382d4e13324f8ba140ca]