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 quit [Remote host closed the connection]
* FromGitter * Blacksmoke16 downvoted
<FromGitter> <Blacksmoke16> ;)
<FromGitter> <girng> :(
<FromGitter> <dscottboggs_gitlab> I saw a thread once where someone proposed a similar syntax feature in python, and it was shot down for, among other reasons, because it was there to be a "tax on the developer" to prevent them from having too many variables passed to the constructor. lol
<FromGitter> <girng> thanks for the constructor `@` trick d scott. it's very nice
<FromGitter> <girng> when i write my initialize now, i start writing the `@` subconsciously
<FromGitter> <dscottboggs_gitlab> np
<FromGitter> <girng> i'm testing pass by copy function parameters
<FromGitter> <girng> https://paste.ee/p/BDhpe
<FromGitter> <girng> my memory usage stays the same the entire time, how come? if it's being passed by copy wouldn't take up a lot of memory?
<FromGitter> <girng> duplicating the struct values over and over again?
rohitpaulk has joined #crystal-lang
<FromGitter> <girng> how can i add a operator overload for my struct Vector2. i want to be able to do += on my vector
<FromGitter> <girng> https://play.crystal-lang.org/#/r/54p3 for example
<FromGitter> <girng> hmm found this https://crystal-lang.org/docs/syntax_and_semantics/operators.html, but how do i add the `+=` part, not just plus
<FromGitter> <girng> actualy.. ignore me, def + will work with += just tested it :D
<FromGitter> <girng> Here's my custom struct i'm working on, would this be how to limit the decimals to two places? https://play.crystal-lang.org/#/r/54qk is it possible to do it without converting it to a string?
bmcginty has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 252 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 260 seconds]
shmibs has quit [Quit: leaving =o]
shmibs has joined #crystal-lang
Groogy1 has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 268 seconds]
Groogy1 has quit [Ping timeout: 268 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter> <sam0x17> how would I go about malloc-ing a C string of a specified size (so I can pass it to a C library)?
<FromGitter> <sam0x17> pass a pointer to the first element of an Array(UInt8)?
<FromGitter> <bew> No, use `Slice(UInt8)`
<FromGitter> <bew> (alias: `Bytes`)
<FromGitter> <dscottboggs_gitlab> why a slice if it's a specific size?
<FromGitter> <sam0x17> so what would the initialization look like for that?
<FromGitter> <bew> A slice is basically a struct for a pointer to some memory, and a size.. So it's perfect for that
<FromGitter> <bew> Btw you could also use a `StaticArray` if all you want is to pass it the a c function, then create a `String` object from it
<FromGitter> <bew> Well look at the docs, you create a slice with a size and a default value (to init each slot of the slice)
<FromGitter> <sam0x17> thx
<FromGitter> <bew> Or for the staticarray, you can do `bla = uninitialized UInt8[256]`, and use `pointerof(bla)` to pass it around to the c binding, or the string ctor
rohitpaulk has quit [Ping timeout: 252 seconds]
DTZUZO has quit [Ping timeout: 252 seconds]
Groogy1 has joined #crystal-lang
rohitpaulk has joined #crystal-lang
baweaver is now known as baweaver_away
<jokke> fridgerator: yeah i thought about that but i wanted to use scratch as the base image so there's literally _nothing_ there
<jokke> re: using netcat to check if postgres is running
<jokke> i guess i have to implement the loop in crystal itself
ashirase has quit [Ping timeout: 268 seconds]
ashirase has joined #crystal-lang
<jokke> i'm a bit confused about the Dockerfile of crystal
<jokke> it says FROM crystallang/crystal
<jokke> i didn't know recursive images are possible
<jokke> anyhow i was wondering what distro the image is based on
<FromGitter> <Timbus> since it does an apt-get, it must be debian, or ubuntu
<FromGitter> <Timbus> guess you could dive into a shell and check out the release info..
<FromGitter> <j8r> you can check `/etc/issue`. I think it's debian 9
DTZUZO has joined #crystal-lang
<FromGitter> <vladfaust> Wake me up
<FromGitter> <vladfaust> September has ended
<jokke> very interesting
<jokke> to ship working static binaries you can't use the official crystal image
<jokke> also it would be against the LGPL
<jokke> (which is the license of glibc)
<FromGitter> <Prutheus> @Sija I am on Mojave, I can’t measure performance differences yet. But I have not tested on performance, but if you want me to run performance testing scripts just tell me
<FromGitter> <j8r> i don't know why the default image isn't on Alpine
<jokke> using alpine as base image you can link libc statically as alpine uses musl libc
<jokke> which is MIT
<FromGitter> <j8r> I've a question
<jokke> shoot
<jokke> jhass: any reason why the docker image isn't based on alpine?
<FromGitter> <j8r> If I compile a MIT program statically against glibc
<FromGitter> <j8r> What's the problem with GPL or LGPL?
<jokke> j8r: you would have to ship sources for glibc
<FromGitter> <j8r> MIT is GPL compatible
<FromGitter> <j8r> So I need to ship the binary and the sources with what I've built the binary
<FromGitter> <j8r> I can't just tell: look at github.com/whatever for sources?
<jokke> i'm not 100% sure
<jokke> Or provide everything that allow the user to relink the application with a different version of the LGPL source code. In this case the other requirements are the same as if it was dynamically linked.
<jokke> from the stackoverflow answer
<jokke> you do that with the source code
<jokke> i think it's becoming a problem with proprietary code that you don't release the source for
<jokke> which is my case
<FromGitter> <j8r> Yes, I think there is no problem for open source if you have a compatible, more permissive license
<jokke> asterite: i'd really appreciate a list of runtime clib deps somewhere in the docs
<FromGitter> <j8r> and more importantly, the source code is available to recompile the same binary (e.g. no proprietary patch)
<jokke> even if they're optional.
<jokke> yeah
<FromGitter> <j8r> `ldd ./mybin`?
<Tortice> speaking of static linking, I can't get --link-flags="-static" to work, ld complains about missing packages, but when I check with ldconfig -p, they are listed
<jokke> Tortice: just use --static
<jokke> it will use the -static link flag
<jokke> Tortice: also it totally depends on the distro you're compiling it on
<jokke> Tortice: i use arch and it doesn't ship static libs by default
<Tortice> oh, that's the same distro I'm using, good to know
<jokke> :)
<Tortice> sorry for the stupid question
<jokke> not stupid
<jokke> Tortice: if you want to make it work you will need to use asp to get the dependencies and modify their PKGBUILDs to include `options=('staticlibs')`
<FromGitter> <girng> how can i set thestruct value based on an operator def method?
<jokke> or you can save yourself a lot of trouble and build inside docker
<jokke> and then just copy the static bin out of the container
<FromGitter> <girng> i've tried self[index] = value, and @index = value, none work :/
<jokke> Tortice: but as i just said, you can't use the crystallang/crystal image
<jokke> i mean, you can, and it will mostly work, but not always
<jokke> girng that won't work without a macro
francisl has joined #crystal-lang
<FromGitter> <Prutheus> Hello. I am using crecto to manage database access. But I need to build the models and migrations by myself, but I don’t know how the migrations needs to look for my models. Is there any way to auto-generate the migrations?
<jokke> girng: something like this: https://play.crystal-lang.org/#/r/54ue
<jokke> Prutheus afaik no
<FromGitter> <girng> O_O
<jokke> Prutheus crecto does have it's own gitter though
<FromGitter> <Prutheus> oh okay
<FromGitter> <girng> @jokke that's pretty cool, ty
<jokke> girng: welcome to the world of macros :P
<FromGitter> <girng> hehe
<FromGitter> <Prutheus> do you know any better ORM systems than crecto or granite?
<FromGitter> <bew> Better in which ways?
<FromGitter> <Prutheus> auto-generating sql stuff
francisl has quit [Quit: francisl]
<FromGitter> <Prutheus> I need an ORM system where I can build my model and then automatically run the migrations which are genereated from my .cr model file
rohitpaulk has quit [Ping timeout: 268 seconds]
<FromGitter> <fridgerator> I dont know, try jennifer.cr
francisl has joined #crystal-lang
<FromGitter> <vladfaust> I'd like to share current progress on params, these are almost ready (adding docs): ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5bb21946600c5f642338ddcc]
ashirase has quit [Ping timeout: 252 seconds]
<FromGitter> <vladfaust> Why? Because ⏎ ⏎ a. Parsing from all sources (path, query, all content-types) ⏎ b. Type-casting, `id` is actually `Int32` and `additional_data` is `struct` and `additional_data.deep` is `struct | Nil`. Will raise `Params::TypeCastError` on parse if couldn't cast though [https://gitter.im/crystal-lang/crystal?at=5bb21abbef4afc4f28013406]
<FromGitter> <vladfaust> This module will bring type safe params to Kemal, Lucky, Amber and other frameworks :)
francisl has quit [Quit: francisl]
ashirase has joined #crystal-lang
<FromGitter> <yxhuvud> doesn't lucky already have type safe params?
<FromGitter> <vladfaust> Yeah, it only supports query params though
<FromGitter> <vladfaust> No nesting nor arrays
<FromGitter> <vladfaust> @paulcsmith once asked if I could extract Prism params to a shard and even promised to get in touch with me about the architecture, but never heard from him thereafter 😅
<FromGitter> <fenicks> @vladfaust Really cool, 👍
<FromGitter> <vladfaust> Thanks, I appreciate
* FromGitter * dscottboggs_gitlab has been making use of macros and is now ruined for other languages
francisl has joined #crystal-lang
<FromGitter> <paulcsmith> @vladfaust Sorry about that :D Been super busy with a new feature in Lucky that is taking longer than expected! I do plan to reach out, but I am just not sure when. Once this feature is done I need to update a bunch of docs and code for the next Lucky release
<FromGitter> <paulcsmith> It's fairly large so it is taking a bit :D
<FromGitter> <vladfaust> I understand, no problem. However, params will require some work to adapt with a framework as well, so it never ends :)
<FromGitter> <vladfaust> I'm wondering what is that feature?
<robacarp> he may keep us all wondering...
akaiiro2 has joined #crystal-lang
<FromGitter> <girng> i love Crystal!
akaiiro2 has quit [Client Quit]
<FromGitter> <girng> Story of my life! (https://i.gyazo.com/960b660fe1e670de03c74b81f2340c59.png)
akaiiro has joined #crystal-lang
<FromGitter> <paulcsmith> @vladfaust transparently encrypted config files with gitattributes. https://gitter.im/luckyframework/Lobby?at=5bae67e65a52b440159bcbd4
<FromGitter> <paulcsmith> Getting all the edge cases sorted out is tricky. Making it easy to merge encrypted files is especially tricky, but it is getting clsoer
<FromGitter> <Prutheus> at jennifer.cr … how to get all rows in a table? I can do User.all … but how to list all rows then?
<FromGitter> <proyb6> Just saw this PR ⏎ https://github.com/crystal-lang/crystal/pull/6897 ⏎ ⏎ Crystal 0.26.1 vs Go 2.11 was that Go is roughly 2x faster than Crystal in fiber. ⏎ https://github.com/songjiayang/crystal-vs-golang ... [https://gitter.im/crystal-lang/crystal?at=5bb22a25a9be136b94dc97ff]
<FromGitter> <codenoid> of course
<FromGitter> <girng> whe nwas that benchmark done again
<FromGitter> <girng> it's been 2 years it looks like
<FromGitter> <proyb6> @girng I did it last night with recently version on 0.26.1 and 2.11
<FromGitter> <girng> o
<FromGitter> <asterite> In Crystal he reads all the file in memory then splits it, in Go he uses a scanner to find each line... that's of course slower in Crystal because of a different algorithm used
<FromGitter> <asterite> not saying that will make Crystal faster, Go is being developed by Google
<FromGitter> <j8r> yes the algos are very different
<FromGitter> <asterite> well, then the benchmark doesn't make sense :-)
<FromGitter> <asterite> please use the same algorithm (probably using gets or something to count lines, but even then I think it's not the same because `gets` will create a new string each time, so you'll have to find a way to do that in Crystal
<FromGitter> <asterite> see, Go's scanner uses an internal slice to reuse memory to find the next token, and this is explicitly documented... there's no way to nicely do that in Crystal (I guess you'd need a `IO::Scanner` type too)
<FromGitter> <asterite> https://golang.org/src/bufio/scan.go?s=4369:4401#L95
<FromGitter> <j8r> A Crystal fellow, @drujensen , has created https://github.com/drujensen/fib
<FromGitter> <j8r> (not related to Fibers benchmarking)
<FromGitter> <proyb6> Interesting, didn't know that! I guess if there is a need for similar API in Crystal.
<FromGitter> <sdzyba> @vladfaust params functionality looks great, where can I find a repo with it? :)
<FromGitter> <Prutheus> at jennifer.cr … how to get all rows in a table? I can do User.all … but how to list all rows then?
<FromGitter> <fusillicode_twitter> Hi guys sorry for the bother, I was wondering if there was a language feature that was close to Scala Case Classes
<FromGitter> <Prutheus> to list all users
<FromGitter> <fusillicode_twitter> Right now I'm in need to have simple value objects with some default values
<FromGitter> <Prutheus> And where is the difference between User.all.where… and User.where...
<FromGitter> <fusillicode_twitter> I'm using NamedTuples but I don't think that they're the right fit for my use case
<FromGitter> <j8r> @fusillicode_twitter often you can use a struct instead
<FromGitter> <j8r> or even an Enum sometimes
<FromGitter> <fusillicode_twitter> Struct!
<FromGitter> <fusillicode_twitter> How did I miss that! I've already used them before!
<FromGitter> <fusillicode_twitter> Thanks a lot as usual @j8r 🙇
<FromGitter> <j8r> Note they are the same as classes (but passed by copy) :)
<FromGitter> <fusillicode_twitter> Yep yep I'm recalling ;)
<FromGitter> <Prutheus> Can someone please tell me how I can get the results out of a query at Jennifer.cr, e.g. from `User.all.where {_email == email}` ?
<FromGitter> <j8r> @Prutheus if nobody answer, this means nobody here use/know this particular library. Please wait and don't ask again :/
<FromGitter> <j8r> You can also try another ORM, like the one from @vladfaust . He would be able to answer you :)
<FromGitter> <Prutheus> hmm but i need to access my database entries now
<FromGitter> <Prutheus> no i need jennifer, its the best one currently, cause i do not need to generate own mysql syntax migrations
<FromGitter> <Blacksmoke16> https://github.com/anykeyh/clear is also quite good but only for PG
<FromGitter> <Blacksmoke16> @Prutheus iirc its eagerly loaded so its not actually loaded until it is used
<FromGitter> <Blacksmoke16> but i might be getting confused with another lib...
<FromGitter> <Blacksmoke16> i.e. try like:
<FromGitter> <Blacksmoke16> ```users = User.all.where {_email == email} ⏎ users.each do |user| ⏎ pp user ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5bb243651e23486b93712215]
<FromGitter> <Blacksmoke16> and see what happens :p
<FromGitter> <Blacksmoke16> `My favorite part. Jennifer allows you to build lazy evaluated queries with chaining syntax. ` so yea thats prob what is happening
francisl has quit [Quit: francisl]
francisl has joined #crystal-lang
druonysus has joined #crystal-lang
druonysus has left #crystal-lang [#crystal-lang]
druonysus has joined #crystal-lang
rohitpaulk has joined #crystal-lang
<FromGitter> <S-YOU> Raw Crystal with just C calls, without concurrency ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ :) [https://gitter.im/crystal-lang/crystal?at=5bb25317e65a6343366a2baa]
DTZUZO has quit [Ping timeout: 246 seconds]
non-aristotelian has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 260 seconds]
<FromGitter> <bew> @S-YOU without the stdlib?
francisl has quit [Quit: francisl]
<jokke> asterite: wanna review my PR to webmock? :) https://github.com/manastech/webmock.cr/pull/27
<jokke> i tried just returning the return value of the yield but that was always nilable
<jokke> i guess because from_io doesn't always yield
<jokke> but by the looks of the source it does. so i'm a bit confused
<FromGitter> <S-YOU> @bew, with some stdlib like Dir.glob. basically following code (which wouldn't directly compile) ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ read_file is C 's open, and read, close calls. malloc is also C [https://gitter.im/crystal-lang/crystal?at=5bb26035bbdc0b2505ce6d7e]
junland has quit [Quit: Disconnected.]
junland has joined #crystal-lang
<FromGitter> <fenicks> I have this error on CentOS7 with libssl, the installed version is libssl.so.1.0.2 and crystal program are looking for 1.1 : `error while loading shared libraries: libssl.so.1.1` ⏎ How can I specify the correct version ? Is that an issue with the detection macro for the ssl version
<FromGitter> <fenicks> Ok, it's probably related with this issue: https://github.com/crystal-lang/crystal/issues/4680
sagax_ has joined #crystal-lang
sagax_ is now known as sagax
francisl has joined #crystal-lang
<FromGitter> <fenicks> It'll be very cool if Crystal didn't depends on LibSSL but have an implementation entirely written in Crystal.
<FromGitter> <dscottboggs_gitlab> I think that would be asking for security bugs. Like I don't see anything wrong with doing an initial implementation of something security focused in crystal, but if there's a library that you can just import that has already been thoroughly vetter, why take a chance?
DTZUZO has joined #crystal-lang
<FromGitter> <girng> @fenicks like a shard?
<FromGitter> <girng> AFAIK there is a github thread of certain features they think should be in shards, and some that should be removed from standard lib
francisl has quit [Quit: francisl]
francisl has joined #crystal-lang
francisl has quit [Client Quit]
<FromGitter> <dscottboggs_gitlab> Is there any way to get a segfault in crystal when you're not working with "unsafe" code? I thought crystal was null-safe?
<FromGitter> <fenicks> @girng For tls and crypto libs, in standard/core library but in pure Crystal
dostoyevsky has quit [Quit: leaving]
dostoyevsky has joined #crystal-lang
dostoyevsky has quit [Client Quit]
dostoyevsky has joined #crystal-lang
<FromGitter> <Sija> @dscottboggs_gitlab there shouldn’t be, and what does it have to do with being null-safe (whatever that means)?
<FromGitter> <fenicks> @dscottboggs_gitlab the problem I have with openssl binding in crystal is that some distro has different version and crystal binary refer another and are missing the correct name/version of the shared library installed in host. In my case I can't compile a specific version of libssl to fix that or change CentOS7 for Ubuntu per example.
<FromGitter> <dscottboggs_gitlab> null safe means it throws a compile time error if the value is nillable, as opposed to languages like Go where nil regularly used and not checked for at compile time
<FromGitter> <Sija> ok, that’s what you have in Crystal
<FromGitter> <dscottboggs_gitlab> my spec is causing a segfault....
<FromGitter> <Sija> could post the offending code?
<FromGitter> <Sija> bear in mind there r still multpile cases of compiler bugs, so with bit of luck you might just stepped on one
<FromGitter> <dscottboggs_gitlab> yeah that's what I was figuring, or maybe a null pointer reference in the spec library?
<FromGitter> <dscottboggs_gitlab> the spec that's causing the problem is `gradient_spec`
<FromGitter> <Sija> could you post the full error?
<FromGitter> <dscottboggs_gitlab> ooh yeah
<FromGitter> <dscottboggs_gitlab> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5bb2a2d75af485306847ef11]
<FromGitter> <dscottboggs_gitlab> @fenicks I agree that that's a problem, but I don't think rewriting LibSSL is the solution to that. there could just be a patch to make it aware of older versions. I suppose static linking isn't an option?
<FromGitter> <fenicks> @dscottboggs_gitlab Static linking makes the program runnable but hangs when dealing with tls
<FromGitter> <dscottboggs_gitlab> what about docker/snap/appimage?
<FromGitter> <fenicks> With Docker and the CentOS7 image crystal complaint with execvp error. I'm trying another king of image
<FromGitter> <Sija> @dscottboggs_gitlab sorry, no idea :/
<FromGitter> <dscottboggs_gitlab> damn, I'll post a bug report then. thanks for taking a look