asterite changed the topic of #crystal-lang to: #crystal-lang The Crystal programming language | http://crystal-lang.org | Crystal 0.6.1 | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/manastech/crystal - Docs: http://crystal-lang.org/docs/ - API: http://crystal-lang.org/api/ - Logs: http://irclog.whitequark.org/crystal-lang
c355E3B has quit [Quit: Leaving]
<Lewix> just switch to clojure guys
<Lewix> problem solved
<jhass> which problem?
<a5i> or will Crystal support Async/wait?
<jhass> asterite is pretty open to including stuff into stdlib, so if you do a nice PR...
<Lewix> jhass: Can you provide me with an ABC of the project -> crystal is the language, and the compiler was built with crystal? Where did you guys use C, How do all the parts fit together. Let's say I want to contribute, where do we start
<jhass> Crystal was bootstrapped in Ruby using an LLVM binding, that was pushed to the point where it could compile a compiler and a binding to LLVM in Crystal itself
<jhass> that's where we are now, Crystal is entirely written in itself
<jhass> which makes it quite easy to hack, stdlib is all Crystal code, just find something that's missing and send a PR or document some existing functionality (there are still tons of docs to write ;) )
waj has joined #crystal-lang
<Lewix> jhass: and crystal is ruby syntax
<jhass> Crystal also has inherited Rubys open class model, which means you can just extend stdlib as you work on a project of yours and later upstream the patches, which is what I usually do
<jhass> Ruby inspired syntax, it's its own language after all
<jhass> don't expect to be able to just run Ruby code
waj has quit [Client Quit]
<Lewix> jhass: and it's as fast as C?
wanderer_ has quit [Ping timeout: 246 seconds]
<jhass> for many usecases, yes
<jhass> it comes with a GC though, so there's that
<a5i> isnt it going to be removed ?
<jhass> no
<a5i> THen whats the temporary part of the GC status ?
<jhass> the specific implementation
<jhass> though I probably should ask asterite to remove the temporary note, it's there for over two years now :P
<a5i> lol
<a5i> Crystal needs a more pimped website design like Nim has
<jhass> PR is welcome, I'm sure ;)
<jhass> there's only so much time and so many people ;)
<Lewix> jhass: hmm I'm really curious about it, it needs three more years..
<jhass> mh, tricky
<jhass> yes, it probably needs about that time to be useful in production
<Lewix> but bravo
<jhass> but, it needs that time with an active and growing community that builds up an ecosystem
<Lewix> I really love where it's going
<a5i> 3 years?
<a5i> nah, prolly shorter
<jhass> so it's the right time to be enthusiastic about it and to seek ways to contribute to that community if you want the language to succeed
<Lewix> unfortunately it's a bad timing for me. I just started diving deep into clojure
Lewix has left #crystal-lang [#crystal-lang]
Lewix has joined #crystal-lang
<Lewix> jhass: how did you guys compare the speed of execution with other languages
<jhass> I never really did personally, there are some microbenchmarks here and there
<Lewix> jhass: i think that's an important phase to sell the language for what it is
<Lewix> jhass: the selling point is "fast" so prove it guys
<Lewix> ^^
<jhass> it compiles the 33kloc of the compiler in about 10-30 seconds, depending on your machine. How's that? :P
<ckreon> hey all, I'm brand new, trying to compile the red_black_trees.cr example file
<ckreon> but it gives an error
<ckreon> ./red_black_tree.cr:334: undefined method 'new' for Random:Class
<jhass> ckreon: ah yes, that was already updated to the changes in head
<ckreon> i literally copy pasted out of the github repo
<ckreon> so it should be latest
<jhass> yes, that's the issue :P
<ckreon> unless the default isn't the latest branch
<jhass> either pick the version tagged with 0.6.1 or clone the entire repo and compile the compiler
<ckreon> jesus
Lewix has quit [Remote host closed the connection]
<jhass> ah, nvm, actually the 0.6.1 version is broken too
<ckreon> ok cool, found the 0.6.1 version, thanks jhass
<ckreon> oh
<ckreon> ok
<ckreon> haha
<jhass> the language is still under quite heavy development ;)
<ckreon> well maybe a different example then
<ckreon> i'll play around
<jhass> yeah
<jhass> 2048 should still work^^
<jhass> or how about some tetris?: https://github.com/weskinner/crystal-tetris ;D
Lewix has joined #crystal-lang
<ckreon> meteor compiled :D
<ckreon> oh cool, will check those as well
<a5i> wait what
<a5i> there's a 2048 game written in Crystal ?
<jhass> yup, in the samples
<Lewix> ahha
<Lewix> 2048 as in year 2048?
<jhass> no
asterite has joined #crystal-lang
<asterite> In fact to try the red_black_tree.cr sample you can clone the repo, stand there and use bin/crystal instead of crystal: that will use the checked out standard library instead of the one that comes in your installation
<Lewix> i think you should find a niche for cystal and focus on it
<asterite> Yes, we think about that many times. @waj for example suggested we could do something like logstash, for example
<ckreon> thanks for help all
ckreon has quit [Quit: Page closed]
<asterite> Or a small web framework... the thing is, it takes a lot of time and effort, plus we still have to take care and "finish" the language
<asterite> So my guess is that that will eventually happen, but not by us
<jhass> yes, I think building up and supporting a community is actually more important at this point
<a5i> jhass, which samples?
<Lewix> i would help is its as fast as it boast and if we intend to include functional languages features
<Lewix> and not strictly OOP
<a5i> thanks
<asterite> There are functional features, like in Ruby
<asterite> >> [1, 2, 3].map { |x| x + 1 }
<DeBot> asterite: [2, 3, 4]
<a5i> err, is that only for linux GUI's ?
<a5i> @ jhass
<jhass> a5i: the 2048 is for your terminal, if you mean that
<a5i> oh thanks god
<Lewix> asterite: i think it would be so nice if it was a immutable version of ruby
<asterite> I think you can only get that far with immutability in terms of performance
<a5i> That's honestly sick...
<a5i> what does --release exactly do?
<jhass> turn on the LLVM optimizer
asterite has quit [Ping timeout: 246 seconds]
<crystal-gh> [crystal] asterite pushed 3 new commits to master: http://git.io/j5YG
<crystal-gh> crystal/master 5b9ea32 Ary Borenszweig: Fixed more cases of "void value expression". Fixes #507
<crystal-gh> crystal/master 535c4c4 Ary Borenszweig: Fixed #504: wrong codegen for function pointer of lib fun
<crystal-gh> crystal/master f28e41c Ary Borenszweig: Allow getting function pointer to lib fun without having to specify the types
<a5i> thats new right
<travis-ci> manastech/crystal#2177 (master - f28e41c : Ary Borenszweig): The build was fixed.
<a5i> ?!
<jhass> first is commits to the repo, second is the result from CI (from running the tests)
ponga has joined #crystal-lang
<a5i> is that sudoku example the fastest sudoku solver implmenation ?
* jhass shrugs
<a5i> how would I declare an array in crystal with Array.new(324) { [] }
<jhass> >> Array.new(5) { [] of String }
<DeBot> jhass: [[], [], [], [], []]
bigbugz has joined #crystal-lang
bigbugz has quit [Client Quit]
Cassyblanca has joined #crystal-lang
<a5i> >> ok = [nil, *1..9]; ok
<DeBot> a5i: Syntax error in eval:3: unterminated array literal
<a5i> huh ?
<a5i> jhass ?
Lewix has quit [Remote host closed the connection]
<jhass> a5i: splats are not as omnipresent as in ruby yet
<a5i> ah ok
shama has quit [Remote host closed the connection]
mah has joined #crystal-lang
ponga has quit [Remote host closed the connection]
ponga has joined #crystal-lang
shama has joined #crystal-lang
mah has quit [Quit: Page closed]
waj has joined #crystal-lang
ponga has quit [Quit: Leaving...]
ponga has joined #crystal-lang
harisamin has joined #crystal-lang
bcardiff has joined #crystal-lang
shama has quit [Quit: (╯°□°)╯︵ɐɯɐɥs]
harisamin has quit []
<Cassyblanca> Do github project dependencies have a means of specifying a branch or commit to use?
leafybasil has quit [Remote host closed the connection]
leafybasil has joined #crystal-lang
bcardiff has quit [Ping timeout: 245 seconds]
sandelius has joined #crystal-lang
leafybasil has quit [Ping timeout: 244 seconds]
bcardiff has joined #crystal-lang
waj has quit [Quit: Leaving.]
bcardiff has quit [Quit: Leaving.]
Ven has joined #crystal-lang
sandelius has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
sandelius has joined #crystal-lang
<sandelius> After a good night sleep I'm still excited about this project.
canhtak has joined #crystal-lang
canhtak has quit [Quit: canhtak]
canhtak has joined #crystal-lang
<jhass> Cassyblanca: I don't think so, sounds like a fun contribution! You can find the sources for that stuff here: https://github.com/manastech/crystal/tree/master/src/crystal/project
canhtak has quit [Quit: canhtak]
canhtak has joined #crystal-lang
tmoore has quit [Quit: Connection closed for inactivity]
sandelius has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
canhtak has quit [Quit: canhtak]
canhtak has joined #crystal-lang
canhtak has quit [Client Quit]
canhtak has joined #crystal-lang
sadin has quit [Remote host closed the connection]
havenwood has quit [Remote host closed the connection]
Ven has quit [Read error: Connection reset by peer]
Ven has joined #crystal-lang
sandelius has joined #crystal-lang
Ven has quit [Ping timeout: 244 seconds]
Ven has joined #crystal-lang
canhtak has quit [Quit: canhtak]
sandelius has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
leafybasil has joined #crystal-lang
leafybasil has quit [Remote host closed the connection]
leafybasil has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
sandelius has joined #crystal-lang
sadin has joined #crystal-lang
Ven has joined #crystal-lang
sadin has quit [Ping timeout: 245 seconds]
canhtak has joined #crystal-lang
sadin has joined #crystal-lang
sadin has quit [Remote host closed the connection]
asterite has joined #crystal-lang
sadin has joined #crystal-lang
sadin has quit [Remote host closed the connection]
asterite has quit [Ping timeout: 246 seconds]
sadin has joined #crystal-lang
sadin has quit [Remote host closed the connection]
asterite has joined #crystal-lang
<asterite> jhass: are you Mr.Yeah?
<jhass> no?
<jhass> Who's that?
<asterite> Ah, never mind... someone who comments on the site and google groups
asterite has quit [Client Quit]
bcardiff has joined #crystal-lang
bcardiff has quit [Quit: Leaving.]
sadin has joined #crystal-lang
wanderer has joined #crystal-lang
wanderer is now known as wanderer_
<wanderer_> jhass: hi, when you print ansi color codes to a terminal it gets translated to color, but what happens if you redirect stdout into a file for example? do you get the \e[ in plaintext
<jhass> >> "\e[".bytes
<DeBot> jhass: [27, 91]
asterite has joined #crystal-lang
<jhass> it's bytes, those bytes are written to your file, how they're represented depends on how you view the file
<asterite> wanderer_: yes, but we could check if the IO is a tty and don't use colors there :)
<jhass> nah, if they call colorize on a string they want the code
<jhass> where that string is sent shouldn't matter
<wanderer_> yes, that's the thing, when using it with a string
<jhass> I'd agree if it would be IO#puts_red or whatever
<jhass> but silently stripping data is a very bad idea
<wanderer_> I'm atm thinking about how to port it
<jhass> don't
<jhass> if you target outputs that don't support ANSI codes, don't use ANSI codes
<jhass> don't try to be smarter than the programmer
<wanderer_> so when a program on linux uses colors and you invoke `./bla > 1.txt` I wonder if the color codes are plainly sent to the file
<jhass> they are
<jhass> as said, it's just bytes
<jhass> it's the terminal output code that interprets them
asterite has quit [Client Quit]
<wanderer_> jhass: why not? you check with isatty() whether it's a console on windows. if not, you emit the color codes, if not you strip them
<jhass> "20"? okay, let's render a space character, "27, 91, something"? okay, let's make that red
<wanderer_> *last "if not" is wrong
<jhass> what happens if I'm writing arbitrary data and those bytes happen to be in there?
<wanderer_> I'm only speaking in regards to colorize
<jhass> colorize is in Sting, it doesn't know where the string is written to
<wanderer_> if you happen to use those escape in a regular puts, then that's what gets written
<wanderer_> it's argument is io so you could use io.tty?
<wanderer_> if goes directly to stdout, then it should be colored
<jhass> maybe I want to write them to a socket and the remote is displaying what I write in a terminal that should render the codes?
<wanderer_> well, this will fail
<wanderer_> if the receiver is a win terminal
<wanderer_> however, it's still as expected
<wanderer_> if you know what you're doing
<jhass> colorize adds ansi escape codes to a string, that's a simple, easy to understand contract
<wanderer_> on windows, however, it's annoying to not have any colors
<jhass> there's no reason to make that contract more complicated and taking away programmers flexibility and choice away at the same time
<wanderer_> so if you know "if I use colorize on stdout on my machine, it's in actual colors"
<wanderer_> I think it's more useful than harmful
<jhass> we can talk about adding a smarter IO#puts version that clearly has "may strip ANSI escape codes"
<jhass> in its contract
<jhass> however terminal detection is actually hard
<jhass> "That's only guessing!" in the fucking VIM code
<jhass> let's not take that burden
<wanderer_> windows has `isatty()`
<jhass> just because it's a tty doesn't mean it interprets ANSI color codes
<wanderer_> not on windows, yes
<wanderer_> if it's compiled for windows and isatty() returns true, then we use SetConsoleTextAttribute
<jhass> sorry, that idea is just wrong and doing it in String#colorize is even more so, I made my points, we're running in circles
<jhass> if you're uncertain whether your target supports ANSI codes, don't use them. Period.
<wanderer_> but it's not about the ansi codes
<wanderer_> crystal's colorize uses ansi color codes, but it's not specified, it's not named colorize_with_ansi_codes
asterite has joined #crystal-lang
bcardiff has joined #crystal-lang
<asterite> On second though, I think for windows we should just do nothing for colorize, and that's it
<wanderer_> I would rather expect color on my terminal than color codes
<jhass> asterite: I disagree, you're again taking away choice about functionality. While it's contrived, running a daemon on windows that sends stuff over the network or whatever to a recipient that has a tty/pty that supports ANSI codes is a valid usecase
<wanderer_> ruby docs contain specific side notes everywhere, so something like "on windows isatty() is used, when true then the ansi codes are stripped and colors are set with the winapi" on colorize would suffice
<jhass> more importantly methods shouldn't behave differently depending on platform, they may be implemented differently or even have different side effects, but their contract changing? no way
<wanderer_> if you use colorize on your own windows terminal, then ansi codes are of no use, except that they add clutter, noone would complain if they were turned to colors
<jhass> we can rename colorize to ansi_colorize or whatever, I would welcome that
<wanderer_> where is colorize's contract stated? I don't expect colorize to output ansi codes for me, I would rather expect it to output color
<asterite> Ok. The compiler uses colorize… it should have different paths for doing that depending on the os?
<jhass> what the current platform is or what the current terminal on stdout is is _none_ of String's business at all
<asterite> wanderer_: colorize is about ansi color codes, that's why I think we should rename it
<jhass> maybe String is the wrong place and it should be on IO
<wanderer_> AFAIR node emulates ansi codes on windows, too
<wanderer_> if you output them within node on windows, you don't get the actual codes, but color
<jhass> just because somebody else does it, doesn't make it well defined behavior
<asterite> jhass: maybe, probably
<wanderer_> ofc, but it has no real drawbacks
<jhass> complicated the contract of a stdlib method is a real drawback to me
<jhass> *complicating
<wanderer_> if you output color codes to a windows console, actually nobody would depend on having those ansi codes output in plain text on his console
<a5i> can this exact code be translated to Crystal? https://github.com/Ap0ph1s/ProjectEuler/blob/master/src/Problem1.rs
<jhass> a5i: pretty much, filter is select
<wanderer_> if you need the color codes themselves, you'd emit them to a string or file
<jhass> I give up, I'd just reiterate what I said already
<wanderer_> posix and windows are too different, you can't make the stdlib behave exactly the same
<asterite> Things always end up being harder than they should :( https://github.com/adoxa/ansicon
<wanderer_> there's no select on file descriptors, there's no fork, etc.
<a5i> jhass, Can I see one?
<wanderer_> paths behave differently
<jhass> a5i: see one what?
<a5i> an example with the ruby versions of the Rust impl
<wanderer_> ruby also has notes for OSes, that the functions could behave in a specific way
<wanderer_> as posix and windows are different from each other, that's actually necessary
<wanderer_> like on node.js, if I use colorize on a console, I'd expect it to use colors
<asterite> a5i: you can do this:
<asterite> >> require "iterator"; (0..1000).iterator.select { |x| (x % 3 == 0) || (x % 5 == 0) }.sum
<DeBot> asterite: 234168
<a5i> w0w
<asterite> That is, to avoid creating an intermediate array
<jhass> wanderer_: that's no reason to mix it all over the place, things like String, Hash, Array and so on are internal stuff, it changing behavior depending on platform is plain unexpected
<asterite> This works too, but creates an intermediate array
<jhass> wanderer_: it's a huge SRP violation
<asterite> >> (0..1000).select { |x| (x % 3 == 0) || (x % 5 == 0) }.sum
<DeBot> asterite: 234168
<asterite> But iterator support is very poor right now, and not very performant
<wanderer_> jhass: I understand your point, however, I say there are reasonable exceptions
<wanderer_> changing the way String, Array, etc. behave wouldn't be one of them
<jhass> I think I offered a more reasonable place for this particular exception
<wanderer_> changing colorize when output to a windows console, however, is
<jhass> god dammit
<jhass> String doesn't know where it's outputted to
<jhass> that's _none_ of it's business to know!
<wanderer_> it's a difference, however, whether it's used on a string or on stdout
<wanderer_> those that don't know color codes would use it on a string, get ansi codes on their windows console, would be like "wtf is that" check the docs, the docs say "on windows use it on stdout to get colors with winapi" they use that and are happy
<jhass> I never said to add it to IO too, I said if we attempt detection, we need to move colorize to IO
<wanderer_> those that know and expect them would use them as they like, however, when they output them to a windows console, they wouldn't mind having the ansi codes get translated to color
<wanderer_> colorize#surround has a io-parameter
<jhass> sigh
canhtak has quit [Quit: canhtak]
<wanderer_> ?
<jhass> get some OOP book please
<wanderer_> ye, I'm coming from C, I'm not that familiar with OOP
<asterite> Is color support really that important right now?
<wanderer_> but what exactly is wrong with using `io.tty?` in colorize#surround?
<asterite> What jhass says: if you are sending that colorized string via a socket into someone else's terminal, they would expect to get colors
<asterite> We could change windows terminal IO to detect ansi codes and colorize those… but I guess that would be slow
<a5i> anyway to make this more idiomatic?
<wanderer_> asterite: not if the docs state otherwise
<wanderer_> like said, I would make the docs say "if on windows and stdout", a socket is not stdout
<jhass> >> [1, 2, 3][-2] # a5i
<DeBot> jhass: 2
<jhass> a5i: also use each in the second loop
<jhass> or even select + sum
<asterite> I think it's better if we discuss colorize in a github issue
<jhass> though that'll be slightly slower
<a5i> I kinda need the fastest
<jhass> each is fine
asterite has quit [Quit: Leaving.]
wanderer_ has quit [Quit: Page closed]
canhtak has joined #crystal-lang
sadin has quit [Remote host closed the connection]
sadin has joined #crystal-lang
sadin has quit [Remote host closed the connection]
sandelius has quit [Quit: Textual IRC Client: www.textualapp.com]
<a5i> is there a difference in Math.sqrt in Crystal ?
<a5i> >> Math.sqrt(2)
<DeBot> a5i: 1.41421
<jhass> "a difference in"
<jhass> compared to is always the question
sadin has joined #crystal-lang
<a5i> jhass, this doesnt work but I'm using Math.sqrt correctly...
<jhass> "doesn't work"
<jhass> you can do better
<a5i> Yeah, I'm getting this error:
<jhass> >> Math.sqrt(1.0_f64)
<DeBot> jhass: 1
<jhass> >> 1.0_f64.sqrt
<DeBot> jhass: Error in line 3: undefined method 'sqrt' for Float64
<jhass> well, that trace is somewhat confusing I guess :P
<jhass> it shows where the Float64 came from
<a5i> omg im dumb...
<jhass> anyway, there's no #sqrt method
<jhass> actually having Number#sqrt would be nice I think
<jhass> I never really got Math
<a5i> jhass, removed the .sqrt got this
<jhass> ah, yeah, 0.6.1 is still Range(T) instead of Range(B, E)
<jhass> you can work around with 2.0..Math ...
<a5i> o
leonrd has joined #crystal-lang
leonrd has quit [Client Quit]
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<a5i> >> Prime.prime?(2)
<DeBot> a5i: Error in line 3: undefined constant Prime
<a5i> D:
<a5i> doesnt it exist?
<jhass> time to write one? ;)
Ven has joined #crystal-lang
sadin has quit []
sillesta has joined #crystal-lang
<a5i> uh huh
<a5i> You can can pull PRs to help translate the Rust PE problems to Crystal https://github.com/Ap0ph1s/ProjectEuler
<jhass> nah, I find PE boring
Ven has quit [Ping timeout: 248 seconds]
shama has joined #crystal-lang
ponga has quit [Quit: Connection closed for inactivity]
havenwood has joined #crystal-lang
canhtak has quit [Quit: canhtak]
* a5i yawns
shadeslayer has quit [Ping timeout: 264 seconds]
shadeslayer has joined #crystal-lang
havenn has joined #crystal-lang
havenwood has quit [Ping timeout: 256 seconds]
c355E3B has joined #crystal-lang
shama has quit [Ping timeout: 256 seconds]
sandelius has joined #crystal-lang
leafybas_ has joined #crystal-lang
leafybasil has quit [Ping timeout: 252 seconds]
leafybas_ has quit [Ping timeout: 256 seconds]
c355E3B has quit [Ping timeout: 272 seconds]
sandelius has quit [Quit: Textual IRC Client: www.textualapp.com]
leafybasil has joined #crystal-lang
shama has joined #crystal-lang
asterite has joined #crystal-lang
asterite has quit [Client Quit]
bcardiff1 has joined #crystal-lang
Cassy|Work has joined #crystal-lang
weskinner_work has joined #crystal-lang
bcardiff has quit [Ping timeout: 250 seconds]
<weskinner_work> everyone been doing alright?
colorisco has joined #crystal-lang
colorisco has left #crystal-lang [#crystal-lang]
bcardiff1 has quit [Quit: Leaving.]
Cassy|Work has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
Cassybla_ has joined #crystal-lang
Cassybla_ is now known as Cassy|Work
a5i has quit [Quit: Connection closed for inactivity]
havenn is now known as havenwood
bcardiff has joined #crystal-lang
Cassy|Work has quit [Quit: Textual IRC Client: www.textualapp.com]
Cassybla_ has joined #crystal-lang
Cassybla_ is now known as Cassy|Work
a5i has joined #crystal-lang
<a5i> Hello
weskinner_work has quit [Ping timeout: 272 seconds]
weskinner_work has joined #crystal-lang
weskinner_work has quit [Ping timeout: 255 seconds]
sillesta has quit [Ping timeout: 255 seconds]
bcardiff has quit [Quit: Leaving.]
Cassy|Work has quit [Quit: Textual IRC Client: www.textualapp.com]