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
<FromGitter> <girng> hi
<FromGitter> <Blacksmoke16> o/
<scott_tams> oh hey guys
<FromGitter> <domgetter> Are there any resources for doing compile time precomputation to, say, precompute values of sin or factorial?
<FromGitter> <Blacksmoke16> Probably doable in a macro to set the value of a constant or something
<oprypin> domgetter, can only be done with https://crystal-lang.org/api/0.27.0/Crystal/Macros.html#run%28filename%2C%2Aargs%29%3AMacroId-instance-method
laaron has joined #crystal-lang
<oprypin> well, technically not true cuz macros are Turing complete lol
<oprypin> this would actually be the perfect example for macro run documentation
<oprypin> `puts "["; 0..90.each { |i| puts Math.sin(i), "," }`
<oprypin> `SIN_TABLE = {{run("that.cr")}}`
<FromGitter> <domgetter> Ah okay, that makes sense. Thank you :)
laaron- has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron- has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron- has joined #crystal-lang
laaron has quit [Remote host closed the connection]
<scott_tams> oh that's really cool oprypin
<FromGitter> <parruda> I gotta say guys, canโ€™t thank you enough for the amazing work youโ€™ve done in this language.
<FromGitter> <parruda> I am using it daily in production without a glitch
<FromGitter> <proyb6> @parruda I'm curious what you ran on it?
<FromGitter> <parruda> https://faastruby.io
<FromGitter> <parruda> The most important pieces of it are written in Crystal
<FromGitter> <proyb6> Oh, I forgot about this, awesome works!
<FromGitter> <parruda> and I just released Crystal support, so people can actually run Crystal functions as well!
<FromGitter> <parruda> hello world running ~250x faster! Lol
<FromGitter> <proyb6> I think it's HackerNews worthy!
<FromGitter> <parruda> I posted there on SHOW
<FromGitter> <parruda> ops
<FromGitter> <proyb6> When was it posted?
<FromGitter> <parruda> ~30 mins ago
<FromGitter> <proyb6> If your account has low score, it won't appear to the public
<FromGitter> <parruda> oh yeah
<FromGitter> <parruda> my karma is 23
<FromGitter> <parruda> is that enough?
<FromGitter> <parruda> Anyways, this is the link I posted: https://faastruby.io/blog/faastruby-0-4-adds-support-for-ruby-2-6-0-and-crystal-0-27-0/
<FromGitter> <proyb6> I see, the best to post in Reddit and let someone share in HN
<FromGitter> <Blacksmoke16> @j8r @vladfaust https://github.com/Blacksmoke16/athena i pushed up the prototype if you wanted to take a look
laaron has joined #crystal-lang
laaron- has quit [Remote host closed the connection]
laaron- has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
Raimondi has quit [Ping timeout: 240 seconds]
laaron- has quit [Remote host closed the connection]
moei has joined #crystal-lang
<FromGitter> <proyb6> Saw it on Show HN!
<FromGitter> <proyb6> Now, I think why not some folks post your Crystal shards on ```Show HN``` in full force? โŽ https://news.ycombinator.com/show
laaron has quit [Remote host closed the connection]
<FromGitter> <vladfaust> @Blacksmoke16 come on, have some respect and write a Readme ๐Ÿ˜•
_whitelogger has joined #crystal-lang
<FromGitter> <redcodefinal> Is there a way to have `JSON.mapping` allow an inheriting class to add to it's `JSON.mapping`? I'm struggling to describe the problem, here is the code. โŽ https://carc.in/#/r/5vn5 โŽ I'd like to get this to work where `B.new.to_json` will spit out variables `A#a` anf `B#b` but unfortunately I need to repeat the entire `JSON.mapping` of the inherited class. โŽ https://carc.in/#/r/5vn6
<FromGitter> <vladfaust> @redcodefinal nope. `JSON.mapping` explicitly defines an initializer with variables passed to it. You either declare `a` nilable or with default value in `A`; or use `JSON::Serializable`
ashirase has quit [Ping timeout: 245 seconds]
laaron has joined #crystal-lang
ashirase has joined #crystal-lang
DTZUZO has joined #crystal-lang
laaron- has joined #crystal-lang
laaron has quit [Remote host closed the connection]
<FromGitter> <redcodefinal> @vladfaust ty for the suggestion worked like a charm.
JuanMiguel has joined #crystal-lang
JuanMiguel has quit [Remote host closed the connection]
<FromGitter> <sam0x17> for the life of me I can't figure this out. I'm using a `Flate::Reader` to decompress some bytes that were compressed with a `Flate::Writer`, and basically everything works fine with the compressing, but the second I call any method that does any reading on the reader (`read_byte`, `read`, `gets_to_end`, etc), I get the following error complaining about `Flate::Writer`. The weirdest thing is nothing in the
<FromGitter> ... stack trace leads back to the lines that, if removed, cause the error to no longer be thrown. https://pastebin.com/NFvgSZg7
<FromGitter> <sam0x17> (compile time error)
laaron has joined #crystal-lang
laaron- has quit [Remote host closed the connection]
<oprypin> sam0x17, don't use that pastebin. here's a list of reasons: https://pastebin.com/pro - use https://bpaste.net/
<oprypin> show the code. i don't know what this is
<mps> crystal doesn't have increment/decrement (++, --) operators, right?
<FromGitter> <Blacksmoke16> @vladfaust I'm getting there, is still a WIP :p
<FromGitter> <Blacksmoke16> i wrote tests, isnt that good enough :D
<FromGitter> <straight-shoota> mps, no it's `i += 1`
<mps> straight-shoota: yes, know that and used it that way. but my son looked at some of my code and asked me why I don't use '++'.
<FromGitter> <Blacksmoke16> because it isnt a thing
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/5vov
<mps> so, i asked here just to be sure and to give him right answer. anyway any doc which explains rationale for omitting inc/dec
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron- has joined #crystal-lang
Raimondi has joined #crystal-lang
ua has quit [Remote host closed the connection]
ua has joined #crystal-lang
ua has quit [Remote host closed the connection]
ua has joined #crystal-lang
Raimondi has quit [Ping timeout: 240 seconds]
sandelius has joined #crystal-lang
laaron- has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron- has joined #crystal-lang
laaron has quit [Remote host closed the connection]
<FromGitter> <j8r> I guess because it's an unnecessary syntax
<FromGitter> <j8r> strange that the compiler knows the syntax, but refuse to compile it by suggesting `+=` instead
<FromGitter> <j8r> In this case I want to slam the compiler and tell it: "You know what I mean, why you don't want to compile it!" >:|
<mps> 'x += 1' is addition operation, i.e. while x++ just increment register so I presume it would be faster than 'x += 1'. assembler programmer speaks from me now ;)
<mps> s/i.e.//
Renich has quit [Ping timeout: 245 seconds]
sandelius has left #crystal-lang ["Textual IRC Client: www.textualapp.com"]
<FromGitter> <j8r> maybe it would worth it to have it then...
<mps> but, if compiler 'know' that '+= 1' is a just increment value (var) by one, maybe it optimizes that at the compiled code
<mps> didn't looked at resulting asm code
<mps> but, every language have inc/dec operators so I think it will not hurt if crystal also have them
<FromGitter> <proyb6> ++x and x++ can be confuse, Swift Evolution has this discussion that they won't implement ++ too
<FromGitter> <proyb6> Ruby didn't too
<FromGitter> <proyb6> Good night
<mps> proyb6: go-lang also, but kept postfix versions
<mps> inc/dec operators causes a lot of confusion for novice programmers, i know, especially prefix/postfix distinction
<mps> imo, it is good to have them just for 'marketing' purposes, so critics of crystal then can't tell 'crystal even doesn't have inc/dec operators'
<FromGitter> <j8r> that a really sub minor topic mps :)
<FromGitter> <j8r> not having inc/dec isn't a big deal
<FromGitter> <j8r> if some is bashing a language because of this, (s)he is mistaken seriously
<mps> agree, but you know FUD (Fear, Uncertainty, Doubt) marketing could be effective, targeting uninitiated
<oprypin> mps, much more effective FUD is "operator abuse"
<oprypin> what rationale do you need, it's just a really stupid operator that just happens to have a useful niche specifically in C
<mps> for me that is not problem and didn't thought about, till yesterday when i showed crystal to my son and explained some syntax and he asked 'no ++' with 'surprising face'
<FromGitter> <j8r> what sad is we cant `def ++; end`
<FromGitter> <j8r> we have to `def increment; end`
<oprypin> in Nim you can. see how that turned out for them
<FromGitter> <j8r> how that turned out?
<oprypin> well it's a mess of random sigils
<mps> I explained to him that the inc/dec isn't important and he agreed, but after that i thought how will other newcomer react to that especially if they don't have someone to explain 'issue' to them
<FromGitter> <j8r> i agree it can be added in https://github.com/crystal-lang/crystal/wiki/FAQ
<oprypin> this is a made up problem, you could find 1000s of examples of "missing" features
<mps> that is not technical question, just 'marketing' issue
<oprypin> Go's main selling point is that it's missing features all around
<mps> behind 'go' is a big company which could 'sell' whatever they want
<oprypin> yes
laaron has joined #crystal-lang
<oprypin> you mentioned it, anyway
<FromGitter> <j8r> the main import point is explaining design decisions
<FromGitter> <j8r> *important
laaron- has quit [Remote host closed the connection]
<oprypin> does one need to explain every feature that was not copied, from every language?
<mps> j8r: again, I agree. that should be in https://crystal-lang.org/docs/syntax_and_semantics/operators.html
<FromGitter> <j8r> oprypin not one, a document
<mps> oprypin: not every but some would be useful
<FromGitter> <j8r> there is no problem to have a big doc explaining the language design
<mps> j8r: that sounds as good idea
<FromGitter> <j8r> for now there is the FAQ
<FromGitter> <j8r> adding a section for inc/dec ops
<mps> FAQ is also fine document
<FromGitter> <Blacksmoke16> https://github.com/Blacksmoke16/CrSerializer should be pretty stable now. I'm out of ideas on what else to add for now; feel free to create some issues ;)
Raimondi has joined #crystal-lang
<mps> j8r: short and simple, just how i like
<FromGitter> <j8r> haha lol
<FromGitter> <straight-shoota> It would be wise if such an FAQ question was based on the actual reasons in the decision making for the language, not some guesswork put together in chat.
<FromGitter> <j8r> that's a starting point @straight-shoota
<FromGitter> <j8r> that's better than nothing at all
<FromGitter> <straight-shoota> No, not really
<FromGitter> <straight-shoota> It doesn't hurt at all to have no mention about why such a minor detail is not present in the language
<FromGitter> <j8r> doens't hurt to have one too
<FromGitter> <drujensen> @Blacksmoke16 ๐Ÿ’ฏ
<FromGitter> <straight-shoota> Of course it does. The answer is simply based on your guesswork.
<FromGitter> <straight-shoota> Please leave answering such questions to people who actually know an answer and don't assume.
<FromGitter> <j8r> that's what the compiler say
<FromGitter> <j8r> not me
<FromGitter> <j8r> `Syntax error in eval:2: postfix increment is not supported, use `exp += 1``
<FromGitter> <straight-shoota> The compiler message says the operator is not supported. It doesn't say ANYTHING about *why*.
<FromGitter> <j8r> me too, don't say why in essence. If the compiler say I need to use +=1, this mean ++ isn't neceessary
<FromGitter> <j8r> or useful in crystal
<FromGitter> <j8r> else it won't suggest me to use +=1 or -=1
<FromGitter> <straight-shoota> That's a bold assumption.
<mps> it doesn't hurt to have that simple FAQ answer till someone who know rationale explain in more details
<FromGitter> <j8r> yeah I've been concise purposely. Not good in English, "necessary" isn't the right word perhaps
<FromGitter> <j8r> we can just keep what the compiler says: `use +=1 instead`
<mps> i learned it when compiler told me
<FromGitter> <straight-shoota> It's not about the content. The point is, you can't answer a question you don't know really know the answer to.
<mps> when I started to learn and play crystal I tried some of my knowledge from other langs without reading a lot about crystal
<mps> it was my intention to see how fast could one (before all I personally) 'jump' to crystal
<FromGitter> <straight-shoota> @j8r If you want to have an FAQ entry about increment/decrement operators, please open an issue and let somebody with knowledge provide it.
<FromGitter> <straight-shoota> Actually, it's probably better to make it a forum topic.
<FromGitter> <straight-shoota> It's not really an issue for the bug tracker.
<FromGitter> <j8r> I think the best would be a repo to host the language specifications
<FromGitter> <j8r> where all/most design decision would be. Actually searching issue comments where a decision was made isn't really practical :/
laaron- has joined #crystal-lang
laaron has quit [Remote host closed the connection]
<FromGitter> <bew> @j8r ๐Ÿ‘ for a repo/forum category to group all language-related
<FromGitter> <j8r> a bit like https://github.com/rust-lang/rfcs
<FromGitter> <j8r> when looking at https://github.com/rust-lang , Rust has done a great job about their organization - thats impressive :o
<FromGitter> <j8r> just noticed they have separated they formatter to is own repo
laaron has joined #crystal-lang
laaron- has quit [Remote host closed the connection]
<scott_tams> with most languages, there are "keywords" and "special cases" which differ from the default syntax. This isn't the case in Crystal. *Everything* is a statically-typed object, or a method which acts upon one. Every single language construct comes from those two concepts (except macros but one could argue that's a second language like Go's Template language). So it doesn't seem that confusing to me to have a `++`
<scott_tams> method which increments something on the object that it's acting upon. It isn't special syntax any more than `+=` is or even basic operators like `+` and `-`, it's just another method. There is a specific list of operators which are methods that compile with syntax sugar, and I don't see the harm in adding a pair more to the list.
<scott_tams> OTOH, crystal seems to be more "one way to do things" than allowing you to work using what you prefer, so it fits with that mindset that it would be excluded.
<FromGitter> <sam0x17> @oprypin or anyone who wants to help -- the error happens if this line is included: https://gist.github.com/sam0x17/cad46612fad8d17c3da85bd427b430c5#file-streams-cr-L173 โŽ here is the current error: https://bpaste.net/raw/bd2886d27524. What is extremely weird is it is complaining about the flate writer / my DeflateStream, which works perfectly fine on its own, and it only complains if there is a @reader.read
<FromGitter> ... line somewhere in the code.
<FromGitter> <sam0x17> what's weird is I don't even need to create an instance of `InflateStream` for the compile error to occur -- if `InflateStream` has a `@reader.read` call somewhere in it, the error appears and complains about `DeflateStream`'s initializer. If `InflateStream` does not have a `@reader.read` call then `DeflateStream` works fine and no compiler error occurs
<scott_tams> where is this "Flate" coming from?
<scott_tams> I don't see a shard by that name
<FromGitter> <bew> @j8r `rust-lang/rfcs` 's readme is pretty good, would be nice to have sth like that (smaller at the beginning) for crystal @bcardiff :)
<oprypin> sam0x17, i suspect that reopening Slice caused this.
<FromGitter> <bew> @sam0x17 what's the full error with trace (with `--error-trace`)
<oprypin> no it's this one, lol
<oprypin> def read(slice : Bytes)
<oprypin> write(slice)
<oprypin> end
<scott_tams> ooof
<oprypin> (not even the fact that it's calling `write`, who knows, maybe it's valid)
<oprypin> `read` must always return an integer
<oprypin> bew, error-trace is very helpful!
<oprypin> sam0x17, props for providing a runnable example :>
<FromGitter> <sam0x17> ahhh that makes sense, I was trying to hack it to do something before and left that
<FromGitter> <sam0x17> thanks so much guys
laaron- has joined #crystal-lang
laaron has quit [Remote host closed the connection]
return0e has quit [Ping timeout: 268 seconds]
return0e has joined #crystal-lang
<FromGitter> <Blacksmoke16> got this working now โŽ โŽ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c2935ee09b80668498c83d0]
<FromGitter> <Blacksmoke16> `GET /posts/123/ # => 123`
<FromGitter> <Blacksmoke16> `GET /posts/ # => 99`
<FromGitter> <Blacksmoke16> limitation is similar to radix tree, in that will kinda break if you have another route with placeholder in same location
<FromGitter> <drujensen> @Blacksmoke16 very cool.
<FromGitter> <Blacksmoke16> as i cant know if you mean to match that, or the other, possibly in future could figure it out based on regex requirements/param types, but that would require good amount of work i think
<FromGitter> <drujensen> still think the annotations are an eye sore
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c2936c62863d8612bb340c5]
<FromGitter> <Blacksmoke16> considering thats all you need i dont mind it ;)
<FromGitter> <Blacksmoke16> not much boilerplate required, such as a `route.rb` or yaml file or something
<FromGitter> <drujensen> right, we talked about this idea
<FromGitter> <drujensen> maybe something we can add to Amber
<FromGitter> <Blacksmoke16> aye
<FromGitter> <drujensen> you could add a class level annotation for `Resource`
<FromGitter> <drujensen> and make it restful
<FromGitter> <drujensen> that would eliminate a bunch of the ugliness
<FromGitter> <Blacksmoke16> yea for sure, would need a way to enumerate over classes that have that annotation tho, which isnt a thing atm tho :(
<FromGitter> <drujensen> hhmm, bummer
<FromGitter> <Blacksmoke16> could also get rid of the inheriting class
<FromGitter> <drujensen> ooh, that is even better
<FromGitter> <Blacksmoke16> as like then you could do like โŽ โŽ ```@[Athena::Controller] โŽ class UserController``` [https://gitter.im/crystal-lang/crystal?at=5c29379209b80668498c8e08]
<FromGitter> <drujensen> so you are kinda AOPโ€™ing the class
<FromGitter> <drujensen> Aspect Oriented
<FromGitter> <Blacksmoke16> currently since you cant get a list of classes with a specific annotation, im just iterating over all the children of `Athena::Controller`
<FromGitter> <Blacksmoke16> then pulling out methods with the `Get/Post/Put/etc` annotations
<FromGitter> <dscottboggs_gitlab> regarding annotation syntax, do you think it would be up for debate or do you think that it's too late for that? If it's open for discussion, where would be the appropriate place? IMO there are a number of options that aren't quite as ugly that would be just as easy to compile with
<FromGitter> <drujensen> lol, i thought we were in the amber channel
<FromGitter> <Blacksmoke16> :P
<FromGitter> <Blacksmoke16> maybe a forum thread?
<FromGitter> <drujensen> didnโ€™t mean to open a can of worms here. sorry.
<FromGitter> <Blacksmoke16> but really its just personal preference, how it looks doesnt really bother me
<FromGitter> <Blacksmoke16> i dont really care
<FromGitter> <drujensen> I read code all day so its a big deal to me
return0e_ has joined #crystal-lang
return0e has quit [Ping timeout: 240 seconds]
<FromGitter> <drujensen> one reason I use ruby and crystal is the syntax is easy to read
<FromGitter> <dscottboggs_gitlab> same
<FromGitter> <dscottboggs_gitlab> I keep forgetting about the forum, though. That probably would be the place
<FromGitter> <Blacksmoke16> :shrug: to each their own
<FromGitter> <drujensen> yup, sounds like it
<FromGitter> <Blacksmoke16> is all good
laaron has joined #crystal-lang
laaron- has quit [Remote host closed the connection]
<FromGitter> <7sedam7> hello people
<FromGitter> <7sedam7> how do i connect to a mysql db over ssh in crystal
<FromGitter> <straight-shoota> @7sedam7 I'm not sure that's possible out of the box
<FromGitter> <straight-shoota> I suppose it's not a common feature in many other DB connectors.
<FromGitter> <straight-shoota> A workaround would be to terminate the ssl connection to a local socket and connect to that. That's what I've done once or twice (not with crystal-db though).