RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.27.0 | 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
notdaniel has joined #crystal-lang
non-aristotelian has quit [Quit: non-aristotelian]
blove has quit [Quit: WeeChat 2.3]
<FromGitter> <pitosalas> Question? About property and initialization...
<FromGitter> <pitosalas> Can someone clarify: if I define a property with a datatype. e.g. property name : String, do I still have to initialize it in the initializer? Is there a way to do all at the same time? define getters, setters, declare a type, and initialize?
<FromGitter> <kinxer> @pitosalas https://carc.in/#/r/5l22
<FromGitter> <kinxer> Does that answer your question?
<FromGitter> <pitosalas> totally. thanks. didn't see that form in the doc
return0e has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
<FromGitter> <kinxer> Yeah, I actually learned it from other people's code here on Gitter.
<FromGitter> <pitosalas> This is bit uglier though ` property row_headers : Array(String) =[] of String`
<FromGitter> <pitosalas> repetitive
<FromGitter> <anamba> @pitosalas `property row_headers = Array(String).new`
notdaniel has quit [Read error: Connection reset by peer]
sz0 has quit [Quit: Connection closed for inactivity]
oz has quit [Ping timeout: 240 seconds]
oz has joined #crystal-lang
pabs has left #crystal-lang [#crystal-lang]
pabs has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 268 seconds]
marmotini_ has joined #crystal-lang
marmotini_ has quit [Remote host closed the connection]
<FromGitter> <dscottboggs_gitlab> you can do `property row_headers = [] of String`
<FromGitter> <j8r> No @dscottboggs_gitlab the first syntax is better, because the standard way to instantiate objects
<FromGitter> <dscottboggs_gitlab> that may be your opinion but both forms are valid. I was just pointing it out because it was closer to what @pitosalas was trying to do. I do think the empty array syntax is confusing though.
<FromGitter> <j8r> This `of` syntax hurts because with it some beginners struggle to do Array of Array. Unnecessary complexity built a top of Array(T).new
<FromGitter> <dscottboggs_gitlab> the problem with it for me was when I first started was that I tried to declare types as empty arrays.
<FromGitter> <dscottboggs_gitlab> `[] of [] of T` doesn't work?
<FromGitter> <dscottboggs_gitlab> nope, it doesn't. yeah that really seems like unnecessary sugar
<FromGitter> <bararchy> yeha the `of` is really bad, I loved it at first but it makes the code less readable
<FromGitter> <bew> It depends on your code
<FromGitter> <bararchy> `Array of String` ⏎ `Array(String).new`
<FromGitter> <bararchy> I think the type inside the () make it look clearer
<FromGitter> <bew> I mean, it's faster for your brain to parse `[] of ..` / `{} of .. => ..` than the standard `Array(..).new`
<FromGitter> <bew> when reading code, it's nice to be able to immediately spot containers
<FromGitter> <proyb6> Crystal is not yet supported?
<FromGitter> <bararchy> @proyb6 not supported where?
<FromGitter> <j8r> But @bew this is non standard. Now I'm used to use `.new` every time to instantiate objects. Ok the `[]` and `{}` might be better looking, but only useful for Array and Hash - one more thing to learn, than can be avoided. Also this adds useless complexity to the compiler
<FromGitter> <j8r> this also hides the very type behind: for me `[]`, brackets, can mean `Array` or `StaticArray` or `Set`. `{}` can mean `Hash` or `NamedTuple` or `Tuple`
<FromGitter> <proyb6> @bararchy Click here to see the list of supported languages.
<FromGitter> <j8r> Maybe @asterite or @RX14 have an explication why this syntax exists
<FromGitter> <proyb6> there is a button listing all the supported languages
<RX14> I'm the wrong person to ask, I proposed removing them lol
<FromGitter> <bararchy> @proyb6 so... click this random link (that you didn't post) to see what you mean? can't you just tell me "isn't supported in ... somewhere"
<RX14> But we still need [] and {}
<RX14> Well we still need array and harsh literals
<RX14> So disallowing empty ones was seen as a bit weird
<FromGitter> <bararchy> literals make sense
<RX14> They're not that bad
rohitpaulk has joined #crystal-lang
<FromGitter> <j8r> yes,`{ "a" => 1 }`, `{ "a", "b"}` and `{ a: "b"}` are clear
<FromGitter> <j8r> But we have `{} of String, String` (a Hash or a NamedTuple)? `{} of String` is invalid too
<FromGitter> <j8r> BTW empty Tuple, NamedTuple or StaticArray have little sense
ashirase has quit [Ping timeout: 268 seconds]
rohitpaulk has quit [Ping timeout: 268 seconds]
ashirase has joined #crystal-lang
rohitpaulk has joined #crystal-lang
<FromGitter> <straight-shoota> @j8r empty literals can happen when they're constructed by macros.
<FromGitter> <proyb6> @bararchy Sorr, I'm on my lhk e
<FromGitter> <proyb6> phone all the while, there is a button on the website which shown the supported language
<FromGitter> <proyb6> http://tke.sourceforge.net/
<FromGitter> <bew> @proyb6 what about vim? :D
<FromGitter> <proyb6> I been using Vin for all editing and coding but it's a little tedious, only if you can develop CLI to generate code faster like Laravel does?
<FromGitter> <bew> what kind of generation do you need?
<FromGitter> <proyb6> @bew Previously I have used Perfect web framework could be easier with HI wizard
<FromGitter> <proyb6> And allow devs to configure cli to our custom code is a time saver
<FromGitter> <bew> I mean if you need it for some web frameworklike amber or lucky they already have tools like that to generate basic files
<FromGitter> <neutrinog> hey I've been tinkering with developing a 3d game engine in crystal. I've seen several attempts, but most are stale and not very far along. I'm building this 3D engine so I have an excuse to learn crystal (love it!). Anyway I thought I'd share a demo of what I've done so far. Maybe generate some interest. https://www.youtube.com/watch?v=-IyXs2Dqs2o&feature=youtu.be
<FromGitter> <bew> That's pretty cool, does it use opengl? (also, on the video the screen flickers, you know why?)
<FromGitter> <neutrinog> it currently uses opengl but down the road I'd like too support vulcan as well. The flickering is due to my screen recorder :(
<FromGitter> <f1refly_gitlab> @neutrinog That looks awesome
<FromGitter> <rishavs> I am trying to convert a `db.query` call into a `db.query_one?`. But I am not sure how to use the block/resultset. ⏎ My original call is; ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5bf555c1a115c91ef76d0d3b]
rohitpaulk has quit [Ping timeout: 272 seconds]
thews has quit [Ping timeout: 250 seconds]
thews has joined #crystal-lang
<FromGitter> <rishavs> @neutrinog this is great work!
<FromGitter> <bararchy> @neutrinog that's pretty cool, but saying `engine in crystal` and then github shows: ` C 75.7% Crystal 24.0% Other 0.3% `
<FromGitter> <bararchy> so it's more of a binding around a c engine?
gangstacat has quit [Quit: Ĝis!]
rohitpaulk has joined #crystal-lang
RX14 has quit [Quit: Fuck this shit, I'm out!]
RX14 has joined #crystal-lang
gangstacat has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 250 seconds]
<FromGitter> <7sedam7> Hello guys
<FromGitter> <mamantoha> GitHub lies
<FromGitter> <j8r> Not necessarily
<FromGitter> <7sedam7> Can some1 tell me what is the difference between: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5bf56d85fa7bbb3fe0e001db]
<FromGitter> <7sedam7> the crystal version gives me error
<FromGitter> <j8r> @mamantoha there are few C headers files that are really big
akaiiro has quit [Ping timeout: 240 seconds]
<FromGitter> <7sedam7> error in a sense that API returns 403, the curl version returns the expected response
<FromGitter> <mamantoha> @j8r you are right. Anyway it’s third-party C file
<FromGitter> <mamantoha> @jacobi-78 `301` is not an error. Crystal `HTTP::Client` does not support redirects
<FromGitter> <mamantoha> you should follow redirects manually
<FromGitter> <mamantoha> or use crest/halite shards which automatically following redirects
akaiiro has joined #crystal-lang
<FromGitter> <7sedam7> I know it's not an error, but point is that curl does not do a redirect
<FromGitter> <7sedam7> so it seems that those 2 requests are not the same, and i can't see a difference
<FromGitter> <7sedam7> and just tried with a halite, getting the same thing
<FromGitter> <7sedam7> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5bf574d9c6cf4524d154d8ca]
<FromGitter> <7sedam7> if i make `Halite.follow.post...` then i get `Unhandled exception: Can not follow 301 redirect (Halite::Exception::StateError`
<FromGitter> <7sedam7> and an extra `'` in `"'Content-Type" => "application/json",` is not the error, fixed it, no improvements
<FromGitter> <Blacksmoke16> hmm
<FromGitter> <7sedam7> Can I somehow have details of the request that crystal creates?
<FromGitter> <Blacksmoke16> if you `curl google.com` you get a 301 moved response, which is the same as what you get with crystal
<FromGitter> <Blacksmoke16> ```CLIENT.before_request do |r| ⏎ pp r ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5bf57913a115c91ef76e06d5]
<FromGitter> <Blacksmoke16> would print the request obj before making the request @7sedam7
<FromGitter> <7sedam7> do you know by heart how to do the same printout with curl so i can compare?
<FromGitter> <7sedam7> thanks for the help @Blacksmoke16
<FromGitter> <Blacksmoke16> uh try like `curl -v google.com`
<FromGitter> <7sedam7> thanks 🙇 Accept and User-Agent are different, will try if it makes any differenece
<FromGitter> <7sedam7> Content-Length is a bit bigger with curl, but I don't see any difference besides that any more, still curl returns 200 and a json response and crystal 301 :/
<jhass> http vs https?
<FromGitter> <7sedam7> both https
<jhass> can you gist both outputs?
<FromGitter> <7sedam7> curl: ⏎ `{"key":"val"}` ⏎ ⏎ crystal: ⏎ ... [https://gitter.im/crystal-lang/crystal?at=5bf57cdd6621313894f726f1]
<FromGitter> <bararchy> @7sedam7 make sure URL is same to last letter as in curl end in `/` so same
rohitpaulk has joined #crystal-lang
<FromGitter> <bararchy> I see your upper example is `/#{API_VERSION}/preorders` while in curl `/preorders/`
<FromGitter> <pitosalas> @bararchy @j8r @bew Thanks... helpful... I thought I saw somewhere that [] of String is preferred to Array(String).new
<FromGitter> <j8r> I really doubt @pitosalas . The syntax is referenced in the docs, that's it
<FromGitter> <bew> There are 2 syntaxes, use whatever you want :)
<FromGitter> <pitosalas> ok. I will see where I saw it . it might have. been a random stackoverflow response :)
<FromGitter> <neutrinog> @bararchy github only shows `C 75.7%` because I'm importing `stb_image.h` until I can find a decent crystal image library. I'm only using one function out of that library to read in images.
rohitpaulk has quit [Ping timeout: 252 seconds]
<FromGitter> <alex-lairan> Hi everyone, ⏎ ⏎ I am using AmberFramework, and I want to Gzip for a specific pipeline (different than Amber::Pipe::Static) ⏎ ⏎ I want to get the HTTP::Server::Response body then update it. ... [https://gitter.im/crystal-lang/crystal?at=5bf597dff048fa1051ff3206]
rohitpaulk has joined #crystal-lang
<FromGitter> <bararchy> @neutrinog got you, thanks for clarifying. What about https://github.com/stumpycr/stumpy_png
<FromGitter> <bararchy> @alex-lairan how about monkey-patching the getter to setter or propreity
<FromGitter> <alex-lairan> @bararchy It look like `HTTP::Server::Context` have a `content` method :o ⏎ ⏎ The documentation don't mention it.
korzybski has joined #crystal-lang
<z64> if you're looking at the stdlib `HTTP::Server::Context` is just a `class` that holds a request and response - https://github.com/crystal-lang/crystal/blob/master/src/http/server/context.cr - amber reopens this class and adds `content`, and some other things. where ambers docs are though, i don't know, in source it's: https://github.com/amberframework/amber/blob/master/src/amber/router/context.cr#L16
<FromGitter> <neutrinog> @bararchy thanks, I'll try it out.
ua_ has quit [Ping timeout: 252 seconds]
<FromGitter> <j8r> A blog post about reducing compilation time in D https://blog.thecybershadow.net/2018/11/18/d-compilation-is-too-slow-and-i-am-forking-the-compiler/
<FromGitter> <j8r> Some ideas are interesting, like compiling packages, create headers and then linking them to our main app
<FromGitter> <j8r> The shards dependencies won't have to be recompiled each time.
<FromGitter> <j8r> Crystal headers don't exist :(
<FromGitter> <asterite> @j8r `[] of ...` exists because `[]` exists in Ruby, that's the equivalent in Crystal. Crystal is basically "let's make Ruby compiled". Most of the design decisions are based on that. It's probably too late now, but I would change a lot of things in the language
<FromGitter> <r00ster91> which things? Besides `[] of ...`
<oprypin> whenever you think something is wrong about the language, changes are it's one of those things
<oprypin> chances*
rohitpaulk has quit [Ping timeout: 252 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 245 seconds]
<FromGitter> <j8r> Doing radical breaking changes is a major point in a language. Python with 2 -> 3. The append-only C++. Perl 5 and 6.
<FromGitter> <j8r> If Crystal can deprecate things properly, and make radical changes, it will stay attractive durably
<FromGitter> <r00ster91> Yeah Crystal is still in a very early stage and thus I wouldn't say it's too late to change things. I don't see any problem with breaking (language) changes before 1.0.0.
rohitpaulk has joined #crystal-lang
Jenz has joined #crystal-lang
* Jenz o/
rohitpaulk has quit [Ping timeout: 268 seconds]
rohitpaulk has joined #crystal-lang
<jokke> o/
<z64> o/
<jokke> does someone know where the default ca certs come from in openssl? i mean from the os for sure, but what if i statically link openssl?
<jokke> currently a statically linked crystal binary fails with PubRelay::WebServer OpenSSL::SSL::Error: SSL_connect: error:14007086:SSL routines:CONNECT_CR_CERT:certificate verify failed
rohitpaulk has quit [Ping timeout: 240 seconds]
<jokke> the binary runs in a scratch docker imag
<jokke> e
<FromGitter> <7sedam7> @bararchy urls are the same, i just removed the content for the example, but `/` was missing, and the API returns 301 if `/` is missing (and it does not behave like that for all the endpoints :D) ⏎ Thanks for the help 🙇
<jokke> never mind
<jokke> openssl version -d
rohitpaulk has joined #crystal-lang
<FromGitter> <bararchy> @7sedam7 NP, happy I helped, I play around with HTTP a lot and this is quite a common scenario
rohitpaulk has quit [Ping timeout: 252 seconds]
<Jenz> I love the automatic symbol to enum cast
Jenz has quit [Quit: Good day]
korzybski has quit [Quit: korzybski]
korzybski has joined #crystal-lang
ua has joined #crystal-lang
sz0 has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 245 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 245 seconds]
<FromGitter> <Blacksmoke16> how would you edit the response and an http response
<FromGitter> <Blacksmoke16> `undefined method 'body=' for HTTP::Server::Response`?
<FromGitter> <Blacksmoke16> well i guess its write only so welp
<woodruffw> what are you trying to accomplish? a `HTTP::Server::Response` is a chunk of data returned by a server, so it makes sense for it not to be modifiable
<woodruffw> (you can probably `dup` the actual body and then modify that copy)
<FromGitter> <Blacksmoke16> (using kemal) plan was to have an `after` filter that runs after certain routes that handles serialization depending on the context, like which route it is etc
<FromGitter> <Blacksmoke16> mainly just messing around
<woodruffw> ah, i see. yeah, for that it might make sense to duplicate the whole response
<woodruffw> (but i'm not extremely familiar with kemal, so there might be a less memory intensive way)
<FromGitter> <Blacksmoke16> yea dunno
<FromGitter> <Blacksmoke16> oh well, not impt