Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 13:47
    straight-shoota closed #12051
  • 13:47
    straight-shoota closed #12050
  • 12:17
    beta-ziliani edited #7318
  • May 15 08:43
    r00ster91 closed #7318
  • May 15 08:17
    r00ster91 closed #7690
  • May 14 17:01
    Blacksmoke16 labeled #11995
  • May 14 13:03
    webhive closed #12055
  • May 14 10:19
    straight-shoota milestoned #12051
  • May 14 10:00
    I3oris edited #12051
  • May 14 08:45
    oprypin review_requested #11977
  • May 13 23:29
    Blacksmoke16 unlabeled #12061
  • May 13 22:56
    Blacksmoke16 edited #12061
  • May 13 22:56
    Blacksmoke16 edited #12061
  • May 13 22:54
    Blacksmoke16 labeled #12061
  • May 13 22:54
    Blacksmoke16 labeled #12061
  • May 13 22:54
    Blacksmoke16 labeled #12061
  • May 13 22:54
    Blacksmoke16 opened #12061
  • May 13 20:14
    straight-shoota labeled #12060
  • May 13 20:14
    straight-shoota labeled #12060
  • May 13 20:14
    straight-shoota opened #12060
Claudio Holanda
@kazzkiq
implementing a Crystal version of http://langserver.org/ would do wonders for support in IDEs and famous Text Editors.
Kingsley Lewis
@vonKingsley
@georgeu2000 the compiler is looking at the method collatz_chain_for and sees that it can return an Array(Int32), or Nil, try adding chain at the end of the method
Faustino Aguilar
@faustinoaq
Screenshot_20170913_162720.png
@kazzkiq :point_up:
Claudio Holanda
@kazzkiq
Lololol totally missed it
From IRC (bridge bot)
@FromIRC
<Papierkorb> @Rinkana, yea I consider that a bug
Serdar Dogruyol - Sedo セド
@sdogruyol
didn't know about emit_null https://stackoverflow.com/a/46196469/911870
Ghost
@ghost~55586c4815522ed4b3e08557
Papierkorb, @Rinkana self.class.X doesn't work because self.class is a call, and the output is not known by the compiler, so I think this is xhy the compiler cannot make a proc from it
Slava Dzyba
@sdzyba
Hey everyone.
I'm trying to do a usual TCP echo server in Crystal to compare it (on local machine) to the Ruby version.
Everything is ok in terms of scalabilty, but for some reason no matter how many fibers spawned (or without fibers at all, serving only one connection) I get 44ms response time. To compare: echo server in Ruby (with nio4r in use, but still) gives some microseconds instead, but fails at serving a lot of connections.
I've also tried Elixir and again latency was absolutely ok, a few microseconds or so.
So what can be wrong with Crystal in that case, am I missing something? Here's the snippet I'm using:
require "socket"

def process(client)
  client.tcp_nodelay = true
  while msg = client.gets
    client.puts(msg)
  end
end

server = TCPServer.new "localhost", 1234
loop { spawn process(server.accept) }
also it's worth to mention that using tcp_nodelay = true dropped the latency from 88ms to 44ms for me.
so I might be missing some additional configuration required for a fast connectivity
Martin Verzilli
@mverzilli
what uri are you using to instance the client? we used to have some issues with DNS resolution, I'm not sure if we still do, but if you're opening the client with "localhost" try replacing that with 127.0.0.1 and see if that changes those metrics
Slava Dzyba
@sdzyba
the same
George
@georgeu2000
@vonKingsley - OK, thanks. Now I know what compile-time type is (Array(Int32) | Nil) means.
Ghost
@ghost~55586c4815522ed4b3e08557

@slava-dzyba how do you test the speed? I get something more like 30-40 nanoseconds for this echo server code. my little tester:

require "socket"
require "benchmark"

client = TCPSocket.new "localhost", 1234

