RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.26.1 | 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
Heaven31415 has joined #crystal-lang
<Heaven31415> Hi
<FromGitter> <gtramontina> @straight-shoota I was using and IRC client and missed a lot of your messages… Just caught up! Thanks for your replies! ⏎ I tend to consider the `specs` the first consumer of the library/module I'm building. That's one of the reasons I like the specs to require it absolutely, rather than relatively… It also helps me (a bit) staying away from testing/coupling with internal details. ⏎ Because I'm on
<FromGitter> ... `make` land, this is how I ended up using (suggestions are always welcome): ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b91c4cc4be56c5918f26d10]
<FromGitter> <gtramontina> Btw… we don't have a `-I`(big i) in crystal, do we (I couldn't find it)? Like ruby's… It would've made things a bit simpler, as I could potentially just do `crystal -Isrc spec`
<FromGitter> <bew> or just do `require "../src/**"` in your `spec_helper.cr` ? (it'll require all .cr files in `src`)
<FromGitter> <bew> hmm didn't actually read your msg above sry
<FromGitter> <Sija> @gtramontina you mean `BigInt`?
<FromGitter> <bew> @Sija no
<FromGitter> <Sija> ahh, sorry, misread your message
<FromGitter> <gtramontina> not really 😅 :-)
<FromGitter> <Sija> :P
<FromGitter> <bew> @gtramontina but your specs/srcs will always be in the same directories, so I don't get why you want to avoid relative require
<FromGitter> <bew> btw you're not using `$(CRYSTAL_BIN)` for `crystal env` shell call
<FromGitter> <gtramontina> If I start having a different structure (which can be a smelly thing on its own) within my `specs` directory, I might end up with `../../../../`. I'll try to dig up something I read in the past that made me go down this path (on other languages and environments as well). Hold on a sec…
<FromGitter> <gtramontina> good catch! thanks! ;-)
<FromGitter> <bew> that's why you can simply require everything, it won't impact compilation speed (or at least it won't be noticable, unless you have looots of macros)
<FromGitter> <gtramontina> found it… https://blog.thecodewhisperer.com/permalink/relative-include-paths-and-the-slow-certain-march-towards-legacy-code – I'm linking this here as a reference, not as a gospel or anything. It made me look at things a bit differently, and I've reaped some benefits on node.js land…
<FromGitter> <bew> just as I start to read, I'm thinking it doesn't apply to Crystal, as Crystal is compiled, not interpreted, so relative code files don't have any impact at runtime
<FromGitter> <gtramontina> I'm not too worried about compilation speed… more around maintainability. With a good IDE, some of these things are not a big deal, given that as you move files around, the IDEs usually take care of adjusting all paths for you anyway… I'm using a simple text editor (mea culpa), and I guess a lot of other people too.
<FromGitter> <gtramontina> This is also one of the reasons I see `require "../../something.[cr|rb|js]"` as a smell that there might be something off about the abstraction levels of the application. There might be some dependencies needing inversion, or some concepts needing to be abstracted…
<FromGitter> <bew> "simple" text editor here too :P btw your link is interesting, nice to see it written, that's exactly how I test my python code when I need to, but I never felt that need for crystal.. other people might have more to say, I didn't do a lot of actual release of my projects on production environments yet
<FromGitter> <bew> in crystal i usually require anything, I then just need to know in which namespace class Foo or Bar is, and I use it (simple case)
<FromGitter> <bew> i try to never require something that is above me (using `../` in the require path), the only exception is in the spec helper file
<FromGitter> <bew> (note: you don't need to put the extension `.cr` when requiring a file, just `require "./foo"` is enough)
<FromGitter> <gtramontina> Yeah… that was just to cover other similar scenarios… :-)
<FromGitter> <gtramontina> Requiring with `*` is one of the things that kinda throws me off… It might be interesting useful in some cases, but I like to have the dependencies explicitly declared.
<FromGitter> <gtramontina> I need to get some paycheck work done now… 😅 Thanks for the conversation! See you around!
<FromGitter> <bew> actually me too before Crystal, but as I use it I'm changing my mind... no idea where I'll end up x)
<FromGitter> <bew> ok, see you!
gtramontina has quit []
<FromGitter> <bew> I can see exactly why it can be bad smell to require everything, and I also have a lot of arguments against that idea, but I've read issues here and there on crystal's github, simply saying that this global require system (not per file) is coming from ruby or sth like that, and that is won't be changed in crystal, so I adapted i guess
<FromGitter> <girng> what's wrong with requiring a file??
<FromGitter> <girng> i use 7+ module requires, and 6 file requires. only compilation speed difference vs a regular blank crystal app is about 1.5 seconds. i tested it
DTZUZO has joined #crystal-lang
Heaven31415 has quit [Quit: Leaving]
rohitpaulk has joined #crystal-lang
<FromGitter> <bararchy> @bew it seems Anatol didn't manage to build the arch package
<FromGitter> <bararchy> #6672
salvor has quit [Ping timeout: 252 seconds]
<FromGitter> <bararchy> So until this issue is resolved no official arch package for 0.26.1
salvor has joined #crystal-lang
<FromGitter> <Timbus> Yay me
<FromGitter> <bararchy> @Timbus are you working to resolve this issue?
<FromGitter> <Timbus> I did
<FromGitter> <bararchy> I saw you commented on both issues
<FromGitter> <bararchy> @Timbus was your fix merged in master?
<FromGitter> <Timbus> Yeah I think so
<FromGitter> <Timbus> If he can test it that'd be cool
<FromGitter> <bararchy> 👍
<FromGitter> <schoening> Why is my compiled kemal server not using the "public" folder to serve static files :o ? the ./sentry version of my server works just fine
<FromGitter> <schoening> I moved the compiled file into a different folder. So perhaps thats why? static file paths?
<FromGitter> <schoening> Wait no, now it is working. odd. disregard.
rohitpaulk has quit [Ping timeout: 244 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 272 seconds]
ua has quit [Read error: Connection reset by peer]
DTZUZO has quit [Ping timeout: 252 seconds]
ua has joined #crystal-lang
Groogy1 has joined #crystal-lang
DTZUZO has joined #crystal-lang
ashirase has quit [Ping timeout: 272 seconds]
ashirase has joined #crystal-lang
<FromGitter> <codenoid> slow compile time
Groogy1 has quit [Ping timeout: 240 seconds]
Groogy1 has joined #crystal-lang
<FromGitter> <codenoid> we must fix this
shalmezad has joined #crystal-lang
<FromGitter> <codenoid> is @jeromegn datanoise ?
<FromGitter> <jeromegn> No
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 240 seconds]
Raimondii is now known as Raimondi
<FromGitter> <bajro17> I work right now on so big project for one Indonesian company and right now I try to promote crystal if all be ok crystal lang will get so big sponsors in future <3
<FromGitter> <bajro17> my biggest argument is this link about redis clients performance https://www.stefanwille.com/2015/05/redis-clients-crystal-vs-ruby-vs-c-vs-go/
<FromGitter> <bajro17> and that so beautiful syntax
<FromGitter> <j8r> what's the concurrent against crystal? Java, Go?
<FromGitter> <bajro17> Golang :)
<FromGitter> <j8r> Generally, Crystal/Go/C even Java can be competitive in performance. The big point is the syntax, close to the scripting world like Ruby, with more good async.
<FromGitter> <bajro17> I use go long time and I love goroutines and concurrency
<FromGitter> <bajro17> but crystal fibers is 10000000000 times better and easier
<FromGitter> <j8r> If the devs are used to OOP, they may feel Go to simple. This is a pros of Crystal with inheritance, generics etc. ⏎ If they worry about no v1.0 release, they only have to if they don't continuously develop the app.
<FromGitter> <j8r> @bajro17 agree for Fibers 💯
<FromGitter> <bajro17> I mostly develop API and I will maintain this
<FromGitter> <bajro17> then I dont worry so much
<FromGitter> <bajro17> because I plan to marry with this language hahahha
<FromGitter> <j8r> haha, @girng also want to marry with Crystal, you aren't on it :)
<FromGitter> <bajro17> I want just promote it how much I can
<FromGitter> <bajro17> I was worry before little about this v1.0 but I dont care anymore
<FromGitter> <bajro17> it go slow but it go on best way developers dont give up
<FromGitter> <j8r> the only think to keep in mind is to have a good test coverage (that all projects should have).
<FromGitter> <j8r> Even if the compiler helps a lot to report breaking changes, this allow you to spot others that might be passed through.
<FromGitter> <yxhuvud> @bajro17 regarding that redis client performance, it is a three year old benchmark. Things may have changed in some competitor library performance
<FromGitter> <j8r> yeah, it may not be the best argument. I think the good one would be: "Performances that match other compiled languages, nice features (fibers, inheritance etc), and with syntax and *productivity* of scripting languages" 😄
<FromGitter> <j8r> economizing money is always something that catch attention
<FromGitter> <j8r> with also saving time is important
<FromGitter> <bajro17> I test on my pc
<FromGitter> <bajro17> still crystal give best
<f1refly> I have code like this in my project: https://carc.in/#/r/4wn3
<f1refly> For some reason, the compiler complains that the function that needs the socket (it calls `gets` on it) can get a `Nil`. When i try to exclude it, that doesn't work. What am i not aware of?
<FromGitter> <bew> i don't understand what your `socket` variable is for, and why it exists in and out the spawn, and why you set it to nil at the loop start each time..
<FromGitter> <bew> i think if you remove the outer `socket = nil` it should work
<f1refly> i have a loop that checks if the connection is lost and tries to reconnect periodically. the "socket" variable is used because i hand the socket to multiple functions that do stuff with it.
<f1refly> i use the nil state to detect if it disconnected
<f1refly> when i don't initialize it crystal gets confused because the variable doesn't exists in the if statement
<FromGitter> <bew> you can keep the intialization in the loop, but if you remove the initialization outside the spawn, it should work
<FromGitter> <bew> (because local variable are typed kinda weirdly when you reference them inside a spawn block: they are handled as an external variable, not local, and thus you can't restrict its type with `if var` etc..
<f1refly> ok, i didnt know that
<f1refly> i can't initialize it inside the loop though, as it kind of defies the purpose when i can't work with the state it had when the loop exited
<f1refly> is there a function that waits for a socket to disconnet that i didnt find in the docs? that would essentially get rid of the whole process
<FromGitter> <bew> you can't "wait for a socket to disconnect", it's not how sockets works
<FromGitter> <bew> you can only detect a disconnection when you try to read or write from/to it, and it raises an exception saying that the socket closed or sth like that
<f1refly> hmm
<f1refly> ok, well, ill work with that
<f1refly> Sorry about my misinformation, im still figuring things out
<FromGitter> <bew> it's ok, come back if you need anything ;)
<FromGitter> <noahlh> hello again everyone. is it possible to create a (smaller, second) Tuple from an initial tuple? I.e. start with `{1,2,4,8,16}` and get a new Tuple that's `{1,2,4}`? I guess I'm wondering if there's a Tuple-equivalent technique that would be the equivalent of `#reject` or `#select` from Array.
<FromGitter> <noahlh> I may be barking up the wrong tree here and need to switch to an Array, but I've been trying to avoid it.
<FromGitter> <noahlh> With `#map` I can get close and get, `{1,2,4,nil,nil}`, but those nils feel wasteful and complicate things.
<Yxhuvud> noah: tuples will have a size determined at compile time, so something like reject doesn't make sense if you want a tuple back
<z64> you could only do it explicitly to another size, i.e.: `b = {a[0], a[1]}`
<FromGitter> <noahlh> totally makes sense
<FromGitter> <bew> a reject or select call will happen at runtime, and as Yxhuvud said, a tuple size must be know at compile time (before runtime)
<FromGitter> <noahlh> @z64 ahh that's getting closer. If I know an explicit size I might be able to use that technique.
<FromGitter> <noahlh> In this particular case I do know the size (it's always n-1)
<FromGitter> <noahlh> this is a good lead - let me think on this but I think that'll get me there. thanks!!
<FromGitter> <noahlh> you guys rock as always
<FromGitter> <noahlh> ty
<z64> np, good luck
<FromGitter> <bew> luck has very little to do here ^^
DTZUZO has quit [Ping timeout: 240 seconds]
Groogy1 has quit [Ping timeout: 245 seconds]
<FromGitter> <girng> @j8r i'm trying out love2d, syntax kinda has a crystal vibe to it. i still like crystal better
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 240 seconds]
Raimondii is now known as Raimondi
<FromGitter> <j8r> Love2d is an engine, with a language. Crystal is a general purpose language. Can't really be compared, each has its field @girng
<FromGitter> <girng> i mean lua
<FromGitter> <girng> @j8r u still workin on that one game??
<FromGitter> <j8r> Me? I don't work on any game
<FromGitter> <j8r> And didn't work on one since 3 years
<FromGitter> <j8r> More on devops things this times
<FromGitter> <girng> @j8r could have sworn another user here making game too. had j in there name
<FromGitter> <j8r> Yeah, IIRC he is on IRC
<FromGitter> <bew> Lua is a great language :)
<FromGitter> <girng> lua doesn't even have table method to get the size of a table
<FromGitter> <girng> i had to write my own
<FromGitter> <bew> Of course there's one: `#table` iirc
<FromGitter> <girng> nah won't work for dictionary tables
<FromGitter> <girng> u have to do pairs or w/e then use a counter, etc
<FromGitter> <girng> i like the syntax thats it, but that pisssedme off yesterday so i ragequit. spent 30min+ on stackoverflow/google trying to use #table, etc nothing worked. waste of time
<robacarp> lua is pretty bare bones
<robacarp> the stdlib is minimal so it can be included in a binary without too much bloat
<robacarp> if you're willing to download a rock, there's always one or two that claim to do what you want for stdlib-like operations
<robacarp> splitting a string on a character was one that really bothered me recently, I think
shalmezad has quit [Quit: Leaving]
<FromGitter> <TeddyDD> howdy, got a question. I'm playing with Raylib bindings (https://gitlab.com/Zatherz/cray) and they work fine, writing bindings to c libraries seems quite easy in Crystal. I just wonder, is it possible to bind header only library like this: https://github.com/raysan5/raygui/tree/master/src ?
<FromGitter> <j8r> No, but there are tools to generate bindings from `.h` files
<FromGitter> <j8r> I suppose you would mean bind directly from a `.h` file?
<FromGitter> <TeddyDD> I'm not sure how this should work, honestly 😃
<FromGitter> <TeddyDD> In C I'd just include that header, but in Crystal I need .o/.so to link right?
<FromGitter> <j8r> Yes, and a `.a` for static linking
<FromGitter> <j8r> But not required for shared linking
<FromGitter> <j8r> So to sumup, you have to compile the C lib to have the .h, .so/.o maybe also .a. Then, you can gen bindings with the .h to use the lib. Finally, you can compile thanks to .so/.o/.a
<FromGitter> <bew> @TeddyDD i don't think you can use a header only C "lib", because you can't link to anything
<FromGitter> <bew> You'll have to reimplement it in Crystal
<FromGitter> <Blacksmoke16> hmm, apparently you cant `to_json` a `HTTP::Client::Resposne` :/
<FromGitter> <TeddyDD> I managed to generate bindings using https://github.com/olbat/libgen
<FromGitter> <TeddyDD> now I need to figure how to force linker to include that header....
<FromGitter> <TeddyDD> ```@[Link("raylib")] ⏎ @[Link(ldflags: "-I#{__dir__}/lib_raygui -lX11")]``` [https://gitter.im/crystal-lang/crystal?at=5b92fd8c0fb4232e388f5553]
<FromGitter> <TeddyDD> this doesn't work for some reason
<FromGitter> <TeddyDD> welp, doesn't work, even with hardcoded path, that's a pity
hightower2 has quit [Ping timeout: 272 seconds]
<FromGitter> <straight-shoota> How should the linker include a header?
<FromGitter> <TeddyDD> I wrote c file with `#include "raygui.h"` then compile .o and linked that
<FromGitter> <TeddyDD> wekrs
<FromGitter> <TeddyDD> :D
hightower2 has joined #crystal-lang
<FromGitter> <TeddyDD> is it possible to use string interpolations in ldflags? I saw some projects doing this on Github but I'v got an error: 'ldflags' link argument must be a String