<FromGitter>
<marksiemers> Can you chain map! - `arr.each_slice.map! ... `
<FromGitter>
<watzon> Nope haha. Tried that but it doesn't work. `map!` isn't available for whatever reason, and `arr = arr.each_slice.map` doesn't work either
<FromGitter>
<marksiemers> `each_slice` probably returns something that isn't enumerable
codenoid has joined #crystal-lang
<FromGitter>
<marksiemers> Just do it the old-fashioned way, and shovel onto a different array
<FromGitter>
<marksiemers> And if you need it to be destructive, than `old_array.replace(new_array)`
<FromGitter>
<marksiemers> Nm, you can't do it destructively - with integer as an example, you would have an `Array(Int32)` and you would be trying to make it an `Array(Array(Int32))` - so unless you create a union, it won't work
<FromGitter>
<marksiemers> Shoveling into a new array works though
codenoid has quit [Ping timeout: 260 seconds]
<FromGitter>
<watzon> Yeah that's what I'm having to do. And unfortunately I need a slice, so I have to create an array, push everything onto the array, then turn the array into a slice
<FromGitter>
<watzon> Such fun lol
qard has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
hightower3 has quit [Ping timeout: 240 seconds]
alex`` has joined #crystal-lang
duane has quit [Ping timeout: 260 seconds]
ephemera_ has quit [Quit: No Ping reply in 180 seconds.]
ephemera_ has joined #crystal-lang
dragonkh has joined #crystal-lang
dragonkh has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
dragonkh has joined #crystal-lang
OceannBoy has joined #crystal-lang
<OceannBoy>
Hello, what is the recommended way to build a crystal project? Make, Rake, a crystal Rake equivalent, up to the developer, or some other build tool?
edoput has quit [Ping timeout: 265 seconds]
davic has quit [Ping timeout: 265 seconds]
edoput has joined #crystal-lang
davic has joined #crystal-lang
illyohs has quit [Ping timeout: 240 seconds]
<FromGitter>
<drosehn> I often use `make`, just because that's what I'm used to. But crystal comes with it's own build-tool environment, assuming your project is all-crystal. So you can say `crystal init` to initialize a crystal project. I'm afraid I don't know the details, though.
dragonkh has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
dragonkh has joined #crystal-lang
dragonkh has quit [Client Quit]
mark_66 has joined #crystal-lang
hightower3 has joined #crystal-lang
<FromGitter>
<Qwerp-Derp> I had a look at #462, for including the splat operator in array literals. What was the outcome of that issue (mentioning @asterite since he closed the issue)?
<FromGitter>
<Qwerp-Derp> @faustinoaq Hmmm, I was thinking of a more "integrated" solution - i.e. a compiler for Crystal written in Java or C#, which could then make use of the native Java environment and things like Maven or Gradle much more easily. But this is obviously better than nothing.
<FromGitter>
<alehander42> you don't need to write the compiler in java/c# if you want to target them
<FromGitter>
<faustinoaq> @Qwerp-Derp Perhaps in the future crystal gains more interest for Java/Net developers 😅 Currently we have to focus on nice features like parallelism and windows support 😉
<FromGitter>
<Qwerp-Derp> @alehander42 Obviously, but what I'm saying is that it would be much easier for developers to work with these platforms if a more native solution was found
<FromGitter>
<Qwerp-Derp> @faustinoaq Those definitely come first, I'm excited about the speed at which progress is made on Crystal :D
<FromGitter>
<alehander42> yes, that's why one would just add a .net / jvm backend to an existing compiler
<FromGitter>
<Qwerp-Derp> Oh
<FromGitter>
<Qwerp-Derp> It's that simple? I don't know anything about porting stuff over to virtual machines
<FromGitter>
<Qwerp-Derp> Nice
<FromGitter>
<alehander42> they run some kind of bytecode, which is just another target for a compiler's backend: it can produce C code, assembly, LLVM opcode, JVM bytecode etc
<FromGitter>
<alehander42> of course usually you need more stuff: the language might depend on some backend specific assumptions, some builtin stuff should be probably rewritten, FFI is a big ?
<FromGitter>
<alehander42> interop with another languages
<FromGitter>
<alehander42> exactly, ^ java.cr is a good example, obviously people already work on that :D
dragonkh has joined #crystal-lang
dragonkh has quit [Client Quit]
<FromGitter>
<Qwerp-Derp> So as far as I can see, java.cr essentially includes a Java parser and transpiles Java files to Crystal?
<FromGitter>
<faustinoaq> @Qwerp-Derp yeah, using JNI ⏎ ⏎ > Generate Java bindings through the Java Native Interface (JNI) automatically from Java classes using the javap tool distributed with the JDK.
<hightower3>
Hey folks, someone here had an example of dynamically loading modules/plugins in runtime. Any recollections who/where that was?
<FromGitter>
<Qwerp-Derp> Wouldn't a more "longterm" solution be to do what @alehander42 said, and to have Crystal generate bytecode instead?
<FromGitter>
<Qwerp-Derp> Again, this issue isn't really that important right now for Crystal, and java.cr basically integrates the JVM and Crystal, but I'm curious on this subject
<FromGitter>
<faustinoaq> @Qwerp-Derp I think We don't know, Perhaps we can have some answers after crystal 1.0 😉
<FromGitter>
<Qwerp-Derp> Looking forward to that! :D
<FromGitter>
<Qwerp-Derp> I can feel that Crystal 1.0 is right around the corner
<FromGitter>
<faustinoaq> > someone here had an example of dynamically loading modules/plugins in runtime. Any recollections who/where that was? ⏎ ⏎ hightower3 I'm afraid that is not possible, although I tried this (https://github.com/faustinoaq/interactive-crystal) some time ago
<hightower3>
Oh yes, that was it! Hehe cool, didn't remember it was you :)
<FromGitter>
<faustinoaq> Yeah, I barely did some dynamic loading (mandel fractal in this case), Would be awesome if someone implements in crystal a dynamic load of GOL (game of life) like http://nullprogram.com/blog/2014/12/23/ did 😉
<FromGitter>
<faustinoaq> hightower3 ^
hightower3 has quit [Ping timeout: 248 seconds]
hightower3 has joined #crystal-lang
<livcd>
just saw techempower round 15 benchmarks. Crystal is in top5. Good job crystal.
<FromGitter>
<watzon> Most of the accepted answers for Ruby don't quite work in Crystal
<FromGitter>
<watzon> I guess `arr.each_slice(2).to_a.transpose.flatten`
jnyw has quit [Quit: WeeChat 2.0.1]
<FromGitter>
<watzon> Can someone explain to me why `2 ** 1024` is 0? Is the resulting number just too big or something?
<FromGitter>
<watzon> Because it should be 1.797693135×10³⁰⁸
<FromGitter>
<yxhuvud> What happens if you try to create that literal?
rohitpaulk has joined #crystal-lang
<FromGitter>
<r00ster91> when im executing this code ⏎ ⏎ ```puts "hello " \ ⏎ "world, " \ ⏎ "no newlines"``` ⏎ ⏎ then I get an " unknown token: '\r' " error. What should I do? Is it something with my file? My file is UTF-8 and I also already tried deleting the file and creating again. I still get this error [https://gitter.im/crystal-lang/crystal?at=5a71a5b736de78850cd184aa]
<FromGitter>
<straight-shoota> or `{% debug %}` in code
duane has joined #crystal-lang
<FromGitter>
<yxhuvud> or use an editor that has support for doing it for you.
rohitpaulk has quit [Ping timeout: 256 seconds]
<OceannBoy>
@drosehn Yes, I did previously look at that page, however it seems that it shows how to compile just one (1) file. I'll plan to continue using Make for now. Thanks for the reply
<hightower3>
straight-shoota: funny, whatever I run it with, it just prints help message
<FromGitter>
<drosehn> Note that you have to compile all of your crystal files if any of them change. You can't compile `main.cr` into `main.o`, and then link that with `*.o` files created from compiling other `*.cr` files.
<FromGitter>
<drosehn> ... or at least, I'm pretty sure that's true!
<FromGitter>
<drosehn> @r00ster91 -> I don't know if this is the problem, but I think you have to make sure there are no blanks after the `\` on those lines. The backslash has to be the last character on the line.
<FromGitter>
<r00ster91> hm ok will try
<OceannBoy>
@drosehn I'll take a closer look at that link. Thanks
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter>
<r00ster91> @drosehn its still happening.. really weird :/
rohitpaulk has joined #crystal-lang
cremes has quit [Quit: cremes]
<FromGitter>
<drosehn> I just tried your example and it worked for me. I even copied the three lines from your post here, pasted them into an empty file, and did a `crystal run long-hello.cr` on that file. And it worked fine: `hello world, no newlines`.
cremes has joined #crystal-lang
<hightower3>
@yxhuvud which editor would that be? VS?
<hightower3>
don't have much luck with crystal tool expand :)
<FromGitter>
<yxhuvud> emacs have support for it :)
rohitpaulk has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
dragonkh has joined #crystal-lang
dragonkh has quit [Client Quit]
dragonkh has joined #crystal-lang
dragonkh has quit [Client Quit]
<FromGitter>
<yxhuvud> (how I know? I wrote the support for it ;)
<hightower3>
;-)
rohitpaulk has quit [Ping timeout: 248 seconds]
mark_66 has quit [Remote host closed the connection]
<FromGitter>
<marksiemers> @r00ster91 - What operating system are you using? A `\r` seems like windows
illyohs has joined #crystal-lang
jokke has quit [Ping timeout: 240 seconds]
<FromGitter>
<ShriekBob> So, I forked and cloned crystal, I ran 'make verbose=1'
<FromGitter>
<ShriekBob> I left it overnight
<FromGitter>
<ShriekBob> nothing
jokke has joined #crystal-lang
<FromGitter>
<ShriekBob> I get that the compiler is trying to be a good unix app by being silent, but it's really not a great user experience when I have no idea if it's still compiling on not, some progress indicator would be *really* usefl
<Papierkorb>
How's your CPU load?
<FromGitter>
<ShriekBob> 1 CPU has been going flat out for 8 hours on an i9
<FromGitter>
<bew> Try `make stats=1`
<FromGitter>
<MrSorcus> Hi, stupid question. How to get `010001` from `65537` %-)
<FromGitter>
<ShriekBob> FYI, make stats=1 gives me the same thing. It's only ran for five minutes, but I get the CRYSTAL_CONFIG path line, then nothing
<FromGitter>
<ShriekBob> ...and I'm not sure if it's my machine or not (I assume so) but I have no idea how to diagnose
<FromGitter>
<bew> @MrSorcus 65537.to_s(2)
illyohs has quit [Remote host closed the connection]
<FromGitter>
<MrSorcus> @bew Very cool. Thanks.
alex`` has quit [Ping timeout: 256 seconds]
<FromGitter>
<MrSorcus> @bew Little question. What does mean `2` in `to_s` method? ⏎ https://crystal-lang.org/api/0.24.1/Int.html#to_s%28base%3AInt%2Cupcase%3ABool%3Dfalse%29-instance-method - here no any description :-(
<FromGitter>
<bew> It's the base
<FromGitter>
<bew> 2 is for base 2
<FromGitter>
<bew> Usually numbers irl are in base 10, you use 10 (0-9) to describe them
<FromGitter>
<bew> 10 digits*
duane has quit [Ping timeout: 248 seconds]
<FromGitter>
<bew> In base 2, there is only 2 digits: 0 & 1
<FromGitter>
<MrSorcus> Oh, i understand now. Cool. Thanks again 😄 👍
<FromGitter>
<bew> You're welcome ;)
<FromGitter>
<bew> The value doesn't change, only the 'string' representation change
<RX14>
has anyone thought about just turning off GC, and spawning a new process every time you run out of memory?
<RX14>
you could optimize it by keeping a "clean" process around to fork from
<RX14>
so you just wait for a child to die and then fork
<RX14>
and a bit of code to exit based on memory threshold when you're in the requrest loop so no requests get dropped
<RX14>
would be... interesting to implement
<RX14>
and interesting to benchmark
ua has quit [Ping timeout: 256 seconds]
duane has joined #crystal-lang
ua has joined #crystal-lang
qard has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
qard has joined #crystal-lang
<vegai>
"Implementing a kernel-assisted GC" heh?
<FromGitter>
<bararchy> RX14, sounds like a great way to have the OOM killer on your process
<FromGitter>
<bararchy> hahah
<RX14>
oh
<RX14>
wow
<RX14>
I don't even need to implement the OOM killer myself
<RX14>
I forgot, it's already there
<FromGitter>
<bararchy> yeha, kernal got a built in one
<vegai>
sounds like a good blog post for April 1st if nothing else
<FromGitter>
<bararchy> XD
<RX14>
no, i'm serious
<RX14>
although the kernel OOM killer is too slow
<FromGitter>
<bararchy> RX14 if you have a huge array, then reset it (a = [] of String) , would it automaticlly clean the memory? or would it need the GC ?
<RX14>
and it would interrupt requests
<RX14>
@bararchy ofc that needs the GC
<RX14>
a = [] of String is nowhere close to resetting it
<RX14>
all you're doing is switching out a reference
<RX14>
there could be many other references to the old array
<RX14>
I think you could create an allocator around this concept and never have to do an expensive fork() at all
<RX14>
just have an initial GC pool which is used for the startup
<RX14>
then you have a secondary pool which is "request memory"
<RX14>
every time you allocate over a threshold in that limit, AND you cann the GC.requestEnd or similar you'd just get the entire pool wiped and start from scratch
<RX14>
and it's ""safe"" since the pool would just be munmapped and mmapped to a different address
<vegai>
you could later add a "liberate" syscall for marking memory areas that the kernel could safely garbage collect early
<RX14>
so you'd get an immediate segfault every time if there was a pointer still lying around
duane has quit [Ping timeout: 260 seconds]
duane has joined #crystal-lang
dragonkh has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
<FromGitter>
<asterite> @ShriekBob If you only see the CRYSTAL_CONFIG_PATH line, then there's something wrong with your machine/setup. You should immediately see a "Parse" line follow by "Semantic (top level)" and others, because these take very little time. I guess you'll have to debug the makefile to know what's going on. Alternatively, just run "bin/crystal src/compiler/crystal.cr -s" and check if that prints something.
<FromGitter>
<ShriekBob> It didn't, it apepars like my mac is all kinds of weird
<FromGitter>
<ShriekBob> I do now have it compiling on WSL though, I need to make a pull request to the docs though, theres a bunch of dependencies that need to be instaleld that aren't in the docs
Liothen has quit [Quit: The Dogmatic Law of Shadowsong]
Liothen has joined #crystal-lang
Liothen has quit [Client Quit]
Liothen has joined #crystal-lang
Liothen has quit [Changing host]
Liothen has joined #crystal-lang
<hightower4>
Can someone help me figure out how do I need to use {% debug %} in code to supposedly dump expanded macro?
<FromGitter>
<asterite> like that, at the end of a macro definitino
<FromGitter>
<ShriekBob> yeah they're on there, I just wnated to change that heading to Ubuntu & Ubuntu on Windows or words to that effect
<FromGitter>
<ShriekBob> to make it more specific
<FromGitter>
<ShriekBob> also putting it in the crystal book, with the installation guide, because it mentioned you might need build essentials, but I'd add a note to the bottom that you might need to install a bunch fo other things too
<FromGitter>
<ShriekBob> Theres a few things I think would be beneficial to add to the docs for making it easier for noobs like me to contribute
dragonkh has joined #crystal-lang
moei has quit [Quit: Leaving...]
alex`` has quit [Ping timeout: 240 seconds]
alex`` has joined #crystal-lang
<hightower4>
I just figured an issue that might happen if one doesn't use fully qualified class/module names. A macro from a different shard was called, and it expanded into a relative class name (e.g. just "Clazz") which was also defined/resolvable in the original code. So there was a method which was accepting argument of type Clazz, but it was understood as the other, non-intended one.
<hightower4>
(if that description makes sense)
FromGitter has quit [Remote host closed the connection]
oprypin has quit [Quit: Bye]
FromGitter has joined #crystal-lang
oprypin has joined #crystal-lang
aroaminggeek has joined #crystal-lang
aroaminggeek has quit [Read error: Connection reset by peer]
<FromGitter>
<elorest> Is it possible to write to a file without closing the File/IO but still have the file exist if the program is killed?
dragonkh has quit [Ping timeout: 240 seconds]
aroaminggeek has joined #crystal-lang
edoput has quit [Ping timeout: 240 seconds]
davic has quit [Ping timeout: 240 seconds]
<hightower4>
@elorest I would think this is default behavior?
<hightower4>
(I tested it with a non-crystal program (opened the file, entered sleep), then killed the program with -9, and file remained on disk, as expected)
<FromGitter>
<ShriekBob> Quick check, does the compiler do incremental compilation?
edoput has joined #crystal-lang
davic has joined #crystal-lang
<FromGitter>
<elorest> <hightower4> Did you write content to it as well? That was my concern.
<FromGitter>
<elorest> I can just test this I just thought someone might know off the top of their head.
<hightower4>
@elorest yes, the content remains as long as you have flushed it before program was killed
<hightower4>
I knew it worked this way and I've tested it
<FromGitter>
<elorest> Flushed?
<hightower4>
flush() call
<hightower4>
I mean wrote out internal buffers. If you use a method which doesn't buffer, then it's written immediately