ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.24.2 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
<bmcginty> All, doing a test on the latest compiler, and getting `Module validation failed: Function return type does not match operand type of return inst!`.
<bmcginty> I'd like to go digging through the compiler myself and see if I can fix the issue, but I can't even tell what function is throwing this out. Obviously I can't emit llvm-ir before it's created, and when I did an inspect on the module, it printed everything, but without function names...which is less than helpful for seeing where in my code the issue is being created.
<bmcginty> I'm going to see if I can strip the parts that are at issue, but if not, anyone have suggestions on how to figure out what's going on?
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
Yxhuvud has joined #crystal-lang
<FromGitter> <j8r> But you have written tests, and in this case they will help you to find where the issues' is... don't you?
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
Yxhuvud has joined #crystal-lang
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
Yxhuvud has joined #crystal-lang
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
Yxhuvud has joined #crystal-lang
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
Yxhuvud has joined #crystal-lang
<bmcginty> j8r: Yes, but it only happened when things were nested a certainw ay, or if there was an extra if statement. Very odd.
<bmcginty> j8r: turns out I had a macro appending to an array, but the macro wasn't defining return types for each key it went through ended up like `a << @name\na << @value\na << @something_else\n`. still not sure why it happened, and I still can't strip the breaking bits into a single example, but it's fixed for now. :(
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
Yxhuvud has joined #crystal-lang
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
Yxhuvud has joined #crystal-lang
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
Yxhuvud has joined #crystal-lang
Nathanaelle has joined #crystal-lang
Nathanaelle has quit [Read error: Connection reset by peer]
Nathanaelle has joined #crystal-lang
Nathanaelle has quit [Ping timeout: 256 seconds]
<FromGitter> <faustinoaq> Interesting, the new atom text editor core is written in Rust https://github.com/atom/xray/
<FromGitter> <faustinoaq> lol https://github.com/kelseyhightower/nocode
<FromGitter> <bew> that's definitely useful x)
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
Yxhuvud has joined #crystal-lang
<FromGitter> <PlayLights_twitter> Like firefox
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
Yxhuvud has joined #crystal-lang
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
Yxhuvud has joined #crystal-lang
Nathanaelle has joined #crystal-lang
Nathanaelle has quit [Read error: Connection reset by peer]
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
Yxhuvud has joined #crystal-lang
<FromGitter> <sherjilozair> Hey guys, loving reading the crystal-lang book right now. So many good design decisions have been made here that I feel like writing a love letter to the developers. I'm going to work on game development using crystal and crSFML. Had a doubt about one of the syntax. What exactly is the behaviour of `break "something"`? The obvious case of a single loop is easy, but what about multiple loops, etc.?
Nathanaelle has joined #crystal-lang
<FromGitter> <Blacksmoke16> `break can also take a parameter which will then be the value that gets returned`
<FromGitter> <sherjilozair> @Blacksmoke16 Even in multiple loops?
<FromGitter> <Blacksmoke16> well it would just break and return a value from that specific loop it was called
<FromGitter> <Blacksmoke16> not break all loops afaik?
<FromGitter> <sherjilozair> Loops have return values? I thought they don't.
<FromGitter> <bew> Yeah in Crystal almost everything has a return value (may not be useful)
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/3xa9
<FromGitter> <Blacksmoke16> if you made it `break "foo"` it would return "foo" with typeof "String"
<FromGitter> <sherjilozair> Got it. It only returns "foo" for that loop, and other loops don't get broken. The presence of the function made me think the function also gets returned.
<FromGitter> <Blacksmoke16> yea afaik its akin to `return x` but for a loop vs a function
<FromGitter> <Blacksmoke16> where by default `return` would be nil type but if you return a value then its that value ofc
bmcginty has quit [Ping timeout: 255 seconds]
<FromGitter> <sherjilozair> Has anyone managed to static link a project in OSX? I can't seem to do that even for an empty project.
<FromGitter> <sherjilozair> Get this error: `ld: library not found for -lcrt0.o`
<FromGitter> <oprypin> no, nobody has
<FromGitter> <sherjilozair> Ouch. Is there a plan to make it possible to static link on OSX? I want to make games with CrSFML (thanks @oprypin for that btw), but without static linking it'd be pretty pointless since I won't be able to distribute.
<FromGitter> <faustinoaq> @sherjilozair Static linking on macOS is a bit different 😅
<FromGitter> <faustinoaq> In linux you need `.a` files available in the right place
<FromGitter> <faustinoaq> but in macOS I guess you need other settings 😅
<FromGitter> <sherjilozair> Do you know what these other settings are? I'll be happy to write the wiki on this, if I get this working.
<FromGitter> <bew> looks like it's not really supported officially on osx
<FromGitter> <sherjilozair> I see. So I guess it's safe to assume that a dynamically linked program would run fine on most macoses?
<FromGitter> <sherjilozair> And only static link for other OSes.
<FromGitter> <faustinoaq> @sherjilozair Yep
<FromGitter> <sherjilozair> Would dynamic linking require users to have crystal installed?
<FromGitter> <faustinoaq> no
<FromGitter> <sherjilozair> Oh okay. I wish this was documented somewhere better.
<FromGitter> <faustinoaq> I would recommend you to check dynamic dependencies by using `ldd mybinary`
<FromGitter> <faustinoaq> I guess crystal still needs some things like libevent, libpcre, and others libs that should come by default 😅
<FromGitter> <sherjilozair> That's still asking for a lot. Most non-coder users won't have libevent, libpcre, etc.
<FromGitter> <bew> "by default" => that depends on what you mean by "default" :P
<FromGitter> <sherjilozair> Is it possible to include as many libraries as possible in the binary and dynamically load others like `crt0`?
<FromGitter> <faustinoaq> Also be aware of those "external" libs you're using in your apps, like libyaml, libxml, database libs, openssl and other common used libs.
<FromGitter> <sherjilozair> How do other languages/engines solve this problem? This problem shouldn't be new to crystal.
<FromGitter> <faustinoaq> @sherjilozair First try to compile a simple program in crystal and try to execute it on other mac machine, and see what happens 😉
<FromGitter> <faustinoaq> Languages like Go has his own libc and all the "essential" libs developed by Go Team, so they can include all them in one executable. ⏎ ⏎ Crystal resuse most libraries like libc, libevent, libpcre, etc.
<FromGitter> <sherjilozair> So why not include them (even if they are not developed by Crystal team)?
<FromGitter> <faustinoaq> @sherjilozair Because those libraries are dynamic by default 😅
<FromGitter> <faustinoaq> You can try to compile "statically" by installing all `-dev` packages and ensure you have the right `.a` files
<FromGitter> <faustinoaq> Commonly static compilation is a "bad practice" on Linux world
<FromGitter> <faustinoaq> You should be able to compile dynamically and fix the dependencies by using `ldd myexecutable`
<FromGitter> <sherjilozair> You should be able to compile dynamically and fix the dependencies by using `ldd myexecutable`. Users won't do this though.
<FromGitter> <faustinoaq> Yeah, I know that
<FromGitter> <faustinoaq> That's why I use copy all required libs aside my app-binary, let me explain:
<FromGitter> <faustinoaq> @sherjilozair you can always copy those libs (`ldd myexecutable`) to a lib folder aside your app-binary and use `LD_LIBRARY_PATH=$(pwd)/lib ./app-executable`
<FromGitter> <sherjilozair> Interesting.
<FromGitter> <faustinoaq> Yeah, You can put that inside a shell script and execute it without any issue
<FromGitter> <sherjilozair> That's dirty. I love it. Thanks!
<FromGitter> <faustinoaq> Yeah, Finally you got a `lib` folder with your `app-executable` and a `app.sh` script to execute `LD_LIBRARY_PATH=`pwd`/lib ./app-executable`
<FromGitter> <faustinoaq> To get the libs for your `lib` folder you can use `ldd app-executable` or automate it using some script (https://gist.github.com/bcardiff/85ae47e66ff0df35a78697508fcb49af) like:
<FromGitter> <faustinoaq> ```code paste, see link```
<FromGitter> <faustinoaq> you can use `deps` folder as well, to avoid conflicts with "shards" `lib` directory
bmcginty has joined #crystal-lang
<FromGitter> <Jens0512> .
<FromGitter> <Jens0512> Oops
<FromGitter> <faustinoaq> @sherjilozair ^^ I just tried it for a simple console app and works pretty well 😉
<FromGitter> <Jens0512> @faustinoaq Next time you’ll list programming languages written in crystal, include
<FromGitter> <Jens0512> https://github.com/myst-lang/myst
<FromGitter> <Jens0512> :D
<FromGitter> <faustinoaq> @Jens0512 Yeah 👍
<FromGitter> <sherjilozair> @faustinoaq Nice. Except macos doesn't have ldd. Has otool isntead, so would need some modifcation.
<FromGitter> <sherjilozair> This is a great PoC though. Do you recommend this approach? Or is this only a hack?
<FromGitter> <sherjilozair> I'm thinking of creating a game framework (like love2d) which generates executables, so would require static linking. Would you recommend doing the above?
<FromGitter> <Jens0512> Static linking is experimental is it not? :/
<FromGitter> <Jens0512> (Currently)
<FromGitter> <faustinoaq> @sherjilozair I think you should use dynamic linking, because static linking is possible but not to easy to achieve ( you need the right dependencies in the right location, sometimes compiling them by yourself)
<FromGitter> <faustinoaq> > Do you recommend this approach? Or is this only a hack?
<FromGitter> <faustinoaq> I guess is kinda hack, but works pretty well
<FromGitter> <faustinoaq> You don't need to worry about libraries in the client, because you're already including all them in your `deps` folder, an using just that, so, no conflict with os libraries, just like a static compiled executable 😉
Nathanaelle has quit [Ping timeout: 256 seconds]
<FromGitter> <sherjilozair> How do you make the binaries loop for the dynamic libraries in the deps/libs folder?
<FromGitter> <sherjilozair> I did what you said, but the binary is still trying to search for the deps elsewhere. Says `Library not loaded: @rpath/libvoidcsfml-graphics.2.4.dylib`
<FromGitter> <sherjilozair> The binary still has old paths: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5add7a1b109bb04332ee200b]
Nathanaelle has joined #crystal-lang
<FromGitter> <faustinoaq> Oh, you need to compile it using `LIBRARY_PATH=$(pwd)/deps crystal build snakes.cr` (first copy the current libs dependencies to your `deps`folder in your project workspace)
<FromGitter> <faustinoaq> I just forgot that 😅
<FromGitter> <sherjilozair> I see, thanks. btw, is it possible to load dynamic libraries without mentioning them in the binary?
<FromGitter> <sherjilozair> i.e., have code load them from a known path, without telling the compiler about it.
<FromGitter> <faustinoaq> Well, I guess yes, then you need to specify them during compilation with `--link-flags`
<FromGitter> <faustinoaq> I mean, You can try first 😅 , sometimes you can be surprised of crystal capabilities
<FromGitter> <sherjilozair> nah I get `ld: library not found for -lvoidcsfml-graphics` when I use your command.
<FromGitter> <sherjilozair> i.e. `LIBRARY_PATH=$(pwd)/deps crystal build snakes.cr`
<FromGitter> <sherjilozair> even though I have copied it over to deps.
<FromGitter> <bew> you forgot `LD_` at the beginning of the env var
<FromGitter> <bew> it should be `LD_LIBRARY_PATH=...`
<FromGitter> <sherjilozair> snakes still has old path.
<FromGitter> <bew> did you re-built with the correct env var?
<FromGitter> <sherjilozair> SherjilOzair:examples sherjilozair$ LD_LIBRARY_PATH=$(pwd)/deps crystal build snakes.cr ⏎ SherjilOzair:examples sherjilozair$ otool -L snakes ⏎ snakes: ⏎ @rpath/libvoidcsfml-graphics.2.4.dylib (compatibility version 2.4.0, current version 2.4.0) ⏎ @rpath/libvoidcsfml-window.2.4.dylib (compatibility version 2.4.0, current version 2.4.0) ... [https://gitter.
<FromGitter> ... im/crystal-lang/crystal?at=5add7d1a109bb04332ee2e62]
<FromGitter> <sherjilozair> @bew Yes.
<FromGitter> <bew> and can you show the content of the `deps` folder?
<FromGitter> <sherjilozair> SherjilOzair:examples sherjilozair$ ls deps ⏎ libvoidcsfml-audio.2.4.dyliblibvoidcsfml-graphics.2.4.dyliblibvoidcsfml-network.2.4.dyliblibvoidcsfml-system.2.4.dyliblibvoidcsfml-window.2.4.dylib ⏎ libvoidcsfml-audio.dyliblibvoidcsfml-graphics.dyliblibvoidcsfml-network.dyliblibvoidcsfml-system.dyliblibvoidcsfml-window.dylib
<FromGitter> <sherjilozair> Just realized that I had global env variables set for LD_LIBRARY and LIBRARY. I removed them, and now the commands do this:
<FromGitter> <sherjilozair> SherjilOzair:examples sherjilozair$ LD_LIBRARY_PATH=$(pwd)/deps crystal build snakes.cr ⏎ ld: library not found for -lvoidcsfml-graphics ⏎ clang: error: linker command failed with exit code 1 (use -v to see invocation) ⏎ Error: execution of command failed with code: 1: `cc "${@}" -o '/Users/sherjilozair/CrystalProjects/crsfml/examples/snakes' -rdynamic -lvoidcsfml-graphics -lvoidcsfml-window
<FromGitter> ... -lvoidcsfml-system -lpcre -lgc -lpthread /usr/local/Cellar/crystal-lang/0.24.2_1/src/ext/libcrystal.a -levent -liconv -ldl -L/usr/lib -L/usr/local/lib` ⏎ SherjilOzair:examples sherjilozair$ LIBRARY_PATH=$(pwd)/deps crystal build snakes.cr ... [https://gitter.im/crystal-lang/crystal?at=5add7e19270d7d3708f61174]
<FromGitter> <faustinoaq> @sherjilozair I guess macOS will always point to system libraries if they exist, Do you have another mac computer to test ``
<FromGitter> <faustinoaq> `LD_LIBRARY_PATH=$(pwd)/deps ./snakes`
<FromGitter> <faustinoaq> Just copy the entire folder to the other computer
<FromGitter> <sherjilozair> I guess I need `install_name_tool ` to change the names myself in the binary.
<FromGitter> <bew> maybe try with `DYLD_LIBRARY_PATH` ?
<FromGitter> <faustinoaq> ^^ Yeah, try this 👍
<FromGitter> <sherjilozair> I get the same thing: `ld: library not found for -lvoidcsfml-graphics`
<FromGitter> <sherjilozair> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5add7f67109bb04332ee38a7]
<FromGitter> <sherjilozair> I just looked inside another macos game, and it seems the practice is to put the dylibs in the same path as the executable.
<FromGitter> <faustinoaq> Oh, ok, you can try to use `-L$(pwd)` as well with `--link-flags`
<FromGitter> <faustinoaq> like this:
<FromGitter> <sherjilozair> However, when I ran otool -L on the executable, those dylibs were NOT mentioned. Which makes me think they were loading those DLLs from code.
<FromGitter> <faustinoaq> DYLD_LIBRARY_PATH=$(pwd)/deps crystal build snakes.cr --link-flags="-L$(pwd)/deps"
<FromGitter> <sherjilozair> This doesn't work either.
<FromGitter> <sherjilozair> And I don't have another macos.
<FromGitter> <sherjilozair> Maybe the rpath needs to be changed?
<FromGitter> <faustinoaq> But you have voidcsfml libs inside the deps folder, right?
<FromGitter> <sherjilozair> Also, I feel like I'm spamming this list a lot. I hope the other 971 people here don't mind.
<FromGitter> <faustinoaq> Nah
<FromGitter> <faustinoaq> 😄
<FromGitter> <sherjilozair> > But you have voidcsfml libs inside the deps folder, right? ⏎ ⏎ Yes!
<FromGitter> <faustinoaq> Oh, then we just need to point them in the compiler
<FromGitter> <sherjilozair> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5add8055270d7d3708f61cd6]
<FromGitter> <sherjilozair> I think I'll just use `install_name_tool ` instead of making `crystal` do it for me.
<FromGitter> <sherjilozair> Thanks, though. This was very informative.
<FromGitter> <faustinoaq> Yeah, I just read https://stackoverflow.com/questions/4677044/how-to-use-dylib-in-mac-os-x-c/11585225#11585225 and looks like the right way 👍
<FromGitter> <sherjilozair> Yeah, I'll write a tool to automate this for crystal apps, and share it. Could be useful for other crystallites.
<FromGitter> <sherjilozair> Gotta get back to learning crystal now. :D
<FromGitter> <bararchy> @faustinoaq we need somekind of a cli packer for ditributed software, its really nice to have ⏎ ⏎ ```crystal pack deps/``` [https://gitter.im/crystal-lang/crystal?at=5add83202d0e228d7ba012c7]
<FromGitter> <bararchy> or something
<FromGitter> <bararchy> and it will pull all needed dynamic libs into the deps folder
<FromGitter> <sherjilozair> 👍
<FromGitter> <bew> @bararchy actually the compiler knows which libs are necessary, we could have an option to at compile time to create an additional file with that list, to allow another tool to generate the deps folder
<FromGitter> <bararchy> @bew great idea :)
<FromGitter> <bararchy> it could also help all those people who wants to static compile, because you can just ship your app with all needed libs, while the systems tries first to use the system wide libs
<FromGitter> <faustinoaq> Oh, nice 👍
<FromGitter> <sherjilozair> This seems like an easy enough task that someone like new could contribute.
<FromGitter> <bew> if anyone wants to fill an issue for that, please do it (I can't do it right now), but makes sure that only 1 person does that ^^
<FromGitter> <bararchy> Should I do it? or @faustinoaq ?
<FromGitter> <bararchy> so we wont both open the issue haha
<FromGitter> <faustinoaq> @bararchy Yeah, go ahead! I think this can be very useful even on Linux, I just tried the command I shared above, and...:
<FromGitter> <bararchy> XD
<FromGitter> <faustinoaq> ^^ It works, but I had to fix a bunch of things before get the executable running on a new fresh machine
<FromGitter> <sherjilozair> How would you do the bundling in linux? Would you just put it all in the binary? Or is there something similar to macos App bundle in linux?
<FromGitter> <bew> nice! It could also be used when buiding a Docker scratch Dockerfile with all the libs and all
<FromGitter> <faustinoaq> I copied the full directory with all libraries inside a `deps`, then I used `LD_LIBRARY_PATH` to specify my path folder, and removing libpthread, libc, and ld-linux, because some incompatibilities issues. Finally I got my dynamic linked executable running 😄
<FromGitter> <bararchy> Makes sense? https://github.com/crystal-lang/crystal/issues/5992
<FromGitter> <sherjilozair> And you had the path set to `deps/`?
<FromGitter> <bew> 'm not sure about getting the paths in that file, as the compiler probably don't know them
<FromGitter> <sherjilozair> @bararchy I think it would be nice to have an option to copy the libs as well, and to modify the executable to point to the copied libs instead of the old locations. That would be a truly complete solution.
<FromGitter> <bew> @sherjilozair see my last msg
<FromGitter> <bararchy> @bew hm, how come ldd can get them?
<FromGitter> <sherjilozair> The compiler won't, but crystal could search for them and then copy them over?
<FromGitter> <bew> well, it resolves everything I guess?
<FromGitter> <faustinoaq> @sherjilozair Well, as you can see in my last screencapture, I used this: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5add87e562316e0505ec5aa0]
<FromGitter> <bararchy> anyway, I would configure to try and take system libs, only then fallback to deps dir
<FromGitter> <bararchy> like Steam is doing
<FromGitter> <faustinoaq> Yeah 👍
<FromGitter> <sherjilozair> Great. Btw, I really think Crystal should try to become a language for game development. It's fast and productive, so it's gonna be very useful for game development.
<FromGitter> <sherjilozair> Lua is the other language popular, but it doesn't have classes, and so can't really do big projects with it.
<FromGitter> <bararchy> @sherjilozair we got lots of game devs here, Groogy, oprypin, etc..
<FromGitter> <faustinoaq> Even electron apps use something like that, electron includes all dynamic libraries dependencies for chromium inside your app folder
<FromGitter> <faustinoaq> @sherjilozair Oh, you should take a look to lua.cr 👉 https://github.com/veelenga/lua.cr
<FromGitter> <bew> @sherjilozair it's different, Lua is an embedded language, it could be embedded in a Crystal-written game
<FromGitter> <faustinoaq> @bew That's right 👍
<FromGitter> <sherjilozair> Right. lua.cr is cool. But I think crystal could supercede it.
<FromGitter> <bew> what do you mean?
<FromGitter> <sherjilozair> I guess Groogy is working on a game framework here: https://github.com/Groogy/ego
<FromGitter> <sherjilozair> @bew I just mean game developers who used to use lua could start using crystal because it's so much better. Faster, as good syntax, static typing, classes, good for larger projects.
<FromGitter> <sherjilozair> It'll also attract C++ and some C# game developers. C# doesn't work well outside MSFT environment (even though mono is cool), and C++ is productive for few people.
<FromGitter> <bararchy> Did anyone benchamrk @ysbaddaden new GC? https://github.com/ysbaddaden/gc
<FromGitter> <bararchy> against the regular bohem GC
<txdv> crystal is only working on linux?
<FromGitter> <bararchy> txdv also on Mac, and Windows subsystem Linux, and a full Windows support is in the works
<FromGitter> <sherjilozair> Do you guys know what Groogy's boleite and ego projects are about? Which kind of game framework are they going to be like?
<FromGitter> <sherjilozair> Figuring out if there is a niche in which I could make my own framework using cr.
<FromGitter> <bew> iirc there are 2 game framework in Crystal in the work, both 3d using opengl
<FromGitter> <bew> (for now I guess)
<txdv> core clr is working on linux, windows and macosx :)
<txdv> doesn't support windows forms and windows specific though
<txdv> which is a crazy thing to want, but people somehow demand it without understand the underlying stuff
<FromGitter> <bararchy> txdv core clr (C# right?) is really young, and mostly driven by Microsoft with a small community
<FromGitter> <bararchy> last time I checked (6-8 months ago)
<FromGitter> <bararchy> and lacked basic stuff like an HTTP::Server etc..
<FromGitter> <bararchy> but it might be different now
<txdv> it literally has asp.net core?
<FromGitter> <bararchy> does it?
<txdv> and entity framework core?
<FromGitter> <bararchy> well, it's still have one huge problem tbh
<FromGitter> <bararchy> it's C# ;)
<FromGitter> <bararchy> hahaha
<FromGitter> <sherjilozair> @bew Names? I know CrSFML, but it's 2d.
<txdv> what?
<FromGitter> <bew> there's boleite from Groogy, can't find the other one..
<txdv> does crystal have something like linq?
rohitpaulk has joined #crystal-lang
<FromGitter> <bararchy> OMG, i totally forgot about https://github.com/bararchy/mos_game hahaha
<FromGitter> <bew> @bararchy I was checking C# lately, it doesn't look that bad
<FromGitter> <sherjilozair> Glove and Cray seems very experimental. I think only CrSFML is usable right now.
<FromGitter> <Qwerp-Derp> @sherjilozair C++ is still the gold standard for making games though
<FromGitter> <sherjilozair> @Qwerp-Derp Yeah, because no other languages is fast enough. Maybe Crystal (in a few years) could supercede it.
<FromGitter> <Qwerp-Derp> Like not many people make games with Java or C# because it doesn't offer the flexibility and such that C++ has, despite the fact that C++ is literally a frankenstein of a language
<FromGitter> <sherjilozair> C# is pretty good too btw, for gamedev.
<FromGitter> <bararchy> @bew ⏎ ⏎ ```Newclass Newobject = new Newclass();``` [https://gitter.im/crystal-lang/crystal?at=5add8e005d7286b43a594fef]
<FromGitter> <Qwerp-Derp> @sherjilozair I guess, Unity's pretty good
<FromGitter> <sherjilozair> Unity, MonoGame both use C#.
<FromGitter> <bew> @bararchy mind changed x)
<FromGitter> <faustinoaq> txdv I have been using C#/.Net on latest months and CoreCLR looks pretty nice 👍
rohitpaulk has quit [Remote host closed the connection]
<FromGitter> <Qwerp-Derp> I tried making a game in Crystal and it completely, utterly failed, maybe it'll work out again in a couple of years when it has IDE support
<FromGitter> <bew> @bararchy but I think you can do `var obj = new Newclass()` too, which is better
<FromGitter> <sherjilozair> I'm actually quite confident that if Crystal has a very good chance of becoming an indie gamedev favorite.
<FromGitter> <sherjilozair> @Qwerp-Derp What did you use? And do you have prior gamedev experience?
<FromGitter> <Qwerp-Derp> @sherjilozair I used CrSFML, and I didn't have any prior gamedev experience
<FromGitter> <faustinoaq> Qwerp-Derp Did you tried VSCode? or even Scry? 😅
<FromGitter> <sherjilozair> I think the "no prior experience" might have been the issue. SFML is not easy for beginners.
<FromGitter> <Qwerp-Derp> @faustinoaq I used VSCode
<FromGitter> <sherjilozair> I use your package in VSCode @faustinoaq , but how do I get Scry to work with it?
<FromGitter> <faustinoaq> Oh, nice, then you should wait for next version of scry, this Language Server Protocol for crystal is getting better every day 😉
<FromGitter> <faustinoaq> I already sent some fixes
<FromGitter> <Qwerp-Derp> TBH the VSCode package isn't really suited for big projects right now, but just my 2c
<FromGitter> <faustinoaq> Also waiting some work-in-progress auto-completion fixes for scry
<livcd> C# looks nice..is not rubyish but I am happy microsoft embraced open source
<FromGitter> <Qwerp-Derp> I'm not sure if I have scry on my copy of the VSCode package
<FromGitter> <Qwerp-Derp> so that might be why I feel that way
<FromGitter> <faustinoaq> @Qwerp-Derp VSCode itself is not suited for big projects 😅 ⏎ ⏎ ^^ https://code.visualstudio.com/docs/supporting/faq#_what-is-the-difference-between-vs-code-and-vs-community
<FromGitter> <bararchy> @bew we can all agree though that Java has the most ugly syntax ⏎ ⏎ ```private static final Logger logger = LoggerFactory.getLogger(this.getClass().getName());``` [https://gitter.im/crystal-lang/crystal?at=5add8f72109bb04332ee8844]
<FromGitter> <Qwerp-Derp> @faustinoaq that's true
<livcd> they say this because they want to sell to enterprise
<FromGitter> <faustinoaq> Hopefully we can have crystal support on Intellij-idea as well https://github.com/crystal-lang-tools/scry/issues/72
<FromGitter> <Qwerp-Derp> @faustinoaq You're working on an IntelliJ plugin as well for Crystal, right?
<FromGitter> <bew> @bararchy it's juste veerryy verboose
<FromGitter> <faustinoaq> Yeah, We're trying to use Scry on Intellij-idea, the fixes are already merged, waiting for the issue author to confirm this is fixed ( or someone else 😉 )
<FromGitter> <bararchy> ```Logger.new```
<FromGitter> <bararchy> much better :)
<FromGitter> <sherjilozair> @faustinoaq Can I use Scry now?
<FromGitter> <bew> but not as modular/configurable though
<FromGitter> <bararchy> @sherjilozair I use Scry with vscode
<FromGitter> <sherjilozair> @bararchy How to set it up?
<FromGitter> <bararchy> @bew yeha, I hope the new logger issue will fix that
<FromGitter> <faustinoaq> @bew I already sent a PR to change the verbosity level 😄
<FromGitter> <bararchy> @sherjilozair ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5add904062316e0505ec8824]
<FromGitter> <bew> yeah I saw ty @faustinoaq (I did a hard change for my scry, but it would be better with your change :) )
<FromGitter> <faustinoaq> 👍
<FromGitter> <bararchy> @faustinoaq when is new version coming for Scry?
<FromGitter> <bew> after his last fixes are merged I quess
<FromGitter> <bararchy> when are you going to merge them? :)
<FromGitter> <bew> 'll sleep now, good day/night!
<FromGitter> <faustinoaq> > but not as modular/configurable though ⏎ ⏎ @bew We're thinking on separate the protocol from scry, @keplersj already created a `lsp` repository for that https://github.com/crystal-lang-tools/lsp
<FromGitter> <bew> lking about @faustinoaq I was talking about the logger here ^^
<FromGitter> <faustinoaq> Oh, ok, no problem 👍
<livcd> Is there some regional promoting for Crystal ? bararchy: do you write articles in hebrew ? :D
<FromGitter> <bew> @faustinoaq https://github.com/crystal-lang-tools/lsp/blob/master/src/lsp/protocol/diagnostic.cr#L46 that needs to be configurable!
<FromGitter> <faustinoaq> @bararchy The next version should be ready after we get some fixes merged. And hopefully https://github.com/crystal-lang-tools/scry/issues/85 get fixed as well by @laginha87 😄
<FromGitter> <bararchy> livcd sadly no, I think I should promote Crystal in Israel, but it seems we already attrected some people with 3 israeli in the channel :)
<FromGitter> <sherjilozair> Is scry able to pull up information from the requires?
<FromGitter> <sherjilozair> It doesn't seem to for me.
<FromGitter> <sherjilozair> For the autocomplete, that is.
<FromGitter> <sherjilozair> It was able to show an error when I wrote the whole thing.
<FromGitter> <faustinoaq> @bew I guess you're right 😅
<FromGitter> <faustinoaq> @sherjilozair I already sent a bunch of fixes, just wait for the next version 😉
<FromGitter> <sherjilozair> Cool. Thanks @faustinoaq
<txdv> 101 people is al ot for such a young language
<txdv> + a bunch sitting on gitter
<txdv> a pie chart with the nationalities of the users in this channel would be interesting
<FromGitter> <faustinoaq> txdv Is 101 people on #crystallang IRC?
<txdv> yes
<FromGitter> <bararchy> txdv 971 in gitter :)
<FromGitter> <faustinoaq> ^^ Oh nice 971 on gitter 😄
<txdv> on gitter people join a channel
<FromGitter> <alex-lairan> \o/
<livcd> txdv: i found that some technologies are very regional
<txdv> and then never use gitter again
<txdv> the number is meaningless
<txdv> in irc people at least have to set up bouncers on their own!D
<FromGitter> <faustinoaq> txdv Yeah, you're right
<txdv> lazy millenials, back in the day we had to set up our idlers on our own
<FromGitter> <bararchy> XD
rohitpaulk has joined #crystal-lang
<FromGitter> <faustinoaq> Well, I like gitter because I can read messages without joining a channel XD
<livcd> i use irssi because i can attach to a session even on slow network
<FromGitter> <faustinoaq> Oh, I just remember I can see IRC logs as well: https://irclog.whitequark.org/crystal-lang/
<FromGitter> <faustinoaq> 😉
<FromGitter> <faustinoaq> And I can search something inside them 🎉 (gitter doesn't have search for old logs)
<FromGitter> <faustinoaq> livcd That's fair, Sometimes I use IRC as well because my computer gets slower on chromium/gitter after using it a lot
<FromGitter> <faustinoaq> @bararchy XD IRC Forever!
<livcd> but to be honest if i would not know how to use irssi i would not have invested my team in learning it.
faustinoaq has joined #crystal-lang
DTZUZO has quit [Ping timeout: 276 seconds]
<jokke> you could invest them in learning weechat instead :)
<jokke> and those who don't want to learn: http://glowingbear.org
<livcd> my time*
guilleiguaran has quit [Quit: Connection closed for inactivity]
<FromGitter> <j8r> I'm starting to think that having a 2nd channel might be good - sometimes, specially when answering questions, we have hard time to keep up with the discussion
<FromGitter> <sherjilozair> I just noticed that Crystal doesn't have any cuda binding. Or am I wrong?
<FromGitter> <bararchy> @sherjilozair it does not, It's one of the things I really want to add but which are really really hard to do
<FromGitter> <sherjilozair> @bararchy What makes it hard?
<FromGitter> <bararchy> @sherjilozair cuda, cuda makes it hard XD ⏎ It's really annoying to bind
<FromGitter> <bararchy> have you ever played around with it?
<FromGitter> <sherjilozair> Yeah, I used python ctypes to create Python bindings once.
<FromGitter> <sherjilozair> At the time it was very undocumented, and it was a pain.
<FromGitter> <sherjilozair> I assume that it's probably better now.
<FromGitter> <sherjilozair> It's also become a huge library now. So that doesn't help.
<FromGitter> <bararchy> most of it is in C++
<FromGitter> <bararchy> which is painful to bind
<FromGitter> <bararchy> hm..
<FromGitter> <bararchy> for my needs though it's easier to bind TensorFlow instead of Cuda and then add support in SHAInet :)
<FromGitter> <sherjilozair> Oh wait. I actually meant CUDNN.
<FromGitter> <sherjilozair> Not CUDA.
<FromGitter> <sherjilozair> I think one just needs to bind cudnn and get neural network goodness.
<FromGitter> <sherjilozair> without having to bind cuda.
<FromGitter> <sherjilozair> because libcudnn would find libcuda in native and we're good.
<FromGitter> <bararchy> in that case just bind TensorFlow
<FromGitter> <bararchy> which is a level above it
<FromGitter> <sherjilozair> TF is much harder!
<FromGitter> <sherjilozair> It's a big API.
<FromGitter> <sherjilozair> And i don't even know how to begin binding python.
<FromGitter> <sherjilozair> I guess we'd bind the C++ API.
<FromGitter> <bararchy> @sherjilozair you can start helping https://github.com/NeuraLegion/tensorflow.cr
<FromGitter> <sherjilozair> But no, I know of an effort to bind TF and they said it's too hard and gave up.
<FromGitter> <bararchy> ;)
<FromGitter> <sherjilozair> Oh are you NeuraLegion?
<FromGitter> <sherjilozair> ```module TensorFlow ⏎ # TODO Put your code here ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5addabec270d7d3708f6eadc]
<FromGitter> <sherjilozair> lol no man
<FromGitter> <sherjilozair> Oh you actually have some stuff there.
<FromGitter> <sherjilozair> Where are you getting the list of functions from?
<FromGitter> <schoening> A little question.. Hashes are heap allocated and Tuples stack allocated, correct? ⏎ So what happens when I fill a Hash with Tuples 😟 ⏎ ⏎ https://play.crystal-lang.org/#/r/3xc6 [https://gitter.im/crystal-lang/crystal?at=5addac9e27c509a7743ef765]
<FromGitter> <sherjilozair> Yeah, but where do you get the API from?
<FromGitter> <bararchy> @sherjilozair auto-generated using crystal-lib
<FromGitter> <sherjilozair> So you only need the header files to generate the binding right?
<FromGitter> <bararchy> yeha
<FromGitter> <bararchy> but it's only like 10% of the work
<FromGitter> <sherjilozair> What's the rest of the work?
<FromGitter> <sherjilozair> Fixing errors?
<FromGitter> <bararchy> Crystal side, make is usable
<FromGitter> <bararchy> classes, objects, logic
<FromGitter> <sherjilozair> I see. That could be fun, actually.
<FromGitter> <bararchy> it is :)
<FromGitter> <bararchy> I did a full bindings to FANN
<FromGitter> <bararchy> after getting my head around C=>Crystal ⏎ the rest of the work was really interesting
<FromGitter> <bararchy> @sherjilozair oh, I just saw you got some interesting repos :) the RNN is really cool!
<FromGitter> <sherjilozair> thanks! I've been doing deep learning for a while now.
moei has quit [Quit: Leaving...]
flaviodesousa has joined #crystal-lang
<crystal-gh> [crystal] esse opened pull request #5993: Add example of using mapping to parse array (master...patch-1) https://git.io/vp3ne
<FromGitter> <girng> good morning
<FromGitter> <bararchy> Morning @girng :)
moei has joined #crystal-lang
duane has quit [Ping timeout: 248 seconds]
DTZUZO has joined #crystal-lang
<FromGitter> <oprypin> @schoening https://pryp.in/blog/24/
mps has joined #crystal-lang
<FromGitter> <girng> that's not me i swear
<FromGitter> <bararchy> @oprypin "once you go stack, you never come back" ;)
duane has joined #crystal-lang
alex`` has joined #crystal-lang
alex`` is now known as alexherbo2
thews has quit [Read error: No route to host]
alexherbo2 is now known as alex``
<crystal-gh> [crystal] sdogruyol pushed 1 new commit to master: https://git.io/vp3VK
<crystal-gh> crystal/master 1c4e4e8 Piotr Szmielew: Add example of using mapping to parse array (#5993)...
duane has quit [Ping timeout: 260 seconds]
thews has joined #crystal-lang
thews has joined #crystal-lang
thews has quit [Changing host]
<FromGitter> <Sija> any Amber dev here knows how to build full request url?
yadkit has joined #crystal-lang
<yadkit> hi
yadkit has quit [Client Quit]
duane has joined #crystal-lang
<travis-ci> crystal-lang/crystal#1c4e4e8 (master - Add example of using mapping to parse array (#5993)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/370078556
<DeBot> https://github.com/crystal-lang/crystal/pull/5993 (Add example of using mapping to parse array)
<FromGitter> <ok2094> @Sija https://gitter.im/amberframework/amber
<FromGitter> <bararchy> When you see people are still trying to get multi-threading to be painless in langs like C++, and you feel ashame you even expected Crystal to support it
<FromGitter> <bararchy> hahaha
<Vexatos> it's pretty painless in some languages
<FromGitter> <bararchy> btw, if someone wants in on the fun binding CUDNN ;) https://github.com/sherjilozair/cudnn.cr
<FromGitter> <ok2094> Is there a handy crystal cheatsheet or do I have to make one?
<FromGitter> <bararchy> @ok2094 what are ou looking for?
<FromGitter> <ok2094> I like having a cheatsheet with the basic functions and other useful stuff, when learning a new language.
hightower2 has joined #crystal-lang
<FromGitter> <bararchy> @ok2094 well, if youre in the giving mood feel free to make one, I'm the sure community will love and benefit from one
<mps> ok2094: please, do. It would be useful
<FromGitter> <sherjilozair> @ok2094 Check this out: https://learnxinyminutes.com/docs/crystal/
hightower3 has quit [Ping timeout: 248 seconds]
<FromGitter> <sherjilozair> It's pretty close to a cheatsheet.
<FromGitter> <ok2094> Oh cool, didn't know there was one for crystal
<FromGitter> <ok2094> but maybe I'll make nicer one.
<FromGitter> <r00ster91> I think I will also make one
pbodev1 has joined #crystal-lang
return0e has joined #crystal-lang
pbodev1_ has joined #crystal-lang
pbodev1 has quit [Ping timeout: 248 seconds]
pbodev1_ is now known as pbodev1
guilleiguaran has joined #crystal-lang
Nathanaelle has quit [Read error: Connection reset by peer]
rohitpaulk has quit [Ping timeout: 268 seconds]
Nathanaelle has joined #crystal-lang
benharri is now known as bhh
<FromGitter> <sherjilozair> How can I get `crystal spec` to use a `.so` file from an alternative path?
<FromGitter> <sherjilozair> I'm on linux now.
<FromGitter> <bararchy> @sherjilozair I just linked the damn /opt/cudnn so libs to my system lib
<FromGitter> <bararchy> `ln -s`
<FromGitter> <sherjilozair> I don't have sudo access.
<FromGitter> <j8r> you can try modifying environment variables
<FromGitter> <j8r> like `PATH`, `CRYSTAL_PATH` - not sure it can works through
<FromGitter> <j8r> How can I spec a method that print to STDOUT?
<oprypin> j8r, make it produce a string and spec that, then optionally make a method that actually prints
<oprypin> or have an arg that accepts IO which is STDOUT by default
<FromGitter> <j8r> ok, I've get around by creating a variable
<FromGitter> <faustinoaq> Next version of Scry gonna be awesome ✨ https://github.com/crystal-lang-tools/scry/pull/92#issuecomment-383621903
faustinoaq has quit [Quit: IRC client terminated!]
<FromGitter> <r00ster91> when defining a method: how do I say that a block can be specified but it doesnt needs to? I mean that this both works: ⏎ ⏎ ```def method(&block = Proc(Nil)) ⏎ ⏎ def method(&block = {})``` ⏎ ⏎ but it doesnt works [https://gitter.im/crystal-lang/crystal?at=5ade07fd27c509a77440f92b]
<FromGitter> <j8r> good job @faustinoaq !
<z64> @r00ster91 block syntax in methods is covered on https://crystal-lang.org/docs/syntax_and_semantics/blocks_and_procs.html
<FromGitter> <r00ster91> yes i already looked there but I cant find any section which explains how to do what im trying
<FromGitter> <yxhuvud> Define two methods.
<FromGitter> <r00ster91> ooooh.. thats simple. thanks
<FromGitter> <yxhuvud> Of course, the nonblock version may call the block version of behavior is similar
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
faustinoaq has joined #crystal-lang
<FromGitter> <sherjilozair> If a module has a function and a class, how can I call the function from a method in the class?
<FromGitter> <fenicks> Hi guys, I launched a survey on Twitter about which language for microservices, if you have any eperiences. Thanks for sharing your experiences : https://twitter.com/christiankakesa/status/987874278514282496
<bmcginty> sherjilozair: ::ModuleName.method_name
Groogy_ has quit [Read error: Connection reset by peer]
<FromGitter> <Whaxion> Hello ! It is possible to get all instance variable of a class ?
<FromGitter> <bew> it depends on when, why do you need them?
<FromGitter> <Whaxion> I need it because I want to add (almost) all instances var to database
<FromGitter> <Whaxion> (So it's in a function inside the class)
<FromGitter> <bew> right, you can access them at compile time, through the use of macros
<FromGitter> <bew> https://crystal-lang.org/api/0.24.2/Crystal/Macros/TypeNode.html#instance_vars%3ACrystal%3A%3AMacros%3A%3AArrayLiteral(MetaVar)-instance-method
<FromGitter> <bew> you can get the TypeNode of the current type with `@type` in a macro
rohitpaulk has joined #crystal-lang
<FromGitter> <bew> for example, here is how `inspect` works: https://github.com/crystal-lang/crystal/blob/master/src/reference.cr#L59-L77 (using `@type.instance_vars`)
<FromGitter> <Whaxion> Thanks a lot ! 😄
rohitpaulk has quit [Ping timeout: 255 seconds]
<FromGitter> <sherjilozair> `::ModuleName.method_name` actually doesn't work.
<FromGitter> <bew> can you show an example of what you're trying to do in http://carc.in/ ?
GoldenBear has joined #crystal-lang
<FromGitter> <everdev> hi guys, loving Crystal so far :) quick question: I'm unable to make an array using a variable class (ex. [] of myClassVar). Here's the code: https://play.crystal-lang.org/#/r/3xfc Any idea what I'm doing wrong?
<FromGitter> <sherjilozair> Class names have to be capitalized.
<FromGitter> <bew> yes, you can't do that like this, but there is a way: https://play.crystal-lang.org/#/r/3xff
<FromGitter> <everdev> awesome, thanks @bew :)
<Yxhuvud> could you alsodo Array(myClass).new perhaps?
<FromGitter> <bew> nah the type must be known at compile time, the var is runtime
<FromGitter> <faustinoaq> @fenicks Nice, although, GoLang community is bigger, so, more likes. Also you had should included Elixir and Nim 😅
<FromGitter> <faustinoaq> Crystal syntax, types and package system is better IMO
<FromGitter> <faustinoaq> Oh, Also `JSON.mapping` is very nice 😉
<FromGitter> <j8r> IMHO for beginners the `Array(String).new` style is better than `[] of String` - more transparent
<FromGitter> <elorest> Usertesting is a pretty big company with around 170 rails devs.
<FromGitter> <sherjilozair> How to represent `void **` in crystal? I'm binding a library which uses `void **`.
<oprypin> sherjilozair, `Void**`
<FromGitter> <sherjilozair> That's... neat. :D
<FromGitter> <faustinoaq> @elorest Great! ✨
<FromGitter> <bew> @sherjilozair in the lib binding you should make a `type RelevantName = Void**` and only use `RelevantName` in the binding
<FromGitter> <sherjilozair> Oh okay. Why is that though?
<FromGitter> <bew> in lib bindings, `type` is a strong alias, that ensures type safety
<FromGitter> <bew> So that when a method returns `RelevantName` and another return `OtherName` (e.g: defined as `type OtherName = Void*`, they will be 2 different types, and you won't be able to pass a `OtherName` when a `RelevantName` is expected (even if you could do that with bare pointers)
<FromGitter> <sherjilozair> I see.
<FromGitter> <sherjilozair> I can't seem to be able to call functions in a module using `::Module.func` or `Module.func` or `Module::func`?
<FromGitter> <j8r> don't forget `self`
<FromGitter> <j8r> 1) when called externally
<FromGitter> <bew> @sherjilozair can you show an example of what you're trying to do in http://carc.in/ ?
<FromGitter> <sherjilozair> `self` did it. Didn't know I had to do `extend self`.
<FromGitter> <sherjilozair> I come from Python where everything is always visible. :|
<FromGitter> <sherjilozair> I got this message! `Error: you've found a bug in the Crystal compiler. Please open an issue, including source code that will allow us to reproduce the bug: https://github.com/crystal-lang/crystal/issues`
<FromGitter> <sherjilozair> Does it actually mean I've found a bug or is it because I'm using unsafe things.
<FromGitter> <r00ster91> please show the code
<FromGitter> <r00ster91> look in https://github.com/crystal-lang/crystal/issues if the bug has been already reported and if not then create a new issue and post the code in it
<FromGitter> <bew> @sherjilozair maybe both ^^ can you make a minimal example that reproduces this bug?
<FromGitter> <sherjilozair> I'll try.
<FromGitter> <bew> (if you can't find it in existing issues)
<FromGitter> <bew> what's the full error message?
<FromGitter> <straight-shoota> hah, I've found a nice ` trying to assign Nil <- HTTP::Client`, too
<FromGitter> <sherjilozair> This is the whole thing for those interested: https://pastebin.com/X9k7w21q
<FromGitter> <straight-shoota> mine it #4290 and I even posted a workaround a few months ago
<DeBot> https://github.com/crystal-lang/crystal/issues/4290 (Module, is_a?, yield, as, and a BUG: trying to assign Nil)
rohitpaulk has joined #crystal-lang
<FromGitter> <bew> @sherjilozair instead of doing `extend self`, you can do `def self.malloc ...`
<FromGitter> <bew> to make it a module-level method
<FromGitter> <sherjilozair> I see. That would still cause the error though, right?
<FromGitter> <bew> yes probably ^^
rohitpaulk has quit [Ping timeout: 256 seconds]
<FromGitter> <sherjilozair> Created an issue for it: https://github.com/crystal-lang/crystal/issues/5996
<FromGitter> <bew> you can add `cr` or `crystal` after code backticks to get syntax highliting
<FromGitter> <bew> (in github)
<FromGitter> <bew> you didn't provided `check_success`
<FromGitter> <bew> nvm you provided a link to your repo ^^
DTZUZO has quit [Quit: WeeChat 2.0]
DTZUZO has joined #crystal-lang
Nathanaelle has quit [Ping timeout: 264 seconds]
Nathanaelle has joined #crystal-lang
Nathanaelle has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 268 seconds]
pbodev1 has quit [Quit: ChatZilla 0.9.93 [Firefox 56.0/20170903140023]]
return0e has quit [Read error: Connection reset by peer]
<FromGitter> <sherjilozair> While I have provided a link to the repo, the code does depend on certain c libraries being placed in certain strategic locations, so I don't think you'd be able to run the code. But you could dry run it.
<FromGitter> <bew> sure, but when those file in specific locations will be needed during the compilation, it would mean that the module validation passed, and that there is no error :)
mps has left #crystal-lang [#crystal-lang]
<FromGitter> <sherjilozair> So is the error that the library cannot be found? Is that the issue?
<FromGitter> <bew> no the issue is that there is a bug in the compiler I think... (I trying to push #5820 so that it's easier to debug problems like this one)
<DeBot> https://github.com/crystal-lang/crystal/issues/5820 (Using --no-codegen blocks --emit options)
return0e_ has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 248 seconds]
<FromGitter> <sherjilozair> Kinda surprised crystal still has such bugs. Not ready for prime time it seems.
<FromGitter> <sherjilozair> How are you sure this is a compiler bug? Because of the emitted message?
<FromGitter> <bew> yes the module validation failed error is most probably a bug in the LLVM IR we generate
duane has quit [Ping timeout: 248 seconds]
<FromGitter> <sherjilozair> Is there a way to guarantee that a certain function will be called when a certain object ends its lifecycle?
<FromGitter> <sherjilozair> I'm basically asking for destructor methods.
<FromGitter> <bew> yes, but you don't know if and when they will be called
<FromGitter> <bew> the method to implement is called `finalize`
<FromGitter> <sherjilozair> Yeah, I found it weird that it's not guaranteed to run.
<FromGitter> <sherjilozair> What if I've allocated GPU memory, and the program ends.
<FromGitter> <bew> it is called just before the GC reclaim a memory area
<FromGitter> <sherjilozair> The allocated GPU memory is now orphan.
<RX14> it's guaranteed to run
<RX14> in infinite time
<RX14> ok, it's guaranteed to run if the object is collected
<RX14> it's not guaranteed to be collected
<FromGitter> <sherjilozair> What if the program is killed?
<RX14> nope
<FromGitter> <sherjilozair> yeah.
<RX14> how would that work?
<FromGitter> <sherjilozair> haha
<RX14> it can't work
<FromGitter> <sherjilozair> oh so destructors in other langs also don't have that property.
<FromGitter> <sherjilozair> got it.
<RX14> the assumption in linux has always been that the OS cleans up resources when you close the process
<RX14> you can always kill -9
<RX14> and there is no way to trap or run anything when that happens
<FromGitter> <sherjilozair> but their destructors are called as soon as the object goes out of scope, right? In C# or C++?
<RX14> GPU memory surely is an OS resource
<RX14> which is returned when a process is killed
<RX14> @sherjilozair not in crystal
<RX14> in C++ structs can have destructors
<RX14> and they're called when they go out of scope
<FromGitter> <sherjilozair> Why did crystal choose to be different in this regard?
<RX14> but in crystal structs cannot have destructors
<RX14> and there's no RAII
<RX14> there's just GC finalizers
<RX14> @sherjilozair idk, hard to implement I think
<RX14> desides you can just do it with blocks
<FromGitter> <sherjilozair> But RAII is awesome, so I don't understand.. oh.
<RX14> look at File.open(&block)
<RX14> that's the "crystal" way to do it
<RX14> automatic RAII is limited to method scope anyway (i think)
<RX14> so the crystal blocks solution is just as powerful yet more explicit
<FromGitter> <sherjilozair> Are you referring to the `ensure` syntax?
<RX14> partially
<RX14> blocks + ensure syntax really
<RX14> ensure is just like `try {} finally {}` in C++
<RX14> but in crystal you can pass blocks to other methods so it's super simple to just yield a handle into a block and clean it up once the block returns
alex`` has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 255 seconds]