Ven has quit [Read error: Connection reset by peer]
Ven has joined #crystal-lang
Ven has quit [Remote host closed the connection]
Ven has joined #crystal-lang
sdogruyol has joined #crystal-lang
sdogruyo_ has joined #crystal-lang
sdogruyol has quit [Read error: Connection reset by peer]
kulelu88 has joined #crystal-lang
zamith has joined #crystal-lang
kyrylo has joined #crystal-lang
sdogruyo_ has quit [Quit: Leaving...]
bawNg has joined #crystal-lang
zamith has quit [Quit: Be back later ...]
<bawNg>
Hi everyone. Has anyone created .Net bindings for Crystal yet?
<BlaXpirit>
bawNg, that sure is strange
<BlaXpirit>
what does that even mean?
<bawNg>
I'd like to use Crystal as a scripting language for a .Net framework
<BlaXpirit>
bawNg, it's not even a scripting language -_-
<bawNg>
Neither is C#, but that doesn't stop people from using it as one
<BlaXpirit>
in fact, .NET languages are closer to scripting languages than Crystal
<bawNg>
The only .Net implementation of Ruby is old and abandoned, so if there were bindings for Crystal, that would be great, as I am a huge fan of Ruby syntax
<BlaXpirit>
it's just inapplicable
<BlaXpirit>
another thing you may not have noticed, Crystal does not yet work on Windows
<bawNg>
That is a shame, I planned on eventually using mruby, but that is still many years away from being sufficiently optimized and mature, it's currently far too slow as far as I know
<bawNg>
Our modular .Net game server modding framework currently supports C#, LuaJIT, V8 JS, Python for sandboxed plugins. Although the majority of supported games are Unity based, we also support other .Net engines. We are also working towards supporting Unreal engine with a native bridge
<bawNg>
C# plugins are compiled on the fly, their .Net IL is patched by a lightweight sandbox process before being loaded
zamith has joined #crystal-lang
zamith has quit [Client Quit]
sleeper_ is now known as sleeper
<dzv>
bawNg: unless there's CLR output for LLVM or someone writes a CLR substitute for the current LLVM code it's never going to work. there are other issues such as relying on POSIX functions directly from libc but those are minor compared to the first issue
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<bawNg>
To be honest, Crystal seems better suited as a replacement for .Net, especially for the native support we are currently moving towards. Unfortunately I'll have a very hard time convincing the rest of our team to scrap years of work in favour of creating a new framework in a language that no one is familiar with
<jhass>
tbh it might be a bit early anyway, the language might still break everything with every single release, we still have some road to 1.0
<bawNg>
Looks like there are quite a few different LLVM bindings for .Net
<bawNg>
I know it's still very early, but it feels like Crystal may be usable before mruby
<bawNg>
Keep in mind, we don't have any issues with living on the bleeding edge, you could even say we thrive on it. Our modular modding framework supports a large number of game servers, all support is entirely reverse engineered, including the servers which are heavily obfuscated
<Netfeed>
http://pastebin.com/TGpdYzaY <-- im getting this error when i try to run the specs in the crystal main repo, does that mean that i've missed installing something? doesn't look like a "library not found error"
<BlaXpirit>
Netfeed, it actually kinda is
<BlaXpirit>
looks like old version of libgc or something
<BlaXpirit>
i had this errror just the other day
<BlaXpirit>
what distro, Netfeed?
<Netfeed>
ubuntu 14.04
<bawNg>
Although Unity3d uses a mono fork which is many years outdated and forces the game developers to be limited to .Net 3.5 and C# 3 syntax, our framework allows plugins to be written using bleeding edge C# 6 syntax
<BlaXpirit>
if you installed crystal from official repository, then just go right for the last line
<bawNg>
We have come across many Mono bugs since introducing support for C# 6 syntax, luckily the mono devs are active and fix them pretty quickly
<Netfeed>
BlaXpirit: nice, thanks
<BlaXpirit>
Netfeed, try the last line and then if it there is an error you may have to do the llvm step
<Netfeed>
that did the trick, thanks!
<BlaXpirit>
too bad that google still pretty much ignores my blog
<BlaXpirit>
i mean, it doesn't ignore, but rankings are garbage
willl has quit [Quit: Connection closed for inactivity]
Gues_____ has joined #crystal-lang
Gues_____ is now known as tatey
tatey is now known as tatey__
<tatey__>
Hey. I'm having a play with Cyrstal and I'm writing a spec where I'm comparing the equality of two static arrays. The test is failing, but the printed values are the same. What should I do differently?
<tatey__>
BlaXpirit: Ah, that's it then. If I call `to_a` then they're considered equal.
<jhass>
sounds like a sane workaround for now
Ven has joined #crystal-lang
<jhass>
or you write StaticArray#== monkey patch it into your project and open a PR so you can drop the monkeypatch with the next release :P
<czaks>
nice, well, i'm impressed with the Crystal, after learning about it yesterday
<tatey__>
That'd work.
<czaks>
i thought it's nearly impossible to do optimized ruby
<jhass>
well, it really isn't Ruby anymore ,)
<tatey__>
jhass: I tried to find where `eq` was being defined in the Crystal source code. I'm guessing it's a macro? Does `eq` do a `==` under the hood?
<czaks>
sure it isn't, but it's sort of compatible
<tatey__>
I showed a bunch of Rubyists Crystal today and they were really impressed.
<jhass>
czaks: there's crystal deps which reads a Projectfile to determine what repos to clone from github and then symlinks into the right paths so you can do require "foo" after that
<jhass>
it's pretty much just a runner for plain classes, could pluck your assert macro in easily
<BlaXpirit>
wooow, power_assert actually already works with spec in mind!!
<BlaXpirit>
so awesome
<BlaXpirit>
no idea why i didn't look at it in more detail
<Netfeed>
there's no way to generate the text "GMT" in a timezone string right now? %z gives +0000 now
<BlaXpirit>
Netfeed, well that's the standardized way to do things
<Netfeed>
what do you mean?
<Netfeed>
can't use an iso-date sadly
<tatey__>
Is there a convention for where to put monkey patches in libraries? Like src/extensions/my_patch.cr?
<czaks>
another thing that bothers me in Ruby and Crystal may fix it (or it already did): in Ruby there are just Arrays and Maps in standard library. and as we all know, some algorithms work better on other structures
<czaks>
for instance like Lists
<czaks>
in java there are lots of data structures to use out of the box
<BlaXpirit>
but generally, why not just use some 3rd party library
<jhass>
tatey__: not really yet, I roughly adopted Ruby's, src/my_lib/core_ext/class.cr
<tatey__>
jhass: Cool. Works for me.
<jhass>
czaks: yeah, my opinion is to just use a third party library if you need an optimized DS, that's not too common to do in Ruby land even though I'm sure there are a couple of gems for it, but given Crystal's focus on performance it might develop to a habit here
<jhass>
czaks: I don't like Java's approach of a standard library providing every corner case so much because then you get confused at about what to use as default and also wonder about what to use now where you didn't even identify a bottleneck yet
<Netfeed>
i can write patches to stuff, but time and timezones is stuff i really don't want to be involved with :P
<jhass>
yeah, understandable we also have no tzdata binding whatsoever yet :P
<jhass>
*given we
<Netfeed>
yup
<Netfeed>
and no documentation for the format, i had to read the code for doing what i wanted, i guess that would be more simple to contribute too :)
<jhass>
of course, we take everything we can get :P
Ven has quit [Remote host closed the connection]
Ven has joined #crystal-lang
<crystal-gh>
[crystal] tatey opened pull request #1250: Add StaticArray#== for equality comparisons (master...static-array-equality) http://git.io/vsRHb
<tatey__>
jhass: There's that PR ;-)
<jhass>
<3
ssvb has quit [Ping timeout: 244 seconds]
<bawNg>
I hope someone can find time to continue working on Windows support soon, there is a lot I would like to use Crystal for in the future, but I'm unfortunately forced to target Windows
<crystal-gh>
[crystal] asterite pushed 1 new commit to master: http://git.io/vsRj6
<crystal-gh>
crystal/master bf0f6c9 Ary Borenszweig: Simpler spec implementation: no need to redefine main
<tatey__>
I've got an enum which I'm using to map an integer to a C struct. I could write out a big switch statement manually, but macros feel like they would be a good fit here. Is it possible to do something like https://gist.github.com/tatey/3c95626750b7a02ffd23?
<BlaXpirit>
tatey__, please say what you actually want
<BlaXpirit>
do you want to turn a number into enum item?
<BlaXpirit>
in that case, use Type.new(number)
<BlaXpirit>
no, that's not right
<jhass>
tatey__: there are lib-level enums, maybe you want that?
<BlaXpirit>
but why, jhass? why not just make it a macro?
<jhass>
because there's actually no need to generate half a dozen methods when one works just fine
<tatey__>
^
<jhass>
I didn't test my idea, does it work? :P
<BlaXpirit>
it's just so wrong - this {% if true %}
<BlaXpirit>
i have no idea
<jhass>
BlaXpirit: never look at Tuple then :P
<tatey__>
Thanks jhass. I'll give that a shot.
<tatey__>
Just CMD + K my IRC client instead of my terminal :(
<tatey__>
jhass: Wrapping the whole thing in that macro syntax worked great.
<BlaXpirit>
why is this so?
<BlaXpirit>
and how is someone supposed to know about this hack?
<tatey__>
Looks like @type.values doesn't work though. I though @type would give me `Type`, but it gives me `TypeNode`.
<jhass>
BlaXpirit: because the result of a macro expression must be a valid Crystal expression
ytti has quit [*.net *.split]
ssvb has joined #crystal-lang
<jhass>
if you don't wrap it your macro starts at the {% for, not at the start of the method
<BlaXpirit>
ok, so the "why" part seems to be clear now
<tatey__>
Yeah, it's like the compiler tried the case statement first, then it got the macro half way through. This treats the whole definition as a macro.
<tatey__>
(That made more sense in my head)
<BlaXpirit>
feels like there should be some syntax for this
<BlaXpirit>
to make like a macro but wrapped in a method
<BlaXpirit>
+ I think replacing `def` with `macro` would work, but the difference would be in force inlining
<tatey__>
Can you check if a type is defined? Sort of like Ruby's const_defined?(:FOO) to check if `FOO` is defined?
ytti has joined #crystal-lang
<jhass>
I don't think so
<jhass>
why would be unsure about that?
<jhass>
I think a lot of the defined? usages in Ruby are abuses
<BlaXpirit>
is it possible to try to require a library but in case it can't be imported add some fallback code?
<jhass>
I don't think so
<jhass>
maybe some load path trickery, but meh
<BlaXpirit>
hmm i guess there could even be 2 cases for this
<BlaXpirit>
one is there is no such crystal file or it doesn't compile
<BlaXpirit>
and the other is some lib (.so) is missing
<BlaXpirit>
let's say my code can work better with some .so but it can also work without it
<jhass>
well yeah, those are quite distinct cases
<BlaXpirit>
jhass, distinct in general
<BlaXpirit>
but if you consider that I want to require XML
<BlaXpirit>
and it fails because libxml is missing
<jhass>
currently there's no active presence check for .so's we just try to link against them and let that fail
<BlaXpirit>
then these 2 cases are merged into one
<jhass>
the require wouldn't break
<jhass>
the linking after the crystal compiler has pretty much done its job would
<jhass>
@[Link] is just a note for what to append to the linker command
<tatey__>
jhass: Fair enough. Thanks anyway.
<BlaXpirit>
jhass, the linking works, but i mean what if the library is missing at runtime
<jhass>
uh
<tatey__>
jhass: Not all my types map to structs. Some of them have no structs as they have no corresponding payload. Instead of checking to see if the constant is defined, I just alias those ones to Nil. Much cleaner than doing a defined check too :-)
<jhass>
can you even recover from that after being linked?
<jhass>
isn't that check done by the loader before any of your code runs?
<jhass>
and to recover we would need to implement our own loader?
<BlaXpirit>
I don't know how it works, but since it's dynamic it's possible to detect
<tatey__>
I'll probably switch away from using nil to my own explicit `NoPayload` type or something.
hiroki has joined #crystal-lang
<jhass>
tatey__: mmh, I guess the way too go is something like {% C.constants.include? "LX#{value}" %} or so (doubt that works, but the general approach)
<Netfeed>
BlaXpirit: ran in 3 minutes on my machine
<Netfeed>
maybe closer to four
<BlaXpirit>
Netfeed, that's probably close to average
<Netfeed>
readline-dev seems to missing from required libraries though
<jhass>
yeah, the travis build should have about 40sec to a minute setup and I guess 20 to 30 sec for compiling the samples
luislavena has left #crystal-lang [#crystal-lang]
<jhass>
Netfeed: it's a wiki ;)
<RX14>
it seems that null causes curl and browsers to hang, but an empty string does not
<jhass>
RX14: indeed, please open an issue with that code
<RX14>
it means in my aplication I need to set the body to a blank string before returning a HTTP error code :(
<Netfeed>
jhass: :)
<Netfeed>
RX14: i've noticed that too, but i thought it was as it should be
<RX14>
artanis examples said you coudl do it, and it seemed like a bug
<RX14>
and hanging the client is the wrong behaviour always
<RX14>
so bug report time
Ven has joined #crystal-lang
<Netfeed>
jhass: should each fix be it's own commit? one for the timeformat error and one for removing return in return nil for example? what's best practice here?
<jhass>
Netfeed: I amend code review corrections into the commits that introduced them
<Netfeed>
ok, this is something completly new for me, how do i do that?
<jhass>
I keep individual changes (introduce date parsing helpers, add cookie classes, use new classes to handle cookies) in their own commits, compared to the target branch
<jhass>
given you have a single commit, you can just git commit --amend -p and force push
<Netfeed>
ooh, yeah, you mean that way, sure
ssvb has joined #crystal-lang
<Netfeed>
jhass: $~ exists, but not Regex.last_match, is the latter something that should be added later?
<jhass>
weird, I thought we had that
<jhass>
$~ it is then
grindhold_ has quit [Quit: No Ping reply in 180 seconds.]
<Netfeed>
made it more "perly" :)
<jhass>
eh yeah, but critical enough code to save the extra call to pcre ;)
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<Netfeed>
hmm, i think i screwed that up, i did a bunch of stuff instead of the git commit --amend -p, because i didn't think it through properly and now i have one commit with the changes i made in it instead and i can't really rebase up anymore, is there a way to fix this?
<jhass>
"can't really rebase up anymore"?
<jhass>
if you have two commits you want to combine, git rebase -i master, change pick to squash or fix for the second one
* Netfeed
has no git-fu at all
<jhass>
it comes with time
<Netfeed>
is it really safe to force push?
<jhass>
to a feature branch? sure
<Netfeed>
scary :)
<Netfeed>
alright, some changes is in now
<Netfeed>
thanks for the help
<jhass>
thanks for the contribution!
elbow_jason has quit [Quit: Leaving]
<Netfeed>
hmm, i can use the Warning header more than once
<crystal-gh>
[crystal] will opened pull request #1254: StringScanner (master...stringscanner) http://git.io/vsuGa
<Netfeed>
alright, two comments left, and i don't really know about them, not sure what's idiomatic here
<jhass>
it's not so much about being idiomatic as much more that I feel like the current approach is making the methods do too much
<jhass>
or know too much
<Netfeed>
yeah, maybe
<jhass>
having to introduce two new params because you need to pass down info you have only elsewhere is a pretty clear sign for that tbh
<jhass>
I remember right that request is always Cookie and Response is always Set-Cookie, right?
<Netfeed>
there's one missing use case too with multible name=value pairs in one cookie, "n1=v1, n2=v2; Path=/", but i'm not really sure how that should be handled as that there, might be a problem with expires then
<Netfeed>
jhass: that's correct
<jhass>
so having Request just add Cookie headers it its @headers when passing them down for serialization and Response doing the same for Set-Cookie headers feels a lot cleaner for me
<jhass>
as I wrote something like @cookies.add_request_headers(@headers) and @cookies.add_response_headers(@headers)
<Netfeed>
but there's one @cookies per request/response and the server doesn't need to respond with the cookies you send
<jhass>
those two could then delegate to add_headers "Cookie", headers and add_headers "Set-Cookie", headers respectively
<jhass>
just return headers if empty?
Codefriar has quit [Read error: Connection reset by peer]
<jhass>
Netfeed: mmh, what do you think, is there actually a good reason to hide the cookie headers while parsing? Why not include them and have cookies merely as a convenience access to them?
NeverDie has quit [Quit: I'm off to sleep. ZZZzzz…]
<RX14>
damn I want a crystal repl :P
<jhass>
RX14: very hard to do unfortunately
<RX14>
yeah I'm sure
<RX14>
crystal eval is okay though
<Netfeed>
jhass: i think the should be split honestly, but i'm considering adding something like Headers#add_cookie(String, Cookies) or something and just show them in there before the write
<Netfeed>
jhass: and then remove the cookie handling from HTTP#serialize...
<Netfeed>
want me to add it or do you want to do it yourself?
<jhass>
btw I don't have commit rights or anything ;)
<Netfeed>
that's true
<jhass>
it's my suggestion and opinion, take it or leave it ;)
<jhass>
(if you want to apply the diff, just paste/pipe it to git apply, I think there's a spec or two that needs fixing then)
<Netfeed>
yeah, done that
<Netfeed>
i'm thinking about what happens if you parse a request/response and then want to add/remove headers, but i don't think that's actually a use case
<jhass>
well yeah, the cookies/headers won't stay in sync, mmh, that's actually a fairly good argument for hiding them
<RX14>
how can I send a type to a method then invoke a static method on that type?
<Netfeed>
you just need to impelemtn <=> for compareable?
<BlaXpirit>
oh, to hell with 0 overhead
<jhass>
Netfeed: yeah
<BlaXpirit>
def <=>(other: Time); microseconds <=> other.microseconds; end
<BlaXpirit>
perfect
<Netfeed>
that's kinda nice, alot of features with just one method and an include :)
<BlaXpirit>
python had something similar but dropped it D:
<jhass>
one spaceship to rule them all
<BlaXpirit>
but they have autoimplementation based on == and < instead of this <=>
<jhass>
mmh, doesn't make that two calls for <=, >= and > though?
<BlaXpirit>
no
<BlaXpirit>
a <= b : not(a > b) a >= b : not(a < b)
<BlaXpirit>
a > b : b < a
<jhass>
ah, right
<jhass>
though swapping receivers is kinda meh
Codefriar has joined #crystal-lang
Codefriar has quit [Ping timeout: 255 seconds]
Codefriar has joined #crystal-lang
<crystal-gh>
[crystal] PragTob opened pull request #1257: Remove the Enumerable#first(n) alias for Enumerable#take(n) (master...remove-first-alias) http://git.io/vszZK
etrepat has joined #crystal-lang
Codefriar has quit [Read error: Connection reset by peer]
elbow_jason has joined #crystal-lang
Codefriar has joined #crystal-lang
etrepat has quit [Client Quit]
etrepat has joined #crystal-lang
etrepat has quit [Client Quit]
<crystal-gh>
[crystal] asterite pushed 3 new commits to master: http://git.io/vsz5q
<crystal-gh>
crystal/master 03a1de9 Ary Borenszweig: Put back MD5 in libcrypto
<crystal-gh>
crystal/master 7509c5d Ary Borenszweig: Error if yielding outside a method (instead of a compiler crash)
<crystal-gh>
crystal/master 4570084 Ary Borenszweig: Unbind block args from yields on call recalculation. Related to #1242