RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.24.1 | 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
<FromGitter> <Dillybob1992> i just had a bunch of global variables and ran functions all over the place in their own files, etc
<FromGitter> <Dillybob1992> kind of a mess...
<FromGitter> <Dillybob1992> global functions too
<RX14> well, to keep that mess I suggest using a module and class vars
<FromGitter> <Dillybob1992> but what really interested me is the benchmarks too, crystal is FAST!
<RX14> let me example you
sz0_ has quit [Quit: Connection closed for inactivity]
<RX14> this is probably the closest you're going to get to avoiding classes (until you're up to speed in the basics)
<RX14> then you can start using classes
<RX14> module and extend self basically gives you the feeling that everything inside the module is at the top level
<RX14> but you have access to class vars like @@users still
jxv has joined #crystal-lang
rohitpaulk has joined #crystal-lang
<FromGitter> <Dillybob1992> oh cool, thanks for sharing that :) im really actually like classes now honestly though, i think it helps with organization
<FromGitter> <Dillybob1992> (from what i had before!)
jxv has quit [Client Quit]
<FromGitter> <Dillybob1992> so for new modules it's .start, and new classes, it's .new?
rohitpaulk has quit [Ping timeout: 240 seconds]
<RX14> @Dillybob1992 no
<RX14> i just renamed your method "start"
<RX14> if you renamed def start to def foo
<RX14> it'd be GameServer.foo
<RX14> also, the "extend self" is a bit of magic I should explain:
jxv has joined #crystal-lang
<RX14> @Dillybob1992 this is the equivalent code to what I just wrote without extend self: https://gist.github.com/RX14/e63a511de007f6bf8943159e5d33b26c
<RX14> extend self is just a shortcut which means you don't need to put self. before all the method names
<FromGitter> <Dillybob1992> ohhh, i see
<RX14> and self. is the syntax for declaring "global methods" on the containing object
<RX14> so def self.foo inside class Foo means you can call Foo.foo
DTZUZO has quit [Quit: WeeChat 2.0]
<RX14> and it works the same for modules too
<FromGitter> <Dillybob1992> awesome, thank you for the explanation and information helps a lot.
<FromGitter> <Dillybob1992> really understand it a lot better
<FromGitter> <marksiemers> @Dillybob1992 - RX14 is a great resource. When you catch him on here with time, there is probably no better way to get an answer. ⏎ When there isn't anyone available, you can reference the docs on Modules for help: https://crystal-lang.org/docs/syntax_and_semantics/modules.html
<RX14> you know, flattery won't make me implement the features you want faster ;) @marksiemers
galstar[m] has quit [Ping timeout: 276 seconds]
galstar[m] has joined #crystal-lang
<FromGitter> <Dillybob1992> thanks, yeah awesome community
jxv has quit [Quit: zzz…]
<FromGitter> <marksiemers> I know RX14, I'm just trying to make sure you don't hate me for all the back-and-forth on those TechEmpower benchmarks. ⏎ There aren't really any features that I'm waiting on - just better db driver performance. Which I don't think you plan on working on anyway.
<FromGitter> <fridgerator> is it possible to use `crystal_lib` to autogenerate bindings for a .h file that includes Objective C types?
<FromGitter> <fridgerator> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5a556ab8ba39a53f1af86e76]
<FromGitter> <fridgerator> `NSWindow`, `NSString`, etc
<FromGitter> <fridgerator> to clarify, i'm trying to bind this file : https://github.com/zserge/webview/blob/master/webview.h
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 260 seconds]
emgonam2 has joined #crystal-lang
sz0_ has joined #crystal-lang
sz0_ has quit [Client Quit]
sz0_ has joined #crystal-lang
illy_ has joined #crystal-lang
illy_ has left #crystal-lang [#crystal-lang]
sz0_ has quit [Client Quit]
hightower3 has quit [Ping timeout: 276 seconds]
hightower3 has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 256 seconds]
snsei has joined #crystal-lang
snsei has quit []
<FromGitter> <fridgerator> nvmd
<FromGitter> <fridgerator> I was mistaken on how bindings work
snsei has joined #crystal-lang
vivus has quit [Quit: Leaving]
hightower3 has quit [Remote host closed the connection]
sz0_ has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
OceannBoy has joined #crystal-lang
<OceannBoy> Hello
rohitpaulk has joined #crystal-lang
<FromGitter> <bararchy> Damn, running a full night to work on data only to crash in the morning with ⏎ ⏎ ```Too many heap sections: Increase MAXHINCR or MAX_HEAP_SECTS``` [https://gitter.im/crystal-lang/crystal?at=5a559eaab48e8c3566c041bf]
wontruefree has joined #crystal-lang
rohitpaulk has quit [Read error: Connection reset by peer]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Read error: Connection reset by peer]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 248 seconds]
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 252 seconds]
wontruefree has quit [Quit: The Internet needs a break and I need a cookie]
wontruefree has joined #crystal-lang
wontruefree has quit [Client Quit]
rohitpaulk has joined #crystal-lang
wontruefree has joined #crystal-lang
wontruefree has quit [Client Quit]
wontruefree has joined #crystal-lang
wontruefree has quit [Client Quit]
wontruefree has joined #crystal-lang
wontruefree has quit [Client Quit]
wontruefree has joined #crystal-lang
wontruefree has quit [Client Quit]
wontruefree has joined #crystal-lang
wontruefree has quit [Client Quit]
wontruefree has joined #crystal-lang
wontruefree has quit [Client Quit]
rohitpaulk has quit [Ping timeout: 276 seconds]
OceannBoy has quit [Ping timeout: 248 seconds]
<FromGitter> <bew> Oops how?
emgonam2 has quit [Ping timeout: 276 seconds]
emgonam2 has joined #crystal-lang
rohitpaulk has joined #crystal-lang
oprypin has quit [Remote host closed the connection]
mark_66 has joined #crystal-lang
<Groogy> Morning! o/
<FromGitter> <sdogruyol> Morning
<FromGitter> <straight-shoota> Greetings!
<FromGitter> <straight-shoota> Seen this? ;) https://github.com/kddeisz/compiling-ruby
<FromGitter> <straight-shoota> There's gonna be a talk at
<FromGitter> <straight-shoota> the ruby on ice conference with the same name... I hoped it was about Crystal :D
<Groogy> nah from what I get it is that you pregenerate the bytecode right?
<Groogy> i.e kind of like JAva
<FromGitter> <straight-shoota> It is still interesting though.
<FromGitter> <straight-shoota> Yep
<FromGitter> <straight-shoota> Essentially with bootsnap gem it reduces time and memory consumption for booting an application
moei has joined #crystal-lang
claudiuinberlin has joined #crystal-lang
<vegai> hmm, Packt is suggesting that I wrote a "Mastering"-level book on Crystal
<vegai> seems a bit ... arrogant
<vegai> then again, I already did on Rust, and that was quite arrogant as well
<vegai> does anyone care about books anymore? :)
<livcd> yes
<livcd> but I do not really like packt ^^...cant you go with manning ?
<FromGitter> <sdogruyol> vegai, I'm writing a book with Packt
<FromGitter> <sdogruyol> interesting to see they're asking for more Crystal books already
<vegai> livcd: I have existing contact to packt because of my earlier work there
<Groogy> oh that contract still holds?
<vegai> contact, not contract :)
<Groogy> I should read through mine again
<Groogy> aaaagh
<FromGitter> <sdogruyol> haha
<vegai> they're asking because I suggested it :P
<FromGitter> <sdogruyol> vegai, how was your experience with them before?
<Groogy> When they ask for "technical expert feedback" you can drop my name, would love to help out and read
<vegai> sdogruyol: this was my first writing project, so they were easily the best publisher I've ever worked with :P
<livcd> the thing is packt books are generally considered to be of low quality
<livcd> of course there are exceptions
<vegai> they tend to rush things quite a lot
<Groogy> Mine is of super high quality
<FromGitter> <sdogruyol> lol
<vegai> yeah, mine too!
<Groogy> but yeah packt just try to churn out as many books as possible
<FromGitter> <sdogruyol> @vegai I agree with that :D
<Groogy> But like my experience working with them was super good
<Groogy> it was more me not being prepared of how much work it actually is
<vegai> I kinda guessed that it would be a lot of work
<vegai> Packt did a good job at whipping me to it. There's no way I could have completed such a project without that
<FromGitter> <sdogruyol> yeah, writing a book is not an easy task
<FromGitter> <sdogruyol> these are yours right?
<livcd> well it's a big business for them
<Groogy> I agree vegai
<vegai> sdogruyol: mastering is mine. Learning really wasn't, I just helped them finish it
<FromGitter> <sdogruyol> how was the book sells?
<Groogy> not high for me
<FromGitter> <sdogruyol> I'm mostly interested in reaching bigger audience
<Groogy> Or well I can notice a big surge whenever a new semester start
<vegai> I hope the contract allows me to talk about these things in public :P
<Groogy> but it's like... $400 a year?
<vegai> yeah, the hourly rate is not very high :P
<Groogy> (though split with 3 people so I guess it is actualyl higher)
<livcd> no wonder they want to sell as many books as possible :D
<FromGitter> <sdogruyol> vegai, having read the contract, didn't see a section about statistics lol
<Groogy> also I freaking hate their covers xD
<FromGitter> <sdogruyol> haha
<Groogy> sdogruyol, vegai pls fix
<Groogy> I couldn't even fit my full first name :( they had to shorten it
<livcd> their covers are really shitty
<vegai> Groogy: :)
emgonam2 has left #crystal-lang ["Leaving"]
emgonam2 has joined #crystal-lang
<emgonam2> haloha
<emgonam2> good everyning
livcd has quit [Remote host closed the connection]
cbass has joined #crystal-lang
<emgonam2> .join #youfuckme
livcd has joined #crystal-lang
emgonam2 has left #crystal-lang ["Leaving"]
jnyw has quit [Quit: WeeChat 2.0.1]
cbass has quit [Ping timeout: 246 seconds]
<FromGitter> <marin117> hi everyone
<FromGitter> <marin117> i have troubles with optionparser
<FromGitter> <marin117> i have args as string and i need to have multiple arguments for flags
<FromGitter> <yxhuvud> Optop
<FromGitter> <yxhuvud> Eh. Optionparser is sort of limited.
<FromGitter> <marin117> it can only parse only first argument?
<FromGitter> <marin117> cause I am splitting args on space (to get an array)
<FromGitter> <marin117> `OptionParser.parse(args.not_nil!.split) do |parser| ⏎ ⏎ ``` parser.on("-n ARG", ""){|arg| puts arg} ⏎ end```` [https://gitter.im/crystal-lang/crystal?at=5a55e3a0ce68c3bc749e4642]
<FromGitter> <marin117> (sorry for bad markdown)
<FromGitter> <marin117> is there any way to parse everything until next flag?
<jokke> marin117: can't you just split on comma?
<jokke> maybe i'm missing what you're actually trying to do. can you give an example of how you'd like to call the program
<FromGitter> <marin117> -f a b c d -g
<FromGitter> <marin117> i need to parse "a b c d" as options for f
<FromGitter> <marin117> `args.not_nil!.split ` ⏎ ⏎ I thought that this is not good way of splitting
<FromGitter> <marin117> but if I put - as separator, split will remove it
<FromGitter> <bararchy> @marin117 Use Admiral or other CLI parsing shard
<FromGitter> <marin117> Then I have to change half of my application :(
<FromGitter> <bararchy> well, if you depend on cli parsing, I would suggest using one of the robust tools made for it, else, you can think on how to re-invent the wheel in your application
<jokke> marin117: why not do it like every other cli application and provide the flag with every param: -f a -f b -f c -f d -g
<jokke> so you can use it like this: --long-f={a,b,c,d} -g
<FromGitter> <marin117> I could that yeah
<FromGitter> <marin117> didn't think about it
<FromGitter> <marin117> thank you :)
cbass has joined #crystal-lang
<jokke> then in your handler you'd have to do something like: parser.on("-n ARG", "--long-n=ARG") { |arg| n_args << arg }
<jokke> afaik it get's called multiple times with all the values
<FromGitter> <marin117> nice
<FromGitter> <marin117> thank you
<FromGitter> <marin117> you helped me a lot :)
<jokke> glad to hear that :)
alex`` has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 276 seconds]
rohitpaulk has joined #crystal-lang
alex`` has quit [Quit: WeeChat 1.9]
alex`` has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 248 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter> <bew> Is there any Crystaler in the area of LosAngeles or SanDiego? I'm moving there for 7 month, maybe we could meet ;)
<Groogy> Oh I have an old childhood friend who lives in San Diego
<Groogy> Pilot
<Groogy> If pilot ever introduces themselves as "Johannes Runström" then get off that plane ASAP
<FromGitter> <bew> Lol why? It's him?
alex`` has quit [Remote host closed the connection]
alex`` has joined #crystal-lang
<Groogy> yes
<FromGitter> <bew> I'll be careful ˆˆ it starts with 2 hours delay for now ><
<Groogy> so why you moving to there?
<FromGitter> <bew> My 4th year at school is abroad, so I'll be in university there :)
<FromGitter> <bararchy> cool
hightower2 has joined #crystal-lang
hightower has quit [Ping timeout: 260 seconds]
OceannBoy has joined #crystal-lang
<crystal-gh> [crystal] omotorin opened pull request #5564: fixed int128 implementation (master...fix_128_bit) https://git.io/vNYkd
<ua> hmm is there any particular reason i cant do "blah".to_sym or Symbol.new("blah) ?
<ua> why i cant do *
<FromGitter> <bew> Symbols are compile time only, you cant create a symbol at runtime
<ua> coming from ruby im triping over so many things i have to start collecting them lol
<FromGitter> <bew> Each symbols will be replaced by an integer for runtime, so all symbols must be known at compile time
<FromGitter> <bew> Ahah yes, it's a good idea
<jokke> hey
<jokke> is it possible to use (seemingly) blocking io read calls that don't actually read anything but rather return whenever something can be read from the IO?
<jokke> this could be useful for using C libs that do blocking IO
<FromGitter> <bararchy> you can IO.read for 1 byte, then IO.rewind
<jokke> barachy: you cannot always rewind
<FromGitter> <bararchy> well, evenloop already let you read whenever you have something to read
<FromGitter> <bararchy> else it will simulate blocking
<jokke> yes
<jokke> but that won't work if the C lib does the reading
<jokke> then the lib blocks the entire thread and thus the event loop
<jokke> with a IO#wait_for_read you could wrap those lib calls
<jokke> barachy: so bytes = Bytes.new(0); io.read(bytes) would always return immediately/
<jokke> ?
<jokke> seems so
OceannBoy has quit [Ping timeout: 264 seconds]
<FromGitter> <ArtLinkov> Btw @bararchy you asked before if I would mind mentoring for using SHAInet. Of course I would love to do it if someone is interested ;)
<FromGitter> <bararchy> @ArtLinkov It's regarding Google Summer of Code, you can see issue #5562 , this is a project from google to help opensource comminities etc.. ⏎ It means you would need to mentor a student for 2-3 months of work (ie, coding SHAInet etc..)
<FromGitter> <codenoid> <3
<jsn-> jokke, there probably is something for you in crystal source, around add_read_event / wait_readable / etc, i'm not sure
<jokke> mhm
<jokke> RX14: ? :)
<RX14> ??
<jsn-> perhaps read_syscall_helper could be useful
<RX14> what are you trying to do jsn-
<RX14> jokke,
<FromGitter> <bew> jsn-: bad idea to mess with scheduler and libevent stuff, even though it would work, nothing is public api there
<RX14> @jokke, the *only* way to wrap a blocking library call if if you can make it have EAGAIN semantics
<jokke> RX14: i'm not sure i know what that means
<RX14> read the man page :)
<RX14> man 2 read
<jsn-> jokke, even if your fd is readable at the moment, your library still can block or fail with EAGAIN if there's not enough read data available
<FromGitter> <bew> Would be nice to allow blocking C calls in system threads and communicate the result via a Channel or sth
<jokke> jsn-: that's true of courese
<jokke> *course
<jokke> but it'd be better than nothing
<jsn-> well, for some interesting definition of "better", maybe
<jokke> RX14: i just heard that there are libs for c++ that run a nonblocking read with nullbuffer in an event loop and notify you when you can read
<RX14> that sounds horrible
<RX14> in every way
<jokke> less horrible than blocking your scheduler :P
<RX14> why? when we have a perfectly acceptable method for doing nonblocking IO with epoll
<jokke> well if your library doesn't use epoll you're screwed
<RX14> well if you can do nonblocking read you can epoll?
<RX14> i'm confused
<jokke> oh
<jokke> yeah, the c++ library could do this
<jokke> maybe it does
<jokke> not sure
<RX14> if you can do a nonblocking read, that means you have a filedescriptor
<FromGitter> <codenoid> boosts have feature for that
<RX14> and so just use it
<jokke> codenoid exactlyu
<crystal-gh> [crystal] asterite pushed 1 new commit to master: https://git.io/vNY3Z
<crystal-gh> crystal/master a3ca37e Michael Petö: Fix Time::Span multiply and divide (#5563)
<jokke> RX14: i can't always pass a filedescriptor to a lib
<RX14> why don't you give me a specific API
<jokke> RX14: remember when i was having trouble with ZeroMQ blocking the scheduler?
<RX14> yeah so just rewrite it in crystal
<jokke> ..
<RX14> there's a nice spec
<RX14> about 5 implementations
<jokke> that's something that is almost never an option
<RX14> well it is for zmq
<jokke> that's true
<jokke> but not for every c lib doing io
<RX14> i mean realistically unless the library is closed source it's *possible*
<RX14> not practical sometimes though
<jokke> of course but having a wrapper around those blocking calls would be so much easier and in most cases "good enough"
<RX14> you can't just "wrap blocking calls"
<RX14> it's not possible without a threadpool
<RX14> and even then it sucks
<Papierkorb> Most simply don't understand how they're affected, "good enough" can easily wreak havoc
<jokke> spawn { io.wait_for_read; LibShittyIO.blocking_read }
<RX14> jokke, to me it sounds like you don't quite understand the problem and want a magic solution
<RX14> there isn't one
<jsn-> from what google shows me, using zeromq with an external event loop is not a completely new and unresearch topic
<RX14> jsn-, yeah I researched it before
<RX14> there's a way for zmq to give you an FD
<RX14> which you can epoll on
<jokke> RX14: i totally understand, that meaning that there is _something_ to read, doesn't mean that the call wouldn't block at all.
<jokke> sounds great!
<RX14> sounds ugly
<RX14> and slow
<jokke> sound's quick and dirty
<RX14> exactly
<jokke> same goes for mqtt btw
<jokke> afaik libmosquitto also uses blocking io
<jokke> i wrote a small mqtt lib for crystal using libmosquitto but it has the same problems as libzmq
<Papierkorb> a good c lib allows you to shove data into it directly without an fd, and/or have a wrapper around read/write methods.
<jokke> and i'm not sure i'd want to reimplement a mqtt lib from scratch
<FromGitter> <bararchy> How can I test if a Float is whole number ? (as in 0 after the . , ex 17.0)
<FromGitter> <bararchy> is there a method for that?
<Papierkorb> isn
<Papierkorb> isn't mqtt a pretty simple pub/sub protocol?
<jokke> barachy: your_float.to_i == your_float
<jokke> Papierkorb: well
<jokke> i guess the client wouldn't be that hard to write
ua has quit [Ping timeout: 248 seconds]
<jokke> it doesn't change the fact that it's super annyoing to have to rewrite a whole lib just because the IO handling
<jokke> *because of
<Papierkorb> Complain to the authors of the lib for not allowing custom FD logic
<Papierkorb> With that it's easy to write that part in Crystal for a full integration
<FromGitter> <bararchy> jokke 👍 lol true , thanks
rohitpaulk has quit [Ping timeout: 276 seconds]
rohitpaulk has joined #crystal-lang
<RX14> But rewriting things is fun! Lol
<jokke> RX14: lol
<jokke> RX14: and very often unjustifiable
<RX14> That's why you have to savour the times when it is
<RX14> Like now
<FromGitter> <bew> Well some love re-inventing the wheel or reimplementing stuff to make it work, others don't (I do ˆˆ)
ua has joined #crystal-lang
<RX14> i guess i'm decreasing my employability by publicly professing my love for NIH
<FromGitter> <codenoid> otw 10K Github Star
<FromGitter> <straight-shoota> 👏
<jokke> RX14: :D
<jokke> ooooooor we could "just" have native thread support ;)
<FromGitter> <bew> Yeah NIH is hard to accept, but usually it's necessary to not rewraite everyrhing
<RX14> jokke, native thread support will still be far slower
<jokke> sure
<jokke> but works ootb
<jokke> and isn't a dirty hack either
<RX14> well zmq provides you an epoll fd
<RX14> so use it and it's better than threading by far
<jokke> yeah
<travis-ci> crystal-lang/crystal#a3ca37e (master - Fix Time::Span multiply and divide (#5563)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/327236903
<DeBot> https://github.com/crystal-lang/crystal/pull/5563 (Fix Time::Span multiply and divide)
<jokke> RX14: i can't find any functions for getting the fd in the api docs
<jokke> i'm looking at: http://api.zeromq.org/master:_start
<RX14> zsock_fd ...
rohitpaulk has quit [Ping timeout: 260 seconds]
<RX14> oh
<RX14> looks like its a new api
<RX14> zmq_getsockopt
<RX14> ZMQ_DONTWAIT on zmq_send and zmq_recv enables EAGAIN
<RX14> and then you use getsockopt ZMQ_FD and add that to the scheduler by copying what IO::FileDescriptor does
<RX14> it'll probably be a bit hard to get right
<RX14> oh, and you ussed to use ZMQ_EVENTS sockopt too
<Papierkorb> bew, I'd wager that some are too eager to reimplement, while others shy away from it too early.
rohitpaulk has joined #crystal-lang
<crystal-gh> [crystal] asterite pushed 1 new commit to master: https://git.io/vNYCS
<crystal-gh> crystal/master 157eca0 TSUYUSATO Kitsune: Clone macro default argument before macro expansion
<crystal-gh> [crystal] asterite closed pull request #5424: Fix to work formatting `foo.[bar] = baz` (master...fix/crystal-format/work-dot-bracket-equal) https://git.io/vbyDs
<travis-ci> crystal-lang/crystal#157eca0 (master - Clone macro default argument before macro expansion): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/327257474
sz0_ has quit [Quit: Connection closed for inactivity]
<travis-ci> crystal-lang/crystal#972f2b3 (master - Fix to work formatting `foo.[bar] = baz`): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/327267038
<crystal-gh> [crystal] ysbaddaden opened pull request #5565: Fix: decode DWARF line sequences with single program entry (master...fix-core-debug-dwarf-line-numbers-parser) https://git.io/vNY2f
mark_66 has quit [Remote host closed the connection]
<crystal-gh> [crystal] ravernkoh opened pull request #5566: Standardize naming of Exceptions and Errors. (master...standardize-error-naming) https://git.io/vNYaw
<crystal-gh> [crystal] bcardiff pushed 1 new commit to master: https://git.io/vNYK0
<crystal-gh> crystal/master 048f77e Julien Portalier: Fix: decode DWARF line sequences with single program entry (#5565)...
<travis-ci> crystal-lang/crystal#048f77e (master - Fix: decode DWARF line sequences with single program entry (#5565)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/327309686
<DeBot> https://github.com/crystal-lang/crystal/pull/5565 (Fix: decode DWARF line sequences with single program entry)
claudiuinberlin has quit [Quit: Textual IRC Client: www.textualapp.com]
<travis-ci> crystal-lang/crystal#5eecd57 (release/0.24 - Fix: decode DWARF line sequences with single program entry (#5565)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/327310238
<DeBot> https://github.com/crystal-lang/crystal/pull/5565 (Fix: decode DWARF line sequences with single program entry)
wontruefree has joined #crystal-lang
lacour has joined #crystal-lang
cbass has quit [Ping timeout: 276 seconds]
oprypin has joined #crystal-lang
<FromGitter> <bararchy> RX14, what's NIH ?
<oprypin> bararchy, "not invented here". in that phrase used as a substitute for "rewriting"
<FromGitter> <bararchy> Oh, I see
<FromGitter> <bararchy> thanks
<RX14> well it's more than that
<oprypin> it is more but you used it inappropriately :p
<RX14> it comes from "not inveted here syndrome"
<RX14> which is basically when a developer or ogasnsization tends to reject solutions they didn't write themselves
<RX14> but yeah I was using it colloquially to just mean rewriting
rohitpaulk has quit [Remote host closed the connection]
<FromGitter> <bararchy> I really wish @ysbaddaden 's GC to be here already, I really hate our current one.
<RX14> why?
<oprypin> there was a company that just disabled GC and opted to instead occasionally restart their services :p
<RX14> i think that expecting it to be amazingly better is just wrong
<RX14> oprypin, yeah i don't think thats really possible given today's allocation rates
<RX14> you'd get maybe 10 http requests into 8gb ram
<oprypin> O_O
<oprypin> i dont believe you
<RX14> ok maybe 10 is too few
<oprypin> off by like 4 orders of magnitude, no biggie
<RX14> doubt it's 4 orders of magnitude
<FromGitter> <bararchy> Beacuse it has the potential to totally crash my program without any way I can rescue it, and it sigfaults on wierd configurations that I need to re-compile the GC if I want ot avoid
<RX14> like a lot
<RX14> @bararchy what are you *doing* to the GC
<FromGitter> <bararchy> XD
<RX14> it's been stable as a rock to me
<FromGitter> <bararchy> are you using Arch ?
<oprypin> tbh on low memory crystal just dies and that's it
<RX14> yes
<FromGitter> <bararchy> Using SHAInet I get this thing all the time ⏎ ⏎ ```Too many heap sections: Increase MAXHINCR or MAX_HEAP_SECTS``` [https://gitter.im/crystal-lang/crystal?at=5a5654a0b48e8c3566c44e4a]
<RX14> stop allocating so many objects
<RX14> what heap usage do you have @bararchy
<oprypin> for sure. neural networks write a lot of data in arrays but they dont need to be new arrays all the time!
<FromGitter> <bararchy> Floats ?
<oprypin> floats dont use GC
<FromGitter> <bararchy> IDK then ... ⏎ The fix is to ⏎ build boehmgc with enableLargeConfig = true
<oprypin> no, thats the kludge
<FromGitter> <bararchy> kludge ?
<RX14> incorrect fix applied to mask the problem not solve it
<FromGitter> <bararchy> I guess, but the error dosen't tell me too much
<FromGitter> <bararchy> what does it mean "too many heap sections"?
<RX14> too many objects
<RX14> lol
<oprypin> you might guess that it means too many heap allocations
<FromGitter> <bararchy> I sometimes need 1k arrays with 200 floats, etc..
<RX14> tbh oprypin it probably means too many mmaps
<FromGitter> <bararchy> is this too much ?
<RX14> depends how often you need them
<FromGitter> <bararchy> sometimes even more
<oprypin> bararchy, no it isnt, but i bet that you keep recreating them
<FromGitter> <bararchy> I keep cleaning them too :)
<oprypin> it's not a problem of how many arrays you have at once, it's how many you create
<FromGitter> <bararchy> I never reach high RAM, always around 8-12gb
<oprypin> ok, besides being actually pretty damn high, what does this have to do with the problem at hand?
<FromGitter> <bararchy> not sure :)
<FromGitter> <bararchy> so, you say I create too many objects too fast ?
<FromGitter> <bararchy> it's not the overall numbers of array, but how often I create them ?
<oprypin> yes
<oprypin> you know how you write a = [1,2,3]; return a.filter{}.map{}.reject{} that's 4 arrays right there
<oprypin> put that in a loop and it's multiplied
<FromGitter> <bararchy> well, I create lots of arrays really fast, the Neural network works on matrixes etc..
<FromGitter> <bararchy> lots of maps, finds, max, etc.
<FromGitter> <bararchy> also sum
<oprypin> out of those only map is relevant
<FromGitter> <bararchy> I see
<oprypin> and basically it should be `map!`
<FromGitter> <bararchy> and select I guess
<oprypin> or reading from one array and writing to another one manually
<FromGitter> <bararchy> map will change current array instead of creating new one?
<FromGitter> <bararchy> ^ oh
<FromGitter> <bararchy> yeha
<oprypin> as for select -- you basically need to rework the code to not use it
<FromGitter> <bararchy> XD
<oprypin> you probably use it to filter out some data then do a quick calculation on that data and immediately throw it away
<oprypin> let's say you do `.select{}.sum` - instead have a loop `sum = 0; array.each |x| if condition; sum += x`
<oprypin> it's unfortunate that you have to avoid such nice language features but it is what it is
<oprypin> and don't forget that removing these allocations also enables you to do parallelism as i mentioned
<oprypin> but that's beside the point
<FromGitter> <bararchy> Yeha, working on that, trying to get it not to crash :\
<oprypin> of course, before going with an axe on your code you should do profiling first -- figure out which spot does the most wasteful allocations an optimize that
<oprypin> bararchy, if the lib is designed from the ground up with those allocations, maybe parallelism is not worth trying for now
<FromGitter> <bararchy> I can work on the code thats for sure, but, when someone will go very "deep", and lots of neurons and layers, it will reach critical allocations again even if optimized
<oprypin> but you still can optimize hot spots for GC
<RX14> oprypin, actually, I think we're wrong on this one
<RX14> to me that doc says to me "we really need to turn this config on"
<RX14> 8gb heap isn't incomrehensible
<oprypin> could be
<FromGitter> <bararchy> Necessary for heaps larger than about 4 GiB on most
<FromGitter> <bararchy> well well well
<FromGitter> <bararchy> XD
<FromGitter> <bararchy> we reach 8-12g
<FromGitter> <bararchy> lol
<FromGitter> <bararchy> I see
<oprypin> i, for one, am not convinced that you could meaningfully iterate on 12 GB of data and teach a neural network of that size in reasonable time
<FromGitter> <asterite> where's the code? and is there some code that can be run in that repo to profile allocations?
<RX14> oprypin, you should be able to read 12gb of data in well under a second
<oprypin> RX14, yeah that's cool but you can't compute 12 gb squared of data which is just the propagation of weights
<RX14> "12gb squared"
<oprypin> you know you understood me
<RX14> you can't even fit that much data oprypin
<RX14> you mean you have to read 12gb n time for one iteration?
<RX14> where n is 12gb / sizeof(float) ?
<FromGitter> <bararchy> @asterite (https://github.com/NeuraLegion/shainet) you can just run specs
claudiuinberlin has joined #crystal-lang
<FromGitter> <bararchy> better to uncomment the "mnist" specs if you want to see the havy lifting
<oprypin> you know what? nvm about the "squared" part
<oprypin> you store N weights and you update N weights
<FromGitter> <bararchy> This is the relevant part @asterite https://github.com/NeuraLegion/shainet/blob/master/spec/network_spec.cr#L224-L292
<FromGitter> <bararchy> travis won't manage to do it so we just comment it out
<RX14> oprypin, by default a plain amber app allocates 116kib per request
<oprypin> (8 gibibytes) / (116 kibibytes) = 72 315.5862
<RX14> so only *nearly* 4 orders of magnitude off
<FromGitter> <asterite> bararchy: no overload matches 'SHAInet::Network#add_layer' with types Symbol, Int32, String, Symbol
<FromGitter> <asterite> Ah, probably I have to use `SHAInet.sigmoid`
wontruefree has quit [Quit: The Internet needs a break and I need a cookie]
<FromGitter> <bararchy> yeha, sorry
<FromGitter> <bararchy> I'll update that
wontruefree has joined #crystal-lang
wontruefree has quit [Client Quit]
wontruefree has joined #crystal-lang
wontruefree has quit [Client Quit]
wontruefree has joined #crystal-lang
wontruefree has quit [Client Quit]
wontruefree has joined #crystal-lang
wontruefree has quit [Client Quit]
wontruefree has joined #crystal-lang
wontruefree has quit [Client Quit]
<FromGitter> <asterite> bararchy: https://imgur.com/a/X3zo6
<FromGitter> <asterite> that's with xcode's instruments tool
<FromGitter> <asterite> it seems transpose takes most of the time/allocation
<FromGitter> <asterite> transpose allocates a whole new memory
<FromGitter> <asterite> and I see it's just used for `each` and then computing max, so maybe there's a more efficient way to do that
<FromGitter> <asterite> once you do that, you run the profiler again and check where's the time, optimize, repeat
<FromGitter> <asterite> (I move that single spec to a foo.cr file)
<FromGitter> <asterite> Plus in that method there's 4 tranpose
<FromGitter> <bararchy> Oh cool
<FromGitter> <bararchy> is this tool for Linux too ?
<RX14> no
<FromGitter> <asterite> no, but I think there are similar tools
<RX14> on linux you have kcachegrind
<RX14> (which is better)
<RX14> you don't get the fanciness but you do get much more detail
<RX14> @asterite do you get instruction-level profiling with instruments?
<FromGitter> <asterite> ummm... what's that?
<RX14> you see the disasembly
<RX14> and the amount of times the instruction was executed etc
<FromGitter> <asterite> i'm not sure, or I can't find it :-)
<RX14> well with callgrind you're running the whole thing in a VM
<RX14> so for every single instruction you get the number of times it was hit
<RX14> the estimated cycle counts
<RX14> hit rates for each cache per-instruction
<RX14> and obviously per source line too
<RX14> it's super detailed
<FromGitter> <asterite> awesome
<FromGitter> <asterite> Yeah, maybe it's available in Instruments but I can't find it
<RX14> probably not tbh
<FromGitter> <asterite> On the other hand, every time I wanted to optimize something (someone was complaining that something was slow in their crystal project) with just doing what I explained above I was able to optimize it a lot
<RX14> the downside is that it runs literally 100+ times slower than realtime
<RX14> so your 1s benchmark becomes 100s
<FromGitter> <asterite> and usually it was just one or two things that had to change, so that's really good :-)
<RX14> and your 20 second compile becomes half an hour
<FromGitter> <asterite> Oh, I don't care if it takes longer as long as it gives me more data
<RX14> i imagine you can use callgrind on osx
<RX14> although i did have to heck it a bit to get intel asm syntax
<RX14> because gas syntax sucks
<FromGitter> <bararchy> @asterite I don't think I can get away from transpose :/ or I will need to do the exact same thing manually
woodruffw has quit [Ping timeout: 260 seconds]
<FromGitter> <asterite> yes, you have to do it manually, or write a method `transpose_each` that does it manually
<FromGitter> <asterite> and then probably compute the maximum value manually too
<FromGitter> <asterite> that's the beauty of Go: if you had written this in Go you had done it manually because you have no other way :-P
woodruffw has joined #crystal-lang
woodruffw has quit [Changing host]
woodruffw has joined #crystal-lang
<FromGitter> <asterite> no expensive abstractions
<FromGitter> <bararchy> 😢
<RX14> you don't even need to allocate do you
<RX14> you're just transposing then immediately running an .each?
<FromGitter> <bararchy> Yeha XD
<RX14> surely it's clear you can just iteratively do that by index
<RX14> it's a 2d matrix
<FromGitter> <bararchy> This one is, ConvLayer is 3d
<RX14> for each i; compute max of arr[i][...]
<RX14> for each j; compute max of arr[...][j#]
<RX14> @bararchy well transpose is 2d
<FromGitter> <bararchy> I'll itirate it , let's see benchmark speed changes
<RX14> also @bararchy
<RX14> at the very least don't use transpose twice in a row
<RX14> @inputs.transpose lines next to each other
<RX14> actually whyyy
<RX14> surely it's clearly faster to call @inputs.transpose once
<RX14> the least you can do is @inputs.transpose.each { |a| i_max << a.max; i_min << a.min }
<RX14> thats free 2x performance gain
<FromGitter> <bararchy> @ArtLinkov ^ optimizations
<FromGitter> <bararchy> RX14, thanks I'll go over it now
wontruefree has joined #crystal-lang
wontruefree has quit [Client Quit]
wontruefree has joined #crystal-lang
wontruefree has quit [Client Quit]
<FromGitter> <marksiemers> This made its way to reddit: https://www.reddit.com/r/ruby/comments/7pel4x/top_5_reasons_for_rubyists_to_use_crystal/ ⏎ With thankfully little backlash (so far).
<RX14> no backlash? even I thought it was a stupid article
<FromGitter> <marksiemers> Do you consider yourself a Ruby-ist?
<RX14> i guess that's a bit harsh
<RX14> but there are some factual errors
<FromGitter> <marksiemers> Probably should have let you in on the review process, some guys at Manas and Amber looked it over.
<FromGitter> <marksiemers> What did we miss?
<FromGitter> <sdogruyol> @RX14 stupid article? That's a bit harsh
<RX14> yeah it was, i'm sorry
<FromGitter> <marksiemers> No worries
<FromGitter> <marksiemers> You weren't my target audience by any stretch. I'm interested in what I missed though.
<RX14> well to me I think the people who find it hardest to learn crystal are rubyists
<RX14> the syntax is the same, cool
<FromGitter> <eliasjpr> I like what I read on reddit, the artlicle is generating the debate that is necessary, we can all learn from all the touch points
<RX14> but dynamic typing vs static typing? learning a new syntax is really really easy compared to learning how static typing works
<RX14> syntax is just how to type
<RX14> going ruby to crystal you need to change how to think
<FromGitter> <eliasjpr> Agree
<RX14> and that'n never easy
<RX14> I dislike hugely the "crystal is easy for rubyists" messaging
<FromGitter> <eliasjpr> > **<RX14>** going ruby to crystal you need to change how to think ⏎ @RX14 did you post that on reddit? I think you should
<RX14> because by seeing someone who has only used ruby come into the channel that idea is instantly expelled
<RX14> plus the title is clickbait
<RX14> just saying
<FromGitter> <marksiemers> Isn't that what blog post titles are supposed to be?
<RX14> depends what you want to do
<RX14> inform people, or spread propaganda
<FromGitter> <eliasjpr> Beware that Crystal gives that impression "easy for rubyists” and while is stactically typed and compiled, the syntaxt similarities also causes the effect of makind it easier to understand how Crystal works
<FromGitter> <marksiemers> Agreed on the point about learning static-typing will be a challenge. ⏎ I consider myself a Ruby-ist for sure, but it wasn't my first language, so the idea of static-typing and method overloading (and native types) isn't brand new like it may be for a lot of Ruby-ists.
<FromGitter> <Fryguy> I have to disagree ... I come from a 10-years-of-Ruby-experience background and Crystal was the fastest language I've ever picked up
<FromGitter> <Fryguy> Mainly because the standard library is nearly identical except for duplicate methods
<RX14> @Fryguy what languages other than ruby had you used before crystal?
<FromGitter> <Fryguy> C, C#, Java, VisualBasic
<RX14> yeah
<FromGitter> <Fryguy> (a bunch)
<RX14> crystal is really easy to pick up if you've learnt ruby AND a statically typed language
<FromGitter> <Fryguy> that's fair
<RX14> because you learn the syntax and stdlib from ruby
<FromGitter> <eliasjpr> For Rubyists that have never worked with a compile language there is a painful lurning curve
<RX14> and the semantics from a static language
<FromGitter> <Fryguy> the stdlib mostly matching was a huge boost for me
<FromGitter> <Fryguy> because I didn't have to "figure out" what the map method was
<FromGitter> <eliasjpr> those who come from languages like java, c# c, wil just need to learn the syntaxt
<FromGitter> <asterite> we are still in time to change the syntax so it doesn't look like ruby ;-)
<FromGitter> <marksiemers> > I dislike hugely the "crystal is easy for rubyists" messaging ⏎ The tagline of the language is a problem regarding this sentiment: "Fast as C, slick as Ruby."
<RX14> @asterite I love the syntax
<FromGitter> <eliasjpr> > we are still in time to change the syntax so it doesn't look like ruby ;-) ⏎ Say what!
<RX14> I think ruby is the second best language syntactically
<RX14> after crystal
<FromGitter> <asterite> well, would you say elixir looks like ruby?
<RX14> not as much as crystal
<FromGitter> <eliasjpr> I almost spilled coffee all over the laptop
<RX14> and it goes in the wrong direction:
<FromGitter> <asterite> and that's goo
<FromGitter> <asterite> good
<RX14> elixir adds more symbols
<FromGitter> <Fryguy> honestly the hardest thing for me to learn what that I had to use local variables to trim down a union type (as opposed to calling a proprty twice like I would in Ruby)
<FromGitter> <asterite> you start coding elixir and you immediately realize it's nothing like ruby
<FromGitter> <eliasjpr> @asterite eleixir feel like ruby
<FromGitter> <asterite> but that doesn't happen with crystal... you can pretend it's ruby but it's not, but the syntax is too deceiving
<FromGitter> <Fryguy> I mean, I understood *why* right away, but remembering to do it and then seeing that was the problem when I got an error took me a while
<FromGitter> <eliasjpr> is not by all means like ruby
<RX14> @asterite the only reason to change the syntax away from ruby would be to change the impression of newcomers
<FromGitter> <marksiemers> I think this a great point though - about people who only know Ruby (and may JS) then come to crystal and are lulled into a sense of knowing how to use the language.
<FromGitter> <asterite> in Manas many times we said in the past: let's stop saying this language has any connection with Ruby
<FromGitter> <Fryguy> yeah Elixir is nothing like Ruby...that was a bigger fallacy to me than the Crystal/Ruby comparison
<RX14> and communities optimizing for newcomers over people who already use the language is a bad idea
<FromGitter> <asterite> but I guess it's inevitable because syntax-wise it does look like Ruby... I wouldn't say the same regarding elixir (defmoudle, destructu, def ... do, if ... do, etc.)
<FromGitter> <eliasjpr> why would you want to change the syntaxt isn’t the syntaxt on of the source of inspiration for prototyping Crystal in the first way
<FromGitter> <eliasjpr> 😠
<FromGitter> <eliasjpr> :)
<FromGitter> <Fryguy> Ruby is "beautiful" and for me that makes it easier to read and understand...I get that exact same feeling out of Crystal
handicraftsman has joined #crystal-lang
<FromGitter> <eliasjpr> Crystal is what I wanted every since I was born - there you go
<FromGitter> <asterite> wow
<FromGitter> <asterite> well, it was just a theoretical proposal with a ";)" smiley
<FromGitter> <asterite> but yes, ruby syntax is really nice
<FromGitter> <Fryguy> yeah, Crystal is the language I have always wanted as I've been progressing through my career
<FromGitter> <marksiemers> Crystal seems to me, you can do a lot just writing nearly-ruby code, but then when you need more (overloading, access to native types, etc.), you can have it.
<FromGitter> <asterite> sometimes it looks too terse, though
<RX14> I like that crystal is basically ruby with the "fat trimmed"
<RX14> like for, gone
<FromGitter> <Fryguy> yeah, but it never seem to get to Perl-level terseness :)
<RX14> post-fix while, gone
<FromGitter> <marksiemers> @asterite - What's an example of terseness?
<FromGitter> <marksiemers> It can't ever be worse than Go
<RX14> it can be
<RX14> apl
<FromGitter> <asterite> oh, Go is the opposite
<FromGitter> <asterite> I mean, in Ruby/Crystal sometimes there's too many things going on in just one line or two
<FromGitter> <eliasjpr> After using Crystal for a while you soon realize that it diverts from ruby mind set, and you see more of a need to right things once and one way
<FromGitter> <asterite> and all put together like someone puked that code
<FromGitter> <asterite> (that's at least what comes to my mind)
<FromGitter> <Fryguy> one-line-all-the-things ;)
<RX14> @asterite there is a sense of that
<RX14> with go youc an't really write eldritch horrors
<RX14> even if you want to
<FromGitter> <asterite> i'll try to find an example, not sure I'll quickly find one
<RX14> with crystal you definitely can
<RX14> crystal gives a lot more trust in the programmer than go
<RX14> but less than ruby
<FromGitter> <eliasjpr> For instance you can see the std lib that crystal does not have 20 methods for the same thing it cuts that nonsense
<RX14> I like crystal's balance
<FromGitter> <marksiemers> > not sure I'll quickly find one ⏎ ⏎ It sounds like it is a sometimes problem, not a most-of-the-time problem
<FromGitter> <eliasjpr> Ruby has like 10 method aliases per implementation
<FromGitter> <asterite> (I wrote it so no one can be offended with that puke comment :-P)
<FromGitter> <asterite> maybe it could benefit with some more newlines... I don't know
<RX14> yeah
<RX14> that was my first reaction
<RX14> "whitespace"!
<RX14> size calc is one "block"
<FromGitter> <asterite> or comments, probably
<FromGitter> <codenoid> i came from php, and i hate it because php doesnt tell me about Int, String, Float type
<RX14> so i'd put whitespace after that and before the array creation
<RX14> then i'd look at the loop body
<FromGitter> <marksiemers> > <RX14> I like crystal's balance ⏎ ⏎ Agreed, its like the tradeoff between the ease (syntactically) of high-level languages, and the speed of lower-level languages has finally been solved.
<RX14> (using end. is ugly)
<FromGitter> <eliasjpr> PHP, lol I was trolling trying to get people to use amber and I got the nastiest response
<RX14> and then i'd think `find[1]`, don't we have a .first ?
<FromGitter> <sdogruyol> for me, Crystal is best of both worlds. I've done Java before falling into love with Ruby
<RX14> and then whitespace between pattern = and copy
<RX14> and then it's kinda neat
<FromGitter> <eliasjpr> Worst than ⏎ ⏎ > **<RX14>** no backlash? even I thought it was a stupid article
<RX14> I wish the article had gone through a PR
<RX14> that's what I think
<RX14> I had no idea about that article until it was published
<FromGitter> <asterite> I liked the article
<FromGitter> <asterite> One thing about type restrictions is that the article doesn't say that if you don't put restrictions and pass an incorrect type, you still get a compile error
<FromGitter> <asterite> by reading it without previous knowledge, it looks like you have to type the arguments in order to get that benefit
<Vexatos> an article?
* Vexatos scrolls up
<RX14> My #1 complaint is overstating the ease of use to newcomers
<FromGitter> <asterite> and that's something that Rubyists would immediately say "no, forget it" when seeing it
<FromGitter> <sdogruyol> it actually went through a review process @RX14, I think @marksiemers forgot to add you on the google docs (he probably didn't know your email)
<RX14> no mention on the core team slack though
<FromGitter> <marksiemers> @asterite - I think that linked code could be refactored with some helpfully names methods, but your point stands, it is possible to write some terse code.
<FromGitter> <sdogruyol> yeah, that's our lack of communication lol
<RX14> Perhaps next time just make a sharing link and paste it in slack
<FromGitter> <sdogruyol> I actually didn't know it's posted on the blog..I saw the link on reddit
<FromGitter> <sdogruyol> a start is always better than nothing. Next time, we'll be more coordinated for sure
<FromGitter> <marksiemers> @RX14 - I emailed crystal@manas.tech and communicated with Brian and Nico via email. They asked for a Google doc for the review process. ⏎ I included them, Serdar, and Paul C Smith (since Kemal and Lucky were mentioned)
<FromGitter> <marksiemers> and members of the Amber team.
<FromGitter> <marksiemers> @asterite and @RX14 - These are points that could definitely go in the Disqus comments and/or the article can get an edit and update noting the changes.
<FromGitter> <marksiemers> I'm guessing the guys at Manas would be willing to do that.
<FromGitter> <marksiemers> I certainly am
<FromGitter> <marksiemers> With any luck, we'll have 3 more posts this month - about 3 of the web frameworks.
<FromGitter> <marksiemers> Next month, hopefully a couple articles from @bararchy and/or @ArtLinkov
<FromGitter> <ArtLinkov> No worries, @marksiemers My fingers are itching to write them up ;)
<FromGitter> <drujensen> @ArtLinkov hopefully on CNN using SHAInet. ;-)
<FromGitter> <ArtLinkov> @drujensen Yeah, we're getting there... I really wanna do a benchmark test comparing a CNN implemented in Crystal vs. the other languages. Hopefully we can make it faster, providing Crystal with a good good in the door for ML
<FromGitter> <fsdevblog> Hello guys ! ⏎ First, Thank you for what you are doing! ⏎ ⏎ Can I ask here, periodically, simple questions? [https://gitter.im/crystal-lang/crystal?at=5a567c915a9ebe4f756fab64]
<FromGitter> <straight-shoota> sure, that's what this chat is about ;)
<FromGitter> <fsdevblog> Here is example ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ How can I test var `@bar`, if class doesn't have a getter? [https://gitter.im/crystal-lang/crystal?at=5a567d0cb48e8c3566c54cef]
<FromGitter> <fsdevblog> I guess you are tired from questions with link to ruby... but i'm looking for something like `instance_variable_get` in Ruby.
<FromGitter> <straight-shoota> Usually you shouldn't have to test private ivars. Though I know it can be useful sometime... my PR for time zone support contains some uses of this.
<FromGitter> <straight-shoota> Basically, you can define a public method on the class only for the spec through reopening:
<FromGitter> <straight-shoota> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5a567fb3b48e8c3566c55ba5]
<FromGitter> <straight-shoota> `Foo#__bar` will only be defined for spec purpose but not in the library itself. The `__` prefix is just my personal preference to make sure it doesn't overwrite any existing instance methods.
<FromGitter> <splattael> I see a strange (invalid?) "macro expansion" behaviour when I use `x = counter[:arg] += 1` with `{{ yield }}` or not: https://gist.github.com/splattael/1073b89bc8b9bce0542980e65517afab
<FromGitter> <splattael> I worked with Crystal 0.23.1
claudiuinberlin has quit [Quit: Textual IRC Client: www.textualapp.com]
<FromGitter> <splattael> It*
<FromGitter> <fsdevblog> @straight-shoota thank you. It's so easy)
<FromGitter> <splattael> I am not sure if I should file an issue or not.
<FromGitter> <splattael> The "macro expansions" differ from 0.23.1 (correct) to 0.24.1 (fail). I've updated the gist above.
<FromGitter> <straight-shoota> you should open an issue about this @splattael
<FromGitter> <splattael> @straight-shoota Ok, thanks. Will do!
<FromGitter> <straight-shoota> the macro expansion is clearly wrong: ⏎ ⏎ ```last_uid = __temp_6 = counter ⏎ __temp_6[:last_uid] = __temp_6[:last_uid] + 1``` [https://gitter.im/crystal-lang/crystal?at=5a5681f6232e79134deee51c]
<oprypin> splattael, pls use carc.in - you could post an example running on different versions, even
<FromGitter> <straight-shoota> seems like a precendence issue, this expansion is actually `(last_uid = counter[:last_uid]) += 1`
<FromGitter> <straight-shoota> which doesn't make sense
<FromGitter> <splattael> @oprypin Thanks!
<oprypin> my examples dont prove anything tho
<FromGitter> <splattael> @oprypin Yes, just saw it :/
<FromGitter> <splattael> @straight-shoota @oprypin Issue filed (https://github.com/crystal-lang/crystal/issues/5568), thanks for your time!
<oprypin> that'll do
<FromGitter> <straight-shoota> you should better use the minimal reproducing examples from oprypin
<FromGitter> <straight-shoota> makes it easier to understand the issue
<oprypin> they dont reproduce anything though, as i said
<oprypin> the point was that 1. you can use carc.in for different versions 2. you can use `pp` to show macro expansion
<oprypin> i couldnt make them actually reproduce the problem, even though yes, it looks different
<FromGitter> <straight-shoota> ah, true
<FromGitter> <straight-shoota> but the code can be reduced and it should
<lvmbdv> why can I not inherit from string
<lvmbdv> i looked at the source it's a 3 line macro
<lvmbdv> the part that's not letting me inherit it
<oprypin> lvmbdv, i dunno, maybe because that object would be impossible to initialize
<oprypin> how would that work, can you tell me?
<oprypin> and, as usual, what are you actually trying to do?
<lvmbdv> how would that work -> IO::Memory maybe
<oprypin> k, and?
<lvmbdv> what i am trying to do -> alias String but as another class object
<lvmbdv> "class object" doesn't sound right
<oprypin> struct
<lvmbdv> let's say more like a typedef and less like a "replace at compile time" deal
<oprypin> record MySuperThing, value : String
<oprypin> lvmbdv, i get that, but we dont have that
<lvmbdv> what's the record macro
<oprypin> https://crystal-lang.org/api/toplevel.html#record%28name%2C%2Aproperties%29-macro
<lvmbdv> thanks
<oprypin> if you want to be cute with it, you can forward_missing_to value
alex`` has quit [Ping timeout: 265 seconds]
<oprypin> though i wouldnt recommend class
<oprypin> but struct
<oprypin> lvmbdv, ^
<lvmbdv> its example is about wrapping String as a class tho
<oprypin> lvmbdv, yes..?
<oprypin> and that's what you want to do
<FromGitter> <splattael> @straight-shoota @oprypin Was able to shrink a bit: https://carc.in/#/r/3d9u & https://carc.in/#/r/3d9q
<lvmbdv> yeah, just weird that you dont recommend what the docs show as an example
alex`` has joined #crystal-lang
<oprypin> lvmbdv, you'll be fine either way but implementation-wise class is just an unneeded additional pointer
<oprypin> with garbage collection and whatnot
<FromGitter> <fsdevblog> @oprypin are you russian?
<lvmbdv> alright, thanks
<oprypin> of course, this wrapper's methods will all return a normal string
<oprypin> fsdevblog, well that's random
<FromGitter> <fsdevblog> @oprypin I thought that maybe you can tell me in Russian in which situations to use the `struct` and in which `class`. it's still hard for me to understand what's happening here)
<FromGitter> <fsdevblog> A couple of hours ago, there was a discussion here that the rubist could easily understand the crystal. So that's it. this is not true )
<oprypin> no, Rubyists have a harder time understanding Crystal
<oprypin> but have some advantages in remembering the standard library
<robacarp> hm, why do you say that?
<FromGitter> <fsdevblog> who? what say?
<oprypin> robacarp, i say that because i keep seeing people who try write Crystal without reading the docs. sounds ridiculous, right?
<robacarp> well, reading the docs should be the first place to go, but what does that have to do with rubist/pythonista/etc
<FromGitter> <fsdevblog> You talking about my question about struct and class?
<oprypin> robacarp, some rubyists think they don't need docs, or at least don't need all of it
<robacarp> @fsdevblog, sorry, no, getting more information about coming from ruby
<robacarp> I came (most recently) from a ruby background and didn't have many issues
<oprypin> fsdevblog, maybe you'll find this abandoned blog post useful https://gist.github.com/oprypin/0267238b3f6bfa1016a0a601466b0576
<robacarp> compiler type inference and safety changes the way I write code a lot, and that's probably a change lots of rubists aren't ready to make
<oprypin> fsdevblog, particularly the bottom of the post
<oprypin> which is a bunch of messages i wrote in IRC then copied there "for later" :|
<oprypin> i should finish it one day, it's (supposed to be) a very nice post
<FromGitter> <fsdevblog> @oprypin , thank you for good article. but if something like this was in the documentation - I would not ask you. Sorry to bother you.
<FromGitter> <imonmyown> guys is there a way to initialize a `Deque` from a `Slice` without extra allocation? `.new` with a `&block`?
<oprypin> imonmyown, there is no way in standard library to do that without copying. there are some ways to do it with hacks though. not recommended
<oprypin> fsdevblog, but the information is there https://crystal-lang.org/docs/syntax_and_semantics/structs.html
<oprypin> it's quite a concise reference, they don't explain every concept in computing
<FromGitter> <imonmyown> @oprypin I see, thanks. What hacks are implied if performance was paramount (not that I need it, just interested)?
<oprypin> imonmyown, reopen Deque and add your own constructor, probably
<FromGitter> <fsdevblog> it's information maybe useful for peoples, who knows for example what is pointers and etc... Not for people, who came from php, ruby and etc.
<FromGitter> <imonmyown> @oprypin, gotcha
<crystal-gh> [crystal] lachlan opened pull request #5570: Fix Iterator spec typo: integreation -> integration (master...iterator-spec-typo) https://git.io/vNOc7
<FromGitter> <imonmyown> @oprypin, I should admit that I have lost my temper in relation to you. Sorry about that
<oprypin> don't mention it, i deserve that
alex`` has quit [Ping timeout: 265 seconds]
<FromGitter> <imonmyown> ok, let us leave it behind then
<oprypin> ok
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
wontruefree has joined #crystal-lang
snsei has quit [Ping timeout: 265 seconds]
<FromGitter> <codenoid> yo, warning all
<FromGitter> <codenoid> *morning all
randy_ has joined #crystal-lang
randy_ has quit [Client Quit]
<FromGitter> <Svenskunganka> It's midnight here but morning to you @codenoid! 😄
<FromGitter> <straight-shoota> so technically it's morning
<FromGitter> <codenoid> ^ +1 😄
sagax has quit [Quit: Konversation terminated!]
vegai has quit [Ping timeout: 268 seconds]
vegai has joined #crystal-lang