<FromGitter>
<Blacksmoke16> is there an issue/thread about it somewhere?
<FromGitter>
<watzon> Not that I can find. I remember having mentioned it a couple years back and the maintainers weren't interested. I can start a thread in the forum though.
<FromGitter>
<Blacksmoke16> Probably not a bad idea
alex`` has quit [Ping timeout: 245 seconds]
<FromGitter>
<Blacksmoke16> Any thoughts on that serialization prototype ^?
chemist69 has quit [Ping timeout: 264 seconds]
chemist69 has joined #crystal-lang
absolutejam1 has joined #crystal-lang
absolutejam1 has quit [Ping timeout: 268 seconds]
absolutejam1 has joined #crystal-lang
ht_ has joined #crystal-lang
absolutejam1 has quit [Ping timeout: 245 seconds]
ht_ has quit [Remote host closed the connection]
absolutejam1 has joined #crystal-lang
<FromGitter>
<j8r> @Blacksmoke16 There are a lot more allocations than regular `JSON::Serialize` 2 Arrays and a Hash at least.
<FromGitter>
<absolutejam_gitlab> Yeah, it would be super powerful if you could dive into the AST like in NIM
<FromGitter>
<absolutejam_gitlab> crystal's macro system is definitely more approachable
<FromGitter>
<absolutejam_gitlab> but limited
return0e has joined #crystal-lang
return0e_ has quit [Ping timeout: 258 seconds]
<FromGitter>
<watzon> All I want is to be able to wrap classes, methods, etc and view/modify the AST
<FromGitter>
<watzon> It would make the macro system so much more powerful
<FromGitter>
<absolutejam_gitlab> yeah
<FromGitter>
<absolutejam_gitlab> I like how NIM has both the way of escaping into the AST and raw AST node traversal/generation/manipulation
<FromGitter>
<absolutejam_gitlab> Dunno why I keep capitilizing it
alex`` has joined #crystal-lang
alex`` has quit [Quit: WeeChat 2.5]
absolutejam1 has quit [Ping timeout: 245 seconds]
lawrence[m] is now known as ternarysolo
<FromGitter>
<Blacksmoke16> @j8r could prob optimize some of that, maybe lazily initialize the hash only when some attributes are going to be set, ill get it more fleshed out then see what i can optimize
gangstacat has quit [Quit: Ĝis!]
gangstacat has joined #crystal-lang
absolutejam1 has joined #crystal-lang
<FromGitter>
<kniknoo> Is there any sort of working group for upgrading the crystal book? Brian mentioned it on the forum and that's where I'd like to start getting a feel for a collab project, but it would be silly for me as a green dev to just start throwing out pull requests.
<FromGitter>
<tenebrousedge> why silly?
absolutejam1 has quit [Ping timeout: 245 seconds]
<FromGitter>
<kniknoo> You know that there is still a lot I take for granted. On one side it's valuable that I'm naive about things that might be assumed, but I feel like I'd still be... so naive about pulling as to be a nuisance.
<FromGitter>
<tenebrousedge> documentation should be written *for* novices, and I would think that being written by a novice would help with that. Worst thing is you write something wrong
<FromGitter>
<kniknoo> Ok, I guess I have some anxiety about first contributions. :) I appreciate that you feel the same.
absolutejam1 has joined #crystal-lang
<FromGitter>
<tenebrousedge> @kniknoo did you ever tackle that Forth problem?
<FromGitter>
<kniknoo> I haven't yet. I've been spreading myself so thin on exercism, I decided to start plowing through the ruby track to completion. I just jumped up by 10% alone yesterday, so I should be back to finishing up crystal soon. I can't wait for that one, it covers some things I was wondering about already.
<FromGitter>
<kniknoo> One tidbit I've picked up along the way is that I'd like to try to set up a tutorial for us that mimics a lot of kotlin's starting ideas. Their presentation is great, though our playground is cooler. (Who wrote crystal play, it's amazing!!!)
<FromGitter>
<kniknoo> And btw, grats all on multithreading, I've been sidetracked but can't wait to try it out!
<FromGitter>
<kniknoo> It's a 4 section playground. ⏎ 1 is a playground. ⏎ 2 builds small practical projects using all the possible targets ⏎ 3 is a tutorial on the basics with runnable inline example ⏎ 4 is the koans section, where they give you toy problems to get used to [https://gitter.im/crystal-lang/crystal?at=5d7103c4b3e2fc579359a3d9]
<FromGitter>
<tenebrousedge> have you done the Ruby Koans?
<FromGitter>
<kniknoo> I had "one for X..." on exercism submitted in a one-liner about an hour after running through basics and some of koans. It's a really valuable interactive tutorial. https://play.kotlinlang.org
<FromGitter>
<kniknoo> Most of it. I got stuck when it got into metaprogramming, one of the last few, but now that I've read the book on your suggestion I'm gonna tie up that loose end too.
<FromGitter>
<kniknoo> I enjoy rubymonk too, but the inline doesn't work on any of my browsers.
<FromGitter>
<tenebrousedge> Oh, awesome. How did you enjoy the book?
<FromGitter>
<kniknoo> It was great, I feel like I understand a lot better now. I'm going to go through and revise some of my submissions to DRY them up a bit. You know I'm a sucker for "the least I could type" :D
<FromGitter>
<tenebrousedge> I suffer from the same problem
<FromGitter>
<kniknoo> I've been building up some philosophical thoughts as I'm language jumping. It's fascinating how we're moving toward conciseness as a language goal.
<FromGitter>
<tenebrousedge> are we? has Golang been told?
<FromGitter>
<kniknoo> :D I can't resist a clever trick. I'm glad that ternaries are starting to be more welcome these days in the languages I like.
<FromGitter>
<kniknoo> I haven't actually checked go yet... noted. Kotlin, Scala, even Swift a bit caught my eye as a style I like.
<FromGitter>
<kniknoo> I feel like we're at a point where the clever merging of OOP and Functional should have its own designation as separate from either parent.
<FromGitter>
<tenebrousedge> Hmm. Picked up any Elixir yet?
<FromGitter>
<kniknoo> It's on the list. Erlang went over my head for the most part. My friend is trying to beat clojure into my brain so that'll likely be my gateway to purer functional thinking.
<FromGitter>
<tenebrousedge> these are your father's parentheses (https://xkcd.com/297/)
<FromGitter>
<kniknoo> Although kotlin will be my gateway to embracing the java way. It's so foreign to me.
<FromGitter>
<tenebrousedge> I have no interest in Java :(
<FromGitter>
<kniknoo> OMG lulz. It's been a couple weeks of us arguing why our language is awesome for us to build the mutual respect.
<FromGitter>
<kniknoo> Not java no, but kotlin is a key for me to make some apps without thinking TOO much about the java ecosystem.
<FromGitter>
<kniknoo> Like not thinking about C in crystal. You can get away with it for little things, but it' all there.
<FromGitter>
<tenebrousedge> there's not that much C in crystal, particularly as compared to Ruby
<FromGitter>
<kniknoo> Right, but in much the same way, kotlin is pretty well abstracted away from its parent, aside from pulling in some of the primitives. Eh, I may stil be too green to explain what it is I'm trying to say. More lineage than application.
<FromGitter>
<kniknoo> ...LLVM always becomes C at some point, yeah? Maybe I'm misunderstanding that.
<FromGitter>
<tenebrousedge> you look more white-and-red than green to me
<FromGitter>
<kniknoo> I'm very much the purple, red, black, and silver type, but...
<FromGitter>
<tenebrousedge> LLVM does not become C, it goes Crystal -> LLVM IR -> machine code
<FromGitter>
<kniknoo> Ok, gotcha. The compiler world is still very new to me, I have a lot to learn about the old ways for the value of the new to make sense. I've been doing a lot of computer history and my Clojure friend has the Dragon book on the way for me.
<FromGitter>
<kniknoo> When I get a downloadable Crystal compiler target for the RasPis up, I'll feel achieved.
<FromGitter>
<kniknoo> Am I right in understanding that with some work I could be programming ATMELs with crystal? Or should I look to the mRuby project?
<FromGitter>
<tenebrousedge> I'm afraid I don't know anything about those
<FromGitter>
<kniknoo> All good, I'm as far as noting that LLVM has an ATMEL target, I'll need to try it without the Arduino training wheels with something else, but a kushy microcontroller language would be awesome.
DTZUZO has quit [Quit: WeeChat 2.0]
DTZUZO has joined #crystal-lang
<FromGitter>
<tenebrousedge> definitely
<FromGitter>
<tenebrousedge> I think I'm going to have to write some mentor notes for the Ruby Tournament problem
<FromGitter>
<tenebrousedge> I don't trust anyone else to find the "right" solution
<FromGitter>
<kniknoo> I haven't seen it yet, that's the finale, yeah?
<FromGitter>
<tenebrousedge> um...maybe?
<FromGitter>
<tenebrousedge> I think it's an optional one
<FromGitter>
<tenebrousedge> no, you're right
<FromGitter>
<tenebrousedge> I had thought there were notes for all the core exercises
<FromGitter>
<kniknoo> I haven't seen it from that side yet, but I'll join you on mentoring once I'm through. I've been catching a few errors on some tests in other languages that make things needlessly difficult on easy.
<FromGitter>
<kniknoo> I can't even start lua because the first test uses a require syntax that I question the validity of. I don't know how to report that kind of stuff.
<FromGitter>
<mavu> https://play.crystal-lang.org/#/r/7i21 ⏎ why does this give me a execution timed out, without any output, shouldn't the second spawn block oputput something while the first waits for input?
<FromGitter>
<Blacksmoke16> right but its a playground, try it locally
<FromGitter>
<Blacksmoke16> i.e. you cant give it input so it eventually times out
DTZUZO has joined #crystal-lang
<FromGitter>
<mavu> ok, that does output things. which is annoying, because I am trying to replicate a problem I have with reading /dev/ttyUSB0 where a spawned fibre just seems to stop the whole execution
<FromGitter>
<watzon> @mavu if you need to test in a playground you can always use the local one
<FromGitter>
<watzon> `crystal play`
<FromGitter>
<mavu> Could someone point me to an example of a file.read that has to wait for something to read?
<FromGitter>
<watzon> What is it waiting for?
<FromGitter>
<mavu> I'm reading from /dev/ttyUSB0 which is a file that sometimes has no more content but is not closed.
<FromGitter>
<mavu> Its a USB serial device
<FromGitter>
<mavu> and I have to wait for the other side tosend something on the wire.
<FromGitter>
<mavu> but I can't think of a example of a file that behaves in the same way to test it without the serial-port requirement
<FromGitter>
<watzon> You should be able to do `File.open` to create a IO stream, and then you can do stuff like check if it's empty, read it, rewind the IO and read it again, etc
<FromGitter>
<mavu> I don't think thats the same, because a normal file always has a EOF
<FromGitter>
<watzon> Hmm true, I'm trying to open `dev/tty` locally and it just keeps going
<FromGitter>
<mavu> I need a file without a end that I can read from and make my example wait until something is available to read again.
<FromGitter>
<mavu> maybe if I read from stdin?
<FromGitter>
<mavu> how do I read from STDIN ?
<FromGitter>
<mavu> can't find it in the api doc
<FromGitter>
<j8r> yes, STDIN you can
<FromGitter>
<watzon> Well `STDIN` is a constant in Crystal that returns a `IO::FileDescriptor`
<FromGitter>
<mavu> ```mkfifo piope``` ⏎ ⏎ you can put stuff into the pipe from a different terminal with for example ⏎ cat > piope ⏎ and if you use cat piope to read the pipe, it works as expected. But above Crystal program just does nothin. [https://gitter.im/crystal-lang/crystal?at=5d712d93767de913fc88d054]
<FromGitter>
<mavu> it hangs on the f.gets
<hightower3>
mavu: if you remove all code from your program except the two lines (one which opens file and one which prints result of f.gets) you will see that it works
<hightower3>
so the issue is in your code, not f.gets
<FromGitter>
<asterite> it works fine in Ruby, though. Might be a problem with Crystal
<FromGitter>
<mavu> Alright, thats a start :)
<FromGitter>
<mavu> It might be a rare case that just never came up in file handling. This sort of wait to read situation usually only happens on sockets/netword
<FromGitter>
<asterite> it seems the LibC.read call blocks forever for some reason
<FromGitter>
<asterite> Might be worth reporting it as a bug for someone to investigate
<FromGitter>
<asterite> The good news is that this seems to work fine with the new multithreading stuff because the other spawn might run in a separate thread
<FromGitter>
<mavu> @asterite that is a nice positive sideeffect.
<FromGitter>
<mavu> I'll report it as a bug, I'll just include everything I wrote above, or should I add anything ?
<hightower3>
mavu: I am unable to reproduce what you are saying
<hightower3>
I ran your program
<hightower3>
and after "f.gets" I put "p :yes"
<hightower3>
and every time I cat into the pipe, it reads the line and afterwards prints :yes
<hightower3>
am I completely misunderstanding your report?
<FromGitter>
<mavu> let me try
<FromGitter>
<asterite> what os are you all in?
<hightower3>
linux here
<FromGitter>
<asterite> mac here
<FromGitter>
<mavu> linux
<FromGitter>
<mavu> (debian)
<FromGitter>
<asterite> hmmm.... thenI don
<FromGitter>
<asterite> then I don't know
<FromGitter>
<asterite> but I was able to reproduce it, it hangs and doesn't execute the other fiber
<FromGitter>
<mavu> if I add p :yes it also hangs.
<FromGitter>
<mavu> weird.
<hightower3>
ah wait, yeah I was focused on the part of the report which said that 'gets' hanged, which it didn't since it does read lines
<hightower3>
but you are right that the other fiber is not executing
<FromGitter>
<mavu> Right, I could have been more clear. but thats what I meant.
<FromGitter>
<j8r> i'm for splitting projects in different repos, core members not
<FromGitter>
<Daniel-Worrall> that makes more sense than what I actually typed
<FromGitter>
<absolutejam_gitlab> Yeah I agree about splitting parts out
<FromGitter>
<Blacksmoke16> you would have to use a case generated using macros
<FromGitter>
<Daniel-Worrall> hmm
<FromGitter>
<Blacksmoke16> whats the use case?
<FromGitter>
<j8r> We end up having JS/HTML/CSS stuff inside a compiler :/
<FromGitter>
<absolutejam_gitlab> You can't use a property that's a hash?
<FromGitter>
<Daniel-Worrall> Use case: Instance variables of handlers. Be able to delete handler using only 1 method instead of the 10 different event types.
<FromGitter>
<Daniel-Worrall> So it'd call `@event_handler_for_foo.delete(bar)`
<FromGitter>
<Blacksmoke16> :thinking:
<FromGitter>
<Daniel-Worrall> I'd probably have to do a case
<FromGitter>
<Daniel-Worrall> I feel like a delete method for each event type would saturate it
<FromGitter>
<Blacksmoke16> if you have to use a case is prob a better approach to the architecture of what you're doing
<FromGitter>
<Daniel-Worrall> unless I use a hash for each array of procs
<FromGitter>
<Daniel-Worrall> like `@all_handlers = { "event_type" => [] of -> }`
<FromGitter>
<absolutejam_gitlab> oh god, that syntax is horrible
<FromGitter>
<Daniel-Worrall> so then it's just a hash call to
<FromGitter>
<Daniel-Worrall> I mean yeah, the syntax is pretty bad, but shortened for example
<FromGitter>
<Blacksmoke16> i dont know enough about what you're trying to do but there is prob a better way
<FromGitter>
<Daniel-Worrall> Probably
<FromGitter>
<Daniel-Worrall> I'm implementing WebSub in a library scope
<FromGitter>
<Daniel-Worrall> So users can add a handler for the callback
<FromGitter>
<Blacksmoke16> have an example of it being used?
<FromGitter>
<Daniel-Worrall> but also be able to remove later without restarting the whole program
<FromGitter>
<j8r> and only have an array of procs?
<FromGitter>
<Daniel-Worrall> that's the kind of syntax I was thinking
<FromGitter>
<Daniel-Worrall> I'm going to implement a hash instance variable for all handlers instead
<FromGitter>
<Daniel-Worrall> although it will add a small overhead
<FromGitter>
<Daniel-Worrall> hmm
<FromGitter>
<Blacksmoke16> is there a need to group them by type?
<FromGitter>
<Daniel-Worrall> type?
<FromGitter>
<Blacksmoke16> like "on_user_follow"
<FromGitter>
<Blacksmoke16> as im assuming that would be the key and value would be array of handlers of that type/
<FromGitter>
<Daniel-Worrall> each endpoint has its own payload type, yeah
<FromGitter>
<Daniel-Worrall> different json mappings
<FromGitter>
<Daniel-Worrall> Okay, I'm going to do the case statement then
<FromGitter>
<Blacksmoke16> yea i dont know enough about this to have any suggestions atm
<FromGitter>
<Blacksmoke16> er only thought i have atm is like what if
<FromGitter>
<Blacksmoke16> each handler was its own object, so would do like `OnUserFollow.create { # do stuff }`
<FromGitter>
<Blacksmoke16> then could be stored in a single array and do like `@handlers.select(OnUserFollow).each &.call`
<FromGitter>
<Blacksmoke16> and array delete would work as well i think
<FromGitter>
<Blacksmoke16> idk how performant that would be vs a hash or your case statement tho
<FromGitter>
<Daniel-Worrall> Eh, I'm already doing a class for each Payload type
<FromGitter>
<Daniel-Worrall> type for each Handler seems excessive
<FromGitter>
<Blacksmoke16> fair enough
alex`` has quit [Ping timeout: 245 seconds]
alex`` has joined #crystal-lang
<FromGitter>
<kniknoo> > also, I don't like `case` and `when` being aligned ⏎ LOL, crystal is why I'm a fan of it. It forces me to be concise, Kai called me out for that in Ruby.
<FromGitter>
<absolutejam_gitlab> a fan of them being aligned?
<FromGitter>
<Blacksmoke16> i dont really care enough
<FromGitter>
<dansimpson> Crystal has been really nice to work with.
ht_ has joined #crystal-lang
<FromGitter>
<Blacksmoke16> np, good to hear ;)
<FromGitter>
<kniknoo> I have a potential example together, just a toy that generates random words, finds the palindromes, and lists them. Also shows a class, monkey patching, getter macro, colorize, and String.build . Do you think it would be wise is we changed the style from the example pages so that they use correct commenting inline in order to subliminally get the layout familiar?
<FromGitter>
<Blacksmoke16> hm?
<FromGitter>
<watzon> @SewerynKaminski `{var_name}` is used with format strings
<FromGitter>
<kniknoo> Well, neither example in the git book is highly applicable because there are no classes or defs, but instead of explaining what's happening afterward: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ as per documentation convention. [https://gitter.im/crystal-lang/crystal?at=5d7176fcbe4a3f13fdf3ac28]
<FromGitter>
<Blacksmoke16> whats the benefit of that vs `#{var}`?
<FromGitter>
<kniknoo> I've never cared for the "fprint" interpolation style like that.
<FromGitter>
<watzon> Can't think of one off the top of my head
<FromGitter>
<Blacksmoke16> remove it ! :P
<FromGitter>
<Blacksmoke16> :trollface:
<FromGitter>
<tenebrousedge> fprint is sometimes useful
<FromGitter>
<watzon> Actually I know
<FromGitter>
<watzon> There's other things you can do there that you can't with basic interpolation
<FromGitter>
<watzon> Like adding padding and formatting
<FromGitter>
<tenebrousedge> yes
<FromGitter>
<Blacksmoke16> i suppose
<FromGitter>
<asterite> it's good for internalization, where if you have multiple things to interpolate they might go in a different order
<FromGitter>
<watzon> That too
<FromGitter>
<asterite> "The {adjective} {noun}" % {adjective: "white", noun: "house"} ⏎ "La {noun} {adjective}" % {adjective: "blanca", noun: "casa"}
<FromGitter>
<kniknoo> Indeed, I'm not gonna pull a Generics are useless or anything.
<FromGitter>
<watzon> You can also store a string like that and then use it later with multiple different values
<FromGitter>
<kniknoo> Nice!
<FromGitter>
<Blacksmoke16> good example
<FromGitter>
<Blacksmoke16> does it just use gsub under the hood?
<FromGitter>
<kniknoo> It's nice there, I guess it's just the Python way that rubs me wrong.
<FromGitter>
<watzon> I don't think so
<FromGitter>
<watzon> I mean it's the ruby way too haha
<FromGitter>
<watzon> But y
<FromGitter>
<Blacksmoke16> i could prob use that in assert
<FromGitter>
<watzon> I've used t
<FromGitter>
<kniknoo> I'm just not familiar enough with the ruby syntax of it yet, it just makes me think of python when I see it.
<FromGitter>
<watzon> Interesting, it looks like the `#` doesn't do anything in Crystal
<FromGitter>
<Blacksmoke16> hm?
<FromGitter>
<kniknoo> That's Nice! ok, While I'm on the mindset of building crystal examples with some density of features, I'll do a simple mock assembler to show padding.
<FromGitter>
<kniknoo> The `#` in `#{}` is optional?
<FromGitter>
<Blacksmoke16> no
<FromGitter>
<watzon> In Ruby's sprintf the `#` will add a `0x` before a hex number
<FromGitter>
<kniknoo> Oh, ok
<FromGitter>
<watzon> So `puts "%#08X" % num` should be `0x00000045`
<FromGitter>
<watzon> Same with binary and octal, but with `0b` and `0o` respectively
<FromGitter>
<kniknoo> This was my entire pointer handler in my assembler: `sprintf "%016b", cmd.lchop("@").to_i16`
<FromGitter>
<asterite> @bararchy all I know is that those functions were added by Brian recently: https://github.com/ivmai/bdwgc/pull/277 . So you must have an older gc version somehow
DeBot has quit [Quit: Crystal IRC]
asterite has quit [Quit: Bye]
jhass has quit [Quit: Bye]
asterite has joined #crystal-lang
DeBot has joined #crystal-lang
jhass has joined #crystal-lang
<FromGitter>
<jwoertink> Can anyone see what I'm missing here with this error?
<FromGitter>
<jwoertink> The code throwing this `Concurrent::Future.new { fetch_network_latest }` where the block returns my `Array(DiscJockey::Burns::Decorator)`
<FromGitter>
<Blacksmoke16> What happens if you assign it within the method
<FromGitter>
<jwoertink> what do you mean?
<FromGitter>
<jwoertink> Or maybe there's a better way to do this
<FromGitter>
<jwoertink> I have to make 4 really large queries for my page to load
<FromGitter>
<jwoertink> I'd like to have them all go async, and then have the page load when they're all done