jhass changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.9.1 | Fund Crystals development: http://is.gd/X7PRtI | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/manastech/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Logs: http://irclog.whitequark.org/crystal-lang
aladage__ has quit [Remote host closed the connection]
fowlduck has quit [Remote host closed the connection]
tomchapin has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
fowlduck has joined #crystal-lang
mroth has quit [Write error: Connection reset by peer]
guilleiguaran__ has quit [Remote host closed the connection]
danzilio has quit [Write error: Connection reset by peer]
aemadrid has quit [Remote host closed the connection]
mroth has joined #crystal-lang
aemadrid has joined #crystal-lang
guilleiguaran__ has joined #crystal-lang
danzilio has joined #crystal-lang
dylanmei has quit [Ping timeout: 250 seconds]
ozra has quit [Ping timeout: 252 seconds]
shama has quit [Quit: (╯°□°)╯︵ɐɯɐɥs]
<crystal-gh> [crystal] jhass closed pull request #1932: fix spelling in OSX installation guide (gh-pages...fix-documentation-issues) http://git.io/vR1DG
fowlduck has quit [Remote host closed the connection]
fowlduck has joined #crystal-lang
fowlduck has quit [Ping timeout: 256 seconds]
<crystal-gh> [crystal] ysbaddaden closed pull request #1933: Fixed a typo in src/socket/tcp_socket.cr (master...typo-fixed) http://git.io/vRMey
fowlduck has joined #crystal-lang
<travis-ci> manastech/crystal#5c72e20 (master - Merge pull request #1933 from ilatif/typo-fixed): The build passed. https://travis-ci.org/manastech/crystal/builds/95518369
<DeBot> https://github.com/manastech/crystal/pull/1933 (Fixed a typo in src/socket/tcp_socket.cr)
fowlduck has quit [Ping timeout: 250 seconds]
SolarSailor has joined #crystal-lang
sane_k_ has joined #crystal-lang
SolarSailor has quit [Quit: Textual IRC Client: www.textualapp.com]
Ven has joined #crystal-lang
fowlduck has joined #crystal-lang
fowlduck has quit [Ping timeout: 250 seconds]
aladagemre has joined #crystal-lang
aladagemre has quit [Remote host closed the connection]
aladagemre has joined #crystal-lang
havenn has joined #crystal-lang
havenn has joined #crystal-lang
havenn is now known as havenwood
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
vegai has joined #crystal-lang
daveshah has joined #crystal-lang
fowlduck has joined #crystal-lang
fowlduck has quit [Ping timeout: 256 seconds]
sardaukar has joined #crystal-lang
ponga has joined #crystal-lang
daveshah has quit [Remote host closed the connection]
trapped has joined #crystal-lang
aladagemre has quit [Remote host closed the connection]
aladagemre has joined #crystal-lang
<crystal-gh> [crystal] askn opened pull request #1934: add css class for markdown code blocks (master...markdown) http://git.io/vRDrq
ozra_ has joined #crystal-lang
ozra_ has quit [Client Quit]
ozra_ has joined #crystal-lang
ozra_ is now known as ozra
Ven has joined #crystal-lang
<crystal-gh> [crystal] jhass pushed 2 new commits to master: http://git.io/vRD1Z
<crystal-gh> crystal/master 3dddb62 Aşkın Gedik: add css class for markdown code blocks
<crystal-gh> crystal/master 505e2e9 Jonne Haß: Merge pull request #1934 from askn/markdown...
trapped has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
aladagemre has quit [Remote host closed the connection]
trapped has joined #crystal-lang
daveshah has joined #crystal-lang
dylanmei has joined #crystal-lang
trapped has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
trapped has joined #crystal-lang
trapped has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
trapped has joined #crystal-lang
knoopx has joined #crystal-lang
knoopx has quit [Remote host closed the connection]
FLOOR_9_ has joined #crystal-lang
<FLOOR_9_> hey guys
<FLOOR_9_> i was here last time , and talking about kemal the web framework
<FLOOR_9_> i am trying the make a simple tcp server with crystal, first i did it in ruby, en benchmarked the latency for a simple ping/pong
<FLOOR_9_> the latency for a simple tcp req/res is about 0.000552s in ruby
<FLOOR_9_> and the same code in crystal is about 0.0012550s
<jhass> FLOOR_9_: release mode?
<FLOOR_9_> yes
<jhass> well, libevent adds some overhead I guess
<jhass> you can try to run a profiler
<FLOOR_9_> is ruby using a different library than crystal for tcp?
<jhass> ruby is using POSIX calls directly
<FLOOR_9_> ah
<jhass> did you run a single benchmark or benchmark/ips?
Virviil has joined #crystal-lang
<FLOOR_9_> first 1 per second , after 10000
<FLOOR_9_> than it's close to ruby, but i want it faster in crystal :D
<jhass> well this stuff is implemented in C in Ruby too
<FLOOR_9_> hm
<jhass> there's only so much speed your network stack can give you
<Virviil> hello, does crystal supports ffi?
<jhass> FLOOR_9_: return a a string concatenation or something :P
<FLOOR_9_> yeah i did, same performance
<jhass> Virviil: we don't really need to, but you should be able to write an ffi binding trivially
<jhass> FLOOR_9_: parse some JSON then :P
<Virviil> jhass:
<FLOOR_9_> what i don't get, is that kemal, the crystal web framework
<FLOOR_9_> has a lower response time compaired to mine
<Virviil> jhass: I read about http://crystal-lang.org/docs/syntax_and_semantics/c_bindings/lib.html, but still dont understand hw to bind to win api dlls for example. Mb some tutorials?
<jhass> Virviil: uh, we don't have windows support yet
<FLOOR_9_> it's 0.000170s in kemal compaired to mine 0.000543s
<jhass> like crystal won't run on windows at the moment, at all
<jhass> FLOOR_9_: it's network stuff, that's well within the stdev I bet
<FLOOR_9_> he used some network tweaking?
<jhass> doubt it
<Virviil> jhass: well.. What about extend FFI::Library ffi_lib FFI::Library::LIBC analog from ruby?
<jhass> FLOOR_9_: getting more consistent timings out of kernel network APIs is a shitload of effort, cloudflares did a couple of blogs around it
<jhass> Virviil: yes, don't really need that for crystal
<FLOOR_9_> yeah i read about 1M concurrent connections, and utilizing kernel parameters for lower latency,
<FLOOR_9_> i'm not doing that , first i want the lowest latency on app level :) network comes after
<jhass> FLOOR_9_: share your code though, maybe there's something obvious
<FLOOR_9_> i will one moment
<Virviil> jhass: So how to attach to libc in crystal?
<jhass> Virviil: you already linked the docs to it
<Virviil> jhass: So, if i want to call ioctl, for example, i should...?
<FLOOR_9_> Server: http://pastebin.com/GiH1Dim1
<FLOOR_9_> client : http://pastebin.com/aPKfnVHX
<jhass> Virviil: lib LibC; fun ioctl(...); LibC.ioctl(...)
<jhass> FLOOR_9_: see if spawning a new coroutine for each accepted socket helps any
<jhass> FLOOR_9_: also make sure to close the client socket
<Virviil> jhass: Nice! And to wrap it somewhere i can just call LibC.ioctl, and put outed value to return from some method?
<jhass> Virviil: probably, I didn't look at the parameters for ioctl
<jhass> Virviil: note that all of our IO goes through libevent by default, so messing with the FDs directly might not be too wise depending on what you're doing
<Virviil> jhass: Well... I wanted to make fast wraping for serialport from https://github.com/hybridgroup/rubyserial
<Virviil> jhass: let it be the first version, async woul be in deep plans. Need serialport library very fast
trapped has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
trapped has joined #crystal-lang
<FLOOR_9_> how can i do a simple spawn in crystal for each socket?
<FLOOR_9_> do i need to add a lot of code?, sorry i am not to familiar with spawn
<Virviil> how to define array in c binding struct?
<Virviil> uint8 String[SIZE_OF_ARRAY]; from C struct?
<jhass> string : UInt8[SIZE_OF_ARRAY±
<jhass> er, ] not (idk how I even did that)
<BlaXpirit> xD
<FLOOR_9_> heh heh
<FLOOR_9_> is it true that libev is 2x faster than libevent?
<BlaXpirit> 2x faster to type
<BlaXpirit> the name
<FLOOR_9_> heh heh
<FLOOR_9_> i am not good at c, that's why i use crystal :)
<FLOOR_9_> like when jhass just showed me the server.cr, i can just read it without much trouble, but reading the http-parser.c , what a headache
<FLOOR_9_> hahahah
<FLOOR_9_> but that's just me, i hated programming years ago, but thanks to ruby i like it
<FLOOR_9_> proble is when dealing with a realtime app, ruby doesn't cut it with cpu cycles
<FLOOR_9_> that's why i think crystal is a blessing :)
Virviil has quit [Read error: No route to host]
<FLOOR_9_> jhass are you familiar with file descriptors in unix?
<jhass> uh, just the very basics
<FLOOR_9_> i was reading , linus torvalds's definition about it
<FLOOR_9_> that in unix not just everything is a file, but a stream of bytes
<FLOOR_9_> i was talking about kemal with sdogruyol (creator of kemal) yesterdya
<FLOOR_9_> and i asked it , why is it that your request's per second are so close to the max file descriptors on a unix system
<FLOOR_9_> *him
<FLOOR_9_> what do you think?
<CompanionCube> although with the coming of more mandatory type annotations, Crystal's similarity to ruby will take a decline
<FLOOR_9_> essentially a socket is a file descriptor right?
<FLOOR_9_> "A socket connection is also a kernel handle." "kernel handles are traditionally called file descriptors in Unix-like systems."
<FLOOR_9_> i knew it!!
<FLOOR_9_> so for each socket the tcp server is opening, it's creating a kernel handle, or file descriptor
<FLOOR_9_> max open file descriptors = 65536
<FLOOR_9_> i think that's why the kemal benchmark shows that number
<FLOOR_9_> anybody got a reaction? :)
trapped has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<jhass> FLOOR_9_: mmh, sounds worth investigating
<FLOOR_9_> yeah
<jhass> that would mean we leak FDs though, no?
<FLOOR_9_> possibly
trapped has joined #crystal-lang
<FLOOR_9_> and that's why my zeromq in node is maxed at that number also i think
<FLOOR_9_> because ipc is also using sockets
Ven has quit [Quit: Textual IRC Client: www.textualapp.com]
dylanmei has quit [Quit: ZZZzzz…]
sane_k_ has quit [Quit: No Ping reply in 180 seconds.]
fowlduck has joined #crystal-lang
Ven has joined #crystal-lang
<FLOOR_9_> jhass, do you know sdogruyol?
trapped has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
trapped has joined #crystal-lang
fowlduck has quit [Ping timeout: 250 seconds]
<jhass> I've seen them around here
daveshah has quit [Remote host closed the connection]
sdogruyol has joined #crystal-lang
sane_k_ has joined #crystal-lang
<FLOOR_9_> hey sdogruyol
<FLOOR_9_> we
daveshah has joined #crystal-lang
<FLOOR_9_> i was just about to ask jhass, when you might be around
<FLOOR_9_> :D
daveshah has quit [Read error: No route to host]
daveshah has joined #crystal-lang
sdogruyol has quit [Ping timeout: 240 seconds]
dylanmei has joined #crystal-lang
trapped has quit [Read error: Connection reset by peer]
dylanmei has quit [Excess Flood]
trapped has joined #crystal-lang
FLOOR_9_ has quit [Ping timeout: 256 seconds]
FLOOR_9_ has joined #crystal-lang
Ven has quit [Ping timeout: 256 seconds]
Bofu2U has quit [Max SendQ exceeded]
Bofu2U has joined #crystal-lang
fowlduck has joined #crystal-lang
fowlduck has quit [Ping timeout: 272 seconds]
daveshah has quit [Remote host closed the connection]
FLOOR_9_ has quit []
daveshah has joined #crystal-lang
Virviil has joined #crystal-lang
Virviil has quit [Remote host closed the connection]
sdogruyol has joined #crystal-lang
daveshah has quit [Remote host closed the connection]
Sadin has joined #crystal-lang
trapped has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
trapped has joined #crystal-lang
ponga has quit [Quit: Connection closed for inactivity]
daveshah has joined #crystal-lang
slash_nick is now known as slash_away
sdogruyol has quit [Read error: Connection reset by peer]
sdogruyol has joined #crystal-lang
sdogruyol has quit [Read error: Connection reset by peer]
Virviil has joined #crystal-lang
<Virviil> Why in LibC::FCNTL enum has only 4 elements?
<Virviil> crystal/src/io.cr
<Virviil> In docs a bit bigger list
<jhass> I guess because only what's needed was mapped out
<Virviil> So, if i need more, i can just add it? lib LibC enum FCNTL FOO = BAR ?
<Virviil> In anyn file&
<Virviil> ?
<jhass> not sure for enums but I would expect so
<Virviil> elsif darwin in ifdef means code for osx?
<jhass> yes
fowlduck has joined #crystal-lang
<Virviil> uchar is uint8 both in linux and ios?
<Virviil> not defined in libc.cr
<Virviil> Why not UChar and Char?
trapped has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
trapped has joined #crystal-lang
<jhass> Virviil: because none of the APIs bound used an uchar yet
<jhass> well actually uchar == char and there's schar?
<jhass> idk C
<Virviil> jhass: It's just come from background - 'u' means 'unsigned'. 's' prefix is absolutely no obvious
<Virviil> as for me
<Virviil> I'll make an issue, mb we could discuss a bit at the github
fowlduck has quit [Remote host closed the connection]
waterlink has joined #crystal-lang
sane_k_ has quit [Ping timeout: 272 seconds]
<waterlink> Hi all. Toying around with alternative anonymous function syntax, typeof and concurrency: https://github.com/waterlink/streams - probably that is how Crystal is not intented to be used :D
<waterlink> I have discovered very interesting thing about anonymous functions (blocks and lambdas): that in cases when compiler can not figure out types of block/lambda, it asks developer to fully annotate it. Turns out that with a bit of generics and typeof, you can annotate only arguments and you do not need to annotate the result (that is where typeof + allocate comes into the play)
shama has joined #crystal-lang
tomchapin has joined #crystal-lang
<Virviil> how to get errno from calling C functions?
<jhass> Virviil: raise Errno.new("ioctl")
<Virviil> jhass: For example I call fd = LibC.open
<jhass> raise Errno.new("open") if fd < 0
<Virviil> jhass: And in this exception would be the error reason?
<jhass> yes
<crystal-gh> [crystal] radarek opened pull request #1938: Array#sort_by & Array#sort_by! calls given block only once for each element (master...sort_by_calls_block_once_for_each_element) http://git.io/vRHIc
fowlduck has joined #crystal-lang
tomchapin has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
fowlduck has quit [Ping timeout: 240 seconds]
FLOOR_9_ has joined #crystal-lang
FLOOR_9_ has quit [Client Quit]
<Virviil> is it good idea to make nonblicking serialport, or no?
<Virviil> As i understand, when nonblocking you can loose part of the message, get zeroes instead of missing bytes?
<jhass> ideally you would hook it up with libevent so that if the call would block the current coroutine is suspended and then resumed when data is ready
<jhass> no
<Virviil> jhass: "no" for what?
<jhass> the data loss
<jhass> can't you subclass FileDescriptorIO or something?
<jhass> subclass or wrap
<jhass> I just realize how little I know about how serialports are exposed on linux
<Virviil> jhass: I thought about include IO
<Virviil> jhass: As i understand, for example, I get 4 data bytes in serail in 4 seconds - 1 byte in second. [1,2,3,4]. If the mode is blocking, the call of serialport.read(4) would block the thread for 4 seconds and then return [1,2,3,4]. But in nonblocking mode, the thread would not be blocked, and because i didnt get more then 1 byte in the port, it would return [1,0,0,0]
<Virviil> So this is wht i mean in data loss
<jhass> if the nonblocking interface would be directly exposed to the user, you wouldn't return [1, 0, 0, 0] but [1] or [1, 0, 0, 0] and "sucessfully read 1 byte of the 4 you requested"
<jhass> but since we can suspend the current coroutine when the user requests 4 bytes but we only got 1 from our nonblocking call, it can look to the user like a blocking call while we can run other coroutines while we wait for the data
<Virviil> jhass: So, because of using libevent, you suggest to make serialport block?
<Virviil> blocking*
<jhass> nonblocking on the kernel API level but seemingly blocking to the user
<jhass> FileDescriptorIO already does that for files, sockets etc, File subclasses it, Socket subclasses it
<Virviil> jhass: Well, i'l try to read read this
<jhass> Virviil: fyi Go does basically the same
aladagemre has joined #crystal-lang
fowlduck has joined #crystal-lang
<Virviil> How to define private method? "priate" like in ruby doesnt work?
<Virviil> put private before every def?
fowlduck has quit [Ping timeout: 250 seconds]
<Papierkorb> Virviil: 'private' acts like a marker, every method after it will be private
<Papierkorb> Virviil: Aaah wrong channel, thought this was #ruby
fowlduck has joined #crystal-lang
<Virviil> Seems to me that i've finished
<Virviil> Need some resources to test, no ideas how to do this - no serilport in my hands now(
<jhass> uh, I'd hand you one of my $9 arduino boards, but ...
<Virviil> jhass: i'l get seril in 5 hours, but still have no idea, how to work with FileDescriptor
<Virviil> mb some examples, to implement into tests?
<jhass> reading its code, tests and existing usages is your best bet, yeah
<crystal-gh> [crystal] asterite opened pull request #1939: Make `String#split` keep all results. Fixes #1070 (master...string_split_keep_all_results) http://git.io/vRHPm
ozra has quit [Ping timeout: 240 seconds]
ozra has joined #crystal-lang
fowlduck has quit [Remote host closed the connection]
fowlduck has joined #crystal-lang