<crystal-gh>
[crystal] asterite pushed 1 new commit to master: http://git.io/vYj2p
<crystal-gh>
crystal/master 0e2e119 Ary Borenszweig: Fixed #1010: allow assigning to underscore (_), give compile-time error when trying to read from it
<Kilo`byte>
like, i want a server that serves normal http, except on lets say /websocket
Locke23rus has quit [Ping timeout: 240 seconds]
<thor77>
Kilo`byte: theres HTTPServer
<thor77>
>> "a.".upper
<DeBot>
thor77: Error in line 4: undefined method 'upper' for String - http://carc.in/#/r/90i
<Kilo`byte>
thor77: yeah, but how'd i use it with websockets
<thor77>
>> "a.".uppercase
<DeBot>
thor77: Error in line 4: undefined method 'uppercase' for String - http://carc.in/#/r/90j
<jhass>
Kilo`byte: you'll have to write a handler that delegates to the other handlers depending on path
<jhass>
yes, but blocks are a syntax construct, not equal to functions
<jhass>
(or Proc's for the matter)
<thor77>
uh, didn't know that. thanks for the explanation :)
<travis-ci>
manastech/crystal#0e2e119 (master - Fixed #1010: allow assigning to underscore (_), give compile-time error when trying to read from it): The build passed. https://travis-ci.org/manastech/crystal/builds/73362920
<crystal-gh>
[crystal] jhass opened pull request #1059: Add convenience methods for accessing a strings codepoints (master...codpoints) http://git.io/vYjd7
<jhass>
thor77: local var won't escape it, there's no real way around it, which usually hints that it's a sign for some potential design improvement ;)
<jhass>
handing out self in a constructor is often asking for trouble, especially in multi threaded environments
<thor77>
ah, okey
<thor77>
seems like i found a way to improve my design :)
sdogruyol has joined #crystal-lang
elia has quit [Quit: (IRC Client: textualapp.com)]
<sdogruyol>
hey all
elia has joined #crystal-lang
<dwahl>
hello
sdogruyol has quit [Remote host closed the connection]
mgarciaisaia has joined #crystal-lang
Ven has quit [Remote host closed the connection]
sdogruyol has joined #crystal-lang
Ven has joined #crystal-lang
<crystal-gh>
[crystal] asterite pushed 5 new commits to master: http://git.io/vOe4r
strcmp1 has quit [Ping timeout: 272 seconds]
<crystal-gh>
crystal/master 3ae391c Jonne Haß: Add codepoints convenience methods to String...
<crystal-gh>
crystal/master 81bc0a1 Jonne Haß: Document String#each_char, String#each_char_with_index and String#chars
<crystal-gh>
crystal/master be1e6d7 Jonne Haß: Document String#each_byte and move String#bytes near it
<crystal-gh>
[crystal] asterite pushed 2 new commits to master: http://git.io/vOeRv
<crystal-gh>
crystal/master cd3c500 Ary Borenszweig: Simpler implementation for `String#each_codepoint` iterator
dbackeus has quit []
<asterite>
I think today I'll release 0.7.5. There are some breaking changes mainly to renames and dropping the 0 prefix for octals, but I don't think incresing the minor is worth it (it's mostly a bug-fix release, again)
blue_deref has joined #crystal-lang
<jhass>
asterite: disallowing to reopen Module might be a quick thing to include :P http://carc.in/#/r/91f
<jhass>
oh, nvm
<jhass>
I broke carc.in :/
<jhass>
going back and forth doesn't always update the code view anymore :(
<dbackeus>
how can I require recursively all directories + files under current directory?
<dbackeus>
require "./**" doesn't seem to take me that far
lucasb has joined #crystal-lang
<dbackeus>
never mind I had the wrong file extension
<lucasb>
asterite: I read in the log about a possible 0.7.5 release today. May I ask if it would be too much trouble to also make available a official 32bit binary for linux as well? But anyway, thank you and the other developers for the work!
<asterite>
lucasb: yes, I'd like that too but we are still missing some bits that would take us more than one day to finish that
DeBot has quit [Read error: Connection reset by peer]
DeBot has joined #crystal-lang
<sdogruyol>
asterite: what's the time goal for 1.0.0?
<jhass>
fkchang: yeah
<fkchang>
jhass: so it's probably better to run off of master if I want quick updates (i.e. the last PR merged)
<strcmp1>
'fkchang: yeah' i can be forgiven for reading that as 'fuck yeah!'
<sdogruyol>
lol
<asterite>
What we need to do (and we'll start doing after this release) is to have a clear roadmap so everyone (including us!) know where we are going
<fkchang>
strcmp1: I can accept being synonomous with 'fuck yeah'
<strcmp1>
lol
mgarciaisaia has joined #crystal-lang
<sdogruyol>
asterite: do you have a feature set on your mind for 1.0.0?
dbackeus has quit [Remote host closed the connection]
<asterite>
They come and go, that's why we need to write them down :-)
mgarciaisaia1 has quit [Ping timeout: 244 seconds]
<asterite>
Also, would be nice to have a list of all the things we want to do for 1.0, for example "File and FileUtils methods", so anyone can tackle that without wondering "do they really want to include this in the std?"
<strcmp1>
im sure world domination and adoption of crystal by Windows as their replacement for .NET/C# family of languages is on the list.
<jhass>
could live without that
<asterite>
At curry on we spoke with Jeff (one of the main developers) and apparently a contributor ported Julia to Windows. Our (me and waj) main problem with windows is that it's been ages since we last used it... and we don't have nice memories about it
<jhass>
arm support would be nice though
<jhass>
is writing ruby extensions still on the list?
<dwahl>
I think windows support isn't necessary for a 1.0 release because adding windows support wont mean adding breaking changes, so there's no reason to have it in for 1.0
<BlaXpirit>
not only would one need to implement actual windows support, but also fix all kinds of bugs on the way
elia has quit [Quit: Computer has gone to sleep.]
<BlaXpirit>
also the horror of bootstrapping
elia has joined #crystal-lang
grios has joined #crystal-lang
<asterite>
BlaXpirit: definitely not forgotten, waj bumped into this issue some days ago and we definitely will fix it
elia has quit [Client Quit]
NeverDie has quit [Quit: I'm off to sleep. ZZZzzz…]
<sdogruyol>
asterite: definitely having clear goals will encourage more people to help
<sdogruyol>
asterite: rust is a great example
<asterite>
Yes, rust is pretty well organized
<dwahl>
when you reopen a class in crystal, how are those changes scoped? one of the horrors of ruby is that class changes are globally applied in the order that files are evaluated, but that wouldn't work in crystal due to static compilation (and shouldn't, really, because ugh)
<asterite>
jhass: we were thinking about releases, doing a blog post for each release... we don't know, maybe we should just announce it on the google groups, tweet and that's it?
<kumpelblase2>
quick question for specs: is there a nice way of checking if a bit is set? apart from (x & z).should eq(z) ?
<jhass>
asterite: if you think so, those are harder to link to though
<kumpelblase2>
thank you
<asterite>
Well, there's always the release tag on github that comes with the changelog
<asterite>
On second thought, maybe a blog post for a release that contains something new or major is worth it, but bug-fix releases are not worth it
<jhass>
backlinks to crystal-lang.org wouldn't hurt though, Google still likes them ;)
Ven_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<jhass>
and as said, don't feel bad about doing a template
<jhass>
"Hey, we just released $version, you can find the changelog and downloads at foo/$version, all repositories have been updated." with some more blabla around it
<sdogruyol>
asterite: blog post for each major release is pretty ok.
<asterite>
That's true. Well, for now I'll do a small blog post. What we'll need to improve is the long list at the bottom of the homepage, or maybe separate categories (releases vs. other suff)
<asterite>
but... later :-)
<sdogruyol>
Actually i think that: Great documentation > Everyhing
<jhass>
yeah, maybe separate news/blog posts
<sdogruyol>
mozilla got steve klabnik just to do documentation lol
<sdogruyol>
and hell he's like the best documentation guy in the planet :D
<asterite>
sdogruyol: I think you need to do `brew update`
<asterite>
The release is up, you can try it :-)
<sdogruyol>
asterite: thanks
blue_deref has joined #crystal-lang
<adam12>
Worked :)
elia has quit [Quit: Computer has gone to sleep.]
_whitelogger____ has joined #crystal-lang
dwahl has joined #crystal-lang
fkchang has quit [Ping timeout: 272 seconds]
DeBot has joined #crystal-lang
grios has quit [Ping timeout: 272 seconds]
mgarciaisaia1 has joined #crystal-lang
Ven has joined #crystal-lang
sdogruyol has quit [Ping timeout: 255 seconds]
sdogruyol has joined #crystal-lang
mgarciaisaia has quit [Ping timeout: 264 seconds]
sdogruyol has quit [Client Quit]
Ven has quit [Read error: Connection reset by peer]
dbackeus has joined #crystal-lang
hangyas has joined #crystal-lang
<dbackeus>
hey! crystal -v works in 7.5 :)
<Mercurial_>
Hi, I'm a bit confused about macros? The documentation makes it a bit confusing, is there anywhere else I could read them from?
<BlaXpirit>
Mercurial_, have u worked with a templating language, like for html or whatever?
<crystal-gh>
[crystal] davydovanton opened pull request #1063: Add documentation for some Iterator methods (master...doc-iterator) http://git.io/vOfdt
<BlaXpirit>
macros can be compared to that
<Mercurial_>
only a bit
<Mercurial_>
I'm a bit confused on why they're needed though
<BlaXpirit>
Mercurial_, it's for compile-time code transformation
<Mercurial_>
what's a situation in which I would need that?
<Mercurial_>
sorry, I'm a noob
<BlaXpirit>
Mercurial_, macros are most often just for convenience
<BlaXpirit>
i can't think of anything that can't be achieved without them
<BlaXpirit>
just look at some examples in standard library
<asterite>
Mercurial_: do you know Ruby's attr_reader?
<Mercurial_>
yeah
<jhass>
BlaXpirit: well, macro method_missing and macro inherited/included would be hard to do otherwise ;)
<BlaXpirit>
oh yeah.
<BlaXpirit>
compiletime hooks as well
<asterite>
In fact I agree with BlaXpirit here, macros aren't needed. Java does fine without macros. Same in Go. They can just help to reduce amount of typing in many cases
dbackeus has quit [Remote host closed the connection]
<asterite>
Mercurial_: how would you implement attr_reader in Ruby?
<Mercurial_>
attr_reader :variable
<Mercurial_>
for your instance variables
<jhass>
Mercurial_: do you know define_method?
<dwahl>
IMO most use cases for the runtime dynamism that ruby allows are mostly used to implement DSLs, which only run when the application launches. therefore, macros replace them really well.
<asterite>
dwahl: Exactly! Also you usually reopen classes before the "main" code, for example with extensions. Reopening classes at runtime is pretty rare (imagine reopening a class in some http requests)
<Mercurial_>
jhass: yeah, another way to define methods for a class
elia has joined #crystal-lang
<dwahl>
asterite, so yeah, to that end, macros are necessary if you want cute ruby DSLs (which are a draw), but they arent strictly necessary
<dwahl>
also they're a hell of a lot of fun for the developer
<dwahl>
probably dangerously fun
elia has quit [Client Quit]
<BlaXpirit>
meh
<asterite>
dwahl: yes, so fun they usually distract the programmer from solving the problem at hand (which can always be solved without macros)
<jhass>
Mercurial_: do you know about usecases for it and similar constructs?
<Mercurial_>
jhass: I'm sorry, I don't :(
<asterite>
Mercurial_: what compiled languages you know?
<dwahl>
Mercurial_, it's basically code that generates code and pastes that code directly into your code. so if you can define a macro that defines some methods for you, and then reuse that macro within another classs to automagically define those same methods without writing any code
elia has quit [Quit: Computer has gone to sleep.]
elia has joined #crystal-lang
<Mercurial_>
how and why would I implement that into my code
<Mercurial_>
besides saving time
<dwahl>
only for saving time
<dwahl>
the real use case if you're doing something like writing an API
<dwahl>
that other programmers will use
<dwahl>
API/library
<dwahl>
and you want other programmers to be able to easily modify their classes to make use of your library
<dwahl>
you can provide macros so that all they need to do is call your macro within their classes, and now code exists for them to easily consume your library
<kumpelblase2>
same thing goes for things like 'getter' and 'accessor' in ruby too. You might as well write the two methods directly, but using, in this case, macros makes the code easier to read and makes you write less code in general
dbackeus has joined #crystal-lang
elia has quit [Client Quit]
<Mercurial_>
ok that makes sense
<Mercurial_>
thanks
<Mercurial_>
is there a really good example of this in use?
<dwahl>
getter and setter in crystal are the best examples
<asterite>
Another good example is the to_s method
<dwahl>
they automatically define def {{attribute}} and def {{attribute}}=, so that the user doesn't need to.
elia has joined #crystal-lang
<dwahl>
so you can just call getter :foo, and now def foo is defined. you, the programmer, can create this same functionality, it's not some special language keyword
<asterite>
I hope we can improve macro readability with small but good deltas
<jhass>
asterite: btw required keyword args is probably the last syntax level feature (well, together with the macro method idea the other day) that I really miss
leafybasil has joined #crystal-lang
<asterite>
So you like his idea?
<jhass>
not sure, I think the current model could work out
<jhass>
I'd rather like to see any argument to be passable as keyword arg
<asterite>
Maybe me too, though that'll make all names be part of the API
<jhass>
as I wrote, since they're also automagically part of the docs, that's not necessarily a bad thing
ylluminate has quit [Quit: Leaving.]
<asterite>
Maybe we could have `def foo(a=, b=0); end;` and that'll mean you have to pass "a" as a keyword argument
<asterite>
so you make that choice explicit (although when you use default args you don't really have a choice)
ylluminate has joined #crystal-lang
<asterite>
so in a way I like his proposal, but adding more syntax is what worries me
<jhass>
meh, I think that would be the least favorable variant, being just inconsistent
<jhass>
so while I see that argument, I actually don't think it's particularly strong
<jhass>
I did run across ruby gems with sparse docs and bad argument names in the past
ylluminate has quit [Client Quit]
<jhass>
having a cult in the community about being considerate in choosing your argument names is something I'd welcome
ylluminate has joined #crystal-lang
ylluminate has quit [Client Quit]
<asterite>
So you'd leave things as they are right now, but you'd also allow using keyword arguments for any argument?
ylluminate has joined #crystal-lang
<jhass>
yes, I'd try that at least for until close to 1.0
<jhass>
I don't think it's working out particular badly so far
<jhass>
and I actually like that there's a single unified concept for passing arguments
<jhass>
ruby couldn't do something like that since it'd break like all ruby code in existence
<jhass>
which is maybe a general observation where we should be careful in following it btw, all syntax introduced for 2.0 is with compatibility in mind, not the best possible syntax
<jhass>
*for 2.0 and later
<jhass>
well, 1.9 and later actually
<asterite>
Yes, not keeping backwards compatibility after you have a lot of code in the wild is the worse decision
<BlaXpirit>
btw i think python 3 has like the best possible handling of function arguments
<sfcgeorge>
Ah I was wondering about Crystal getting more advanced args. I'm familiar with all of Ruby 2.1's various args.
BlaXpirit has quit [Client Quit]
<asterite>
I think BlaXpirit might have abandoned us in favor of python 3 :-(
<sfcgeorge>
Hah!
<asterite>
I wanted to ask him about python 3. I thought it was similar to ruby, with those *args and **args
<sfcgeorge>
Well I like in Python that any arg can be a named arg, that's kinda nice. But I also like Ruby's splats and doublesplat (that seems less well known)
<kumpelblase2>
he was talking about python, not crystal I think
<sfcgeorge>
no not assigning locals, calling the method in python :)
<jhass>
oh, okay, ignore me
<sfcgeorge>
The point is that a method doesn't have to be defined as having named parameters as in Crystby. Every positional parameter can be used as a named one, or not.
dbackeus has quit [Ping timeout: 252 seconds]
<sfcgeorge>
I'm not sure what the benefits of each way are. Ruby is certainly complicated with: positional args, default positional args, splats, named args, default named args, double splats. And which order and combination you're allowed is only knowable by trial and error. So Python is certainly simpler there.
<jhass>
yeah totally
<jhass>
I didn't realize python already allows that
<jhass>
that might make a good case for refuting #1064 :P
elia has joined #crystal-lang
<sfcgeorge>
Yep. foo(1, 2) is same as foo(baz=2, bar=1) which in Rubal could look foo(1, 2) foo(baz: 2, bar: 1)
kumpelblase2 has quit [Quit: Leaving...]
<sfcgeorge>
I was wondering about basically this issue. Crystal has diverged from Ruby here, I guess more like Python. Nice to hear the reason against : is that's already used for type restriction.
<asterite>
It's funny that on the profile of wconrad (the one that fired the discussion) its website is yagni.com
<asterite>
which... doesn't work
<sfcgeorge>
You aren't gonna need it. Get it ;) Maybe it's not supposed to work :D
<crystal-gh>
[crystal] asterite pushed 2 new commits to master: http://git.io/vOJhg
<crystal-gh>
crystal/master 055ec8b Ary Borenszweig: Enabled a pending spec
<crystal-gh>
crystal/master bcc2831 Ary Borenszweig: Fixed #1062: "read before definition" when argument used as default also has a default
<asterite>
sfcgeorge: exactly my thoughts! :)
<sfcgeorge>
btw asterite thank you for working on Crystal, it's beautiful. Just what I've dreamed of, a faster Rubyish language. Donated as soon as I saw the campaign :)
<jhass>
well, whois for yagni.com has it actually regged to him ;)
<trapped_>
when crosscompiling to win32: crystal build --target "MINGW32_NT-6.1 i686" --target "x86_64-unknown-win32-unknown" src/app.cr
<asterite>
ylluminate: another issue is that hashes are used a lot as a quick replacement of proper types. They are also used for keyword arguments. Porting that to crystal won't happen, or at least I see it very hard to do
<asterite>
On the other hand, Ruby can be made much faster. If v8 is fast, I don't see why ruby couldn't do it
<sfcgeorg_>
The experimental jruby-9000-dev-truffle-graal looks insanely faster on that benchmark.
sfcgeorg_ is now known as sfcgeorge
<sfcgeorge>
I was initially disappointed that Crystal isn't a fast Ruby. But Ruby has a lot of weirdness that I love sometimes, but it's nice to have an alternative for certain projects where speed and simplicity are more important. Plus Crystal adds wonderful macros. I feel they both have a place anyway.
<jhass>
exactly, crystal it's its own language and you won't ever have a "compiled" ruby without embedding a runtime into the binary you generate
<jhass>
*is
<jhass>
I recall there's actually a project that does so, but can't find it
<trapped_>
what is the omit_null option for JSON mappings supposed to do
<asterite>
trapped_: if you say `nilable: true` in a json mapping, when you convert that object to json and the property is nil, "null" isn't emited for that property
havenwood has quit [Ping timeout: 246 seconds]
<asterite>
but if you say `emit_null: true`, then "null" will be emited
<asterite>
I need to document that JSON module...
blue_deref has quit [Quit: bbn]
<trapped_>
would the whole line for that property get omitted
<jhass>
yes
<jhass>
>> require "json"; record Foo, foo do json_mapping({foo: {type: String, nilable: true}}); end; Foo.new(nil).to_json
<jhass>
asterite: I was wondering if json_mapping should also generate an initializer taking all the attributes. Would also play really nice with the required keyword args idea then
<asterite>
It's true. Nilable properties could be left at the end with a default nil value
<sfcgeorge>
Do we have `blank?` method on nil, Sring etc? Like in ActiveSupport.
<jhass>
nope
<jhass>
and I never needed it outside webapps in Ruby
<sfcgeorge>
Is it something that might get added, or are there reasons against?
<jhass>
I don't like it too much, it has such a loose contract
<jhass>
what's a blank value feels quite application dependent actually
<sfcgeorge>
Hmm. It's useful for when nil or empty string can both be treated the same. But I guess with a strictly typed language you won't get that case much, unless it's a union.
<jhass>
yeah, if you code in crystal for a while, you'll learn to avoid passing nil around too much anyway
<jhass>
which is a good takeaway to ruby too btw
<sfcgeorge>
Yes I know best practice is usually to avoid that. I still like the andand gem on occasion, even though it's frowned uppon.
<jhass>
ugh
<jhass>
:P
<jhass>
they should make it a refinement and yank all other versions :P
<sfcgeorge>
;) I have a CS degree so I should know better, but still sometimes I like to think I know best and beat the system into doing what I want.
<jhass>
just drop class NilClass; def !; [true, false, 42].sample; end; end; into your projects then
<sfcgeorge>
Ahaha, yes why not. It could be a drinking game along side a bash script to kill random PIDs