ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.29.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
woodruffw has quit [Ping timeout: 248 seconds]
woodruffw has joined #crystal-lang
_whitelogger has joined #crystal-lang
<FromGitter> <Blacksmoke16> started doing a new thing
<FromGitter> <Blacksmoke16> been giving args i dont want to restrict the type of a `: _` restriction
<FromGitter> <Blacksmoke16> so future me knows they can be anything vs just missing a restriction
<FromGitter> <watzon> That's interesting
<FromGitter> <watzon> I kind of like that idea
<FromGitter> <Blacksmoke16> is a bit more explicit but yea, deff useful imo
<FromGitter> <watzon> I prefer to be more explicit anyway
<FromGitter> <Blacksmoke16> wish you could define methods to useful in macro land
laaron has quit [Remote host closed the connection]
<FromGitter> <tenebrousedge> yeah :(
laaron has joined #crystal-lang
<FromGitter> <Blacksmoke16> this DI macro code is a big out there
<FromGitter> <Blacksmoke16> adding comments but still
<FromGitter> <Blacksmoke16> `{{(0...initializer.args.size).map { |idx| arg = service_ann.pos_args[idx]; arg.is_a?(StringLiteral) && arg.starts_with?('@') ? "@services[#{arg[1..-1]}].as(#{initializer.args[idx].restriction})".id : arg.is_a?(StringLiteral) && arg.starts_with?('!') ? %(#{services_tags[arg[1..-1]].map { |ts| "@services[#{ts}].as(#{initializer.args[idx].restriction.type_vars.splat})".id
<FromGitter> ... }}.as(#{initializer.args[idx].restriction})).id : arg }.splat}}` 😬
<FromGitter> <meltheadorable> the crystal book docs thing says that there are no user-defined annotations yet — it looks like DI utilizes user-defined annotations — is that some hack or is the book out of date?
<FromGitter> <Blacksmoke16> where you read that?
<FromGitter> <meltheadorable> i think i meant attributes sorry https://crystal-lang.org/reference/syntax_and_semantics/attributes.html
<FromGitter> <meltheadorable> they have basically the same syntax i think i got confused
<FromGitter> <Blacksmoke16> hold up
<FromGitter> <Blacksmoke16> i dont even see that page anymore on my version
<FromGitter> <Blacksmoke16> oh must still exist, just not avaliable in the list
<FromGitter> <Blacksmoke16> they used to be called attributes yea
<FromGitter> <meltheadorable> okay so the documentation isn’t out of date you can just sometimes accidentally get to out of date documentation
<FromGitter> <Blacksmoke16> yea idk how you found that page
<FromGitter> <meltheadorable> google
<FromGitter> <Blacksmoke16> ah interesting
<FromGitter> <watzon> It must have not gotten deleted when the docs got updated
<FromGitter> <Blacksmoke16> it did, because i was the one who deleted it
<FromGitter> <Blacksmoke16> well renamed*
<FromGitter> <watzon> Weird
<FromGitter> <meltheadorable> ¯\\\_(ツ)\_/¯
* FromGitter * tenebrousedge blames @Blacksmoke16
<FromGitter> <Blacksmoke16> hehe
<FromGitter> <Blacksmoke16> but yea, user defined annotations are a thing
<FromGitter> <watzon> @watzon blames @microsoft
<FromGitter> <Blacksmoke16> are decently documented now as well
<FromGitter> <meltheadorable> fantastic
<FromGitter> <Blacksmoke16> https://dev.to/blacksmoke16/utilizing-macros-annotations-in-a-web-framework-3abk might also be a good read for you
<FromGitter> <meltheadorable> atm im really struggling to find a good project for learning crystal in any depth where crystal is an appropriate choice compared w/ alternatives right now, so i’m just trying to soak up as many small tidbits as i can until the right project comes along
<FromGitter> <Blacksmoke16> maybe look into making/contributing to a shard you like?
<FromGitter> <watzon> What I do is just look for wholes in the ecosystem and try to fill them
<FromGitter> <tenebrousedge> there's a list of wanted shards I think
<FromGitter> <watzon> It's why I have so many damn shards
<FromGitter> <watzon> Lol
<FromGitter> <Blacksmoke16> go make a Mockery shard for me :P
<FromGitter> <watzon> That seems like it might be a slight pain in the butt
<FromGitter> <Blacksmoke16> probably
<FromGitter> <Blacksmoke16> would be *super* useful imo tho
<FromGitter> <Blacksmoke16> esp for testing classes/services with DI
<FromGitter> <meltheadorable> I’ve looked into contributing to the ecosystem but I figured the best way to do that would be to start filling a need I have and unfortunately the needs I have are either beyond my abilities or already exist in another ecosystem that would be a better fit for the project I need them for, and when getting the project done is more important than learning crystal, i have to be pragmatic and set it down
<FromGitter> <Blacksmoke16> then you could just do like `api_mock.should_recieve("get").with(12, "foo").once`
<FromGitter> <Blacksmoke16> would be a cool challenge
<FromGitter> <Blacksmoke16> would have to track method calls/args etc
<FromGitter> <watzon> It would be really nice to have
<FromGitter> <watzon> As would a better spec library in general
<FromGitter> <watzon> A more complete rspec implementation
<FromGitter> <Blacksmoke16> wonder if you could do something like what ameba does
<FromGitter> <Blacksmoke16> with dealing with ast nodes and stuff
<FromGitter> <Blacksmoke16> imagine you could calculate all of it at compile time?
<FromGitter> <Blacksmoke16> and maybe replace the return value...hm
<FromGitter> <meltheadorable> the stuff you’re doing with annotations seems clever, i’m not totally feeling it as a dev interface, like its a cool experiment but im not quite feeling it as something id wanna work with
<FromGitter> <Blacksmoke16> i.e. `api_mock.should_recieve("get").with(12, "foo").and_return("RESPONSE").once`
<FromGitter> <Blacksmoke16> no?
<FromGitter> <Blacksmoke16> most people seem to not like the syntax
<FromGitter> <watzon> Personally I like the annotation based syntax. Until I saw Athena I was thinking of doing a web framework in a similar way
<FromGitter> <Blacksmoke16> ;P
<FromGitter> <meltheadorable> im also not big on the syntax, it also in some cases — like with route definitions — feels like “hiding” information that is actually critical in a feature that is really not quite designed for that — i’ve not used other crystal web frameworks yet so there’s a chance i’d like it better than whatever lucky or amber are doing at the moment for instance — but something about annotations
<FromGitter> ... being “commenty” makes me not want to use them for critical logic
<FromGitter> <meltheadorable> like routes or validations
<FromGitter> <Blacksmoke16> just what you're used to tbh
<FromGitter> <Blacksmoke16> we use symfony at work so im used to using them for defining orm columns or routes etc
<FromGitter> <watzon> I've seen annotations used for routes in other frameworks tbh
<FromGitter> <watzon> I think the first was a rust framework
<FromGitter> <Blacksmoke16> coming from rails you're used to doing everything in some file
<FromGitter> <Blacksmoke16> which makes can make it harder as you're separating related things
<FromGitter> <Blacksmoke16> kemal/lucky do like
<FromGitter> <Blacksmoke16> ```get "some/path" do ⏎ # Route action ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5d3a64124a32b65507d88edf]
<FromGitter> <Blacksmoke16> amber does like `get "/", ApiController, :index`
<FromGitter> <watzon> I like Lucky's approach for the most part
<FromGitter> <watzon> The route/controller are tightly integrated
<FromGitter> <Blacksmoke16> depends what you're used to tbh, amber would seem more at home for someone coming from rails
<FromGitter> <Blacksmoke16> kemal/lucky if sinatra
<FromGitter> <Blacksmoke16> athena if symonfy/spring
<FromGitter> <watzon> Yeah that makes sense
<FromGitter> <meltheadorable> i trust thoughtbot’s judgment in general so i extend lucky a lot of benefit of the doubt — amber does seem a little bit more homey but i also appreciate that lucky is primed to try to take more advantage of crystal being crystal not ruby
<FromGitter> <Blacksmoke16> idk if one is *bad*, just what you prefer
<FromGitter> <watzon> I agree. Thoughtbot is a good company and I think they've done an amazing job with Lucky so far
<FromGitter> <meltheadorable> I hate sinatra but only because i’ve never actually encountered a project where it was a good fit
<FromGitter> <watzon> Avram is a very powerful ORM
<FromGitter> <meltheadorable> i’m pretty spoiled by how good activerecord is, dealing with databases is one of my biggest anticipated pain points moving to crystal
<FromGitter> <Blacksmoke16> dont really know much about avram
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
<FromGitter> <Blacksmoke16> eeee they use mutable constants
<FromGitter> <Blacksmoke16> but a pretty good implementation of it
<FromGitter> <Blacksmoke16> could be worse
<FromGitter> <Blacksmoke16> i been partial to Granite
<FromGitter> <tenebrousedge> "mutable constant" is supposed to be a joke <__< "variables won't, and constants aren't"
<FromGitter> <Blacksmoke16> afaik only one that easily supports `*::Serializable` and annotations on columns
<FromGitter> <girng> "Mutable constants"
<FromGitter> <girng> ..lol
<FromGitter> <meltheadorable> what are people using mutable constants to accomplish?
<FromGitter> <Blacksmoke16> ORMs that arent using annotations under the hood are most likely using them
<FromGitter> <Blacksmoke16> mutable in the sense they are edited to compile time via macro
<FromGitter> <meltheadorable> hmm
<FromGitter> <Blacksmoke16> i.e. when you use like `column name : String`, it either pushes it to an array, or sets some hash value. then later iterates over it
<FromGitter> <Blacksmoke16> or something along those lines
<FromGitter> <watzon> Avram is the best ORM implementation I've seen in Crystal so far
<FromGitter> <watzon> And they're about to add support for polymorphic joins
<FromGitter> <girng> that's a new term i've never heard of
<FromGitter> <Blacksmoke16> are there any docs anywhere?
<FromGitter> <watzon> @girng polymorphicism?
<FromGitter> <girng> well, i heard of that word, but not with "joins"
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <girng> is it like a left join in sql
<FromGitter> <watzon> There aren't any specifically for Avram though
<FromGitter> <watzon> Not yet anyway
<FromGitter> <watzon> @girng relationships would've been a better word than joins
<FromGitter> <watzon> But it's the same idea
<FromGitter> <tenebrousedge> yes
<FromGitter> <tenebrousedge> say you have a "Tag" class which could be associated with a number of others
<FromGitter> <tenebrousedge> e.g. Posts, Categories, Movies
<FromGitter> <tenebrousedge> `tags` would have both a FK reference and the name of the associated model
<FromGitter> <tenebrousedge> then you can do `post.tags` and `movie.tags` in your code
<FromGitter> <meltheadorable> I like the rails naming conventions for these — where you’d call that `Taggable` and the table would store a `taggable_id`along with the type of the class it’s associating to so that the object can be reconstructed
<FromGitter> <watzon> @meltheadorable that's what you do currently in Avram too
<FromGitter> <watzon> Although apparently the way they are going to store things in the database for the official implementation is going to use a different schema design
<FromGitter> <meltheadorable> I don’t particularly know that that’s the best way to model every polymorphic modeling relationship in a schema, it works really well for tags and progressively worse for most other things they get abused to handle
<FromGitter> <meltheadorable> I’ve always wanted to see a good implementation of multi-table inheritance for rails
<FromGitter> <watzon> I think there are certain things that polymorphic relationships are really good for. Tags, comments, categories, in some cases avatars if you have multiple models that need them
<FromGitter> <watzon> But they certainly get abused
<FromGitter> <Blacksmoke16> new service registration code
<FromGitter> <meltheadorable> I’m more a maybe on comments, but they are generally hard to get right
<FromGitter> <meltheadorable> Attachments, including avatars, are an interesting case — but I often wonder how much use of polymorphic associations is like, using the best out of a toolbox with no appropriate tools rather than actually the best tool
<FromGitter> <watzon> @Blacksmoke16 is the API remaining the same? I don't see any spec changes
<FromGitter> <Blacksmoke16> correct, all passes 😄
<FromGitter> <watzon> Nice :)
<FromGitter> <Blacksmoke16> going to add more tho
<FromGitter> <tenebrousedge> @meltheadorable what would the best tool be?
<FromGitter> <watzon> ActiveStorage helps a lot by hiding the database stuff for the most part
<FromGitter> <Blacksmoke16> need to add some to test the `"!partner"` logic
<FromGitter> <meltheadorable> I dunno, comments and attachments are really complex schema design problems in general, more idly wondering
<FromGitter> <Blacksmoke16> and still figure out detecting circular dependencies and such
<FromGitter> <Blacksmoke16> but im off to bed o/
<FromGitter> <watzon> Night o/
<FromGitter> <meltheadorable> I think polymorphic associations are often a good fit when you only need to access the association from the other model’s side — sometimes that’s true for comments, and it’s usually true for tags and often but not universally true for attachments — but like, another thing it’s tempting to use polymorphic associations for is things like addresses or contact information — because you can
<FromGitter> ... apply those to people (which may be representable by multiple classes) and organizations, and groups — etc — but often you want to be able to operate on a collection of like, all addressable/contactable entities across the different model types and suddenly polymorphic associations are a major querying problem
<FromGitter> <meltheadorable> and that can be an issue for some search-shaped problems too
<FromGitter> <tenebrousedge> I mean, that sounds like a problem with that schema
<FromGitter> <tenebrousedge> but if you're storing the model name elsewhere I don't think it would be an issue
<FromGitter> <watzon> Yeah I think addresses can definitely be a use case for polymorphic relationships, you just need to take care to structure things correctly
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
DTZUZU has quit [Read error: Connection reset by peer]
DTZUZU has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
_whitelogger has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
absolutejam2 has joined #crystal-lang
<FromGitter> <absolutejam_gitlab> I can't sign up on forums with an email
<FromGitter> <absolutejam_gitlab> Getting incorrect username, email or password when trying to sign up
<FromGitter> <girng> that's weird
<FromGitter> <girng> why would it say incorrect username when registering
<FromGitter> <girng> did you use an inappropriate name or something
<FromGitter> <gdotdesign> Hey folks, I launched Base (https://www.base-api.io) yesterday, and its backend is written in Crystal 🎉 (2.4 Mb binary, ~2300 LOC)
<FromGitter> <absolutejam_gitlab> ooh, looks snazzy]
<FromGitter> <watzon> @gdotdesign Mint front-end, whats the backend?
<FromGitter> <gdotdesign> Crystal :D what else :D
<FromGitter> <girng> wow, beautiful site
<FromGitter> <watzon> @gdotdesign I mean framework haha. Are you using one?
<FromGitter> <absolutejam_gitlab> I wish there was a crystal -> JS transpiler
<FromGitter> <gdotdesign> wrote a little something myself, try to move it to a shard soon(ish)
<FromGitter> <watzon> Nice :) well good job
<FromGitter> <gdotdesign> thanks :)
_whitelogger has joined #crystal-lang
alex`` has joined #crystal-lang
absolutejam2 has quit [Ping timeout: 272 seconds]
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
flaviodesousa has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
absolutejam2 has joined #crystal-lang
ht_ has joined #crystal-lang
absolutejam2 has quit [Ping timeout: 272 seconds]
laaron has quit [Remote host closed the connection]
<FromGitter> <absolutejam_gitlab> Do we have an accepted standard for documentation comments on methods?
<FromGitter> <absolutejam_gitlab> eg. for documenting args
absolutejam2 has joined #crystal-lang
<FromGitter> <watzon> Not really, at least not as far as I know
<FromGitter> <absolutejam_gitlab> Looks like it's more explanatory with examples
<FromGitter> <watzon> One thing that a better documentation generator could help with
<FromGitter> <absolutejam_gitlab> Than strictly explaining each argument, etc.
laaron has joined #crystal-lang
<FromGitter> <absolutejam_gitlab> Raising exceptions in a method is a good example
<FromGitter> <absolutejam_gitlab> would be nice to document what is raised
<FromGitter> <watzon> Yeah it would
<FromGitter> <absolutejam_gitlab> maybe an RFC proposal is needed
<FromGitter> <watzon> And technically the documentation generator could automatically do that
<FromGitter> <watzon> It just doesn't right now
<FromGitter> <absolutejam_gitlab> yeah
<FromGitter> <absolutejam_gitlab> would be case of defining what is needed then updating the generator
absolutejam2 has quit [Ping timeout: 268 seconds]
flaviodesousa has quit [Quit: KVIrc 4.9.3 Aria http://www.kvirc.net/]
<FromGitter> <absolutejam_gitlab> Will `not_nil!` cause an exception at runtime if it is actually nil?
<Yxhuvud> yes, it will
<FromGitter> <absolutejam_gitlab> Thought as much, thanks
<FromGitter> <absolutejam_gitlab> I have already validated that it's definitely not `nil` and there's no mutation or concurrency going on, so I'm happy with using it
<FromGitter> <watzon> A good thing to do instead of using `not_nil!` is to use `try`
<FromGitter> <absolutejam_gitlab> well I was using a guard clause
<Yxhuvud> or just a regular if.
<FromGitter> <absolutejam_gitlab> yeah ^
<FromGitter> <absolutejam_gitlab> But I have already done all the validation prior to this point
<FromGitter> <absolutejam_gitlab> so it just makes my main statement have tonnes of indentation
<FromGitter> <watzon> `try` is much more concise than a guard clause, especially if you have multiple things in a chain that might be nil
<FromGitter> <watzon> But they're useful in different instances
<Yxhuvud> care to share the code? It may be that it is possible to arrange it so that you don't need any checks at all if you have already checked it against nil
<FromGitter> <absolutejam_gitlab> well it's checked in a different function, prior to this one being called
<FromGitter> <absolutejam_gitlab> but the value is retrieved again
<FromGitter> <absolutejam_gitlab> from a property
<FromGitter> <absolutejam_gitlab> so there's a function that runs and validates the property, then later, the 'main' function pulls this property and uses it
<FromGitter> <absolutejam_gitlab> `try` looks quite nice
<FromGitter> <absolutejam_gitlab> I keep meaning to spin up a blog again and start writing bits about Crystal
<Yxhuvud> to un-nil instance variables, the usual way to do it is to assign it to a local variable and then do the nil check on that
<FromGitter> <absolutejam_gitlab> Yeah, I previously had that in an if statement
<FromGitter> <absolutejam_gitlab> Actually a couple of them as there's a couple of union types that could be nil
<FromGitter> <absolutejam_gitlab> ```if (arg = cmd.get_arg("foo") && arg.parsed_value.as(String)) ⏎ # do stuff ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5d3ab831f4c906673aef1cf4]
<FromGitter> <absolutejam_gitlab> something like that
<FromGitter> <absolutejam_gitlab> > To automatically link to other types, enclose them with single backticks.
<FromGitter> <absolutejam_gitlab> Oh, so that is in there
<FromGitter> <absolutejam_gitlab> I missed that from Elixir, but I guess I just haven't written the examples properly haha
<FromGitter> <girng> :D
<FromGitter> <watzon> ```if arg = cmd.try &.get_arg("foo").parsed_value.as(String) ⏎ # do stuff ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5d3ab8d66f384439766127a3]
<FromGitter> <watzon> That might work
<FromGitter> <watzon> Just an example of using try
<FromGitter> <absolutejam_gitlab> I really don't like the short lambda syntax
<FromGitter> <absolutejam_gitlab> I should just learn to love it
<FromGitter> <watzon> It's much more concise than the alternative
<FromGitter> <absolutejam_gitlab> again, same with in Elixir
<FromGitter> <watzon> `if arg = cmd.try { |a| a.get_arg("foo").parsed_value.as(String) }`
<FromGitter> <absolutejam_gitlab> Eh, I much prefer that
<FromGitter> <absolutejam_gitlab> Sorry, short block syntax*
<FromGitter> <watzon> To me it's just ugly, but personal preference
<FromGitter> <watzon> The main advantage the shorter syntax has is when you chain them
<FromGitter> <watzon> `foo.try &.bar.baz.try &.foo_bar`
<FromGitter> <girng> -_-
<FromGitter> <absolutejam_gitlab> yeah, fair enough
<FromGitter> <girng> guard clause #1 eZ
<FromGitter> <absolutejam_gitlab> Does that evaluate to multiple blocks? @watzon
<FromGitter> <watzon> @absolutejam_gitlab what do you mean?
<FromGitter> <watzon> There are multiple blocks there
<FromGitter> <absolutejam_gitlab> I mean, does it evaluate to multiple try statements?
<FromGitter> <absolutejam_gitlab> with their own block
<FromGitter> <watzon> Yes
<FromGitter> <absolutejam_gitlab> oh nevermind
<FromGitter> <absolutejam_gitlab> I didn't see the second `try` in there
<FromGitter> <absolutejam_gitlab> I thought it was some chaining magic
<FromGitter> <absolutejam_gitlab> that's why it confused me
<FromGitter> <absolutejam_gitlab> I thought you had `foo.try &.bar.baz &.foo_bar`
<FromGitter> <watzon> It's the same thing as ``foo.try { |f| f.bar.baz.try { |b| b.foo_bar } }`
<FromGitter> <absolutejam_gitlab> Which makes no sense
<FromGitter> <watzon> Ahhh I gotcha
sorcus has joined #crystal-lang
go|dfish has quit [Ping timeout: 244 seconds]
absolutejam2 has joined #crystal-lang
absolutejam2 has quit [Ping timeout: 244 seconds]
absolutejam2 has joined #crystal-lang
absolutejam2 has quit [Ping timeout: 246 seconds]
gangstacat has joined #crystal-lang
<FromGitter> <absolutejam_gitlab> Can you `include` one or more methods from a module?
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
absolutejam2 has joined #crystal-lang
absolutejam2 has quit [Ping timeout: 245 seconds]
_whitelogger has joined #crystal-lang
absolutejam2 has joined #crystal-lang
absolutejam2 has quit [Ping timeout: 246 seconds]
<FromGitter> <bararchy> @bcardiff any news on the MT work? I know you guys are working on this but I would love some general progress info
<FromGitter> <bararchy> even a generic ETA god forbid XD
<FromGitter> <mwlang> *sigh* google-fu for "cgi" is failing me. Apparently, it's no longer common gateway interface and is not computer generated imagery.
<FromGitter> <mwlang> long story short, I built my first JAMStack site in a while using Ruby-based Jekyll and then realized as I got nearly done that I need to handle contact form submission. Idea: small crystal program as a CGI and just configure nginx to call it when form's submitted.
<FromGitter> <Blacksmoke16> > Do we have an accepted standard for documentation comments on methods? ⏎ ⏎ Yes @absolutejam_gitlab
<FromGitter> <Blacksmoke16> https://crystal-lang.org/reference/conventions/documenting_code.html some of it is in here
<FromGitter> <absolutejam_gitlab> Yeah, I've seen that sorry
<FromGitter> <absolutejam_gitlab> I meant like documenting methods (their usage, what should be expected, etc.), exceptions
<FromGitter> <Blacksmoke16> ah gotcha
<FromGitter> <absolutejam_gitlab> I know you don't need to document input and output types
<FromGitter> <absolutejam_gitlab> because that'd be crazy
<FromGitter> <Blacksmoke16> i mean if you can you should
<FromGitter> <Blacksmoke16> but some cases you just cant
<FromGitter> <mwlang> document from the point of view of a user that needs to know how to use the code. sometimes as the author of a library, we get stuck in the mode of thinking of what the code does and documenting that instead of it's use in other code bases.
<FromGitter> <mwlang> and with that point in mind comes the next bit, document use examples.
<FromGitter> <Blacksmoke16> documentation should be at a higher level than the code
<FromGitter> <Blacksmoke16> i.e. dont add a comment saying like `# Iterate over the values and do x`
<FromGitter> <Blacksmoke16> when someone can just look at it and see you're doing a .each
<FromGitter> <mwlang> this actually brings up one grief I have with current limited markdown facilities...it's hard to document close to proximity of the code *and* write useful documentation. Or, I guess I should say, it's definitely an acquired skill to get it right.
<FromGitter> <tenebrousedge> write shorter methods?
<FromGitter> <Blacksmoke16> i would still like this to get done at some point
<FromGitter> <mwlang> that's a nice idea inheriting comments from parent classes/implementations
<FromGitter> <absolutejam_gitlab> > i mean if you can you should
<FromGitter> <absolutejam_gitlab> I mean, there's no need to document the types of input & output
<FromGitter> <absolutejam_gitlab> because they are produced automatically
<FromGitter> <absolutejam_gitlab> Exceptions could also be pulled automatically, but it might be nice to add some information
<FromGitter> <Blacksmoke16> oh right, yea. i misread. was thinking you were meaning return type restrictions
<FromGitter> <Blacksmoke16> i.e. type restrictions
<FromGitter> <absolutejam_gitlab> I always declare my return types
<FromGitter> <absolutejam_gitlab> Feels shoddy to not
<FromGitter> <absolutejam_gitlab> and I want the compiler to validate my output == what I say it is, vs. inferring it
<FromGitter> <absolutejam_gitlab> and that can lead to `nil`, right?
<FromGitter> <absolutejam_gitlab> if you returned nil without an explicit return type restriction in the method declaration
<FromGitter> <Blacksmoke16> right yea
<FromGitter> <Blacksmoke16> without it, it would allow anything
<FromGitter> <Blacksmoke16> you can also set the return type to `: Nil`, which makes it return `nil` no matte what
<FromGitter> <absolutejam_gitlab> yeah, I also caught myself out by doing that on a Proc
<FromGitter> <absolutejam_gitlab> Spent 10 minutes trying to find why it wasn't returning anything
<sorcus> > https://play.crystal-lang.org/#/r/7aoc - why i can't do that?
<FromGitter> <Blacksmoke16> that should be reverted imo
<FromGitter> <absolutejam_gitlab> can you use a required param as an optional?
<FromGitter> <Blacksmoke16> hm?
<FromGitter> <absolutejam_gitlab> I thought the compiler would complain that you're declaring `initialize` twice with the same arity
<FromGitter> <Blacksmoke16> still not sure i follow
absolutejam2 has joined #crystal-lang
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
<sorcus> Ok, that's expected behavior or not?
absolutejam2 has quit [Ping timeout: 244 seconds]
<FromGitter> <asterite> it's expected behavior, you are redefining a method
<FromGitter> <asterite> Try this: https://play.crystal-lang.org/#/r/7aoe
lucasb has joined #crystal-lang
<sorcus> Oh, ok. Thanks.
<FromGitter> <asterite> Though I'm more and more inclined to force a `@[Redefines]` annotation when a method is redefined. Then you would get an error if you redefine but don't notice, and it would be much more obvious when something is redefined.
<FromGitter> <asterite> @gdotdesign do you have any feedback of using Crystal?
return0e has quit [Ping timeout: 246 seconds]
absolutejam2 has joined #crystal-lang
<FromGitter> <gdotdesign> It's awesome 😀 I keep it simple, minimum abstraction and it's working great 👍
<FromGitter> <gdotdesign> on Heroku Base is 2.4 Mb slug size, memory about 10Mb and respons time is about 10ms :D
Yxhuvud has quit [Read error: Connection reset by peer]
absolutejam2 has quit [Ping timeout: 245 seconds]
return0e has joined #crystal-lang
<FromGitter> <asterite> Cool!
absolutejam2 has joined #crystal-lang
<FromGitter> <absolutejam_gitlab> @asterite thanks for taking the time to reply to my post
<FromGitter> <absolutejam_gitlab> I was looking for an IO Multireader - must have missed that!
absolutejam2 has quit [Ping timeout: 268 seconds]
absolutejam2 has joined #crystal-lang
<FromGitter> <fernandes> @gdotdesign `in Budapest` awesome! :D
<FromGitter> <gdotdesign> @fernandes yeah :D
<FromGitter> <fernandes> I'm here next few days, I love this city hahaha nice to see it being created here 😉 nk
<jokke> is there a factory-girl alternative for crystal?
absolutejam2 has quit [Ping timeout: 245 seconds]
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
go|dfish has joined #crystal-lang
Yxhuvud has joined #crystal-lang
<FromGitter> <watzon> @jokke not that I know of
<jokke> k
<jokke> i'm helping myself using optional named args
<FromGitter> <absolutejam_gitlab> Anyone tried using golang libs in crystal?
<FromGitter> <absolutejam_gitlab> Really tempted to look at porting podman
<FromGitter> <absolutejam_gitlab> No idea if it'd work or what's involved
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
<FromGitter> <watzon> I'd try to create a podman alternative in Crystal rather than wrapping the existing Go implementation
laaron has joined #crystal-lang
<FromGitter> <absolutejam_gitlab> Reinventing the wheel
<FromGitter> <watzon> Not necessarily, it's possibly doing it better in a better language
<FromGitter> <watzon> Not to mention a faster language, if you don't include Go's coroutines
<FromGitter> <absolutejam_gitlab> Sorry, one handed typing on mobile . Wasn't meant to be lung
<FromGitter> <absolutejam_gitlab> Blunt
<FromGitter> <girng> hello
<FromGitter> <Blacksmoke16> o/
<FromGitter> <absolutejam_gitlab> Reading about varlink
<FromGitter> <absolutejam_gitlab> News to me
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron- has joined #crystal-lang
<FromGitter> <drosehn> FWIW, I like the idea of a `@[Redefine]` annotation.
absolutejam2 has joined #crystal-lang
<FromGitter> <girng> long time no see, @drosehn
<FromGitter> <drosehn> I catch up a few times a week, but usually don't say much. I do see interesting topics I'd join in on, but I see them more than 12 hours after the topic has died out, so I don't say much. In this case asterite's comment was only 6 hours old. 😄
<FromGitter> <drosehn> Also I've been really busy at work — which is always true. But one of our main guys retired a few weeks ago, so now I'm even busier.
<FromGitter> <girng> @drosehn that sucks. hope they hire someone else to offset the load
<FromGitter> <girng> or.. maybe now you get more overtime and more $, lol
absolutejam3 has joined #crystal-lang
absolutejam2 has quit [Ping timeout: 258 seconds]
absolutejam4 has joined #crystal-lang
absolutejam3 has quit [Ping timeout: 245 seconds]
ht__ has joined #crystal-lang
ht_ has quit [Ping timeout: 264 seconds]
<FromGitter> <drosehn> My job is the kind where they don't pay overtime. ⏎ ⏎ Originally "management" here claimed they would hire the guy who just retired on a part-time, consultant basis. But somehow that never got setup, and now the guy is kinda mad about that so I'm not sure he would take it if it was offered.
ht__ is now known as ht_
<FromGitter> <watzon> e
<FromGitter> <absolutejam_gitlab> sweet, TIL of https://crystal-lang.org/api/0.29.0/Iterator.html and the likes of `IO.each_line` for lazy eval 👍
<FromGitter> <watzon> Yep. Can be nice
<FromGitter> <tenebrousedge> `Iterator` is my bae
<FromGitter> <Blacksmoke16> i remember hearing someone used it to implement fetching all pages for an api
<FromGitter> <Blacksmoke16> where `#next` returns the data for the next page`
<FromGitter> <absolutejam_gitlab> fair enough
<FromGitter> <Blacksmoke16> which is quite slick
dingenskirchen has left #crystal-lang [#crystal-lang]
dingenskirchen has joined #crystal-lang
absolutejam4 has quit [Ping timeout: 258 seconds]
<FromGitter> <Daniel-Worrall> https://gist.github.com/Daniel-Worrall/9e4586963f764a1c7e17b79bec5623bb I'm getting a tricky cross compile error `/mnt/c/Users/Daniel/git/crystal/` being the crystal dir where I built with llvm7
<FromGitter> <Daniel-Worrall> It's a Kemal app with almost no code
<FromGitter> <Daniel-Worrall> SSL will forever haunt me
<FromGitter> <watzon> @Daniel-Worrall do you have openssl installed?
<FromGitter> <Daniel-Worrall> I do
<FromGitter> <Daniel-Worrall> pkg-config libssl --modversion ⏎ ⏎ 1) 1.1c
<FromGitter> <watzon> Hmm, I have no clue then
<FromGitter> <watzon> I know I've seen that before, but I could swear installing openssl fixed it
<FromGitter> <Daniel-Worrall> It's being built on WSL to cross compile to rpi
<FromGitter> <Daniel-Worrall> so really, I'm asking for problems
<FromGitter> <Daniel-Worrall> Could it be that libssl is different versions across the compile? 1.02g on WSL, 1.1.1c on rpi
<FromGitter> <watzon> Hmm quite possibly
<FromGitter> <Blacksmoke16> nice
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d3b6a29422eab0d333b403d]
mps has joined #crystal-lang
absolutejam4 has joined #crystal-lang
<FromGitter> <Blacksmoke16> compile time error too 😉
<FromGitter> <watzon> Good job!
<FromGitter> <girng> so many colons why
<FromGitter> <Blacksmoke16> namespaces man
<FromGitter> <Blacksmoke16> makes things more modular
<FromGitter> <girng> eh i never use those
<FromGitter> <Blacksmoke16> i know :P
<FromGitter> <girng> lol
<FromGitter> <watzon> Namespaces are a good thing
<FromGitter> <girng> i mean.. i'll prob end up using em eventually
<FromGitter> <Blacksmoke16> i mainly use it to group related things on the generated docs
sorcus has quit [Ping timeout: 264 seconds]
<FromGitter> <Blacksmoke16> as each nested namespace gets its own "sub folder"
<FromGitter> <girng> why does it feel like namespace syntax doesn't go well with ruby's syntax
<FromGitter> <girng> or is it just me?
<FromGitter> <Blacksmoke16> php handles it with the `use` statment
<FromGitter> <Blacksmoke16> so at the top you do like `use src/di/class_service;` then everywhere in file can just use `ClassService` without the full path
<FromGitter> <girng> oh yeah true
<FromGitter> <girng> i remember seeing `use`
<FromGitter> <girng> ruby's namespace syntx is similar to c++'s right?
<FromGitter> <girng> double colon
<FromGitter> <girng> 4m results, holy
<FromGitter> <girng> > The :: operator is called the scope-resolution operator and does just that, it resolves scope. So, by prefixing a type-name with this, it tells your compiler to look in the global namespace for the type. ⏎ ⏎ is `::` the only way to resolve scope in ruby/crystal?
<FromGitter> <kinxer> Couldn't you `alias`, too?
<FromGitter> <kinxer> `alias DIRegister = Athena::DI::Register`
<FromGitter> <kinxer> Presumably if you're only using a specific class or module.
<FromGitter> <girng> lol. had to do `extend self` on each module for it to work
<FromGitter> <girng> yeah, i don't like namespaces
<FromGitter> <watzon> You can alias, you can also just include. It's similar to `using namespace` in C++
<FromGitter> <girng> confusing, convoluted, redundant af, and makes code look more complex than it is
<FromGitter> <watzon> So `include Athena::DI` would allow you to use everything in that namespace
<FromGitter> <watzon> @girng also necessary if you want to modularize things
<FromGitter> <kinxer> @girng https://play.crystal-lang.org/#/r/7aqk ?
<FromGitter> <watzon> @kinxer for the love of all that is good in the world
<FromGitter> <watzon> Why?
<FromGitter> <watzon> Lol
<FromGitter> <kinxer> Compare with @girng 's previous play link.
<FromGitter> <girng> @kinxer oh nice, yeah i was just going off the example here https://crystal-lang.org/reference/syntax_and_semantics/modules.html
<FromGitter> <girng> record macro hides a lot of complexity though
<FromGitter> <watzon> Ahh yeah
<FromGitter> <girng> but it does look way nicer, your way
<FromGitter> <watzon> Yeah chaining module names is nice sometimes
<FromGitter> <watzon> Hopefully you never get that deep though
<FromGitter> <girng> I think they should have put that macro record example in gitbook as an example
<FromGitter> <kinxer> Yeah, if you get that deep you probably just need to separate components completely.
<FromGitter> <watzon> Also, just sayin https://play.crystal-lang.org/#/r/7aql
<FromGitter> <girng> there are a lot of short cuts in crystal you can do, to cut down on code huh lol and make the syntax better
<FromGitter> <watzon> Yes there are
<FromGitter> <girng> what just happened with my example is a prime example
<FromGitter> <girng> that's how i thought i would have to do it, if i were to nest modules
alex`` has quit [Ping timeout: 245 seconds]
<FromGitter> <watzon> Well now you know
<FromGitter> <meltheadorable> i’m not sure why you’d ever end up that many modules deep but “don’t namespace anything” feels like a bad call
<FromGitter> <watzon> If you ever have to nest that deep though you've got something wrong with your code
<FromGitter> <girng> i don't really use modules personally, except the ones inherited from the shards i use
<FromGitter> <watzon> You should think about it. Modules are kind of an important part of Crystal and Ruby
<FromGitter> <watzon> Just like Interfaces are in Rust
<FromGitter> <meltheadorable> they’re more or less an essential organization technique, and if you’re writing shards you also should consider it if only to avoid polluting people’s global namespace with your classes
<FromGitter> <girng> my philosophy / train of thought is, write a method for what you want to do. then use that method. it's dead simple, and if you have the methods organized out separately, it's the perfect work flow for me
<FromGitter> <watzon> That's the biggest thing
<FromGitter> <meltheadorable> use a flat namespace internally if you really need to, but “put everything in the global namespace” doesn’t work for code you want other people to be able to use
<FromGitter> <watzon> Like @meltheadorable, it's more about not polluting the global namespace
<FromGitter> <girng> global namespace is my home
<FromGitter> <meltheadorable> are you also not using separate classes?
<FromGitter> <watzon> Just saying, if you're writing code that you expect others to use it's best to be considerate
<FromGitter> <girng> lol like anyone gonna use my code
<FromGitter> <watzon> That's the spirit
<FromGitter> <girng> wouldn't touch it with a ten foot pole
<FromGitter> <watzon> Lol
<FromGitter> <girng> if the crystla compiler doesn't error, i'm doing it right. that's my motto
<FromGitter> <meltheadorable> i care about best practices to a fault
<FromGitter> <girng> i trust the lead devs enough lol
<FromGitter> <kniknoo> *shrug* I find refactoring for practical style to be fun.
moei has joined #crystal-lang
<FromGitter> <meltheadorable> the compiler doesn’t enforce good code, just code
<FromGitter> <watzon> @meltheadorable same. Even if I'm the only one that is ever gonna see my code
<FromGitter> <meltheadorable> @watzon yep, i am the only one writing code for my side projects, and I keep refactoring things instead of letting it be good enough for now and moving onto the next piece
<FromGitter> <watzon> Even with personal projects it's important to be able to navigate the code and refactor easily. And who knows, someday you may want to publish the code for that project and others might want to use it.
<FromGitter> <girng> i'm just happy my brain functions with crystal code. i can think of something and code it out, that's all that matters to me.
<FromGitter> <girng> i can't do that with other languages
<FromGitter> <kniknoo> I spent all day yesterday writing a Discordian Calendar library and all day today making the code look nice. :)
<FromGitter> <girng> besides php and js
<FromGitter> <watzon> Now that you can though you might want to look into implementing best practices. You can always improve.
<FromGitter> <girng> well, i started using guard clauses now
<FromGitter> <girng> removes nested ifs, helps a lot
<FromGitter> <kniknoo> in rb/cr there's a certain satisfaction in going from "working" to "elegant". Part of the fun.
<FromGitter> <watzon> Agreed
<FromGitter> <girng> @kniknoo discordian calendar??
<FromGitter> <girng> never heard of that. i'm not good with dates n whatnot, nice
<FromGitter> <girng> too many issues. leap year, etc
<FromGitter> <watzon> It's kinda hilarious
<FromGitter> <girng> > This is because 4 years + 1 day = 5, a holy number ⏎ ⏎ instantly thought of templeOS lmaoo
<FromGitter> <watzon> 😂
<FromGitter> <girng> 😆
<FromGitter> <girng> interesting
<FromGitter> <kniknoo> It was actually really simple piggybacking off of Time. I just had to figure out the day of the year, assuming that feb29 is a special case and the rest came together pretty naturally. I read the original C++ source today and I reckon I have a few features to add still. :D ⏎ ⏎ I just installed TempleOS a few days ago... I'm genuinely curious about the hypertext into the source code concept.
<FromGitter> <watzon> Wait what?
<FromGitter> <watzon> Hypertext into the source code?
<FromGitter> <kniknoo> My understanding is that you can essentially monkey patch the OS, but I'm going to need to do some reading lest I misunderstood what I was told.
<FromGitter> <girng> never heard of this term/phrase, but it sounds fascinating
<FromGitter> <kniknoo> I'm stoked for the idea of a low level code that's pretty easy to read, I wanna crystallize everything for the sake of more eyes capable of working on core libraries in the future.
<FromGitter> <tenebrousedge> @girng which phrase are you talking about?
<FromGitter> <watzon> @kniknoo that's pretty much my goal
<FromGitter> <kniknoo> I'm grateful for the collection we've inherited, but excited to start updating some of this stuff that's barely been touched since the 90s.
<FromGitter> <girng> "hypertext into the source code"
<FromGitter> <girng> this is prob low level stuff far beyond my knowledge...
<FromGitter> <girng> i shouldn't of even said anything
<FromGitter> <tenebrousedge> TempleOS was technologically quite interesting
<FromGitter> <kniknoo> There was a concept in there where he doesn't distinguish code from data and is able to use hyperlinks to either just as readily. ⏎ ⏎ Yeah, dude was in his own world, but he had some great ideas. I hope to find inspiration in his work for my own projects.
<FromGitter> <tenebrousedge> I would never want to use it, and probably never want to develop anything in/for it
<FromGitter> <kniknoo> Nope, I'm just deer in the headlights when I open it, but I love OSes for their individual ideas.
<FromGitter> <kniknoo> Thanks for that link!
<FromGitter> <tenebrousedge> > TempleOS's unified hypertext really shines when presented in the shell. From the command-line, you can call Uf("Foo") to disassemble a function, and each symbol printed will be hyperlinked in the shell window. Click on it to go to the source. objdump can't do that.
<FromGitter> <girng> yeah i'm lost
<FromGitter> <meltheadorable> sounds like smalltalk
* FromGitter * girng alt-tabs back to vscode
<FromGitter> <tenebrousedge> yeah, it seems kinda like the spirit of smalltalk
<FromGitter> <tenebrousedge> I mean, not that I've ever played with that
<FromGitter> <meltheadorable> that aspect of smalltalk is really the only thing i missed much when I picked up ruby
<FromGitter> <meltheadorable> but it was worth being able to be actually productive in it and the friendlier syntax
<FromGitter> <meltheadorable> and ruby had also given me some of what i loved about lisps at the time
<FromGitter> <tenebrousedge> Ruby has been accused of being an acceptable LISP (http://www.randomhacks.net/2005/12/03/why-ruby-is-an-acceptable-lisp/)
<FromGitter> <meltheadorable> i keep crossing my fingers that crystal is an acceptable ruby 😄
<FromGitter> <girng> > Smalltalk was created as the language in underpinning the "new world" of computing exemplified by "human–computer symbiosis" ⏎ ⏎ That's how I feel with Crystal <3
<FromGitter> <girng> "human–computer symbiosis" i like that
<FromGitter> <watzon> > The Type() function is used to display files, like DOS's type or Unix's cat. Of course, hypertext is respected. You can even use Type to show .BMP files directly in the shell. It raises an interesting challenge for other OSs - why do shells have to be pure text? Why can't we have a multimedia shell?
<FromGitter> <watzon> I like this
<FromGitter> <watzon> It's a valid question
<FromGitter> <kniknoo> I picked up a course on Pharo when I was learning about Crystal at exercism. It's a smalltalk, really strange, it's almost like an OS in itself.
<FromGitter> <meltheadorable> Yep
<FromGitter> <girng> i'm liking this smalltalk language, should have never mentioned it,
<FromGitter> <meltheadorable> Smalltalk is strange and a little beautiful
<FromGitter> <girng> now does it have sockets? i want to get a little tcp server running with it
<FromGitter> <meltheadorable> and also a little messy
<FromGitter> <girng> nvm im getting ahead of myself
<FromGitter> <meltheadorable> It is elegantly committed to the purity of its paradigm, which is a thing I appreciate in a toy language and not in one I want to get work done in 😂
<FromGitter> <tenebrousedge> @meltheadorable Crystal is almost certainly an acceptable Ruby. Metaprogramming is more difficult, but type safety is a big win. No more error logs with `NoMethodError: Undefined method '+' for NilClass`
<FromGitter> <watzon> Definitely better than Sorbet
<FromGitter> <meltheadorable> I’ve never much minded those types of errors, and I’ve certainly never hated them enough to be willing to sacrifice what every other typed language would make me sacrifice to get rid of them
<FromGitter> <meltheadorable> Crystal tries really hard not to force me to make that choice, which I appreciate, but it makes trying to solve certain exploratory problems harder
<FromGitter> <tenebrousedge> @watzon people have made multimedia shells before. I'll have to dig up the one I'm thinking of after I'm done cooking
<FromGitter> <watzon> There are definitely some things that Crystal makes difficult
<FromGitter> <meltheadorable> dealing with complex nested data structures in crystal is really painful, feels like parsing would generally pose similar challenges
<FromGitter> <meltheadorable> i understand why and the speed benefits might be worth that pain for some things
<FromGitter> <tenebrousedge> Cider-dijon pork chops with roasted sweet potatoes and apples (https://www.epicurious.com/recipes/food/views/cider-dijon-pork-chops-with-roasted-sweet-potatoes-and-apples-51163600)
<FromGitter> <Blacksmoke16> if you're using hashes yes, but its not that bad when using objects tho?
<FromGitter> <meltheadorable> you need to define all the objects first — ruby would let me get a first pass or two out really quickly while i’m still finding the edges of the logic problem, crystal requires me to know things i don’t know yet
<FromGitter> <meltheadorable> it’s not worse, just hard
<FromGitter> <Blacksmoke16> just different id say
<FromGitter> <watzon> @tenebrousedge besides the sweet potatoes (which are not my thing) that sounds delicious
<FromGitter> <girng> yeah statically compiled. i had that issue in the beginning as well
<FromGitter> <meltheadorable> ruby makes it easier to solve part of a problem at a time and putter along until it breaks on an edge case — crystal requires you to solve more of the problem up front or it won’t handle your types
<FromGitter> <meltheadorable> that’s not a dig against crystal, it just makes crystal harder to work with for things i don’t understand the full scope of yet, which tends to be a lot of stuff i work on
<FromGitter> <meltheadorable> the result is probably more correct than my first 3-4 passes in ruby might be
<FromGitter> <meltheadorable> but its also more friction
<FromGitter> <meltheadorable> that’s a good tradeoff for production software with really well-defined boundaries i suspect
<FromGitter> <tenebrousedge> I do a lot of Ruby coding in `pry`, and `icr` is a pretty good substitute, but it's hard to beat `pry`
<FromGitter> <Blacksmoke16> i mean yea, a static compiled lang is prob never going to be as flexible to prototype stuff than one that isnt typed or compiled
<FromGitter> <watzon> Yeah there are definite tradeoffs
<FromGitter> <absolutejam_gitlab> You cna alia snetbkds
<FromGitter> <absolutejam_gitlab> Woah Shah
<FromGitter> <absolutejam_gitlab> I swear I'm sobe r
<FromGitter> <watzon> The thing I care about the most is speed and type safety
<FromGitter> <girng> @meltheadorable when you say "define all the objects first" what do you mean? like an example please. are you talking about like needing to write the properties and types for `from_json` to work, etc? or?
<FromGitter> <absolutejam_gitlab> Auto correct isn't doing its thing
<FromGitter> <tenebrousedge> but going from `pry` noodling to Crystal is also pretty easy
<FromGitter> <absolutejam_gitlab> You can alias methods?
<FromGitter> <Blacksmoke16> yes
<FromGitter> <Blacksmoke16> well kinda
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/0.29.0/Object.html#delegate(*methods,toobject)-macro
<FromGitter> <Blacksmoke16> mm prob not what you're looking for tho...
<FromGitter> <girng> why would you want to alias a method
<FromGitter> <girng> a method already has a name...
<FromGitter> <girng> it's the method
<FromGitter> <meltheadorable> I occasionally care about speed, I care not at all about type safety but the type safety is related to providing the speed, and Crystal makes a best effort to get out of my way, so I am along for the ride for now
<FromGitter> <watzon> Idk about aliasing methods, but you can alias the class or module that has the methods
<FromGitter> <Blacksmoke16> or just literally do like
<FromGitter> <Blacksmoke16> ```def alias_name ⏎ real_name ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5d3b7dff09575942228ceb84]
<FromGitter> <watzon> Ahh you mean like a ruby method alias
<FromGitter> <watzon> Yeah you can do that or you can make a macro like I did for octokit.cr
<FromGitter> <watzon> Not perfect by any means
<FromGitter> <watzon> Method aliasing is somewhat frowned upon in Crystal though
<FromGitter> <Blacksmoke16> ^
<FromGitter> <Blacksmoke16> whats the use case @absolutejam_gitlab ?
<FromGitter> <tenebrousedge> @girng sometimes it's nice to have more than one name, and sometimes it's nice to rename something and then redefine the original
<FromGitter> <watzon> The only reason I'm doing it with octokit is because I'm trying to match the Ruby API as closely as possible
<FromGitter> <watzon> For ease of transferrence
mps has left #crystal-lang [#crystal-lang]
<FromGitter> <girng> lol more than 1 name for a method..
<FromGitter> <girng> my mindd oes not compute
<FromGitter> <watzon> It's common in Ruby
<FromGitter> <tenebrousedge> doesn't Crystal do that for a couple functions?
<FromGitter> <watzon> To make things make sense semantically
<FromGitter> <watzon> @tenebrousedge they've tried to remove the majority of aliased methods
<FromGitter> <watzon> There were quite a few in the beginning, but as a general rule they don't want any
<FromGitter> <tenebrousedge> hmmm
<FromGitter> <Blacksmoke16> i.e. only `size` not `count`/`length`
<FromGitter> <watzon> Gets confusing sometimes when porting ruby code
<FromGitter> <girng> i view methods as unique identifiers
<FromGitter> <girng> like UUIDs
<FromGitter> <watzon> for instance, there's `Array#map` and `Array#collect`
<FromGitter> <watzon> Same thing, but most people seem to use collect
<FromGitter> <girng> i can't find #collect in docs
<FromGitter> <watzon> I'm talking about in Ruby
<FromGitter> <watzon> Crystal only has map
<FromGitter> <girng> oh my bad
<FromGitter> <girng> why does ruby have synonymous methods?
<FromGitter> <girng> just to confuse the shit out of the developer?
<FromGitter> <watzon> It's to be more semantic
<FromGitter> <watzon> There are some cases in which things make more sense sematically with a different method name
<FromGitter> <girng> eh, i'd argue being more semantic is using 1 word that is semantically correct and pure, instead of using multiple that could be ambigious
<FromGitter> <girng> btw, not arguing with you directly lol. just my thoughts on their reasoning.
<FromGitter> <watzon> While I do agree that multiple methods for the same thing can be confusing, I get the reasoning
<FromGitter> <girng> yeah i mean, he's the lead dev of the language he can do w/e he wants
<FromGitter> <girng> just like the recent addition pipe operator
<FromGitter> <watzon> Ruby also has both `Enumerable#reduce` and `Enumerable#inject`. I can see how both make sense, and depending on what you're doing one may make more sense than the other
<FromGitter> <meltheadorable> i think most codebases tend to standardize on one method or another of doing things, i like that you can choose the most semantically appropriate name for things to make reading the code fluid though
<FromGitter> <watzon> Exactly. It can make things confusing because you have more method names to memorize, but it can also help your code make more sense
<FromGitter> <girng> double-edged sword
<FromGitter> <watzon> Like most helpful things
<FromGitter> <girng> > Because *I* want to *experiment* it in the real world. Remember Ruby is not driven by democracy. ⏎ ⏎ I like this quote
<FromGitter> <meltheadorable> i tend to bristle a little bit when i see people talking about language design saying that having exactly one way to do things is better without like, really examining that idea, as if it was just a truth of the universe and not a tradeoff like anything else
<FromGitter> <watzon> Yeah same, everything has tradeoffs
<FromGitter> <meltheadorable> having many ways to express an idea lets you pick a most fitting expression, rather than having it dictated for you, that can make a language feel more alive and fluid
<FromGitter> <girng> twitter is outraged over a pipe operator and shunning Matsumoto, and he still defends his language ⏎ all over a NEW feature, that isn't even a breaking-change. glad i don't have twitter anymore, that place is a cesspool of negativity
<FromGitter> <watzon> Lol
<FromGitter> <watzon> Twitter is kinda terrible
<FromGitter> <watzon> I love it
<FromGitter> <watzon> And I hate it
<FromGitter> <girng> only reason i was on twitter because i was looking at asterite's feed
<FromGitter> <girng> and some other core contributors
<FromGitter> <girng> each time i clicked on a feed that was interesting to me (like Matsumoto's quote). the entire chain of comments just so negative and toxic
<FromGitter> <absolutejam_gitlab> It was just somebody mentioned alias for a method
<FromGitter> <girng> a lot of gaslighting there, trying to make people feel guilty for shit that they shouldn't even feel bad about
<FromGitter> <absolutejam_gitlab> @girng well it doesnt seem like you can import select methods from a Module
<FromGitter> <watzon> Sure they were talking about a method and not a module?
<FromGitter> <absolutejam_gitlab> not sure tbh
<FromGitter> <watzon> Pretty sure I know what you're talking about
<FromGitter> <absolutejam_gitlab> so an alias would be a good way of doing that, or you could use it like a public API for a module/set of modules
<FromGitter> <absolutejam_gitlab> but that sounds a bit weird
<FromGitter> <absolutejam_gitlab> anyway, importing select methods would be nice. I generally fully qualify my method names
<FromGitter> <watzon> You can do this `alias Baz = Foo:;Bar`
<FromGitter> <absolutejam_gitlab> but sometimes it's just annoying
<FromGitter> <meltheadorable> i wish GUI toolkits weren’t so complicated, the need for one has completely stalled the one project i really wanna use crystal for, but i don’t know enough to write my own or make my own bindings
<FromGitter> <Daniel-Worrall> @watzon I got it to compile. I installed same openssl version from source on the target
<FromGitter> <watzon> Ahh so that was it
<FromGitter> <watzon> Glad you figured it out
<FromGitter> <watzon> @meltheadorable agreed. We really need a workable GUI solution in Crystal
<FromGitter> <girng> @meltheadorable you seem very educated and knowledgeable to me, i'm sure you could write your own
<FromGitter> <absolutejam_gitlab> Writing your own is a loooot of work
<FromGitter> <meltheadorable> I’m good at web stuff, desktop app junk is a whole new world for me
<FromGitter> <meltheadorable> so I’d have to learn anything I wanted to bind
<FromGitter> <absolutejam_gitlab> Do the shard sites only search GH?
<FromGitter> <meltheadorable> or if i was writing my own, I’d need to learn native ones and then build good abstractions over it
<FromGitter> <watzon> I've started trying to make webview bindings
<FromGitter> <absolutejam_gitlab> I have a CLI lib I want to put out there
<FromGitter> <watzon> That could make for a good gui solution
<FromGitter> <absolutejam_gitlab> still needs a bit of work
<FromGitter> <absolutejam_gitlab> but I use GitLab
<FromGitter> <absolutejam_gitlab> has the best name though.
<FromGitter> <absolutejam_gitlab> That's all that matters right?
<FromGitter> <meltheadorable> @watzon I managed to bind the very outermost function of a very simple webview solution last weekend, but webviews won’t work for the thing I have in mind, even if they’d be good in general, so I’m still pretty stuff
<FromGitter> <Daniel-Worrall> After all this cross compile shit, I want to make a project of docker builds with different llvms on different archs
<FromGitter> <absolutejam_gitlab> Golang is a great language, objectively. But I wish some of that love would come to Crystal, haha.
<FromGitter> <watzon> Eww
<FromGitter> <watzon> Take that back
<FromGitter> <absolutejam_gitlab> so much power, and I wish I could just sit down and write it
<FromGitter> <watzon> 👅
<FromGitter> <absolutejam_gitlab> but it just irritates me
<FromGitter> <watzon> Personally I can't stand Go. Everything about it besides it's marshaling.
<FromGitter> <watzon> I feel like that's the one thing they did well
<FromGitter> <absolutejam_gitlab> the ecosystem and the concurrency story
<FromGitter> <meltheadorable> i am stubbornly refusing to learn rust even though its probably objectively.a good fit for a lot of my more recent project ideas
<FromGitter> <absolutejam_gitlab> and the ecosystem again (kubernetes, docker, etc.)
<FromGitter> <girng> @absolutejam_gitlab yeah, true. that's why i just use godot for client side, and crystal for server-side. however, this is just what i do. i do understand some people want a crystal based GUI but as you said, creating a really good ui system is a lot of work. ⏎ ⏎ although, in regards to crystal, struct and classes (class Control property x property y, etc) would be a great foundation for a gui system. one
<FromGitter> ... day, i was thinking of writing some of godot's UI classes to crystal. would be very fun a good learning experience. i'd start with the small things as @watzon told me. probably just a simple text label at first, then move on to something more advanced, like the richtextlabel, etc.
<FromGitter> <absolutejam_gitlab> Rust looks great but I have no need for it
<FromGitter> <watzon> I much prefer Rust tbh
<FromGitter> <watzon> Better language overall
<FromGitter> <absolutejam_gitlab> the thing with Go is that its simple
<FromGitter> <absolutejam_gitlab> not elegant
<FromGitter> <watzon> That it is
<FromGitter> <absolutejam_gitlab> but you can just write stuff that works. If you don't mind `err`
<FromGitter> <watzon> That's one of my huge problems with it is the syntax
<FromGitter> <meltheadorable> I’ve looked into maybe picking up nim to avoid learning rust or C
<FromGitter> <absolutejam_gitlab> I nearly wrote the CLI app I've been working on in Go
<FromGitter> <watzon> It's like an uglier C
<FromGitter> <watzon> Nim is nice
<FromGitter> <absolutejam_gitlab> But a no string interpolation either
<FromGitter> <absolutejam_gitlab> I started on Nim for a while
<FromGitter> <watzon> Nim is pretty powerful
<FromGitter> <watzon> Great macro system
<FromGitter> <meltheadorable> I also took a peek at zig
<FromGitter> <absolutejam_gitlab> It's a bit unclear
<FromGitter> <absolutejam_gitlab> just overall as a language
<FromGitter> <watzon> Not a bad syntax, but the whitespacyness of it gives me the same hangups I have with Python
<FromGitter> <girng> nim's multi-threaded tcp server looks cool
<FromGitter> <absolutejam_gitlab> some weirdness too, like the func name casing
<FromGitter> <girng> syntax is a bit odd for me though, have to get used to it
<FromGitter> <watzon> Good for small projects, but you'd get lost in a large codebase
<FromGitter> <girng> so i went back to crystal
<FromGitter> <absolutejam_gitlab> I started on Python, but got frustrated with it eventually. I hate the superficial limitations
<FromGitter> <Blacksmoke16> What ever happened with V
<FromGitter> <meltheadorable> My hangups with python are less whitespacey more the bizarre choices it makes for some of its objects and constructs
<FromGitter> <watzon> Python is just a really shitty language overall
<FromGitter> <absolutejam_gitlab> like single line lambdas, comprehensions > better functional styles
<FromGitter> <girng> @Blacksmoke16 https://vlang.io/
<FromGitter> <girng> @Blacksmoke16 still going i guess..
<FromGitter> <meltheadorable> It’s just routinely surprising
<FromGitter> <absolutejam_gitlab> Python's biggest selling point is again, the ecosystem
<FromGitter> <absolutejam_gitlab> there's a lib for anything
<FromGitter> <watzon> @Blacksmoke16 V is still being developed. It's progressing, but I'm not necessarily liking the direction
<FromGitter> <absolutejam_gitlab> and officially supported for massive systems
<FromGitter> <absolutejam_gitlab> All the cloud providers
<FromGitter> <absolutejam_gitlab> Nice to see google are doing official (generated) libs for a lot of languages now, including Elixir
<FromGitter> <girng> @watzon what do you mean direction? disagreements with their lead developer?
<FromGitter> <Blacksmoke16> It get past the initial wave after going open source?
<FromGitter> <watzon> @absolutejam_gitlab that's really its only selling point. I still think that if Ruby had come out a year earlier it would be sitting where Python is now
<FromGitter> <watzon> @Blacksmoke16 pretty much haha
<FromGitter> <meltheadorable> The basic/simple example I keep coming back to is the bizarre behavior of its range function if you want actual ranges — making range right-exclusive so that the single argument version would act like a zero-indexed array seems like a concession to C prorammers more than like a decision anyone would make in an object-based language
<FromGitter> <girng> wow they got 10k stars already
<FromGitter> <absolutejam_gitlab> Yeah.
<FromGitter> <watzon> The hype has died down a bit
<FromGitter> <absolutejam_gitlab> I love Ruby's syntax
<FromGitter> <meltheadorable> and Python is just full of little weirdo decisions like that
<FromGitter> <absolutejam_gitlab> But never really write mufvj
<FromGitter> <watzon> Yes it is
<FromGitter> <absolutejam_gitlab> Much
<FromGitter> <watzon> I actually hate Python more than I hate C++
<FromGitter> <watzon> And that's a lot
<FromGitter> <watzon> I actually think I may hate it more than PHP...
<FromGitter> <girng> vlang needs a new homepage, it's terrible
<FromGitter> <meltheadorable> I want to be able to like python but I can’t get past how surprising a lot of its stdlib is coming from ruby
<FromGitter> <watzon> I just wish I liked it a little more so I could get past reading the shitty code and port some things to Crystal
<FromGitter> <meltheadorable> the whitespace doesn’t bother me but i am just routinely frustrated by the weird little things it makes painful that don’t need to be painful
<FromGitter> <watzon> There are a lot of good ML libraries that I want
<FromGitter> <absolutejam_gitlab> I wrote an MR at work in PHP (I'm not a dev) and I couldn't believe that map and filter args are different order
<FromGitter> <absolutejam_gitlab> I mean come on
<FromGitter> <girng> https://github.com/vlang/v/blob/master/examples/tetris/tetris.v#L105 this syntax literally looks like golang
<FromGitter> <girng> or just me?
<FromGitter> <watzon> But the other problem is that anything that's performant and written in Python is actually written in C
<FromGitter> <absolutejam_gitlab> Melody my thoughts exactly
<FromGitter> <watzon> @girng it was written in Go
<FromGitter> <watzon> And has a lot of the same syntax
<FromGitter> <watzon> They improved some things about the syntax
<FromGitter> <absolutejam_gitlab> I hope crystals adoption increases with MT
<FromGitter> <watzon> But it still looks very similar
<FromGitter> <girng> how was it written in Go, wtf. by this logic, we could create a programming language with crystal?
<FromGitter> <absolutejam_gitlab> Yes
<FromGitter> <watzon> Yes...
<FromGitter> <meltheadorable> I’ve thought hard about maybe trying to implement some NLP libraries in crystal but with most things moving away from traditional parsing techniques and towards ML I’m afraid it’d largely not be appreciated effort
<FromGitter> <watzon> Crystal was originally written in Ruby
<FromGitter> <girng> WTF
<FromGitter> <girng> How does that work
<FromGitter> <watzon> LLVM
<FromGitter> <absolutejam_gitlab> Every language is written in a language
<FromGitter> <absolutejam_gitlab> Even if its binary or assembly
<FromGitter> <meltheadorable> also a programming language is just a program that turns text into another representation
<FromGitter> <watzon> All you have to do is be able to compile to machine code in one way or another
<FromGitter> <watzon> Crystal uses LLVM IR for that
<FromGitter> <girng> what does LLVM use
<FromGitter> <girng> where does it end
<FromGitter> <watzon> LLVM is written in C++
<FromGitter> <meltheadorable> you can write a programming language in any programming language, though some programming languages are easier to write programming languages in than others
<FromGitter> <watzon> But it compiles to machine code eventually
<FromGitter> <girng> so shit is all ontop of C++? crystal/ruby/llvm?
<FromGitter> <meltheadorable> not the way you’re conceptualizing it i don’t think
<FromGitter> <watzon> If you think about it that way, sure
<FromGitter> <watzon> But also not really
<FromGitter> <watzon> I mean it's not like Crystal is written in C++
<FromGitter> <watzon> It's written in Crystal
<FromGitter> <watzon> And has been since Crystal was able to hook into LLVM itself and compile itself
<FromGitter> <meltheadorable> and C++ doesn’t have a runtime so it’s also not like, running C++ code
<FromGitter> <watzon> Yup
<FromGitter> <girng> yeah, i mean c++ is what makes llvm work. and if crystal relies on llvm, crystal relies on c++ to work too
<FromGitter> <girng> right????
<FromGitter> <meltheadorable> sorta
<FromGitter> <watzon> Sure
<FromGitter> <meltheadorable> you could rewrite the part of LLVM that turns LLVM IR into machine code
<FromGitter> <meltheadorable> in any other language
<FromGitter> <watzon> Yup
<FromGitter> <watzon> It's not like C++ is a necessity
<FromGitter> <girng> what is "llvm IR"
<FromGitter> <watzon> It just happens to be what LLVM was written in
<FromGitter> <girng> compared to LLVM with no IR
<FromGitter> <meltheadorable> it stands for “Intermediate representation”
<FromGitter> <watzon> It's bytecode
<FromGitter> <meltheadorable> it’s basically an assembly language with extra metadata
<FromGitter> <girng> ty
<FromGitter> <meltheadorable> that is designed around being optimizable
<FromGitter> <meltheadorable> so you transform other languages to LLVM IR and then the LLVM IR can be optimized by the compiler
<FromGitter> <girng> so llvm is where the "magic" happens i assume? ⏎ that and.. crystal macro code, lol
<FromGitter> <meltheadorable> crystal’s compiler compiles to LLVM IR, LLVM is what makes crystal code executable on the machine, but the magic happens mostly in crystal’s compiler
<FromGitter> <watzon> Yup
<FromGitter> <watzon> Same with Rust
<FromGitter> <watzon> And Go
<FromGitter> <watzon> And V
<FromGitter> <girng> where is crystal's compiler
<FromGitter> <watzon> And lots of other languages
<FromGitter> <girng> so how does crystal code.. get read by LLVM
<FromGitter> <watzon> LLVM doesn't read it
<FromGitter> <absolutejam_gitlab> I really need to remember || syntax
<FromGitter> <girng> where is the transition
<FromGitter> <girng> from crystal to bytecode
<FromGitter> <watzon> Crystal hooks into LLVM's API
<FromGitter> <absolutejam_gitlab> For assignment
<FromGitter> <watzon> And LLVM generates bytecode
<FromGitter> <watzon> @absolutejam_gitlab `||=` is bae
<FromGitter> <girng> okay so LLVM has an API that crystal must follow?
<FromGitter> <girng> for it to work
<FromGitter> <watzon> Yup
<FromGitter> <watzon> Which is changing constantly
absolutejam4 has quit [Ping timeout: 245 seconds]
<FromGitter> <Blacksmoke16> v9 is coming out soon apparently
<FromGitter> <watzon> That's why changes have to be made to support the newest LLVM version
<FromGitter> <girng> does this hinder crystal developers in a negative way?
<FromGitter> <watzon> A bit
<FromGitter> <girng> interesting... i didn't know this
gangstacat has quit [Quit: Ĝis!]
<FromGitter> <girng> omg i got more questions
<FromGitter> <girng> phone call fack brb
<FromGitter> <watzon> Sometimes I wish this was discord haha
<FromGitter> <watzon> Voice chat would be nice
<FromGitter> <Blacksmoke16> there is an unofficial discord server
<FromGitter> <Blacksmoke16> https://discord.gg/2Kervu
<FromGitter> <watzon> Yeah, the unnoficial part is the problem. Not many people.
<FromGitter> <Blacksmoke16> doubt you'd ever get an "official" one anyway
<FromGitter> <watzon> Most likely not
<FromGitter> <meltheadorable> I’m actually a little curious what hooking into the LLVM API looks like, I kind of assumed for the most part you had to emit the IR directly, and you’d just be feeding it through LLVM from there to get the machine code — are there actually broader APIs for LLVM frontends that you need to use to get the IR?
<FromGitter> <watzon> I haven't done much digging myself. I know that Crystal exposes an LLVM module that is used in the compiler
<FromGitter> <watzon> But of course it's not documented
<FromGitter> <meltheadorable> fair enough, i do not believe i care enough to investigate deeply
<FromGitter> <watzon> Same
<FromGitter> <girng> @watzon nice, so piggybacking on what melody said
<FromGitter> <girng> where is the transition from actual crystal code, into what llvm reads
<FromGitter> <watzon> It's in the compiler somewhere
<FromGitter> <tenebrousedge> ugh. Now I am aware of the Ruby `|>`, and I am unhappy
<FromGitter> <girng> hahahaha
<FromGitter> <tenebrousedge> they should have just used `&.`
<FromGitter> <meltheadorable> unless ruby is removing `&.` which is not something i’ve heard, the good news is you can
<FromGitter> <girng> @watzon does ruby use LLVM as well?
<FromGitter> <tenebrousedge> you may be thinking of the safe navigation operator rather than Crystal's `&.`
<FromGitter> <watzon> It has a LLVM gem
<FromGitter> <watzon> But Ruby isn't compiled
<FromGitter> <meltheadorable> Oh, I probably am
<FromGitter> <girng> @watzon oh duh
<FromGitter> <meltheadorable> We were talking about ruby, so I assumed you meant the thing in ruby
<FromGitter> <girng> @watzon so basically, LLVM can be used to create higher level programming languages if you conform to their API standards?
<FromGitter> <girng> the hard part is.. creating your own compiler to conform their api standards
<FromGitter> <girng> do i got that right???
<FromGitter> <watzon> Well it's not really that hard. LLVM allows you to do pretty much anything you want.
<FromGitter> <Blacksmoke16> And the parsing of the syntax
<FromGitter> <kniknoo> It makes things that USED to be really hard fairly simple and unified.
<FromGitter> <Blacksmoke16> Into something you give to it
ht_ has quit [Quit: ht_]
<FromGitter> <meltheadorable> It’s not that much harder to produce assembly or machine code than LLVM IR — LLVM makes targeting multiple architectures and optimizing a lot lot easier though
<FromGitter> <girng> Like a Lexer? @Blacksmoke16
<FromGitter> <meltheadorable> LLVM IR is an abstract representation of machine code that can be optimized before producing actual machine code for the target architecture, it’s like assembly language for a theoretical computer
<FromGitter> <meltheadorable> but rather than being interpreted like a VM, it’s compiled