<unshadow>
I really dont like how much the undefined method 'intelligence' for Nil is coming all the time
<unshadow>
...
<unshadow>
if @@player_char && @@player_char.intelligence >= 1
<unshadow>
^~~~~~~~~~~~
<unshadow>
Do I need to warp every check with " if @@player_char" ?
<unshadow>
Ok, it looks like a bug or something
<jhass>
unshadow: @@player_char is shared state
<jhass>
think about a threaded environment, the value of @@player_char may change between the nil check and the second half of the &&
<jhass>
assign those to a local fist
<jhass>
*first
<unshadow>
but using @player_char isn't supported :(
<jhass>
player_char = @@player_char
<jhass>
same for @player_char
<unshadow>
So, what should I do ?
<jhass>
player_char = @@player_char (maybe that's actually a constant btw?)
<jhass>
if player_char && player_char.intelligence >= 1
<unshadow>
Well, then i'll just pass it around like a normal value, def something(player_char)
<jhass>
that'll work too, likely with less nil checks even
<jhass>
at first it's a bit annoying, but you'll love it once you no longer run into the dreaded NoMethodError for nil at runtime anymore ;)
<unshadow>
thats true hahah
<unshadow>
Btw, I used a cool script to run ldd on my exec, then cp all the needed libs to a local dir, after that I added LD_LIBRARY_PATH="./ext/", I hope this will work
<jhass>
oh, since when is that violet and not gray anymore?
<unshadow>
strcmp1, becuase I wanted to sheep out all the .so libs :)
<unshadow>
I used a cool script to run ldd on my exec, then cp all the needed libs to a local dir, after that I added LD_LIBRARY_PATH="./ext/"
<strcmp1>
the compiler should be able to statically compile a binary instead of doing that :/
<unshadow>
Can it ?
<strcmp1>
i donno
<vikaton>
jhass, a few days ago
<vikaton>
I would uch rather have the light gray one, but this is cool and unique
<strcmp1>
crystal seems far less useful if the binaries you distribute depend on dynamic libraries like libgc etc, unless you can statically compile a binary and distribute that.
<jhass>
build has the --link-flags option
<jhass>
--link-flags -static throws me TCPSocket:(.text+0x6e1): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
<jhass>
and then ld seems to fail on it, not sure if for that message
<strcmp1>
it would ultimately be nicer if the compiler solved the problem, and for all platforms.
<unshadow>
jhass, LOL Files, created by statifier ("pseudo-static") combine disadvantages of both of them:
<jhass>
strcmp1: the problem is that you usually don't have static versions of those libraries available
<jhass>
I'm not sure that's something the compiler can/should solve
<jhass>
at most the official compiler packages may
<jhass>
but think about linking to stuff besides what the compiler itself uses
<strcmp1>
it seems reasonable to me that the compiler should be able to compile a statically linked binary, otherwise i think crystal loses a lot of appeal, because it depends on so many dynamic libraries.
<jhass>
unshadow: that's the same approach as statifier
<strcmp1>
yeah, i would be fine dynamically linking libpq, and so on, but with a fresh slate (just vanilla crystal), i think it would be a big win if it were possible.
<strcmp1>
besides the performance boost, binaries are appealing to me because you can distribute them without dependencies such as an interpreter or whatever, crystal falls down hard here it seems
<unshadow>
I too think we need to find a solution to this, right now I'm sending 15 libs, and this is without actually using anything other then a =~ /a/i or puts
jtarchie has quit []
jtarchie has joined #crystal-lang
<unshadow>
What will happen is I'll try to use Curses, OpenSSL, Sockets.... hell
<strcmp1>
i would be fine dynamically linking stuff like curses, openssl... but pcre/libgc no.
<jhass>
I would be fine with shipping the core .a's in the compiler packages and adding a --static shortcut to crystal build for --link-flags -static as well as a --mixed flag who only tries to link those core libs statically
<strcmp1>
yes i like the sound of that too
<jhass>
but I'm not even sure I'd agree about it being the default mode
<asterite>
the method that accept symbols is for the case when the color is dynamic, otherwise you can use the named methods, much cleaner and type safe
<asterite>
(but apparently nobody knows that, I need to add docs to the module)
<unshadow>
Why dosent the colorize just overloads the String, like in ruby so that .red becomes part of String ?
<unshadow>
so you can just type "hello".red
<asterite>
jhass: I was wondering why the color codes didn't show up, then I saw the text was red. Pretty cool :-)
datanoise has quit [Ping timeout: 250 seconds]
ismaelga has joined #crystal-lang
<jhass>
asterite: ;)
<unshadow>
yeha the website is awsome, I really liked that you added the colors in edit mode (syntax highlight)
<jhass>
it's like rails, if you understand and follow the intended paths, it works well
<asterite>
In my workplace we used Knokcout and Angular, I prefer Knockout... but we still have to "play" with other JS libraries, and Ember was a possibility
<asterite>
Ah, yes, I see the directory structure...
<jhass>
well, that's just additional oppionated stuff on top: ember-cli.com
<asterite>
BTW, there's @[Link(..., static: true)] now that I remember, but it's not very useful
<asterite>
I'd like to also provide static-everything, I'm sure waj will know how to do it... but I don't think everything can be statically linked
<jhass>
it can make sense, but for core libs I'd like to be able to decide it on invoking crystal build
<jhass>
glibc apparently can't fully
<asterite>
Yes, exactly
<unshadow>
packing libgc.so feels wierd ..
<asterite>
(to both of your statemenets)
<unshadow>
well... lets think about this for a sec, I got my project, right now it uses specific 15+\- libs, what will be the best course of action to lower the needed packages ?
bcardiff has joined #crystal-lang
<unshadow>
1) build on target system
<unshadow>
2) Hope everyone has same versions of the libs (yeha right)
<unshadow>
3) use a 3rd party tool to simulate the libs
<unshadow>
non of those are really cool tbh :(
<asterite>
Rewrite evrything in Crystal? :-P
<unshadow>
hahahah glibc.cr :)
<jhass>
interestingly linux desktop is slowly moving towards 3 for desktop application package management
<unshadow>
Id like to see the day hahah
<jhass>
ship everything in an appdir that ships all necessary libraries
<jhass>
eventually even run that in a thin container
<asterite>
When we started Crystal we intended it to be for webserver stuff, so it's not very bothersome to install crystal on the server, the deps, and compile on deploy
ismaelga has quit [Remote host closed the connection]
<asterite>
but of course console apps and GUI apps are also possible, so we have to think about that
bcardiff has quit [Read error: Connection reset by peer]
bcardiff has joined #crystal-lang
<unshadow>
Well, I'm proud to be the first one to try and create a game using Crystal :)
asterite has quit [Quit: Page closed]
<jhass>
well...
<jhass>
let's say an original game :P
<ponga>
really?
<unshadow>
hahah I remmber 2048 right ?
<ponga>
wasn't tetris first?
<strcmp1>
tetris is so original
<ponga>
nah i mean in Crystal
<ponga>
there was a guy who made tetris in Crystal here
<jhass>
or regarding the RPC area a nice soap client
<unshadow>
which is wierd, a web server without gzip\defalte ?
<jhass>
well, you should still reverse proxy it unconditionally IMO
<unshadow>
jhass, I'll give you a mission, its a hard one, in the HTTP::Server there is an ssl option, if you can get this to work, i'll give you back a lib of your choise to be added to crystal
asterite has joined #crystal-lang
<unshadow>
jhass, you cannot reverse proxy without gzip\defalte, you may need to rewrite content inside a page etc...
<unshadow>
if you cannot decode it, you cannot re-write it
<asterite>
You think we should bind to zlib or write the algorithm ourselves? Is it hard?
<jhass>
unshadow: one of my todo list is crystal-posix, which would allow you to write crystal programs doing IO and not depending on libevent and libpcl
<asterite>
he said he'll eventually create a pull request with that
<unshadow>
cool !!! I'll send him some requests, thanks :)
asterite has quit [Quit: Page closed]
<jhass>
asterite: I have to say it out loud: you have the weirdest IRC workflow ever :P reading the web log and joining via webchat if you have something to say...
BlaXpirit_ has joined #crystal-lang
BlaXpirit has quit [Killed (orwell.freenode.net (Nickname regained by services))]
vikaton has joined #crystal-lang
<unshadow>
jhass, how can you actually do IO without binding a c lib? (not that I think it's not possible, i really am interested)
<jhass>
mh, I don't think you need to link anything for the syscalls to work?
asterite has joined #crystal-lang
<asterite>
jhass: oh, it's because I'm not with the computer the whole time, and from time to time I check if you are talking about something interesting or where I can comment :-)
<asterite>
Well, zlib is a beast of a library, I was wrong about the "small" part of "small and fun"
<vikaton>
asterite: Crystal is being added to techempower benchmarks :P
<asterite>
vikaton: Nice :-)
<asterite>
Though I doubt it will excel right now
<vikaton>
It's pretty fast as is though
<vikaton>
asterite: how much faster you think it can get o.0
<asterite>
well, we didn't spend much time optimizing things, we are more focused in defining the API of things, fixing bugs, adding/removing features from the language, etc.
<vikaton>
ah
ismaelga has joined #crystal-lang
datanoise has joined #crystal-lang
ismaelga has quit [Remote host closed the connection]
ismaelga has joined #crystal-lang
ismaelga has quit [Remote host closed the connection]
willllll has joined #crystal-lang
<asterite>
vikaton: I'm still curious to see what performance we get right now :-)
<jhass>
asterite: btw did you see the proposals to Ruby to add Object#try as foo.?bar ?
<jhass>
(which in Ruby would be optimized/a shortcut)
<jhass>
what if you're uncertain whether a key exists?
<jhass>
always handle the exception?
<strcmp1>
or use a predicate, like key?
<asterite>
You can check if a key exists, and then ask for the value, but that means it's a double lookup
<asterite>
Or you could make it yield to a block... that's another option
<asterite>
but I think then it will become like JS's callback hell
<jhass>
hash["foo"]? || compute_default vs (hash.has_key?("foo") && hash["foo"]) || compute_default
<strcmp1>
the longer version seems better to me if i don't have to worry about something being nil or not when it ends up being used later, but im just very anti-nil i guess
DerisiveLogic has joined #crystal-lang
DerisiveLogic has quit [Remote host closed the connection]
DerisiveLogic has joined #crystal-lang
<asterite>
I think that methods ending with "?" mean they return something truthy or falsey. []? might return nil, so that makes it follow the rule
<asterite>
So predicates and error-nil methods are similar to me
<asterite>
asking for a non-existing key might be considered an error, or just a predicate that returns a falsey value (nil) if the key doesn't exist
<jhass>
mmh, I have to see if I can incorporate that into my thought model :P
jtarchie has quit [Quit: Connection closed for inactivity]
<unshadow>
I reallt miss .methods
sandelius has joined #crystal-lang
<asterite>
Well, there went the chapter about Generics. I think the docs are "finished" now
<asterite>
If anyone finds something missing, please let me know. I'll later maybe write a chapter on how to use the compiler (mainly the crystal foo.cr, crystal build foo.cr and crystal build foo.cr --release differences), and maybe a FAQ or "coding with performance in mind"
<asterite>
jhass: hopefully you'll have an easier time in this IRC channel from now on :-)
<jhass>
asterite: speaking of it, how about you try to get founder rights for #crystal? it looks vacant for years, so usually you can convince staff to give it to you if you have a project with the same name
<asterite>
unshadow: http://carc.in/#/r/av , but not something I would use... there's also a way to get all methods
<jhass>
we can just +F it to here, so it's easier to find for people
<asterite>
You mean the #crystal channel?
<jhass>
yes
<strcmp1>
we should create #crystal-lang to be more like ruby
<jhass>
strcmp1: what do you mean?
<asterite>
What's the difference between ruby and ruby-lang?
<strcmp1>
it has two channels
<jhass>
it's difficult
<jhass>
the person who registered #ruby pretty much abandoned it
<asterite>
Got to go now, but i'll try to get the #crystal channel for us
<jhass>
so we had no means to appoint new ops for a long time
<asterite>
I think one channel should be good, it makes it easier for those who want to ask questions: there's only one option :-)
<jhass>
which is why ruby core decided on #ruby-lang to become the official channel
<jhass>
asterite: yeah, I mean secure it so we can prevent a split
<jhass>
you can forward one channel to another
<unshadow>
1. Installation -
<jhass>
so everybody who would join there would end up here
<unshadow>
1.4 on Arch Linux
<unshadow>
btw, where are the docs ? are they on git ?
<jhass>
strcmp1: anyway, #ruby grew bigger, and today is factor 4 bigger than #ruby-lang, mainly because #ruby-lang was set to ban non-registered users for a long time
<jhass>
these days we convinced freenode staff to appoint new founders and have a new op team for #ruby
<jhass>
I'm actually trying to make #ruby the official channel and eventually merge #ruby-lang into it
<BlaXpirit>
that sure would be best
asterite has quit [Ping timeout: 246 seconds]
<strcmp1>
good luck jhass, it has been like that for so long i'm not sure it will ever change but i hope it does :)
<unshadow>
what's the diff between "def bar=(foo)" and "def bar(foo)" ?
<jhass>
unshadow: the former you can call with foo.bar = baz
<jhass>
though at that scale, it might just be load variances on the host system
<vikaton>
whoops
<vikaton>
whoops :P
<vikaton>
still impressive
ismaelga has quit []
<datanoise>
to me it's just llvm test. see how crystal is close to rust
<jhass>
well, you can still mess up by generating code that's hard to optimize for llvm
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
waterlink has joined #crystal-lang
<kulelu88>
what the fish, crystal is faster than Nim also
<strcmp1>
that surprised me too
<kulelu88>
D is actually faster though, on gdc
<datanoise>
this benchmark is quite strange. look at clang numbers...
havenwood has joined #crystal-lang
<vikaton>
datanoise, kulelu88 look at the latest commit, befor and after times
<vikaton>
its very veriable
<vikaton>
variable*
<vikaton>
Nim is still pretty fast
<crystal-gh>
[crystal] asterite pushed 1 new commit to master: http://git.io/vTKPB
<crystal-gh>
crystal/master de499b2 Ary Borenszweig: Fixed: don't crash on private def as last expression (was missing a Nil type)
waterlink has quit [Quit: Leaving.]
unshadow has joined #crystal-lang
unshadow has quit [Client Quit]
jua__ has quit [Quit: Vision[0.9.7-H-20140108]: i've been blurred!]
datanoise_ has joined #crystal-lang
<crystal-gh>
[crystal] will opened pull request #679: SIGPIPE, non-blocking fds passed to other procs, and the os x travis failures (master...fixosxcat) http://git.io/vTK7J
vikaton has quit []
<travis-ci>
manastech/crystal#2357 (master - de499b2 : Ary Borenszweig): The build is still failing.
<asterite>
willllll: thank you so much! I can't remember the last I saw that message here
<asterite>
willllll: The same issue happened in python?
<willllll>
Yeah, but Dan does a lot of low level stuff in wal-e for speed. By default it doesn't do non-blocking IO, and he wired that up with gevent manually