ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.34.0 | 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
HumanG33k has quit [Quit: Leaving]
straight-shoota has quit [Ping timeout: 260 seconds]
teardown has joined #crystal-lang
deavmi has quit [Ping timeout: 272 seconds]
deavmi has joined #crystal-lang
<FromGitter> <didactic-drunk> I don't see why stdlib can't have GC or no GC depending on use ⏎ ⏎ 1) Define `free` for non-GC classes. ⏎ 2) Class.new uses GC `malloc` and doesn't call `free`. ⏎ 3) SomeOtherSyntax creates the object using a non-GC `malloc`(boehm has a function for this) and expects the programmer to manage `free`. ... [https://gitter.im/crystal-lang/crystal?at=5eae2f913d58de7a38ef79d6]
Welog has quit [Ping timeout: 256 seconds]
rocx has quit [Ping timeout: 260 seconds]
Welog has joined #crystal-lang
_whitelogger has joined #crystal-lang
candynsky has joined #crystal-lang
candynsky has left #crystal-lang [#crystal-lang]
sorcus has quit [Ping timeout: 240 seconds]
gangstacat has quit [Ping timeout: 265 seconds]
<FromGitter> <RomainFranceschini> Would be fun to come up with an ObjC style manual reference counting that plays nicely with `-Dgc_none`
<FromGitter> <RomainFranceschini> Something like ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5eae7b7fb6dd230697a17dfb]
<FromGitter> <RomainFranceschini> And a default `#release` for `Object` ⏎ ⏎ `````` [https://gitter.im/crystal-lang/crystal?at=5eae7bddb6dd230697a17e64]
<FromGitter> <RomainFranceschini> Then monkey patch all stdlib to add proper retain and release calls 😀
_ht has joined #crystal-lang
sorcus has joined #crystal-lang
gangstacat has joined #crystal-lang
<livcd> Is ysbaddaden
<livcd> not involved with Crystal anymore?
<xyhuvud> why do you think that? He comments in the issue tracker now and then.
<livcd> Bad wording on my part.
<livcd> What I meant is if he is not part of the core team anymore.
<jhass> he has chosen to resign, yes
<sorcus> jhass: why?
<jhass> he didn't have fun anymore :)
<sorcus> Sad X-)
_ht has quit [Remote host closed the connection]
_ht has joined #crystal-lang
<livcd> What was the main thing about not having fun anymore?
straight-shoota has joined #crystal-lang
<jhass> he didn't make his goodbye message public, so I'm not the one to share it. Ask him directly :)
<livcd> oh noez crystal dead
return0e has joined #crystal-lang
v2px__ has quit [Ping timeout: 265 seconds]
_whitelogger has joined #crystal-lang
sz0 has quit [Quit: Connection closed for inactivity]
return0e has quit []
rocx has joined #crystal-lang
<FromGitter> <xmonader> is there an easy way to convert parsed toml object to json or yaml without defining structs ahead of time?
sagax has quit [Quit: Konversation terminated!]
sagax has joined #crystal-lang
<jhass> it seems to return just a hash? Did you try just calling to_json on it?
<FromGitter> <xmonader> i'd want to be able to do that flawlessly between all 3 types, just asking before wasting time on something that can't happen :)
<straight-shoota> You mean transform TOML::Any to JSON::Any or YAML::Any?=
<jhass> there's no TOML::Any fwiw
<straight-shoota> Ah okay so that shard still uses the recursive alias approach
<straight-shoota> Anyway, then its TOML::Type to JSON::Any or YAML::Any
<jhass> `::Any` ist just a wrapper around the recursive alias too https://github.com/crystal-lang/crystal/blob/master/src/json/any.cr#L20
<jhass> but I think it's not even relevant if it's just about serializing the Hash parsed from TOML to JSON or YAML?
<FromGitter> <naqvis> Thank you @straigh-shoota and thanks for the PR.
<jhass> you'd just call to_json on it
<FromGitter> <naqvis> Thank you
<straight-shoota> Technically Any doesn't use recursive aliases.
<straight-shoota> But it's essentially the same, just not the language construct recursive alias because that can cause issues
<jhass> what's the thing I linked to then?
<straight-shoota> That's a recursive alias
<straight-shoota> I'm talking about JSON::Any and YAML::Any
<jhass> in what file is that link?
<straight-shoota> sry, missed the second link
<straight-shoota> yeah, that's JSON::Any but it's not a recursive alias.
<straight-shoota> The alias `Type` does not appear on the right side
<straight-shoota> It's obviously indirectly recursive through `Any`
<FromGitter> <naqvis> Thanks @vlazar
<oprypin> daang, javascript has gone a long way
<oprypin> concurrency is so good and easy
<oprypin> python now has the same paradigms but javascript has a much easier time making new usages feel natural because they were already using callbacks, which now naturally convert to promises
<FromGitter> <kinxer> @Blacksmoke16 Re serialization shard: I'm thinking of trying to get automatic (de)serialization of XML in Crystal. I figured that I'd avoid duplicating some structure if you already had something I could build on top of.
<FromGitter> <Blacksmoke16> this is what i got atm
<FromGitter> <Blacksmoke16> so in theory if you have something that implements (method list not final), like yaml/json Any, then it should just work
<FromGitter> <Blacksmoke16> then would have a visitor that does something to parse the data and return that `ASR::Any`
<FromGitter> <Blacksmoke16> im not sure if that fits into how you were going to handle the parsing side of things
<FromGitter> <Blacksmoke16> a more robust solution would ofc do something built in versus just relying on `JSON::Any` and `YAML::Any` and have a true `ASR::Any` type, but as a first iteration i figured this was fine
_ht has quit [Remote host closed the connection]
_ht has joined #crystal-lang
<FromGitter> <kinxer> Yeah, that makes sense. I haven't had a chance yet to give it a lot of thought (since it's mostly peripheral to my actual work), but my end goal is to create shards for automatic Crystal code generation from XML schemas and (eventually) DFDL Schemas (https://en.wikipedia.org/wiki/Data_Format_Description_Language).
<FromGitter> <Blacksmoke16> sounds ambitious :P XML is a pita
HumanG33k has joined #crystal-lang
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
<FromGitter> <kinxer> It is, but we have a lot of legacy code using XML that won't change because "it works" (also, more reasonably, XML allows a lot more specificity than, say, JSON), and we have a number of proprietary ASCII or binary formats that really need schemas (instead of semi-formal specification documents and partial implementations where they're needed, i.e. serialization in one program and deserialization in another).
<FromGitter> <kinxer> So it seems like a reasonable backburner project to try and get some specifications, and I'd rather work in Crystal if I can.
<FromGitter> <Blacksmoke16> for sure
<FromGitter> <Blacksmoke16> main thing im dealing with now is how to handle deserialization long term
<FromGitter> <Blacksmoke16> each type gets its own `visit` method
<FromGitter> <Blacksmoke16> or do i want to add some class method to all types, then it would just be like `type.deserialize self, data`. I.e.
<FromGitter> <Blacksmoke16> ```def String.deserialize(visit, data) ⏎ data.as_s ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5eaedc03d898fe7a3762782b]
<FromGitter> <kinxer> I like the latter API, but it seems much more likely to collide with some other shard (the danger of patching the standard library).
<FromGitter> <Blacksmoke16> sucky thing is im kinda doing both atm
<FromGitter> <Blacksmoke16> as for like tuples/namedTuples/Unions i need access to `T` since i just cant dynamically create a tuple
<FromGitter> <kinxer> Can `::JSON` currently deserialize into a Tuple?
<FromGitter> <Blacksmoke16> yea
<FromGitter> <kinxer> Huh. That never occurred to me as a possibility.
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/9062
<FromGitter> <kinxer> What does it do if the data is the wrong length? Parsing error?
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/9063
<FromGitter> <Blacksmoke16> bombs out yea
<FromGitter> <kinxer> Hm... Gotcha. Yeah, that seems difficult to solve.
<FromGitter> <kinxer> I unfortunately don't have the bandwidth to think too deeply about this right now.
<FromGitter> <Blacksmoke16> no worries
<FromGitter> <Blacksmoke16> ill prob go the `self.deserialize` method route, bit cleaner and would easily allow defining custom logic for unsupported types etc
<FromGitter> <Blacksmoke16> now to think what happens if you try to deserialize an unsupported type 😆, return `nil` or exception
Human_G33k has joined #crystal-lang
<FromGitter> <naqvis> i would vote for exception ⭐
HumanG33k has quit [Ping timeout: 265 seconds]
<FromGitter> <naqvis> as that would save the pain of `.try` or var assignment
<FromGitter> <kinxer> Also, an exception can give you more information about the problem.
<FromGitter> <naqvis> true
<FromGitter> <Blacksmoke16> mainly thinking about this scenario
<FromGitter> <kinxer> And I believe that would be symmetrical with the standard library.
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5eaee01997338850a2e4fca2]
<FromGitter> <Blacksmoke16> idt i would be able to deserialize `User` with just `{"name":"Fred"}` if the error is not nilable or has a default value
<FromGitter> <Blacksmoke16> wonder what the stdlib does
<FromGitter> <naqvis> imo portions of code which doesn't opt for functionality should be discarded
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5eaee0b7347bd6163051a3f7]
<FromGitter> <Blacksmoke16> which makes sense
<FromGitter> <Blacksmoke16> this would be the use for `@[JSON::Field(ignore: true)]`
<FromGitter> <Blacksmoke16> ill play around with it, just have a bunch of test cases ha
<FromGitter> <naqvis> i'm just thinking about stdlib approach on such use-cases, afaik stdlib is include - all otherwise opted to get ignored
<FromGitter> <naqvis> and if the composed attr/obj doesn't support (de)serialization, it will blow up
<FromGitter> <naqvis> i might be wrong, but that's what i can recall
<FromGitter> <Blacksmoke16> seems to be the case in this example
<FromGitter> <Blacksmoke16> would either have to reopen `SomeClass` to allow deserialization, or redefine the ivar to ignore it
<FromGitter> <naqvis> Go approach is different, it traverses the instance and if val implements marshaler interface and its not nil, val marshaller is called
<FromGitter> <naqvis> i believe this should be the way
<FromGitter> <naqvis> so in above example, SomeModule shouldn't be (de)serialized, as it doesn't opt for serialization
<FromGitter> <Blacksmoke16> right, yea that would be the cleanest solution
<FromGitter> <naqvis> yeah, totally agree
_ht has quit [Remote host closed the connection]
<FromGitter> <Blacksmoke16> but in order to just skip it, it would have to have a default or be nilable yea?
_ht has joined #crystal-lang
<FromGitter> <kinxer> How would you accomplish that? Can you find out in macro-land whether an instance variable came from a module inclusion?
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5eaee525b6dd230697a25f27]
<FromGitter> <Blacksmoke16> is what im doing now
<FromGitter> <Blacksmoke16> if its nilable you get `#<User:0x7f8a533eed00 @error=nil, @name="Fred">`
<FromGitter> <naqvis> but that means, code is deserializing even if this module doesn't asked to do so
<FromGitter> <Blacksmoke16> right but i just cant leave `error` uninitialized
<FromGitter> <naqvis> gotcha
<FromGitter> <naqvis> then exception is correct behavior
<FromGitter> <Blacksmoke16> thats more of a crystal thing ofc, not sure how gohandles that
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5eaee5d6adb0ec5c2be1057b]
<FromGitter> <Blacksmoke16> like this example
<FromGitter> <naqvis> i mean when deserialized, for vars which doesn't ask for deserialization, code should treat them as nil
<FromGitter> <kinxer> You said Go handles that somehow? Does it just leave it as an uninitialized variable?
<FromGitter> <naqvis> in go, everything has default value
<FromGitter> <naqvis> for pointers, default is nil
<FromGitter> <kinxer> Ah, I see.
<FromGitter> <Blacksmoke16> ah so everything is nilable by default?
<FromGitter> <naqvis> only pointers are nilable by default
<FromGitter> <kinxer> But every type has an "unset" value?
<FromGitter> <Blacksmoke16> so what would happen in Go with that example?
<FromGitter> <naqvis> ints are 0, strings are empty
<FromGitter> <Blacksmoke16> since `Bar` doesnt opt into (de)serialization
<FromGitter> <naqvis> structs are called with default initializer, which in turn assign default values to vars
<FromGitter> <kinxer> Well, the exception class is an object, so presumably it would be a nil pointer.
<FromGitter> <kinxer> Oh. Yeah, that makes sense, too.
<FromGitter> <Blacksmoke16> so it would default to like `Bar.new`?
<FromGitter> <naqvis> yeah
<FromGitter> <Blacksmoke16> and even if `Bar` and an `Int32` ivars itself they would be defaulted to `0` or `""` if they were a string
<FromGitter> <naqvis> yup
<FromGitter> <Blacksmoke16> so yea i guess they dont have to worry about the uninitialized state
<FromGitter> <naqvis> true thing
<FromGitter> <Blacksmoke16> in which in Crystal land an exception is prob best i can do
<FromGitter> <naqvis> in go there is no uninitialized state
<FromGitter> <naqvis> compiler will always initialize ivars to their default values, if you haven't done so
<FromGitter> <naqvis> agree and imo that would be the cleanest option
<FromGitter> <naqvis> as kinxer said, exception will also give better context to dev
<FromGitter> <Blacksmoke16> for sure
<FromGitter> <Blacksmoke16> thanks, that deff clears up some questions
<FromGitter> <naqvis> thanks 👍
<FromGitter> <rishavs> is anyone using Crystal on Windows + VSCode? I do not have autocomplete, error detection etc which I take for granted nowadays. Anyone knows a workaround that worked for them?
<FromGitter> <naqvis> is `scry` working on windows?
<FromGitter> <naqvis> on non-windows platform, that `autocomplete` is done via `scry` and code checks are done via `ameba` extension
<FromGitter> <naqvis> but tbh, autocomplete isn't that perfect atm, or at least i couldn't get it working at its max
<FromGitter> <rishavs> good point. I dont think scry works on windows and probably will not be done till signals are done
_ht has quit [Remote host closed the connection]
_ht has joined #crystal-lang
<FromGitter> <watzon> Most things Crystal don't work on windows yet
<FromGitter> <watzon> Scry still isn't great right now either. I'm hoping development on it picks up around the v1.0 release since the language will be stabilized at that point.
<FromGitter> <rishavs> Is it possible to run the language server over wsl?
<FromGitter> <watzon> Not easily. There are two options. WSL2 + VSCode uses a containerized approach, so with WSL2 and an updated VSCode things should just work. Otherwise you can take the approach outlined in https://github.com/watzon/wsl-proxy
travis-ci has joined #crystal-lang
<travis-ci> crystal-lang/crystal#f42b5f5 (master - Parser: refactor and fix parser for `unless` inside macro (#9167)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/682651392
travis-ci has left #crystal-lang [#crystal-lang]
<DeBot> https://github.com/crystal-lang/crystal/pull/9167 (Parser: refactor and fix parser for `unless` inside macro)
<oprypin> how did i end up on *this* far of a tangent https://github.com/ilammy/msvc-dev-cmd/pull/6/files
<jhass> heh. Better than me wondering why bdwgc would destroy some memory allocated by glibc for 8 hours
<jhass> sorry, GLib I mean
<jhass> or gtksourceview specifically, nothing else showed symptoms so far
<FromGitter> <Blacksmoke16> @naqvis @kinxer ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5eaf166d97338850a2e5777c]
<FromGitter> <Blacksmoke16> is what i got
<FromGitter> <Blacksmoke16> the `Kinda makes sense?` ones, it would deff be a bug within the application's code, but i think im handling it the best i can
<FromGitter> <Blacksmoke16> i.e. can tell there is an array but am unable to parse anything out of it
<FromGitter> <kinxer> `{"name":"Jim","id":19,"bars":[{"id":1}]}` to `#<Foo:0x7ff987d82ea0 @bars=[], @id=19, @name="Jim">` doesn't make sense to me. Why do you lose the contents of `bars`?
<FromGitter> <Blacksmoke16> `Bar` doesnt include the module, i.e. doesnt opt into serialization
<FromGitter> <Blacksmoke16> in that example
<FromGitter> <kinxer> Ah... I see.
<FromGitter> <Blacksmoke16> so i wouldnt know how to serialize it
<FromGitter> <Blacksmoke16> deserialize
<FromGitter> <Blacksmoke16> it would deff be a bug in the code, i.e. someone just forgot to include the module
<FromGitter> <kinxer> I think I would prefer an error in that case as opposed to a best guess.
<FromGitter> <Blacksmoke16> i could prob do it
<FromGitter> <Blacksmoke16> but im happy with this, at least as a WIP prototype
<FromGitter> <Blacksmoke16> ill deff need to do a pass on what exceptions and where i need to raise them and such
<FromGitter> <Blacksmoke16> actually nvm i got it working
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5eaf18d597338850a2e57d46]
<FromGitter> <Blacksmoke16> well
<FromGitter> <Blacksmoke16> what if this array comes from another shard, guess would you rather it not compile, it just ignore stuff
<FromGitter> <Blacksmoke16> the latter would make it easier to use, and conflict less with other stuff
<FromGitter> <Blacksmoke16> :shrug:
<FromGitter> <kinxer> The standard library could bear to have better error messages in this case: https://carc.in/#/r/9082
<FromGitter> <kinxer> Might be a little hairy to implement those, though.
<FromGitter> <kinxer> Could your serializer have an option for that?
<FromGitter> <kinxer> Or perhaps a class-level annotation?
<FromGitter> <kinxer> Or a module?
<FromGitter> <Blacksmoke16> hm, to make it be more strict?
<FromGitter> <kinxer> To do the non-default behavior (whether that's more strict or less strict).
<FromGitter> <Blacksmoke16> hmm
<FromGitter> <Blacksmoke16> deff with a compile time flag `-Dstrict_deserialization`
<FromGitter> <kinxer> I guess that's an approach, but it would be nice to do it on a case-by-case basis (e.g. strict JSON and non-strict YAML).
<FromGitter> <kinxer> Rather, to *be able* to do it on a case-by-base basis.
<FromGitter> <Blacksmoke16> i could deff do something like that at runtime
<FromGitter> <Blacksmoke16> but having a compile time error like this be configurable is a bit tricker
<FromGitter> <kinxer> Yeah, that's certainly fair.
return0e has joined #crystal-lang
<FromGitter> <Blacksmoke16> prob go less strict for now
<FromGitter> <Blacksmoke16> then revisit some stuff like this
<FromGitter> <watzon> Did some memory profiling of tourmaline vs other Telegram bot frameworks in python and nodejs
<FromGitter> <watzon> This is what I like to see
<FromGitter> <Blacksmoke16> neat
<FromGitter> <Blacksmoke16> what you use for that?
<FromGitter> <watzon> `valgrind --tool=massif`
<FromGitter> <Blacksmoke16> a `Profiling` section within https://crystal-lang.org/reference/guides/ would be 💯
<FromGitter> <watzon> And then massif-visualizer
<FromGitter> <watzon> I agree, a profiling section would be nice
<FromGitter> <watzon> valgrind, massif, and callgrind all seem to work pretty well
_ht has quit [Remote host closed the connection]
_ht has joined #crystal-lang
return0e has quit []
return0e has joined #crystal-lang
_ht has quit [Quit: _ht]
return0e has quit [Remote host closed the connection]
return0e has joined #crystal-lang
v2px__ has joined #crystal-lang