<strcmp1>
i have a recurring and persistent problem related to bundling + openssl, just curious if you have seen anything like SSL_connect SYSCALL returned=5 errno=0 state=SSLv2/v3 read server hello A before?
<strcmp1>
there's a long pause, and that eventually happens. cannot figure out why, and debugging for a long time :(
<strcmp1>
i also thought sslv3 was deprecated.
asterite has joined #crystal-lang
<asterite>
vikaton: you there?
<vikaton>
yes asterite
<asterite>
thanks for posting things in reddit, and also notifying projects to update to newer crystal versions
<vikaton>
No problem :P
<asterite>
I'm not sure this is good, thought (honestly, I'm not sure), maybe some might think we are trying to push crystal everywhere, but that's not true
<asterite>
I think I agree with the first comment, there's nothing new in 0.7.2, mostly bug fixes
<asterite>
(but I just see the other reply, so that's why I'm not sure)
<jhass>
strcmp1: openssl often refers to "any supported SSL/TLS version" as SSLv23
<vikaton>
asterite: I didnt know Crystal was updated until I accidently saw your tweet
<vikaton>
so its good as a heads up
<strcmp1>
jhass, ah okay, i thought somehow forcing tlsv1_2 would fix it, and maybe rubygems.org basically didn't support it.
<asterite>
Yeah, I didn't even post it in the google groups... maybe I should
<strcmp1>
how can i debug such things? :)
<jhass>
it's just bundler? gem install works?
<jhass>
(we probably should take that to #ruby btw)
<strcmp1>
alright
<kulelu88>
does Crystal support HTTPS (if that makes sense) ?
asterite has quit [Ping timeout: 246 seconds]
<vikaton>
kulelu88: you mean SSL? yes
<kulelu88>
what big sites/apps have been built in crystal so far?
<jhass>
what's big?
<kulelu88>
+1 million site visits?
<jhass>
none
<jhass>
it's a young language, the base ecosystem is still developing
<kulelu88>
can it handle that capacity? Lets say maybe 5,000 concurrent users
<vikaton>
kulelu88: my website was written in crystal
<vikaton>
until it broke from an update
<vikaton>
and I have yet to fix it
<vikaton>
vikaton: Yes ofc it can
<jhass>
sure, pretty much anything can if you scale it right
<vikaton>
kulelu88: Crystal is literally being added to techempoer benchmarks as we speak
<vikaton>
techempower*
<kulelu88>
but I'm talking about it from a cheapo perspective. I know that some big websites use very little server infrastructure because (partly) their language of choice was performant
<vikaton>
Crystal is performant
<vikaton>
I benchmarked myself
<kulelu88>
I don't understand just 1 thing. If you don't need to tell Crystal what types the variables has, how does it compile?
<vikaton>
kulelu88: Type inference
<kulelu88>
at compile time?
<vikaton>
Yes
<kulelu88>
does this slow down the compile time?
<vikaton>
Not sure, since the compile time is pretty fast as is
<jhass>
the compiler is quite optimized already, so yeah, quite fast
<kulelu88>
I guess we will know its true performance when someone tries to compile code with big LoC
<jhass>
most time (in release mode) is spent in the llvm optimizer, by factor 50 or so, not in type interference
<jhass>
like the compiler? ;)
<kulelu88>
how long does the compiler take to compile itself?
<kulelu88>
Also, if I am not doing type-checking in my Crystal code, is it very similar to programming in a dynamic language?
<jhass>
it feels quite a bit like it, yeah
<jhass>
you can go a long way with no constraints and duck typing
<jhass>
Parse: 00:00:00.5395810
<kulelu88>
My mind is still boggled as to why some modern static languages don't do type inference
<jhass>
Type inference: 00:00:10.4589840
<jhass>
Codegen (crystal): 00:00:03.8070470
<jhass>
Codegen (bc+obj): 00:03:09.6533090
<jhass>
Codegen (clang): 00:00:04.1050050
<jhass>
compiling the compiler in release mode on my machine
<thelinuxlich>
is it possible to call crystal code using ffi on another language?
<unshadow>
thelinuxlich: I was asking around the same question before, you have a few options, I guees you want to create some lib in Crystal and then call it from Ruby right ?
<thelinuxlich>
unshadow: actually I was thinking about calling from Node
<unshadow>
thelinuxlich: Ok, first, you need to use --single-module, fish the .o out of .crystal and link it manually into an .so
<unshadow>
then you can just hook to it
<unshadow>
You'll also need to provide an interface with fun's
<thelinuxlich>
you're speaking chinese to me, I'm still building the Crystal executable :)
<thelinuxlich>
I thought there were docs for this kind of stuff
<unshadow>
Sadly no, this is a newish project, and the aim as of now is more to stablaize the standard libs and root out the bugs, so I belive as more developers will get in with the projcet more people will give time to document and maybe automate those sort of things
<unshadow>
But really, creating the so isn't that hard, I did it a few times to play around
<thelinuxlich>
ok
Ven has joined #crystal-lang
thelinuxlich has quit [Quit: Page closed]
<unshadow>
jhass: here ?
willl has quit [Quit: Connection closed for inactivity]
<unshadow>
Can @[Link("ssl")] be called to "/path/of/lib" ?
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
leafybasil has quit [Remote host closed the connection]
<strcmp1>
unshadow, did you try @[Link(ldflags: '-L/path/to/lib -lssl -lcrypto')] ?
<strcmp1>
btw using non-standard paths will probably break if distribute the binary around.
<unshadow>
hm... thats ok, the -L option with flags seems to work, I'll just bundle the .so file in the package
leafybasil has joined #crystal-lang
JBat has joined #crystal-lang
DerisiveLogic has quit [Ping timeout: 265 seconds]
<unshadow>
The ruby Version works, but the Crystal version complains about Libinjection::SqliScan:(.text+0x90): undefined reference to `libinjection_sqli_init'
DerisiveLogic has joined #crystal-lang
<strcmp1>
what does ldd the-binary say?
<strcmp1>
i guess relative paths dont work
<strcmp1>
you also dont link it
<strcmp1>
you just add a path
<unshadow>
strcmp1: what do you mean I dont link it ?
<strcmp1>
there is nothing like -linjection
<strcmp1>
-L adds a path to the search path, thats all, you still have to do -linjection
vikaton has joined #crystal-lang
<unshadow>
Oh.... ok I guess this makes sense, Added that and it works
<strcmp1>
you will have to manually copy it to crystal
<unshadow>
ok, thats what I was going to ask
<jhass>
unshadow: do you need to allocate the struct yourself or access its fields?
<unshadow>
jhass: passing over a pointer will work too, the thing is I want to know what size of a pointer to pass, If I can create the struct and pass a pointer of it into the program I wont need to calculate for size
<jhass>
or do you have functions you can call, state* foo_new(), foo_get_string(*state) etc
<jhass>
?
c355E3B has joined #crystal-lang
<unshadow>
jhass: looking at the c code example here --> https://github.com/client9/libinjection , I can see he dies this "sfilter state;" where looking at the header file sfilter is a struct, then, he passes that struct to the function like this libinjection_sqli_init(&state, input, slen, FLAG_NONE);
<unshadow>
wow.. my typos are terrible sorry
<jhass>
so caller side allocation indeed :/
<jhass>
you might still get off with just doing sizeof(sfilter) in a small C program struct SFilter; _data : UInt8[that_value]; end
<unshadow>
but, This also works if I just pass over a Pointer, so, should I just stay with passing 1024 malloc pointer ?
<unshadow>
Oh.. ok
Ven has joined #crystal-lang
<jhass>
well, it's essentially the same, defining a struct like that gives a bit better type safety
<jhass>
so you don't start to pass a String pointer where it expects a SFilter pointer etc
<unshadow>
I just call a Void pointer
<jhass>
yeah, that's not so good for type safety, at least create an alias :)
<unshadow>
alias Sfilter = Void* :)
<jhass>
but then the size for the struct changes and you have to update all locations...
<unshadow>
:(
<jhass>
miss one and have subtle bugs
<unshadow>
I guess I have to just create this manually
<jhass>
I'd prefer the struct SFilter; _data : UInt8[size]; end; variant if you have to allocate yourself
<unshadow>
Can I just do that in an emedded C kind of way ?
<jhass>
let's you also do things like SFilter.new and foo :: SFilter
<jhass>
mmh, a run macro that prints it could be fun :D
<jhass>
but probably not worth it
<unshadow>
writing in c.... I guess my day is over now hahah
Ven has quit [Read error: Connection reset by peer]
<unshadow>
jhass: I think my lack of C expireace is making this a little hard, Let me summerize so I can see I got you. You want me to create a little C program, which will take the struct as it comes in, evaluate the size , and the I can pass it to the Pointer ? or, You do you mean I should create the Struct in Crystal ? what is this code " struct SFilter; _data :: UInt8[value]; end;" where should that go ?
<jhass>
the latter, it should go into your lib declaration in crystal
<jhass>
value replaced by the actual size you determined with the help of the little C program that just prints the size of the real struct
<unshadow>
jhass: Ok, I get it now, thanks
<jhass>
and then you replace sfilter foo in the C examples with foo :: LibInjection::SFilter
<jhass>
sfilter* in the C function signatures becomes SFilter* etc
<unshadow>
Should I use SFilter* and then pass pointerof( LibInjection::SFilter) ?
<jhass>
yeah
<unshadow>
I mean "ptr = Lib_injection::SFilter" then pass pointerof(ptr)
<unshadow>
what does [value] means ? in the struct ?
<unshadow>
can't see it in the docs
<jhass>
like Foo* is short for Pointer(Foo), Foo[n] is short for StaticArray(Foo, n) (iirc)
<jhass>
UInt8 is just a type that's 1 byte long
<jhass>
so we just use it to get a continues block of memory of that size
<jhass>
*continuous
<unshadow>
Syntax error in ./lib/libinjection.cr:5: expecting token 'CONST', not 'value'
<unshadow>
_data : UInt8[value]
<unshadow>
^
<jhass>
:: UInt8[123]
<jhass>
or maybe it was :? I can never remember somehow
<jhass>
though I think I said replace value with the actual thing like 5 times now
<unshadow>
...
<unshadow>
what's the actual this ? you mean the data from user right ?
<unshadow>
this* thing
<jhass>
no
<jhass>
the value the C program doing sizeof(sfilter) outputs
<unshadow>
I really feel stupid right now
<unshadow>
hhhhhhhhhhhhhhhhhh
<unshadow>
haaaaaa
<unshadow>
ok
<unshadow>
now everything falls into place
<unshadow>
Working
<unshadow>
Thanks for the explanations
<vikaton>
what is fork()
<jhass>
fork creates a copy of the current process
<jhass>
returns 0 in the copied process and the pid of the created process in the original
<jhass>
see man fork
<jhass>
(man 2 fork)
<unshadow>
you can also use it in a block , like fork do; ... ; end
<jhass>
yes, the block will be run in the copied (also called child) process only
<vikaton>
what about Signal.trap() ?
<unshadow>
I believe this is to catch signlas, like SIGHUP or SIGKILL and when one is traped, do something
<unshadow>
like catch ^c, and write "Ctrl C presses , program closing" etc..
<jhass>
SIGKILL is about the only one you can't trap ;)
<jhass>
but yeah, Ctrl+C causes your process to get a SIGINT send, normal kill sends a SIGTERM
<jhass>
SIGHUP is often used as "reload yourself"
<unshadow>
I wasn't sure about SIGKILL ;) , I used it to handle Ctrl Z and Ctrl C , also Ctrl \
<jhass>
Ctrl+\ is SIGQUIT iirc
<unshadow>
vikaton: I think you can use both Signal.trap("INT") and Signal.trap("SIGINT"), at lest thats how it is in Ruby
bcardiff has quit [Quit: Leaving.]
DerisiveLogic has quit [Read error: Connection reset by peer]
<unshadow>
Becuase Crystal uses '' for chars and "" for strings, and usually a string with "" will be parsed in another way to find if there are veriables inside it like #{}, dosen't that mean a loss of optimization ?
<unshadow>
(This is what I know from Ruby, maybe it doesn't metter for Crystal)
DerisiveLogic has joined #crystal-lang
<strcmp1>
even in ruby, "" and '' is the probably the most premature and useless optimization of all time
<strcmp1>
you will surely find better places to optimize :)
<unshadow>
strcmp1: really ? rubocop is kind of pressitance on that XD
<strcmp1>
yeah, at least when i last looked at the benchmarks it wasn't anything that seemed significant
<jhass>
rubocop is stupid about many things
<jhass>
both crystal & ruby do #{} at parse time
<jhass>
in ruby parse time is just harder to differentiate from runtime
<jhass>
looks interesting yeah. Does it have a CSS and XPath query API?
<zamith>
I would like it to
<zamith>
that was the idea
<zamith>
at least CSS
<zamith>
a nokogiri like tool, but faster
JBat has joined #crystal-lang
jua_ has joined #crystal-lang
willl has joined #crystal-lang
<unshadow>
Can it also generate XML's ?
<unshadow>
jhass: How would a type restrication will look ? contains_sqli?(data : String) , is that ok ?
<jhass>
yep
<unshadow>
also most of the times the data could come in runtime, so lets say a users send some request , there is an issue and the request is empty, or, some issue in the code above, and then it will be nil
<unshadow>
data = Socket.read_nonblock or something
<jhass>
yeah, and the type restriction will force them to handle that case at compile time
<unshadow>
I see, liek it wont allow for something to be nil for example... I get it
JBat has quit [Read error: Connection reset by peer]
bcardiff1 has joined #crystal-lang
bcardiff has quit [Ping timeout: 265 seconds]
<vikaton>
Crystal is now officially in techempower
<jhass>
Codcore: sorry, you won't be able to write send with a macro, at least not for dynamic values. Think about it, macros are executed at compile time, they have no clue about what concrete value will be in your variable
<wanderer_>
yesterday I pulled like 140 new commits and atm I'm integrating them into my current branch
<wanderer_>
and print somehow stopped working, although puts works normally
<wanderer_>
don't both simply call IO#<<?
<jhass>
I doubt anybody will have a clue with that amount of information/access :/
<jhass>
mmh, yeah
<wanderer_>
I'm using the code from master's HEAD
<jhass>
when you say puts, you're talking about puts foo vs print foo, right?
<jhass>
argless puts doesn't go through IO#<<
<wanderer_>
yes, the global functions that call STDOUT.print and STDOUT.puts
<wanderer_>
puts "hello" vs print "hello"
<Codcore>
ijhass I have concrete value(method name) at it sets at compile time and not changes
<jhass>
Codcore: not even foo = "Bar"; some_macro(foo) is the same as some_macro("Bar")
<jhass>
the compiler doesn't resolve the local variable at compile time
<wanderer_>
fkn exceptions.. after pulling those 140 commits, I can't compile the compiler anymore because of "unexpected token: <" and because I'm unable to implement exceptions there's no unwinding thus no further information
<jhass>
you need to update more often :P
<jhass>
less big bangs
<jhass>
fully porting to windows will be a long term effort, you need to continuously reintregrate if you want to make it
<jhass>
like at very least weekly
<jhass>
better daily if there was a commit upstream
<wanderer_>
how annoying, now I gotta create a new copy of the old, working version, change it to print the source of the error and compile it
<wanderer_>
to replace it, compile the new version again and see what's happening
<wanderer_>
having exceptions would be easier, but I don't know how LLVM works
<jhass>
I take it you're merge conflict free?
<wanderer_>
yes
<wanderer_>
can't find "<<<" or "==="
<zamith>
I got a Pointer(X), how do I get X?
<jhass>
git bisect might help then to narrow it to the commit that broke it for you
<jhass>
zamith: .value
<zamith>
thanks
<vikaton>
no problem
<wanderer_>
git bisect?
<jhass>
yeah, you mark the working commit, the broken one and then git bisect walks you through a binary search until you identify the fist commit that introduced the issue you're testing for
<jhass>
git bisect start; git bisect good 2861653a4b0ebb9dedae276e9971238d15b08280 (I guess); git bisect bad HEAD; test ? git bisect good : git bisect bad
<wanderer_>
so on every iteration it changes the working copy to a previous commit?
<wanderer_>
do you know how I can output the current location there?
<wanderer_>
I'll try @token.location
strcmp1 has quit [Ping timeout: 255 seconds]
<wanderer_>
k, got the location with a newly compiled old version: unexpected token: \\crystal \\src\\compiler\\crystal\\tools\\init\\template\\example_spec.cr.ecr:5:1 <
<wanderer_>
describe <%= module_name %> do
<wanderer_>
I guess it's a new feature not supported yet on my older branch?
<wanderer_>
nope, it's not, lol
DerisiveLogic has quit [Ping timeout: 240 seconds]
strcmp has joined #crystal-lang
strcmp is now known as strcmp1
strcmp1 has quit [Client Quit]
Codcore_ has joined #crystal-lang
strcmp1 has joined #crystal-lang
<Codcore_>
why don't we use gutter instead of irc?
<Codcore_>
g*gitter
<strcmp1>
Codcore, gitter is for the hipsters
<strcmp1>
we're keeping the scene alive, here, on IRC
<havenwood>
irc \o/
<wanderer_>
do I have to commit my current changes to use git bisect?
<vikaton>
gitter is ually dead
<jhass>
wanderer_: yes
<wanderer_>
"Bisecting: 76 revisions left to test after this (roughly 6 steps)" k, let's see :)
<wanderer_>
hm, it deleted my crystal.bat
<wanderer_>
somehow I'm now entirely on the master-branch or something like that
<wanderer_>
it doesn't recognize my stuff added for windows at all
<wanderer_>
I'm too tired for this shit..
<wanderer_>
wtf, like I said, I must have switched to master-branch or something, now I switched back to abort bisecting and tried to compile to see the error again and now it works...
<strcmp1>
you arent as tired as me trust me, i think i might just become unconscious soon
<wanderer_>
I remember when I stayed up whole nights and tried to learn but ended up playing cs:s back in school, sleep deprivation is a horrible thing
<strcmp1>
it really is
<strcmp1>
my problem is that i cannot sleep for longer than 4 hours without waking up, and i donno why. i might try something to put me into a deeper sleep.
<wanderer_>
you could try breathing exercises, take some valerian or go see a doctor
<wanderer_>
actually, I had such an issue myself two years and also one year ago, two years ago I fell in love and sometimes woke up five times a night, no shit, for multiple months, then it disappeared
<wanderer_>
one year ago I had it again but only for some weeks
<wanderer_>
why is this working, though? when is flush executed?
<jhass>
well, at very last with .close I guess
<jhass>
that is on program exit
<wanderer_>
does it get registered with at_exit?
havenwood has joined #crystal-lang
<jhass>
I don't think so, I wouldn't be surprised if the kernel triggers it
<wanderer_>
but BufferedIO is using a buffer-variable that needs to get written before the program closes
<wanderer_>
elsewise there is nothing to flush
<jhass>
it is always written?
<jhass>
oh, wait, it isn't
<jhass>
I'm tired too :P
<wanderer_>
AutoFlushBufferedIO only flushes if there's an \n, elsewise it calls BufferedIO#write which then flushes if the buffer is full, if not, it's used until it's full, until that nothing is written to the fd
<wanderer_>
so if you use `print "hello"` and exit after that, some line must call BufferedIO#flush
<wanderer_>
also, I'd expect STDOUT and STDERR to always flush if they're ttys, I really wonder why it got implemented like this
<jhass>
because it's a lot faster
<jhass>
syscalls are expensive, tty's are really slow
<wanderer_>
I've never experienced that stdout was not flushed after writing to it (when it's a console)
<jhass>
Ruby does the same actually I think, unless you set IO#sync to true