<crystal-gh>
[crystal] asterite closed pull request #1007: Add documentation about JSON serialization and deserialization (master...doc-json) http://git.io/vm9fI
Mercurial_ has joined #crystal-lang
<asterite>
A note on the comments about nil and blank?: in Crystal it becomes less useful because the compiler won't restrict types like that inside an if. In Ruby it's OK, but I actually find a lot present?/blank? calls in a Rails app to just be nil checks, and they add a lot of noise to the code... so I wouldn't mind not having that in crystal
<asterite>
Crystal almost forces you to do `if var` instead of `if var == nil`, `if var != nil`, `if var.blank?`, `if var.present?`, all of which are longer variants (and slower)
<sfcgeorge>
Okay that makes sense :) thank you for the explanation
DrThunder has quit [Remote host closed the connection]
BlaXpirit has joined #crystal-lang
vegai has quit [Quit: leaving]
vegai has joined #crystal-lang
dbackeus has joined #crystal-lang
dbackeus has quit [Ping timeout: 246 seconds]
dbackeus has joined #crystal-lang
willl has joined #crystal-lang
elia has joined #crystal-lang
shadeslayer has quit [Ping timeout: 244 seconds]
<unshadow>
jhass: I just upgraded to latest crystal-git via AUR, it seems you changed the build process a little bit, why do you build all specs ? what's the point ?
<jhass>
it's actually good practice
<jhass>
so you don't get a faulty package
<unshadow>
Hmm... didn't think about that, cool :)
shadeslayer has joined #crystal-lang
elia has quit [Quit: Computer has gone to sleep.]
NeverDie has quit [Quit: I'm off to sleep. ZZZzzz…]
<unshadow_>
jhass: fuck... it creates a "crystal-git.git" folder, not a crystal-git folder
<unshadow_>
my bad sorry :(
<jhass>
huh, weird
<jhass>
doesn't do that here either
<unshadow_>
are you cloning with .git in the end of the url ?
<jhass>
yes
<unshadow_>
jhass: Oh, I found the issue
<jhass>
copy pasted your command to be sure
<unshadow_>
if you clone "git clone https://aur4.archlinux.org/crystal-git.git/" it creates a crystal-git.git folder, is you remove the "/" in the end of the url, it will create a crystal-git folder
<jhass>
ah
<jhass>
I managed to not copy the / :D
<unshadow_>
jhass: I didnt know git behaves like that, it was a first for me too
leafybasil has quit [Remote host closed the connection]
Ven has joined #crystal-lang
leafybasil has joined #crystal-lang
Ven has quit [Ping timeout: 244 seconds]
Ven has joined #crystal-lang
Ven_ has joined #crystal-lang
Ven has quit [Ping timeout: 240 seconds]
dbackeus has quit [Remote host closed the connection]
dbackeus has joined #crystal-lang
DeBot has quit [Read error: Connection reset by peer]
DeBot has joined #crystal-lang
Ven_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
dbackeus has quit [Remote host closed the connection]
unshadow has joined #crystal-lang
unshadow_ has quit [Ping timeout: 246 seconds]
Raimondi has quit [Ping timeout: 246 seconds]
dbackeus has joined #crystal-lang
Ven has joined #crystal-lang
<dbackeus>
can I metaprogram based on files in the filesystem? for example glob for .ecr files and generate view classes for them at compile time?
<jhass>
dbackeus: kind of, you can always end up doing arbitrary stuff with the run macro
<dbackeus>
can I get the result of run to generate a macro result though?
<dbackeus>
for example: {% for view in run("./get_views_array") %} {% puts view %} {% end %}
<dbackeus>
errors with: expression must be an array, hash or tuple literal, not MacroId
<dbackeus>
I can get the result as a runtime thing (views = {{run("./get_views_array")}}; puts views) but to build classes I guess I would need to have it in compile time?
<jhass>
well, you wouldn't return just the array, you would return the entire code the macro should generate
<dbackeus>
alright
<dbackeus>
I'll give it a shot
<jhass>
so more like {{run("./generate_views")}}
<dbackeus>
not sure how I can get around the "can't declare a class within a block" limitation
<dbackeus>
at some point I need to do `Dir.glob("*.ecr").each do |file|` and generate the classes, right?
<jhass>
you want to do the glob at compile time and build strings with its output that when parsed give the classes
<jhass>
so you print those strings to stdout and the run macro pastes that into the target file, basically
<dbackeus>
oh right, so it's more like `puts "class #{class_name}"`
<dbackeus>
etc
<jhass>
yeah
<dbackeus>
ok, this is making my head heart a little
<dbackeus>
*hurt
<dbackeus>
;)
<jhass>
hehe, it gets funny if you realize you could stack it endlessly by using the run macro in that file again... :P
<dbackeus>
a dream within a dream
<dbackeus>
are there any literals for creating long multi line strings (like in Ruby you can do <--END ... END?
<jhass>
heredoc works pretty much the same
<jhass>
aw, it doesn't interpolate apparently :(
<jhass>
well, you can put newlines into " and %( too
<dbackeus>
oh right
Speeder has joined #crystal-lang
<Speeder>
hey
<jhass>
hi
unshadow has quit [Quit: leaving]
<jhass>
Speeder: there's not a whole lot of talk going on here, so if you got any questions, just ask ;)
<Speeder>
ok
<Speeder>
I saw on SFML's page there is a binding of a SFML to Crystal. I've typed in Google: crystal programming lang. On Crystal's site I read that's similiar to Ruby. I want to try to learn it but is Crystal fast enough for gamedev (I love gamedev)?
<Speeder>
for indie-2D-games
<BlaXpirit>
hi, Speeder
<Speeder>
hey
<BlaXpirit>
it's certainly very fast
<jhass>
we hope so, it is a compiled language with an LLVM backend, so it does actually achieve comparable speeds to C and the like in some cases
<dbackeus>
the ruby way of recursively globbing files `Dir.glob("**/*.ecr")` doesn't seem to work in Crystal. Is this by design? Any other ways of doing it?
<Speeder>
What about this Crystal on Windows? I like Visual Studio (C#, C++), so I'm coding on Windows. Should I use Linux to code in Crystal? That's not a big problem to install Linux for me.
<jhass>
dbackeus: it's not by design, it's essentially a missing feature that requires reimplementing all of that functionality
<jhass>
since glibc glob doesn't do it
<BlaXpirit>
Speeder, the problem is that you can't even run Crystal programs on Windows yet
<jhass>
and everybody seems to reimplement it
<jhass>
dbackeus: for now you're probably best of with a recursive method using Dir.entries / Dir.directory?
<Speeder>
ok
wuehlmaus has joined #crystal-lang
<Speeder>
first I'll try it on Virtual Machine, then I'll install Linux (if Crystal will be nice)
<jhass>
sounds good
<Speeder>
bye thanks for help
<jhass>
yw
Speeder has quit [Quit: Page closed]
<dbackeus>
ok thanks
grios has quit [Ping timeout: 250 seconds]
Raimondi has joined #crystal-lang
dwahl has joined #crystal-lang
<dbackeus>
is there any filename conventions for multi word filenames for crystal, is many-words.cr preferred or many_words.cr?
<dwahl>
probably underscores since that's the ruby convention
<dbackeus>
(guessing looking at the crystal source seems like underscore is the way)
<dbackeus>
probably useful to get word out on conventions in an official place, the more correct package names out there vs weird ones the higher chance people take note of the right way to do it
<dwahl>
if you make it official then it's not a convention :)
<dbackeus>
a few camelcased ones and mix of _ vs -
<dwahl>
i think there's something to be said for letting the community figure out what works for bike sheddy things like that, but that's probably a dumb opinion
<dbackeus>
depends if we care about communicative and clean looking Projectfile or not I guess
Raimondi has quit [Read error: Connection reset by peer]
dwahl has quit [Ping timeout: 265 seconds]
<dbackeus>
on the topic of the Projectfile, any other ways of including projects than github, such as from a local directory?
<BlaXpirit>
whether it's constants or some special "defines"
<jhass>
kostya: seems to be in the standard deviation
<dbackeus>
so no idea of how to achieve the equivalent of {% if "Asdf".constant_defined? %}
<BlaXpirit>
you cannot
<dbackeus>
I see
<dbackeus>
darn
<BlaXpirit>
btw i'm talking out of experience and what i've seen so far. maybe there is something i haven't seen that allows this, but i really doubt it.
DeBot has joined #crystal-lang
<jhass>
mmh, we need a faq/wiki page for the "can I run ruby stuff" question
<jhass>
can I/will I be able to
dbackeus has quit [Remote host closed the connection]
<asterite>
Someone in our office suggested this for the t-shirt phrase: "No, it's not compiled Ruby. But thanks for asking"
<jhass>
:D
<asterite>
Maybe Ruby's syntax is too strong, so you see it and you can't think of other languages (but if I say "semicolons" you can think of many). In our homepage the only thing said about Ruby is "Ruby-inspired syntax"
<jhass>
I guess
<jhass>
doesn't mean it should become less similar :P
<thor77>
is there a way to rescue a keyboard-interrupt?
<thor77>
whats the "right" way to close a socket? can't find any documentation on that at /api
<jhass>
.close?
<jhass>
Socket < FileDescriptorIO which includes BufferedIOMixin which defines that
<jhass>
would be nice if the docs give a list of inherited methods like yard does
<thor77>
uh :O didn't know about BufferedIOMixin
<thor77>
it doesn't appear anywhere at the TCPSocket-tree
<jhass>
it does
<jhass>
if you go to FileDescriptorIO
<jhass>
but yeah, it's kinda hidden, hence my above comment
<thor77>
uh "included modules"
<thor77>
i only looked at superclass hierarchy
mgarciaisaia has quit [Quit: Leaving.]
blue_deref has joined #crystal-lang
NeverDie has joined #crystal-lang
grios has joined #crystal-lang
shama has joined #crystal-lang
mgarciaisaia has joined #crystal-lang
<asterite>
Yes, I need to improve the docs generation to include that info. But thor77, in Ruby I usually think "How would I close a socket? Let's try close" (and replace this example with any other) and it usually works, so I'd suggest to always try the name that you think would be "the one"
<thor77>
atm i always think of the way i would do it in python
<thor77>
and this way mostly doesn't work
<asterite>
how do you close a socket in python?
<thor77>
.close()
<BlaXpirit>
uhhh
<thor77>
bad example :P
<asterite>
:-D
<jhass>
thor77: okay to convert the python mindset, also replace most foo(x) with x.foo :P
<BlaXpirit>
it's a tiny part of it
dbackeus has joined #crystal-lang
elia has quit [Quit: Computer has gone to sleep.]
dbackeus has quit [Ping timeout: 264 seconds]
<thor77>
jhass: seems like a good start ;)
<jhass>
and until then we have also the hangman training camp
<jhass>
DeBot: !hangman crystal
<DeBot>
␣␣␣␣␣␣␣␣␣␣␣␣ [] 0/12 (crystal)
<jhass>
DeBot: :
<DeBot>
␣␣␣␣␣␣␣␣␣␣␣␣ [:] 1/12 (crystal)
<jhass>
DeBot: #
<DeBot>
␣␣␣␣␣␣#␣␣␣␣␣ [:] 1/12 (crystal)
<thor77>
e
<thor77>
DeBot: e
<DeBot>
␣␣␣␣e␣#␣␣␣␣␣ [:] 1/12 (crystal)
<thor77>
what does this 1/12 mean?
<thor77>
i
<thor77>
DeBot: i
<DeBot>
␣␣␣␣e␣#␣␣␣␣␣ [:i] 2/12 (crystal)
<thor77>
DeBot: o
<DeBot>
␣␣␣␣e␣#␣o␣␣␣ [:i] 2/12 (crystal)
<thor77>
DeBot: u
<jhass>
DeBot: a
<DeBot>
␣␣␣␣e␣#␣o␣␣␣ [:ia] 3/12 (crystal)
<jhass>
DeBot: r
<DeBot>
␣␣␣␣er#ro␣␣␣ [:ia] 3/12 (crystal)
<jhass>
DeBot: n
<DeBot>
N␣␣␣er#ro␣n␣ [:ia] 3/12 (crystal)
<jhass>
DeBot: umb
<DeBot>
Number#roun␣ [:ia] 3/12 (crystal)
<jhass>
DeBot: d
<DeBot>
Number#round [:ia] 3/12 (crystal) You won!
<jhass>
well, looks like you can round any number in crystal!
mgarciaisaia1 has quit [Ping timeout: 240 seconds]
Speeder has joined #crystal-lang
<Speeder>
hey
<Speeder>
I wanted to ask you, what linux should I choose? I like GUI and console is good too.
<jhass>
Ubuntu or Fedora
<BlaXpirit>
here we go again
<BlaXpirit>
let me just recommend Kubuntu 14.04 and get outta here
sailorswift has joined #crystal-lang
<dwahl>
osx is clearly the best linux
<wconrad>
jhass: Sorry, I was unclear. I've cloned the Crystal repo and want to tinker around it in. How do I, for example, run Crystal's own unit tests?
<jhass>
make spec
<dwahl>
easiest way to run the crystal tests is with the makefile
<jhass>
(sorry missed your qustion)
<dwahl>
you can look at it to see how the tests are executed
<dwahl>
(beaten)
<wconrad>
Nice. Thanks. And you may not have missed the question... I was having some IRC client trouble.