Kug3lis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Disrecollection has joined #crystal-lang
snsei has joined #crystal-lang
rocky has joined #crystal-lang
<Disrecollection>
I tried to "include FileUtils" in a program but the compiler says "undefined constant" ?
<FromGitter>
<elorest> We should use https://ace.c9.io/ for crystal play and play.crystallang.org so that indenting will work better and we can use vim mode :)
pduncan has quit [Ping timeout: 255 seconds]
Disrecollection has quit [Ping timeout: 260 seconds]
snsei has quit [Remote host closed the connection]
Disrecollection has joined #crystal-lang
<Disrecollection>
Huh.
<Disrecollection>
Just had weird rc.
A124 has quit [Quit: '']
<Disrecollection>
So I built a program using the release flag. How do I run that prog from the console(so I can give it the inputs it asks for) ?
A124 has joined #crystal-lang
<Disrecollection>
running xubuntu
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter>
<bararchy> ./program
<FromGitter>
<bararchy> ./program arts
<FromGitter>
<bararchy> ./program args1 args2
<FromGitter>
<bararchy> Etc..
rohitpaulk has joined #crystal-lang
Disrecollection has quit [Quit: Leaving.]
bzb_hh has joined #crystal-lang
Disrecollection has joined #crystal-lang
bzb_hh has quit [Client Quit]
rohitpaulk has quit [Ping timeout: 246 seconds]
early has quit [Quit: Leaving]
early has joined #crystal-lang
hightower3 has joined #crystal-lang
lacour has quit [Quit: Leaving]
mark_66 has joined #crystal-lang
hightower2 has quit [Ping timeout: 246 seconds]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 255 seconds]
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 268 seconds]
Raimondii is now known as Raimondi
mark_66 has quit [Quit: Leaving.]
mark_66 has joined #crystal-lang
mark_66 has quit [Quit: Leaving.]
mark_66 has joined #crystal-lang
<hightower3>
Disrecollection, "require" instead of "include"?
Kug3lis has joined #crystal-lang
rohitpaulk has joined #crystal-lang
vikaton has quit [Quit: Connection closed for inactivity]
Kug3lis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter>
<sdogruyol> hey all
<hightower3>
z0
<hightower3>
y0*
rohitpaulk has joined #crystal-lang
hightower3 has quit [Ping timeout: 255 seconds]
hightower3 has joined #crystal-lang
hightower3 has quit [Ping timeout: 240 seconds]
<FromGitter>
<akzhan> hi )
splitty__ has joined #crystal-lang
splitty___ has joined #crystal-lang
splitty_ has quit [Ping timeout: 260 seconds]
splitty__ has quit [Ping timeout: 240 seconds]
Kug3lis has joined #crystal-lang
Kug3lis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Kug3lis has joined #crystal-lang
Kug3lis has quit [Client Quit]
<FromGitter>
<eliasjpr> 👋🏻
Raimondi has quit [Ping timeout: 260 seconds]
rohitpaulk has quit [Ping timeout: 246 seconds]
Kug3lis has joined #crystal-lang
jhass has quit [Remote host closed the connection]
asterite has quit [Remote host closed the connection]
asterite has joined #crystal-lang
jhass has joined #crystal-lang
hightower2 has joined #crystal-lang
Kug3lis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Kug3lis has joined #crystal-lang
Kug3lis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Raimondi has joined #crystal-lang
<thews>
anyone know the syntax to launch a system command using Process ? specifically I want to run it then be able to store the pid afterwards, I'm just not finding examples
asterite has quit [Quit: Bye]
jhass has quit [Quit: Bye]
asterite has joined #crystal-lang
Raimondi has quit [Ping timeout: 268 seconds]
jhass has joined #crystal-lang
rohitpaulk has joined #crystal-lang
asterite has quit [Quit: Bye]
jhass has quit [Client Quit]
asterite has joined #crystal-lang
<thews>
figured out how to run something and grab the output using IO::Memory, still don't 100% get how to get the pid
Kug3lis has joined #crystal-lang
jhass has joined #crystal-lang
<Papierkorb>
what do you need the PID for?
<Papierkorb>
There's Process#pid
rohitpaulk has quit [Ping timeout: 255 seconds]
<thews>
Papierkorb: I'm trying to write a little starter program to go through my OTA recorder that records stuff in raw and sometimes ffmpeg stalls looping on a corrupt frame over and over
asterite has quit [Ping timeout: 260 seconds]
<thews>
so I want to store the PID and look to see how long it's been running
<thews>
and kill it
<thews>
but also launch it from inside crystal
<Papierkorb>
Use `Process`, no need to mess with pids directly
jhass has quit [Ping timeout: 268 seconds]
<thews>
if I use process directly should I use spawn so that it's not in the main thread? I'm not sure how I would monitor it from process alone
<thews>
I'm fresh to crystal, and since it's relatively new I've had a hard time finding similar projects to learn from or some real world examples
<thews>
I'm just trying to sort of scaffold it up, but I'm hung up on that part right now
Kug3lis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter>
<bew> here, `test` is a `Process` instance, on which you can call several methods, ar store it somewhere, monitor the running process, etc
Kug3lis has joined #crystal-lang
rohitpaulk has joined #crystal-lang
asterite has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 260 seconds]
jhass has joined #crystal-lang
LastWhisper____ has joined #crystal-lang
Kug3lis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<crystal-gh>
[crystal] straight-shoota opened pull request #4535: Fix negative digit precision for `Number#round` (master...jm-number-round) https://git.io/vHMLF
pduncan has joined #crystal-lang
pduncan has quit [Read error: Connection reset by peer]
<FromGitter>
<codenoid> what happend with crystal docs site
<FromGitter>
<molovo> @codenoid Working fine for me
snsei has quit [Remote host closed the connection]
hightower6 has joined #crystal-lang
<hightower6>
Hey, is there something like Netty available for Crystal? Or a beginning of such project?
<FromGitter>
<sdogruyol> isnt netty an async server?
<FromGitter>
<bew> Idk, and I'm not sure it's needed, as crystal is already full asynchronous, and the stdlib is quite good in network regards and stuff
<RX14>
hightower6, what problem are you trying to solve using netty?
<hightower6>
It abstracts all the low-level details of the socket access as well as provides uniform interface to multiple transports/protocols with minimal or no changes needed in the code based on it
<RX14>
how can it provide a uniform interface to multiple protocols if they have different semantics?
<FromGitter>
<fridgerator> like mqtt?
<hightower6>
Beats me, but it does :)
<crystal-gh>
[crystal] konovod opened pull request #4536: Adds PCG32 random generator, makes it default (master...rng) https://git.io/vHMg0
<RX14>
sounds like too much abstraction to me
<RX14>
any byte stream can be represented using an IO in crystal
<RX14>
and that's in the stdlib
<RX14>
working with IO is easy in crystal
<hightower6>
cool
<RX14>
we tend not to get too abstract like netty
<RX14>
i'd suggest trying without any such library first
<hightower6>
Will do
<FromGitter>
<fridgerator> hightower, like from police academy?
<hightower6>
No, unrelated to it :)
<FromGitter>
<fridgerator> lol ok
<hightower6>
Are there any particular helpers for using epoll, or I just use it using the C interface?
<RX14>
all IO is async by default in crystal
<RX14>
have you used go?
<hightower6>
no, coming from a Ruby background
<hightower6>
I know there's a concept of channels like Go has
<RX14>
basically you write linear blocking code in crystal
<hightower6>
Help me put that into perspective - I still do need to use epoll? Or you mean crystal uses epoll in the background on Linux?
<RX14>
no need to even think about async IO
<FromGitter>
<bew> it's async by default, no need to worry about it
<RX14>
just treat your IO like it's blocking and spawn{} as Thread.new
<RX14>
and you'll be fast
<RX14>
HTTP::Server gets 100k requests per second by doing just that
<RX14>
and it doesn't even parse HTTP efficiently lol
<hightower6>
Although I should use fibers instead of threads, right?
<RX14>
spawn{} is fibers
<RX14>
but you can mostly treat them as threads
<RX14>
basically you can write the dumbest, blocking, easiest to write IO code and it'll perform better than nodejs by a lot
<hightower6>
Oh I understand your comment, you meant I can use "spawn{}" as a fast alternative to what would otherwise be "Thread.new{}"
<hightower6>
Ok
<RX14>
yeah we don't have Thread.new
<hightower6>
Right, right
<RX14>
it's segfaulted for about
<RX14>
2 years
<RX14>
and it's not been removed...
<hightower6>
Ok sounds pretty great
<RX14>
but yeah
<RX14>
ignore that :P
Kug3lis has joined #crystal-lang
<hightower6>
And, using fibers how am I gonna share some variables between them? Do I see it right in the documentation that basically I am best off using channels for that?
<FromGitter>
<bew> yes exactly
Kug3lis has quit [Ping timeout: 255 seconds]
Kug3lis has joined #crystal-lang
<hightower6>
So, if I want to have controlled access to say, a Hash, I create a channel, and a fiber reading from that channel and receiving (key,value) pairs, which it then saves into the Hash?
<FromGitter>
<bew> ah no sorry, channels are used to communicate between 2 fibers, not really to share a variable
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
<hightower6>
What would I do in the case of a variable shared between fibers, on which I need to have some sort of a lock/mutex?
<FromGitter>
<sdogruyol> @hightower6 for now you dont have to do anything
<FromGitter>
<sdogruyol> because Crystal is single threaded
<hightower6>
Right, but assuming I want to do it right instead of having to change/update code later. I could put some placeholders in place now even if they'd be no-op
<hightower6>
Seems I could just use Mutex (which would become thread-safe at some point, and my code would work as expected when it does?)
<FromGitter>
<sdogruyol> `spawn` and `Channel` are the way to do concurrent / parallel stuff
<FromGitter>
<sdogruyol> and they'll become multi-threaded
<hightower6>
Right, I mean for access to a shared variable
<hightower6>
Which bew told me I shouldn't use Channels for
<FromGitter>
<bew> I'm not sure about that though
<FromGitter>
<sdogruyol> not sure
<hightower6>
By the way, I just realized that in Crystal modules can be 'include'd into other modules, carrying over methods and instance vars as one would expect them
<hightower6>
(Unlike the behavior/implementation in Ruby_
<hightower6>
I see I can't call 'include' inside a 'def', nor do something like 'obj.include Module'. Is there a way to 'include' a module in runtime?
<FromGitter>
<bew> no, there is no way to change classes/module/struct hierarchy at runtime
<FromGitter>
<bew> crystal is not an interpreted language, the flexibility is at compile time, not at runtime
<hightower6>
muy bien
<FromGitter>
<bew> what are you trying to do?
<hightower6>
Just pondering about some other code I have in another language, which dynamically adds something to its inheritance chain
<hightower6>
or ancestors chain, rather
<hightower6>
it finds out which Module it needs to include (this happens in runtime), and then it includes it
<Papierkorb>
Crystal is not ruby. besides that you can't modify the program during runtime, many paradigms aren't applicable either
Kug3lis has joined #crystal-lang
Kug3lis has quit [Client Quit]
<hightower6>
sure, no worries, just figuring out to what extent the equivalents are supported
rocky has joined #crystal-lang
Disrecollection has quit [Quit: Leaving.]
<crystal-gh>
[crystal] llamicron opened pull request #4537: Fixes a very minor comment typo in file_utils (master...file_utils_typo_fix) https://git.io/vHMMq
<FromGitter>
<asterite> Mutex is for what you were discussing previously
greengriminal has quit [Quit: This computer has gone to sleep]
hightower5 has joined #crystal-lang
hightower6 has quit [Ping timeout: 260 seconds]
<hightower5>
asterite: for access to a shared variable you mean?
<Papierkorb>
apart from writing it on a { single line }? Nope
<FromGitter>
<bew> okay, thanks
Disrecollection has joined #crystal-lang
greengriminal has joined #crystal-lang
<hightower5>
Hey folks, help me a little bit please. I am trying to use the Benchmark module to test how many times per second I can .send and .receive a char on a channel
<hightower5>
How would I go about the structure of that benchmark?
<hightower5>
(from 2 fibers, one doing .receive;.send, the other doing .send;.receive)
<FromGitter>
<johnjansen> ~17 for the 1st, ~16 for the second ;-)
<RX14>
1M higher makes sense because the CPU cache is primed and the clock is turboed
<RX14>
@johnjansen using my gist? that's in million?
<hightower5>
Awesome, how do you get a guarantee that it's not going to just fill the channel while the other end didn't read it? Does a non-buffered channel have a length of 1?
<FromGitter>
<johnjansen> haha yes
<hightower5>
(RX14)
<RX14>
@johnjansen on osx?
<FromGitter>
<johnjansen> otherwise id come back tomorrow to tell you the answer ;-)
<RX14>
or linux
<FromGitter>
<johnjansen> osx
<RX14>
huh
<RX14>
maybe @sdogruyol needs to return his laptop
<RX14>
hightower5, channels are unbuffered by default
<RX14>
Channel#new gets you an unbuffered channel
<RX14>
Channel#new(Int32) gets you a buffered one
<hightower5>
RX14, right, right, I mean does unbuffered imply a length of 1?
<RX14>
yes
<hightower5>
ok got it, cool
<RX14>
it essentialy has a "value" variable
<RX14>
the buffered one uses a deque
<hightower5>
thanks for the example, changing locations and bb in an hour
hightower5 has quit [Remote host closed the connection]
<RX14>
so according to kcov crystal's specs don't have 100% converage
<RX14>
lol
<FromGitter>
<sdogruyol> @RX14 it's just OS X dont worry :P
<RX14>
how come @johnjansen got a much better result then
<RX14>
also on osx
<FromGitter>
<sdogruyol> he got 17M i got 16.3M
<FromGitter>
<sdogruyol> how's that much better?
<RX14>
i thought you said 3 million
<RX14>
i don't get edits from gitter
<FromGitter>
<johnjansen> im doing several things here so let me dump the results in case i read something wrong
<RX14>
remember
<FromGitter>
<sdogruyol> oh ok
<FromGitter>
<sdogruyol> anyway
<FromGitter>
<justinledwards> any special build flags or anything?
<FromGitter>
<sdogruyol> @hightower5 as you can see Crystal is really fast :P
<FromGitter>
<bew> the comments are working well then :D
<FromGitter>
<straight-shoota> hehe, good docs need to be covered! =)
<FromGitter>
<straight-shoota> I'm having issues with kcov since a few days... seems to run in an infinite loop. the executable itself runs and it does not seem to depend on the code, kcov can't even finish a simple hello world :/ dunno what's wrong there
<RX14>
weird
<Yxhuvud>
rx14: that is sort of how it could look if the macros keep the line number in whatever file that defined the macro, but the macro line numbers then get registered in the file that use them.
<RX14>
could be
greengriminal has quit [Quit: This computer has gone to sleep]
<FromGitter>
<straight-shoota> in callstacks macros locations are correct...
<FromGitter>
<straight-shoota> but procs have issues
<FromGitter>
<straight-shoota> or combination of macro and proc, I'm not sure
greengriminal has joined #crystal-lang
greengriminal has quit [Remote host closed the connection]
<crystal-gh>
[crystal] RX14 opened pull request #4538: Add codecov reporting to travis (master...feature/travis-coverage) https://git.io/vHMjm
<crystal-gh>
[crystal] asterite closed pull request #4537: Fixes a very minor comment typo in file_utils (master...file_utils_typo_fix) https://git.io/vHMMq
<FromGitter>
<bigtunacan> Probably a stupid question for all of the language implementation gurus; but when I look at the Crystal source code itself I feel overwhelmed and not sure where to start. While I have many years programming experience none of that has been writing a language; any pointers would be great.
<FromGitter>
<bew> you mean the stdlib or the compiler?
duckqlz has quit [Changing host]
duckqlz has joined #crystal-lang
LastWhisper____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<FromGitter>
<bew> that's what I thought, it's the "easy" part of crystal!
<Papierkorb>
bigtunacan, each compiler pretty much consists out of these phases: Reading source file(s) -> tokenizer (or scanner) -> parser -> semantic analysis (some simple ones don't need this) -> code generation
<Papierkorb>
bigtunacan, You can find all of these steps in the crystal compiler too. No idea if learning about compilers through the crystal compiler is a good idea, maybe for a simpler language.
<Papierkorb>
bigtunacan, that being said, here's a week-end project for you: Build a simple but properly working calculator. The user gives you some expression like `2+3*(4-5/2)`, then you 1) tokenize 2) parse 3) "code gen" (in this case, calculate the result) and print what it evaluates to
greengriminal has joined #crystal-lang
<Papierkorb>
bigtunacan, when all of that works, add variables. And after variables work, `if` and some kind of loop. Don't mess with LLVM, write it as a simple interpreter. With all that done, you not only created a turing-complete programming language, but also learnt how compilers work (expect for the code gen part). And then you should be perfectly fine understanding what's going on in the crystal compiler.
<FromGitter>
<bigtunacan> @Papierkorb i've done a few weekend projects and work through understanding computation. Currently I'm reading SI CP. Most of the stuff that I'm done with Crystal is web development or libraries, but I figured this is as good a time as any to start learning about how a real compiler works
<Papierkorb>
SICP?
greengriminal has quit [Quit: This computer has gone to sleep]
<FromGitter>
<bigtunacan> It's a book from MIT that goes through creating a lisp like language compiler use the lisp
<FromGitter>
<bew> cool *added to loong-to-read-list*
<FromGitter>
<bigtunacan> It's like I just can't get past theory and make the connection to a real practical compiler
greengriminal has quit [Quit: Leaving]
manveru has quit [Ping timeout: 365 seconds]
manveru_ has joined #crystal-lang
Raimondi has quit [Write error: Broken pipe]
Raimondi has joined #crystal-lang
<hightower2>
RX14, ran your Fiber benchmark test on my main computer here which is Linux ubuntu 4.8.0 on Intel i7-4790K CPU @ 4.00GHz
<hightower2>
got 29Mil /s
<hightower2>
Is there a module, similar/related to benchmark, that can be used for saving benchmark results and then comparing them to previous runs later?
plujon has quit [Remote host closed the connection]