<FromGitter>
<rishavs> > Its now bind_tcp β yeah. Looks like we aught to update all the examples. Shall I go ahead and create an issue?
DTZUZO has joined #crystal-lang
<FromGitter>
<bew> @MrSorcus wel that depends on what you're trying to do
<FromGitter>
<bendietze_twitter> This is known but time is limited :) I think for newbies just want to try Crystsl its not fine, but for us - we would morely ask here :) @rishavs
<FromGitter>
<rishavs> well, i have added an issue in the docs repo. To be fair, i was pretty confused till I rememberd that there were breaking changes wrt http server in v.25
<FromGitter>
<bendietze_twitter> I think it could be an idea to link the latest changelog directly under the release banner? @bcardiff
<FromGitter>
<bendietze_twitter> Please read this first: changelog.md
<FromGitter>
<MrSorcus> > @MrSorcus wel that depends on what you're trying to do β β Just merge two hash with union one or more similar keys.
<FromGitter>
<bendietze_twitter> @rishavs i think most of us had run into this :)
<FromGitter>
<j8r> @MrSorcus don't get why you use symbols in a Hash. This adds nothing. Either you use String in Hash or Symbols in NamedTuples.
moei has quit [Read error: Connection reset by peer]
<FromGitter>
<MrSorcus> > @MrSorcus don't get why you use symbols in a Hash. This adds nothing. Either you use String in Hash or Symbols in NamedTuples. β β It doesn't matter. Just example code. Just `merge(!)` with block doesn't have any example or docs.
moei has joined #crystal-lang
<FromGitter>
<3rror> Hello guys, I'm new to Crystal and I have a question :) β I was trying to write some simple programs and, in the last one, I was parsing a json this way: β β ```file = File.new("very_big_json.json") β messages = Array(Message).from_json(file)``` β ... [https://gitter.im/crystal-lang/crystal?at=5b349a5cad21887018e52b70]
<jokke>
hey o/ who's the kemal dev again?
<FromGitter>
<bendietze_twitter> jokke Do you mean @sdogruyol ? Kemal has a gitter chatroom too :)
<jokke>
oh
<jokke>
i'm not a fan of gitter :/
<FromGitter>
<bendietze_twitter> Me too ... I am hanging around in gitter π
<FromGitter>
<bendietze_twitter> Tried the third time use the App instead of web on my phone but again its just laggy and hangs π π
<jokke>
@sdogruyol would you be open to a pull request adding fork-support for kemal? so that instead of run(port) you would have run(port, workers) or sth which would fork n workers using port reuse
<FromGitter>
<MrSorcus> Hm... There is no `sort` for `Hash`?
<FromGitter>
<j8r> @3rror `File.new` creates a new class allocated on the heap, and `File.read` open the file and returns a `String`
<FromGitter>
<yxhuvud> @j8r that shouldn't explain the performance difference though. My guess is that from_json(io) doesn't read in the contents in a buffered way
<FromGitter>
<3rror> @yxhuvud I was thinking the same but digging in the Crystal library it seems that it's buffered. BTW a friend was trying to write the same program in Rust and, without buffering, the read was much much slower (14x). β I think that maybe `File.read` read the entire file at once and from_json cycle throught every single char with read_char(). I don't know if this makes sense though.
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 264 seconds]
Raimondii is now known as Raimondi
<FromGitter>
<S-YOU> It is easy to use LibC.read if File.read is the issue. But I think it is on JSON parsing.
<FromGitter>
<3rror> `File.read` is not the issue here, in fact, it's faster π. My question was about how `.from_json(IO)` is so much slower than `.from_json(File.read("..."))`. It's not really a problem for me, because even if the json file is pretty large, it's not large enough so that loading the content into a string creates a memory problem. But, if someone in the future will need to load a very large (GBs) json, he might
<RX14>
@ArtLinkov but remember that foo.a isn't an instance variable
<RX14>
it's the result of calling a method
<RX14>
so the answer is that yes you can take a pointer of an ivar, but only inside the class because *outside* the class, it's all just method calls
<FromGitter>
<ArtLinkov> ah... is there a way around it? :)
<RX14>
what are you trying to take a pointerof?
<RX14>
and is it inside the stdlib?
<RX14>
if it's an array, #to_unsafe is pointerof the memory allocation
<RX14>
similar for some other classes
<RX14>
like string
<FromGitter>
<ArtLinkov> I'm still working in the implementaion of a pointer matrix for SHAInet. β I want to do the matrix math outside each class but keep the OO
<RX14>
define to_unsafe on the matrix as pointerof(@the_memory)
<FromGitter>
<ArtLinkov> for example, if I have a neuron with several variables like "activation" or "bias"
<RX14>
or just returning @the_memory if it's already a pointer
<RX14>
if you need something inside the class from outside, just define a method
<FromGitter>
<ArtLinkov> I'm not sure I understand, can you give me an example?
<RX14>
well, in your matrix class you malloc and store a pointer, I assume
<RX14>
to where the actual matrix data goes
<FromGitter>
<ArtLinkov> I didn't do a mtrix class, its all Slice of Slice
<RX14>
oh
<FromGitter>
<ArtLinkov> ideally, the data needs to go directly at the pointers targets
<RX14>
well slices have to_unsafe which returns their pointer
<RX14>
well in your example you'd just define def a_ptr as pointerof(@a)
<RX14>
and then use c = foo.a_ptr
<RX14>
I assume you control the class
<FromGitter>
<ArtLinkov> I see, so defining the pointers as part of the class and then creating a matrix of these pointers will work?
<RX14>
yes
<FromGitter>
<ArtLinkov> Cool :) Thanks
<RX14>
@ArtLinkov btw, have you looked at array of structs vs struct of arrays?
<RX14>
the latter is far more complex to get a good interface for but should be possible and should be a lot faster
<FromGitter>
<yxhuvud> @ArtLinkov have you looked at the different bindings to lapack that we have?
<FromGitter>
<ArtLinkov> I haven't, still looking for a good trick for including matrices without destroying the OO :)
<FromGitter>
<ArtLinkov> @yxhuvud I'm not familiar with lapack, what do you mean?
<FromGitter>
<yxhuvud> I mean there are already matrix implementations that is fairly efficient.
<FromGitter>
<yxhuvud> even if the downside is that the actual implementations are in some other random language :/
<RX14>
@ArtLinkov it would be possible to make wrapper structs which include only enough information to access the underlying representation
<RX14>
then you've abstracted the OO from the underlying representation
<RX14>
for example in SoA you'd have your struct with arrays in hidden away somewhere
<RX14>
but you'd return to the user a wrapper struct with a pointer to the struct containing the arrays and the array indexes
<FromGitter>
<ArtLinkov> Oh, well I'm sure there are some good libs. The problem is that what I'm trying to do with SHAInet requires the OO approach (giving each neuron a class for example), and I don;t even know where to start so I'm jsut trying things :)
<RX14>
then you'd `def a; internal.a[i]`
<RX14>
optimizing shainet sounds like an interesting problem
<RX14>
I wish I had the time to work on it
<FromGitter>
<ArtLinkov> RX14 it sounds like a good idea, but I don't have a lot of experience with structs unfortunately. I'll give it a try :) thanks a lot guys!
<FromGitter>
<sdogruyol> no @RX14 you should focus on what you do :D
<FromGitter>
<asterite> pointerof(foo.@a) works fine
<FromGitter>
<sdogruyol> that's interesting
<FromGitter>
<asterite> Gianluca Andreotti: when you parse from a string, you can take subslices. When you parse from an IO you can't, so you have to append to some buffer while you read, and then convert that to a string. That's why it's slower to parse from an IO (but in turn it can consume less memory)
<RX14>
@asterite it works fine but its not the right solution
<FromGitter>
<asterite> I was just saying it's possible :-)
<RX14>
I try to keep .@ a secret
<RX14>
as far as i'm concerned, .@ syntax should be used only when it's 2am and you can't be bothred to monkey patch an accessor to debug your code
<FromGitter>
<asterite> Or when writing low level code. I think the guy wanted to optimize hash needed to use it
<RX14>
nah, in that case you should just add an accessor
<FromGitter>
<ArtLinkov> RX14 why shouldn't I use .@a? I seems like a perfect solution for me :)
<FromGitter>
<3rror> @asterite Ty π
<RX14>
@ArtLinkov because it's not OO at all
<RX14>
the syntax should be removed
<RX14>
knowledge of it allows you to access private and undocumented ivars from anywhere in the code
<FromGitter>
<ArtLinkov> ok, I'll try to win over the temptation :D β I'll try to use your first suggestion to access pointers from outside the class. After it's done I'll play around with AOS/SOA
<FromGitter>
<asterite> You can do that in Ruby too ;-)
<RX14>
@ArtLinkov matrix class first, then SoA
<FromGitter>
<asterite> Jonathan Blow is making a language where SOA is really easy to use (but the language isn't public yet)
<RX14>
then the idea becomes operating on a struct of matrixes i guess
<FromGitter>
<ArtLinkov> RX14 π
<RX14>
not a matrix of structs
<RX14>
or whatever you do
<RX14>
in fact
<FromGitter>
<ArtLinkov> I just want simple to edit 2d matrices
<FromGitter>
<ArtLinkov> and by edit i mean only the content
<FromGitter>
<ArtLinkov> not dimention
<RX14>
what you're doing is converting your data to a struct of matrixes
<RX14>
you're basically doing SoA without realising it
<RX14>
just with pointers
<RX14>
and without (m)any of the advantages
<FromGitter>
<ArtLinkov> lol got it, I'll go educate myslef on SOA :D
<RX14>
then this whole "getting the pointer" problem is obviated
<RX14>
because instead of a Matrix(Foo)
<RX14>
you'll have a Foo which contains a Matrix(Int32) for each of the ivars
rohitpaulk has quit [Ping timeout: 245 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 248 seconds]
<crystal-gh>
[crystal] asterite opened pull request #6284: Compiler: make sure to remove literal types before instantiating matches (master...bug/6239-literals-not-removed) https://git.io/f4FPk
<FromGitter>
<hugoabonizio> @RX14 you know too much computer science to be 18 π
rohitpaulk has joined #crystal-lang
duane has quit [Ping timeout: 256 seconds]
duane has joined #crystal-lang
duane has quit [Read error: Connection reset by peer]
duane has joined #crystal-lang
duane has quit [Read error: Connection reset by peer]
return0e has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
duane has joined #crystal-lang
duane has quit [Read error: Connection reset by peer]
<FromGitter>
<oz> I don't know who's managing the Crystal weekly's newsletter, but the text version is still from issue 31 (HTML is π though).
duane has joined #crystal-lang
duane has quit [Read error: Connection reset by peer]
<FromGitter>
<sdogruyol> I'm managing @oz thanks for the notice
<FromGitter>
<sdogruyol> Not sure why version is broken though
rohitpaulk has quit [Ping timeout: 265 seconds]
duane has joined #crystal-lang
duane has quit [Read error: Connection reset by peer]
<crystal-gh>
[crystal] asterite opened pull request #6285: Fix YAML spec for libyaml 0.2.1 (master...bug/6283-libyaml-0.2.1) https://git.io/f4F7N
duane has joined #crystal-lang
duane has quit [Read error: Connection reset by peer]
alex`` has joined #crystal-lang
duane has joined #crystal-lang
duane has quit [Read error: Connection reset by peer]
duane has joined #crystal-lang
duane has quit [Read error: Connection reset by peer]
snsei_ has joined #crystal-lang
duane has joined #crystal-lang
duane has quit [Read error: Connection reset by peer]
duane has joined #crystal-lang
duane has quit [Read error: Connection reset by peer]
duane has joined #crystal-lang
duane has quit [Read error: Connection reset by peer]
duane has joined #crystal-lang
duane has quit [Read error: Connection reset by peer]
duane has joined #crystal-lang
duane has quit [Read error: Connection reset by peer]
lvmbdv has quit [Quit: Leaving.]
duane has joined #crystal-lang
duane has quit [Read error: Connection reset by peer]
duane has joined #crystal-lang
duane has quit [Read error: Connection reset by peer]
flaviodesousa has quit [Ping timeout: 265 seconds]
duane has joined #crystal-lang
duane has quit [Read error: Connection reset by peer]
duane has joined #crystal-lang
duane has quit [Read error: Connection reset by peer]
<FromGitter>
<jspillers> i am testing web sockets and have come across a difficult to debug problem... the first URL works fine, the second URL (commented out one) results in a `Unhandled exception: Unexpected end of http request (Exception)`. Not even really sure how to go about figuring out if the problem is with the client or on the remote end... any suggestions? β β ```code paste, see link```
duane has quit [Read error: Connection reset by peer]
<FromGitter>
<confact> Hi, I have problems with HTTP::Client. How do I stop HTTP::Client to read the body if the content-type is audio and not text/html as I send in Accept header?
duane has joined #crystal-lang
duane has quit [Read error: Connection reset by peer]
duane has joined #crystal-lang
duane has quit [Read error: Connection reset by peer]
<FromGitter>
<r00ster91> When I do for example this: β β ```code paste, see link``` β β Then it prints me `155` (the b value) but how do I now get for example the g value of the yield? Because not just b has been modified in the yield. ... [https://gitter.im/crystal-lang/crystal?at=5b35048472b31d3691fb8b85]
<FromGitter>
<r00ster91> nono I want to do something with these values then in the method. Im making a library and there I give the user some values and then the user modifys them and then I want to do something with them in the method. The user just should modify them.
<FromGitter>
<confact> Want is the best way to "break" or stop a block if it is done and I dont want to continue in the block?
<FromGitter>
<r00ster91> simply `break`
benharri has quit [Quit: not here right now...]
<FromGitter>
<confact> ok, just thinking what to do it correct way. Want to code "correct" as well.
<FromGitter>
<confact> so t hanks @r00ster91
<FromGitter>
<r00ster91> np
benharri has joined #crystal-lang
lvmbdv has joined #crystal-lang
<FromGitter>
<sdogruyol> Is there anyone using AWS SQS with Crystal?
<FromGitter>
<rishavs> not me.
<FromGitter>
<rishavs> where can I learn more on `@instance_vars are not yet allowed in metaclasses: use @@class_vars instead`? cant find this in api docs
<FromGitter>
<r00ster91> why do you want to find that in the API docs? Its an error message. You could find it in the source on github
<FromGitter>
<rishavs> I meant, where can I learn about @@class_vars
<FromGitter>
<hugoabonizio> `print` doesn't include a "\n"
<FromGitter>
<codenoid> right
snsei_ has joined #crystal-lang
wontruefree has joined #crystal-lang
wontruefree has quit [Quit: bye]
wontruefree has joined #crystal-lang
alex``` has joined #crystal-lang
alex`` has quit [Ping timeout: 260 seconds]
<FromGitter>
<Blacksmoke16> if im using JSON.mapping and `from_json` is there a way to tap into the initialization of the object to modify it? For example take a value and downcase it or something
<FromGitter>
<Blacksmoke16> without creating my own from_json method
<FromGitter>
<Blacksmoke16> wait, thats prob what the converter can be used for
<FromGitter>
<Blacksmoke16> yea nvm
wontruefree has quit [Quit: bye]
wontruefree has joined #crystal-lang
DTZUZU has quit [Quit: WeeChat 1.9]
zachk has joined #crystal-lang
zachk has joined #crystal-lang
DTZUZU has joined #crystal-lang
<FromGitter>
<rishavs> Just done coding my stupidly simple views/templates. I will drop the tutorial tomorrow. :D β next will be an improved router. Woo!! i am about to crash now.....
<crystal-gh>
[crystal] ysbaddaden closed pull request #6284: Compiler: make sure to remove literal types before instantiating matches (master...bug/6239-literals-not-removed) https://git.io/f4FPk
<FromGitter>
<asterite> @Blacksmoke16 if you use `include JSON::Serializable` there's an `after_initialize` method
<FromGitter>
<asterite> (which should probably be renamed to something that says `json` somewhere :-P)
snsei_ has quit [Ping timeout: 260 seconds]
<FromGitter>
<Blacksmoke16> thats literally exactly what i wanted <3
<FromGitter>
<Blacksmoke16> thank you!
<FromGitter>
<Blacksmoke16> that should be put in the docs somewhere
<FromGitter>
<rogiernitschelm_twitter> @rishavs sounds like a great initiative :)
<FromGitter>
<rishavs> Thanks @rogiernitschelm_twitter !! By not using any framework, i just feel like I have learned so much. Every small challenge I conquer, makes me feel clever and helps me keep the focus. π
<FromGitter>
<rogiernitschelm_twitter> I'm happy to see your enthusiasm. Nothing so rewarding as learning something new. Reminds me to get my feet dirty myself. π
<FromGitter>
<rishavs> I am having a programmer's high right now. when you are suddenly able to code after a big block. Its quite a rush. :D
rohitpaulk has quit [Ping timeout: 260 seconds]
<FromGitter>
<hugoabonizio> @rishavs π
<FromGitter>
<girng> hello my friend
<FromGitter>
<girng> I have a question about crystal's TCP, and if an SSD or HDD affects its speed
<FromGitter>
<girng> since it's i/o related? just curious thanks
<FromGitter>
<waghanza> hi @girng , I'm not sure it's related to `crystal`
<FromGitter>
<waghanza> any app need `is` will be more performing on `ssd` than `hdd`
<FromGitter>
<girng> in other words, if i buy a hdd VPS vs a SSD VPS.. will TCP messages be faster or slower when sent to players?
<FromGitter>
<waghanza> theorically faster, but there is no guarentee
<FromGitter>
<waghanza> it depends on so many things
<FromGitter>
<bew> Wat? hdd/ssd is for storage, network is not impacted in anyway by your choice of storage device
<FromGitter>
<bew> in any* way
<FromGitter>
<waghanza> > will TCP messages be faster or slower when sent to players? β TCP = network
<FromGitter>
<rishavs> In it I have created the simplest view system i could think of and used it to give me composable html components for my app
<FromGitter>
<rishavs> I am going to crash for the night/morning. But just a teaser on the next one; its called "Routing up a Storm" and I will try to improve on my router. It will still be a simple cascading router (no radix, mux or anything fancy) but structured better.
<FromGitter>
<bew> About me: I are awesome, should be I am awesome
<FromGitter>
<rishavs> Please keep giving your comments and feedback on my coding so I can get better at Crysta and improve my tutorials
<FromGitter>
<bew> Otherwise, great post!
<FromGitter>
<rishavs> @bew I know! I am just going for the flavor of stupidity throughout my article :D
<FromGitter>
<rishavs> Want to keep it fun for people new to crystal
<FromGitter>
<girng> These Kimsufi servers look really good then. HDD Space, but you get 2 full dedicated cores, with hyperthreading at only $17/m @ 3.4GHZ!
snsei_ has joined #crystal-lang
lvmbdv has quit [Quit: Leaving.]
greengriminal has joined #crystal-lang
<FromGitter>
<adamgotterer_twitter> Would there be any reason that calling close on a socket passed to HTTP::WebSocketHandler from an HTTP::Server would cause all the open sockets to be closed?
maxpowa has quit [Ping timeout: 256 seconds]
hightower2 has joined #crystal-lang
<crystal-gh>
[crystal] jcs opened pull request #6289: Spec: silence errors from system_spec on BSD platforms (master...master) https://git.io/f4bDf
greengriminal has quit [Quit: This computer has gone to sleep]
wontruefree has quit [Quit: bye]
wontruefree has joined #crystal-lang
duane has quit [Ping timeout: 265 seconds]
greengriminal has joined #crystal-lang
alex``` has quit [Quit: WeeChat 2.1]
snsei_ has quit [Remote host closed the connection]
<FromGitter>
<straight-shoota> @adamgotterer_twitter No. The web socket handler is passed the current client socket, which will be closed when the handler finishes. But it shouldn't affect other client sockets or the server socket.