payload = "Hello world" * 1_000
time = Benchmark.measure do
  client.puts payload
  client.gets
end
puts time

Sample output: 0.000000 0.000000 0.000000 ( 0.000048)

just tried with Benchmark ips, I got 43-44ms like you, maybe I mis-read the Benchmark measure above.. (need to sleep maybe......)
Slava Dzyba
@sdzyba
That's a disappoinment. It really prevents me from playing with Crystal further and I'm not sure what can I do about it.
Martin Verzilli
@mverzilli
I guess the best you can do is to open an issue
George
@georgeu2000
Is it possible to update the call stack? For example, if you have a recursive function, remove all calls to that function from the stack?
Sam Eaton
@samueleaton

Does anyone have experience working with the parser? There aren't any comments or guides and I would like to make an addition.

Basically, I was thinking it would be cool to be able to splat a tuple just like you can in a method definition, but during multiple assignment. Like this:

head, *tail = {"Seattle", "Hong Kong", "London"}
head # => "Seattle"
tail # => {"Hong Kong", "London"}
Sam Eaton
@samueleaton
@slava-dzyba What were you using for benchmarking. I'd like to replicate it.
Faustino Aguilar
@faustinoaq
@samueleaton someting like https://carc.in/#/r/2pym
def splat(head, *tail)
  {head, tail}
end
head, tail = splat(*{"Seattle", "Hong Kong", "London"})
pp head
pp tail

Does anyone have experience working with the parser?

https://github.com/crystal-jp/techbookfest2/tree/master/makenowjust by @MakeNowJust but in Japanesse :sweat_smile:

Sam Eaton
@samueleaton
@faustinoaq yup, just like you showed in the method
def splat(head, *tail)
~~~~~~~~~~~~~~~~^~~~~
Faustino Aguilar
@faustinoaq
:+1:
require "compiler/crystal/syntax"

parser = Crystal::Lexer.new("def f!=")
puts parser.next_token
puts parser.next_token
puts parser.next_token
puts parser.next_token
I'm learning about Crystal compiler itself, I just started with the lexer :sweat_smile:
Jason Waldrip
@jwaldrip
How can I extract block arguments from a crystal macro when using yield?
inside a macro
Bar Hofesh
@bararchy
Does Crystal HTTP Client supports NTLM authentication ?
Ghost
@ghost~55586c4815522ed4b3e08557
@jwaldrip don't use yield if you want to inspect the block, add the argument &block, and use block.args or something like that (look at the docs)
@bararchy never heard / read about it, so I think the response is no (not sure at all)
From IRC (bridge bot)
@FromIRC
<Papierkorb_> Mornin'
Ghost
@ghost~55586c4815522ed4b3e08557
@bararchy just seen you opened an issue, maybe I should read them before the gitter in my wakeup process ˆˆ
Bar Hofesh
@bararchy
@bew lol all good , it was like "do we have ntlm?" ... Searching ... Basic auth.
Nope ... I'll ask in hitter
Hitter
Lol
Hitter
OMG autocorrect
Then was like , I'll just open a feature request
From IRC (bridge bot)
@FromIRC
<Papierkorb_> @bararchy, there's a "windows authentication" ticket in the wanted shards repo
<Papierkorb_> they probably were thinking about ntlm too
Rinkana
@Rinkana
Papierkorb, i've made an issue for that self.class proc thing. Just to make shure that is is atleast working as intended.
Bar Hofesh
@bararchy
Papierkorb_ you mean this: crystal-community/crystal-libraries-needed#64 ? look who opened it ;)
But I really think it's something that should live in STD at least NTLM, as for Kerberos and GSSAPI I can argue that it might better live off in a shard
From IRC (bridge bot)
@FromIRC
<Papierkorb_> If I had the time I'd be inclined to actually look into Kerberos
From IRC (bridge bot)
@FromIRC
<Groogy> Morning!
Ghost
@ghost~55586c4815522ed4b3e08557
'ning!