ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.33.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
ur5us has joined #crystal-lang
<FromGitter> <smalls12> whats a good way to parse files in crystal? ⏎ ( asking here before googling )
<FromGitter> <tenebrousedge> parse how?
<FromGitter> <smalls12> my use case will be to read one of my crystal files that defines my C bindings
<FromGitter> <smalls12> and find the function signatures
<FromGitter> <smalls12> I want to parse them out so I can auto make wraper functions and then link to cmocka so I can mock my c bindings
<FromGitter> <tenebrousedge> you can use the compiler directly if you need to to get the AST nodes and suchlike
<FromGitter> <smalls12> do you happen to have a link for something like that? not sure what to google from that :)
<FromGitter> <tenebrousedge> I am not sure what information exists about that
<FromGitter> <tenebrousedge> but you might take a look at how ameba does things
postmodern has joined #crystal-lang
<FromGitter> <tenebrousedge> I'm not entirely sure what you'll need to `require`; something under `compiler/crystal`
<FromGitter> <watzon> Anyone here use vim regularly?
<FromGitter> <nilium> I do.
Nilium has left #crystal-lang [#crystal-lang]
<FromGitter> <tenebrousedge> spacevim
<FromGitter> <nilium> Boring normal vim for me.
<FromGitter> <tenebrousedge> spacevim is <3
<FromGitter> <watzon> I just added Crystal support instructions to the tagbar wiki (https://github.com/majutsushi/tagbar/wiki#crystal) if you want ctags support and a nice tree view
<FromGitter> <watzon> Also any-jump.nvim supports Crystal and it's awesome
<FromGitter> <smalls12> fancy
<FromGitter> <smalls12> I use vs code like a pleb
<FromGitter> <tenebrousedge> vscode has vim bindings
<FromGitter> <tenebrousedge> they even mostly work
<FromGitter> <smalls12> does that just make vs code work like vim ?
<FromGitter> <tenebrousedge> more or less, yeah
<FromGitter> <watzon> Yeah, but they're not great compared to the real vim experience
<FromGitter> <watzon> Imo the only thing that comes close is emacs' evil mode
<FromGitter> <smalls12> I wouldn't see the appeal, but clearly someone likes that idea, their github repo has a;most 5k commits
<FromGitter> <watzon> The main appeal is the ability to code faster if you're use to vim
<FromGitter> <watzon> But if you're use to vim, may as well use vim haha
<FromGitter> <smalls12> I like vim when I only have a terminal, I find it frustrating when the people that built the filesystem only installed nano
<FromGitter> <watzon> Yeah...
<FromGitter> <watzon> Fuck nano
<FromGitter> <watzon> Vi is usually installed as well, but vi != vim
<FromGitter> <nilium> Haven't tried tagbar in a long time. Might look at it again, but I don't know if I'd have a lot of use for it.
<FromGitter> <watzon> I like the idea of it, don't know if it will help my workflow yet, but it's nice to see an overview of all the definitions in a file
<FromGitter> <nilium> Yeah. It's not without use, I'm still not sure what my workflow will look like for Crystal yet.
<FromGitter> <watzon> Something I do really like is any-jump though. The dev should be adding ctag support soon I hope.
<FromGitter> <watzon> Should be better than using ripgrep
<FromGitter> <nilium> I mostly hop around files by way of searching internally and then just memorizing any paths that're relevant
<FromGitter> <nilium> Basically, my vim set up is pretty boring.
<FromGitter> <watzon> I like making mine very IDE like
<FromGitter> <watzon> Vim is so damn fast it almost doesn't matter how many plugins I add
<FromGitter> <nilium> I once had a lot of plugins and managed to slow it down, but it's been a long-ish time. Also switched to emacs (via spacemacs) for a few months about two years ago -- it was nice, but far, far slower than Vim. Even base emacs seems to start slower than my normal vim configuration.
<FromGitter> <nilium> I think the way you're supposed to use it is to set up a daemon, but at that point the workflow's pretty clunky, so I went back to vim.
<FromGitter> <watzon> Yeah emacs is extremely slow in comparison
<FromGitter> <watzon> It's nice, but I like vim's speed
<FromGitter> <nilium> I mostly miss org mode.
<FromGitter> <nilium> vim-wiki is nice, but it's not as nice.
ur5us has quit [Ping timeout: 240 seconds]
<FromGitter> <watzon> Yeah I agree. There's an implementation for vim, but it's not complete.
sagax has quit [Remote host closed the connection]
DTZUZU has quit [Ping timeout: 240 seconds]
DTZUZU has joined #crystal-lang
<FromGitter> <absolutejam_twitter> I've just started using emacs with doom mode
<FromGitter> <absolutejam_twitter> It's amazing
<FromGitter> <absolutejam_twitter> -mode
<FromGitter> <absolutejam_twitter> Tried spacemacs a few times in the past but it was too flakey
<FromGitter> <watzon> Yeah doom emacs is nice
<FromGitter> <watzon> Faster than spacemacs
<FromGitter> <absolutejam_twitter> And emacs daemon mode solved
<FromGitter> <absolutejam_twitter> And startup delays
<FromGitter> <absolutejam_twitter> But I actually wish there was more tooling around md instead of org
<FromGitter> <absolutejam_twitter> Maybe I shoukd bite the bullet
<FromGitter> <watzon> Org is really a lot better, but it's a lot to learn
_ht has joined #crystal-lang
_ht has quit [Remote host closed the connection]
<FromGitter> <yxhuvud> I use org for presentations but not much else.
dwdv has joined #crystal-lang
<FromGitter> <manveru> just found https://org-roam.readthedocs.io/en/latest/ and it's pretty nice
ur5us has joined #crystal-lang
lunarkitty has quit [Ping timeout: 252 seconds]
ur5us has quit [Ping timeout: 256 seconds]
lunarkitty has joined #crystal-lang
sagax has joined #crystal-lang
postmodern has quit [Read error: Connection reset by peer]
postmodern has joined #crystal-lang
travis-ci has joined #crystal-lang
travis-ci has left #crystal-lang [#crystal-lang]
<travis-ci> crystal-lang/crystal#81a6717 (master - Update the cant_infer_block_return_type URL (#8869)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/657281280
<DeBot> https://github.com/crystal-lang/crystal/pull/8869 (Update the cant_infer_block_return_type URL)
Human_G33k has joined #crystal-lang
HumanGeek has quit [Ping timeout: 255 seconds]
darkstarx has quit [Remote host closed the connection]
darkstarx has joined #crystal-lang
darkstarx has quit [Remote host closed the connection]
darkstarx has joined #crystal-lang
<FromGitter> <watzon> @manveru unfortunately doesn't seem to support tangling
<FromGitter> <watzon> If it did I'd use the shit out of it
darkstarx has quit [Remote host closed the connection]
darkstarx has joined #crystal-lang
ancorgs has left #crystal-lang ["Konversation terminated!"]
Pqzcih5 has joined #crystal-lang
<Pqzcih5> Hello guys!
<Pqzcih5> I am pretty new to crystal, and the language seems pretty cool.
<Pqzcih5> I was wondering is there a way to read a file line by line?
<Pqzcih5> What I am trying to do is read a file line by line and create a function to yield each one
<Pqzcih5> So the function can be used like a list. Is this possible with crystal?
<FromGitter> <asterite> There's File.each_line: https://crystal-lang.org/api/0.33.0/File.html#each_line(filename,encoding=nil,invalid=nil,chomp=true,&)-class-method
<FromGitter> <asterite> And File.read_lines: https://crystal-lang.org/api/0.33.0/File.html#read_lines(filename,encoding=nil,invalid=nil,chomp=true):Array(String)-class-method
<Pqzcih5> FromGitter: Thank you, but I need something different, basically something like each_line but I don't need to do each one
<FromGitter> Pqzcih5, I'm a bot, *bleep, bloop*. I relay messages between here and https://gitter.im/crystal-lang/crystal
<Pqzcih5> oh... ok
<FromGitter> <j8r> I got Swagger docs working for controllers :)
<FromGitter> <watzon> Wooo
<Pqzcih5> asterite: is there a way to yield over the lines manually?
<Pqzcih5> I am trying to do a lines(filename) so I could just yield over the lines
<FromGitter> <watzon> What do you mean by "yield over the lines"?
<FromGitter> <watzon> `File#each_line` returns a block that yields each line, `File#read_lines` returns every line as an array.
<FromGitter> <j8r> Free API docs! ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ Now a API docs page is served at http://localhost:3000/docs! [https://gitter.im/crystal-lang/crystal?at=5e5d410253fa513e28652b12]
<FromGitter> <watzon> Nice~
_ht has joined #crystal-lang
<FromGitter> <kiti-nomad> I want to ask you a question, are JIT and AOT the characteristics of the VM language? I never encountered such a concept when I was learning C ++ and D
<FromGitter> <kiti-nomad> Although this has nothing to do with the subject you discussed, I know you are all professionals
<FromGitter> <stronny> I wouldn't say that, the same language may be JIT, AOT or even interpreted. I'd languages have natural preferences. It's easier to JIT some rather than others and so on.
<FromGitter> <Daniel-Worrall> ... why did I click that link
<FromGitter> <kiti-nomad> Someone told me that the jvm language takes AOT when compiled into bytecode, and JIT when run in a virtual machine. Languages ​​like cpp directly generate executables, so it takes AOT ⏎ is it right?
<FromGitter> <stronny> yes. however the words "virtual machine" do not mean hupervisor/domU distinction, it means that JDK compiles your sources into an intermediate code that need a runtime (JRE) to execute
Pqzcih5- has joined #crystal-lang
Pqzcih5 has quit [Remote host closed the connection]
<FromGitter> <watzon> Python has a limited bytecode as well that's used to speed things up a little bit
<FromGitter> <watzon> Still slow as sin though
Pqzcih5- has quit [Ping timeout: 240 seconds]
sz0 has joined #crystal-lang
<FromGitter> <j8r> @Daniel-Worrall haha :)
<FromGitter> <j8r> It looks like https://petstore.swagger.io/
Pqzcih5 has joined #crystal-lang
<FromGitter> <Blacksmoke16> > as a major feature compared to Kemal and others, there is a route conflict detection. An error will be raised at startup if there on any conflict. ⏎ ⏎ I'm assuming this means if you define the same route twice?
<FromGitter> <j8r> Yes, or a path containing a path parameter
<FromGitter> <j8r> e.g. `/api/{UserID}` and `/api/public` conflict
<FromGitter> <Blacksmoke16> neat
<FromGitter> <j8r> This kind of checks are at runtime (startup). I think it is fine
<FromGitter> <j8r> macros will be unreadable
<FromGitter> <Blacksmoke16> prob is fine
<FromGitter> <j8r> I have done a CLI builder that is compile time safe. Now I think that raising at startup is also fine
<FromGitter> <Blacksmoke16> when/if #8836 gets merged prob could do some fancier stuff
<DeBot> https://github.com/crystal-lang/crystal/pull/8836 ([Experimental] Allow user-defined macro methods)
<FromGitter> <j8r> For me on this case, there is not much benefit of using macros
<FromGitter> <j8r> More importantly, the error will show the conflicting route, the controller it belongs
<FromGitter> <j8r> Preventing an error in prod is the most important at the end :)
<FromGitter> <watzon> I'm curious as to why Crystal is lagging so far behind in the cross compilation space. Languages like Rust, Nim, and Zig can already cross compile to most any target, but if we want to do it you have to generate a `.o` file and run a gcc script on the target machine.
<FromGitter> <watzon> Or use alpine
<FromGitter> <Blacksmoke16> @j8r indeed
<FromGitter> <Blacksmoke16> been thinking how i want to implement the 405 errors
<FromGitter> <Blacksmoke16> current idea is to keep a map of like `path => [methods]` while compiling the routes
<FromGitter> <j8r> As a macro variable?
<FromGitter> <Blacksmoke16> er no, im not a fan of that anymore
ur5us has joined #crystal-lang
<FromGitter> <j8r> That's a bit like I did
<FromGitter> <j8r> But instead of an Array, it's a struct
<FromGitter> <Blacksmoke16> key thing im missing is that concept that groups routes
<FromGitter> <Blacksmoke16> that i think you have
<FromGitter> <j8r> Yeah, but that's only inside the implementation
<FromGitter> <j8r> Maybe a NamedTupleLiteral` instead of an `Array`?
<FromGitter> <Blacksmoke16> also helps you're running your own router right?
<FromGitter> <Blacksmoke16> well atm there isnt any grouping, each route is considered independent
<FromGitter> <Blacksmoke16> where in order to implement 405s youd have to have some concept of grouping routes by path, and knowing what methods they are pointed at
<FromGitter> <j8r> It helps, quite a lot yes
<FromGitter> <j8r> You could use it too
<FromGitter> <j8r> Don't know if it would hurt performance vs yours
<FromGitter> <j8r> Which is in pure macro
<FromGitter> <j8r> Not sure how the path is matched/parsed?
<FromGitter> <j8r> Radix parses per char, mine per string
<FromGitter> <j8r> An obvious disadvantage are intermediate strings :/
<FromGitter> <j8r> I'm sure I can optimize it – not high priority
<FromGitter> <Blacksmoke16> sorry, to be clear my routing still happens at runtime
<FromGitter> <Blacksmoke16> i just *add* the routes to it via macros
<FromGitter> <Blacksmoke16> current plan would be to remove the method prefix from the route
<FromGitter> <Blacksmoke16> then could do something like
<FromGitter> <j8r> Ha ok!
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e5d6d4b8e04426dd01adfb7]
<FromGitter> <Blacksmoke16> well with one match id still check method as well
<FromGitter> <Blacksmoke16> :shrug: prob be fien?
<FromGitter> <j8r> You could also use my router haha
<FromGitter> <j8r> A lot simpler, but less powerful than the amber one
<FromGitter> <j8r> No glob parameter, don't know the use case?
<FromGitter> <Blacksmoke16> i dont really have one in athena either
<FromGitter> <j8r> Cannot be documented with Swagger anyway
<FromGitter> <Blacksmoke16> i like the constraints tho
<FromGitter> <Blacksmoke16> dunno if you have something similar?
<FromGitter> <j8r> No, have you an example in the amber router?
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e5d6eaab873303e27760b9e]
<FromGitter> <j8r> Like above, cannot be documented by swagger
<FromGitter> <j8r> Ha ok, i see, but meh
<FromGitter> <j8r> In my web framework, this logic would be done on the struct (e.g. `UserID.from_string`)
<FromGitter> <j8r> So, the router can handle this, but only 1 parameter
<FromGitter> <j8r> (At a given position)
<FromGitter> <Blacksmoke16> gotcha
<FromGitter> <j8r> But the router is very flexible
<FromGitter> <j8r> It will be required to be implemented yourself with a custom `PathParameter` (like I've done too btw)
<FromGitter> <Blacksmoke16> gotcha, prob going to roll my own router in the future, but for now i think ill stick with the amber one. Since it works and does what i need
<FromGitter> <Blacksmoke16> by roll my own, i prob mean think about it, realize i wouldnt get much out of it, and continue with what i have 😆
<FromGitter> <Blacksmoke16> ha, symfony does a bunch of nested if/elses
<FromGitter> <Blacksmoke16> ```code paste, see link``` ⏎ ⏎ 😬 [https://gitter.im/crystal-lang/crystal?at=5e5d75f3a157485cb46c993e]
<FromGitter> <Blacksmoke16> i mean i guess what essentially what radix is doing
<FromGitter> <j8r> It parses char by char
<FromGitter> <Blacksmoke16> to build out the tree?
<FromGitter> <j8r> Not sure about the tree
<FromGitter> <Blacksmoke16> id imagine it would have to do something similar, just structured differently
<FromGitter> <j8r> But I have only seen `Char::Reader`s
<FromGitter> <j8r> Any limitation with my router?
<FromGitter> <Blacksmoke16> hm?
<FromGitter> <j8r> I mean, it may not be needed for you to rebuild a full router
<FromGitter> <Blacksmoke16> not sure what else you could do router wise other than radix
<FromGitter> <Blacksmoke16> (in general, not related to a specific router shard)
<FromGitter> <j8r> It is more specific
<FromGitter> <j8r> Router are stored a way to easily generate Swagger docs, and handle path parameters
<FromGitter> <j8r> And also, multiple verbs for a given route
<FromGitter> <j8r> Not saying it raises on conflicting routes
<FromGitter> <Blacksmoke16> looks like PHP uses regex to match routes as well
<FromGitter> <Blacksmoke16> er symfony at least
<FromGitter> <j8r> Wow, not cool
<FromGitter> <wontruefree> We are hosting a speaker at Chicago Crystal who is running all his production apps with Crystal. https://www.meetup.com/Crystal-Lang-Chicago/events/dfpqmrybcfbhb/
<FromGitter> <j8r> For multiple verbs for a given route, it may be possible with Radix
<FromGitter> <j8r> However, I don't see how to generate docs and raise on conflicting routes without having a similiar representation as my router
<FromGitter> <j8r> @wontruefree Love it :)
<FromGitter> <wontruefree> yeah I am exited to hear what he has to say
sz0 has quit [Quit: Connection closed for inactivity]
_ht has quit [Remote host closed the connection]
<Pqzcih5> Hey, is there a way to convert a String ["a","b","c"] into an array easily?
<Pqzcih5> because otherwise I should use splits and doesn't seem that elegant to be honest
<FromGitter> <watzon> Why do you have a string array?
<FromGitter> <watzon> The String is literally that? `"[\"a\",\"b\",\"c\"]"`
<Pqzcih5> I read it froma conf file
<Pqzcih5> from a*
<FromGitter> <watzon> What format is the file in? Because there's probably a parser written.
<Pqzcih5> ini
<Pqzcih5> I am including the ini actually
<Pqzcih5> but one variable is an array
FromGitter has quit [Read error: Connection reset by peer]
<Pqzcih5> basically if i puts the variable I get
<Pqzcih5> this: ["-a","-z"]
<Pqzcih5> since It is pretty hard to explain in words, this is the function