jhass changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.28.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> <Blacksmoke16> https://api.apis.guru/v2/specs/github.com/v3/swagger.json could maybe just write something to consume this and generate everything?
<FromGitter> <Blacksmoke16> vs manually defining each class, :shrug:
<FromGitter> <Blacksmoke16> but slow progress is better than no progress :)
<FromGitter> <watzon> I could swagger, but I like to do things the hard way
<FromGitter> <watzon> Lol
<FromGitter> <watzon> Do macros defined in a module not filter down to other classes/modules that are a part of the top level module?
<FromGitter> <watzon> Example: https://carc.in/#/r/6y1x
<FromGitter> <watzon> I don't want to pollute the top level namespace by defining them outside of the module, but I also would rather not have to do `ModuleName.macro_name` to call the macro
<FromGitter> <Blacksmoke16> https://carc.in/#/r/6y22
<FromGitter> <Blacksmoke16> if you actually include it
<FromGitter> <watzon> Damn
<alexherbo21372> It is not specified, but does the same rule applies to Process.run(cmd) than system(cmd) (which can spawn a shell if it contains space)
<FromGitter> <Blacksmoke16> prob https://crystal-lang.org/api/0.28.0/Process.html#run%28command%3AString%2Cargs%3Dnil%2Cenv%3AEnv%3Dnil%2Cclear_env%3ABool%3Dfalse%2Cshell%3ABool%3Dfalse%2Cinput%3AStdio%3DRedirect%3A%3AClose%2Coutput%3AStdio%3DRedirect%3A%3AClose%2Cerror%3AStdio%3DRedirect%3A%3AClose%2Cchdir%3AString%3F%3Dnil%29%3AProcess%3A%3AStatus-class-method
<FromGitter> <Blacksmoke16> the command is also just a string
<alexherbo21372> stdin = IO::Memory.new; stdin << "test"; stdout = IO::Memory.new; Process.run("cat", args: [] of String, input: stdin, output: stdout); puts stdout does not contain "test" why?
alexherbo2 has joined #crystal-lang
<alexherbo2> re
<alexherbo2> don’t read if i got a response (got disconnected)
alexherbo21372 has quit [Ping timeout: 245 seconds]
<FromGitter> <Blacksmoke16> stdout.to_d
<FromGitter> <Blacksmoke16> .to_s
<FromGitter> <zhenfeng-zhu> Crystal compiler not found. Some features can throw errors.
<FromGitter> <watzon> @zhenfeng-zhu what's the terminal output for `which crystal`?
<FromGitter> <zhenfeng-zhu> /usr/local/bin/crystal
<FromGitter> <zhenfeng-zhu> I solved it
<FromGitter> <zhenfeng-zhu> "crystal-lang.compiler": "crystal", ⏎ "crystal-lang.hover": true, ⏎ "crystal-lang.problems": "build", ⏎ "crystal-lang.implementations": true, ⏎ "crystal-lang.completion": true [https://gitter.im/crystal-lang/crystal?at=5ce20ee513e9854e333359a6]
<FromGitter> <zhenfeng-zhu> add those config to setting.json
<FromGitter> <watzon> What was compiler set to before? `crystal` should be the default.
<FromGitter> <zhenfeng-zhu> i don't know
<FromGitter> <zhenfeng-zhu> this maybe conflict with my Alfred shortcut
<FromGitter> <zhenfeng-zhu> cmd+space
<FromGitter> <watzon> It probably will
<FromGitter> <zhenfeng-zhu> Can I change to other shortcuts?
<FromGitter> <watzon> Go to File > Preferences > Keyboard Shortcuts and change Trigger Suggest to whatever you want
<FromGitter> <zhenfeng-zhu> @watzon thx~
<FromGitter> <watzon> No problem
<FromGitter> <zhenfeng-zhu> Does it now support function jumps?
<FromGitter> <watzon> That I don't know
_whitelogger has joined #crystal-lang
<FromGitter> <pynixwang> how to reference module constant with `.`
<FromGitter> <pynixwang> now I only can use `::`
prettyrobots has joined #crystal-lang
<FromGitter> <watzon> You can always only use `::`
<FromGitter> <watzon> That is the constant access pattern
<FromGitter> <watzon> `.` is for methods
<FromGitter> <watzon> PSA: did everyone know that carbon (https://carbon.now.sh) works with Crystal?
<FromGitter> <pynixwang> ..
Liothen has quit [Ping timeout: 258 seconds]
jetpack_joe has quit [Write error: Connection reset by peer]
Liothen has joined #crystal-lang
jetpack_joe has joined #crystal-lang
<FromGitter> <watzon> @pynixwang?
<FromGitter> <pynixwang> nothing
gangstacat has quit [Quit: Ĝis!]
<FromGitter> <watzon> Waiting for it to be approved by hackernoon, but here's another article for my Doing Crystal series https://hackernoon.com/doing-crystal-2-501daaf8390d
ashirase has quit [Ping timeout: 255 seconds]
alexherbo2 has quit [Ping timeout: 246 seconds]
<FromGitter> <kaukas_gitlab> Hello! Is there any standard way to limit the amount of memory a crystal process can allocate, and then force GC to clean up? My script is leaking memory somewhere, or the GC is simply not cleaning up old objects. How could I debug that?
ur5us has joined #crystal-lang
vegai has left #crystal-lang ["User left"]
ur5us has quit [Quit: Leaving]
alexherbo2 has joined #crystal-lang
ashirase has joined #crystal-lang
ashirase has quit [Ping timeout: 244 seconds]
ashirase has joined #crystal-lang
ShalokShalom has joined #crystal-lang
<ShalokShalom> hi there
<ShalokShalom> I think I found an issue in your documentation: https://crystal-lang.org/reference/guides/concurrency.html
<ShalokShalom> threads in Erlang are super light, you can have millions of connections in one node
<ShalokShalom> this becomes obvious once you understand that Thread are NOT inherently depended on the underlying OS: https://stackoverflow.com/questions/2708033/technically-why-are-processes-in-erlang-more-efficient-than-os-threads
<FromGitter> <j8r> because Erlang threads, as said in your articles, aren't OS threads
<FromGitter> <j8r> other names for similar technologies are green threads, goroutines, fibers etc
<FromGitter> <j8r> it's clearly mentioned "system thread" in the doc
<ShalokShalom> no
<ShalokShalom> read "A Fiber"
<FromGitter> <j8r> what's the sentence?
<ShalokShalom> the thing is that you assume preemptive means OS threads
<FromGitter> <j8r> > A fiber is in a way similar to an operating system thread except ...
<ShalokShalom> "the advantage of"
<ShalokShalom> And "A Fiber is much more lightweight as a thread"
<FromGitter> <j8r> Ok so you would like to clarify this "Fibers, unlike threads, are cooperative. Threads are pre-emptive" to "Fibers, unlike OS threads, are cooperative. OS Threads are pre-emptive"
<FromGitter> <j8r> and every place `threads` is, to clarify that's OS threads
<ShalokShalom> yes
<ShalokShalom> something like this
<ShalokShalom> maybe even mentioning there are other threads
<FromGitter> <j8r> I think it's quite obvious, because only OS threads are mentioned before
<ShalokShalom> and the benefits of an auto healing system, which is only possible with preemptive scheduling
<ShalokShalom> yeah, if you read that section before
<ShalokShalom> I was reading just tat mentioned section, since I was interested about how Crystal implements that
<ShalokShalom> otherwise, you are correct, of course
<FromGitter> <j8r> you can submit a PR an see what other people think, why not
ShalokShalom has quit [Remote host closed the connection]
<mps> j8r: you want to have pre-emptive fibers?
ShalokShalom has joined #crystal-lang
<ShalokShalom> why has Crystal an incomplete type inference?
<FromGitter> <Blacksmoke16> hm
<ShalokShalom> why do I have to type out types sometimes?
<ShalokShalom> opposed to total type inference on any item
<FromGitter> <Blacksmoke16> because its a statically typed language?
<FromGitter> <Blacksmoke16> ah
<ShalokShalom> OCaml?
<ShalokShalom> F#?
<ShalokShalom> Haskell?
<ShalokShalom> Elm?
<ShalokShalom> they type infer everything
<FromGitter> <Blacksmoke16> its a feature to allow typing when needed but isnt required to have method args or local vars typed all the time
<FromGitter> <Blacksmoke16> well this isnt any of those so not a good comparison :)
<ShalokShalom> I ask why this is
<ShalokShalom> and not if this a good comparison
<ShalokShalom> Pony has also complete type inference and its more imperative / object oriented
<FromGitter> <Blacksmoke16> i dont have an exact reason, but that was just one of the goals of the lang `Be statically type-checked, but without having to specify the type of variables or method arguments.`
<ShalokShalom> yes, I know
<ShalokShalom> I ask for the reason, why this is not the case yet :)
<ShalokShalom> Incomplete is nice, more than nothing :D
<FromGitter> <Blacksmoke16> `yet`, its not going to be ever
<FromGitter> <Blacksmoke16> its by design
<ShalokShalom> Aha?
<FromGitter> <Blacksmoke16> as i just said, its a goal of the lang `Be statically type-checked, but without having to specify the type of variables or method arguments.`
<mps> how to infer 'x = 1', what is it: int32 or int64
<ShalokShalom> So you dont know why it is how it is, while you know it will stay so?
<FromGitter> <Blacksmoke16> its inferred to be Int32
<ShalokShalom> mps: How do you type inference?
<ShalokShalom> Hindler-Milner?
<FromGitter> <Blacksmoke16> `x : Int32 = 1`
<ShalokShalom> *Hindley
<FromGitter> <Blacksmoke16> now its restricted to Int32
<ShalokShalom> you infer it from the context, of course
<mps> Blacksmoke16: yes, I know, but what if think it is int64, obviously wrong
<FromGitter> <Blacksmoke16> thats the feature, you dont *HAVE* to give a local variable a type restriction, but you can
<ShalokShalom> and you can look up how other languages are doing that
<FromGitter> <Blacksmoke16> then you do `x = 1_i64`
<ShalokShalom> But sometimes I need
<ShalokShalom> In Crystal
<mps> ofc, but then it is not inference
<ShalokShalom> Thats the case...
<ShalokShalom> So why is it incomplete here?
<ShalokShalom> And complete in others
<ShalokShalom> And why will it stay this way
<mps> ShalokShalom: maybe by intention
<FromGitter> <Blacksmoke16> i mean you could also do `x = 1_i64`
<ShalokShalom> I know Rust does it also this why
<ShalokShalom> maybe...
<FromGitter> <Blacksmoke16> then its inferred to be Int64
<ShalokShalom> this is computer science :D
<ShalokShalom> thanks
<ShalokShalom> thats not infered
<mps> and I think it is good as it is now
<ShalokShalom> I mean "not typin"
<FromGitter> <Blacksmoke16> but Int32 is the default unless otherwise stated
<ShalokShalom> Yeah, because you dont know it in any other way
<ShalokShalom> then why not always choosing a default?
ShalokShalom has quit [Remote host closed the connection]
<FromGitter> <Blacksmoke16> im not sure i follow anymore but the default type for numbers is Int32
<FromGitter> <Blacksmoke16> if you dont specify otherwise
<FromGitter> <Blacksmoke16> also assuming ist not a float
<FromGitter> <pynixwang> alpine docker does 'nt support ssl?
<FromGitter> <j8r> ?
<FromGitter> <j8r> TLS, OpenSSL, LibreSSL?
<FromGitter> <pynixwang> worker container output: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ce29c98509b1035c77e862f]
<FromGitter> <pynixwang> busybox.
<FromGitter> <Blacksmoke16> prob some some cert lib?
<FromGitter> <Blacksmoke16> `RUN apt-get update && apt-get install -y ca-certificates`
<FromGitter> <Blacksmoke16> or something like that, i dont know which specifically off hand
<FromGitter> <pynixwang> ok
<mps> Blacksmoke16: 'apk add ...'
<FromGitter> <Blacksmoke16> oh right, picked the debian imagine oops
<FromGitter> <Blacksmoke16> seems ca-certificates is the one you need tho
<FromGitter> <Blacksmoke16> same for both
<mps> meh, who can remember all distro's package managers syntax
<FromGitter> <Blacksmoke16> ikr?
<mps> what 'ikr' mean
<FromGitter> <Blacksmoke16> i know right*
<mps> aha, thanks
<FromGitter> <Blacksmoke16> np
ua has quit [Ping timeout: 252 seconds]
<FromGitter> <asterite> ShalokShalom: all the languages which have the type inference you want don't have default arguments, overloads, splats, etc. It seems that kind of type inference isn't compatible with those features
<FromGitter> <pynixwang> alpine ssl works
<FromGitter> <pynixwang> busybox not works
<mps> pynixwang: alpine have ssl_client which is used as busybox 'helper' for some busybox applets, wget for example
<FromGitter> <pynixwang> image
<FromGitter> <pynixwang> alpine image works
<FromGitter> <pynixwang> busybox image not ok
<mps> I'm not sure if busybox supports ssl at all
<z64> @pynixwang not sure what the issue is exactly, just skimmed the convo, but maybe this is helpful: https://hub.docker.com/r/kubler/openssl/
ua has joined #crystal-lang
<FromGitter> <pynixwang> ok
<FromGitter> <pynixwang> size: ~17mb
<FromGitter> <pynixwang> alpine latest 3 MB
<z64> if you're going by the compressed size, its 9 MB. but anyways, i was more suggesting to look at that image to see if it has what you might need so that you could make something smaller
<FromGitter> <pynixwang> alpine is ok
<FromGitter> <pynixwang> 3 crystal binary 54M
<FromGitter> <pynixwang> crystal binary is fat.
<FromGitter> <pynixwang> latest fc74393ba6c7 About an hour ago 54.9MB
<jhass> ever looked at rust or go?
<jhass> similar binary sizes
ShalokShalom has joined #crystal-lang
<FromGitter> <pynixwang> selfhost
<FromGitter> <pynixwang> runtime overhead
<FromGitter> <j8r> I don't know what I'm doing wrong, why the fastest change when I swap the order of the benchmark for ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ce2aeca83ae782aee9dfd57]
<jhass> because they boil down to the same bytecode I bet
<jhass> so let me guess, the second one is always faster? -> hot caches
<FromGitter> <j8r> yes
<FromGitter> <j8r> how to prevent this?
<FromGitter> <pynixwang> same bytecode
<FromGitter> <pynixwang> no need bench
<FromGitter> <pynixwang> call it once before bench
<FromGitter> <j8r> this kind of things aren't obvious when doing various benchmarks, how to know this?
<jhass> well in theory ips warms up the cache but...
<jhass> didn't run it myself still, but next bet: the difference you see is in the ns and well within the stdev
<jhass> that tells you there's no actual difference
<FromGitter> <j8r> I see `0.0B/op`
<jhass> that's memory allocations
<FromGitter> <j8r> That's an indication
<FromGitter> <j8r> Benchmark.ips can be improved, I guess
<FromGitter> <pynixwang> crystal STDOUT is buffered?
<FromGitter> <pynixwang> I can not see my log from docker
<jhass> it's if it's not a tty iirc
<FromGitter> <j8r> I can open an issue on the benchmark cache issue
ShalokShalom has quit [Remote host closed the connection]
<FromGitter> <pynixwang> slow log from docker
<FromGitter> <pynixwang> is not acceptable.
<jhass> j8r: there really isn't anything broken
<FromGitter> <pynixwang> difficult to debug
<FromGitter> <j8r> jhass: at least, the benchmark must not indicate 1.13 slower or fastest if there are equal
<jhass> so I'm getting 2.04ns with 2.4% variance and 2.62ns with 6.64% variance for example, that gives a range of 2.9ns to 2.09ns vs a range of 2.4ns 2.8ns, the smallest difference is just 0.3ns
<jhass> that's just within measurement errors
<jhass> if you feel the need to benchmark stuff on such a low level you have to get involved into understanding modern CPU architectures
<jhass> and everything between your program and the CPU
<jhass> pynixwang: https://crystal-lang.org/api/0.28.0/IO/Buffered.html#sync%3D%28sync%29-instance-method
<jhass> you can turn it off explicitly
<FromGitter> <j8r> I got also ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ce2b5bc63dea422b4b5a8b6]
<FromGitter> <j8r> hum wait, I use `999.times`
<FromGitter> <j8r> nmv
<FromGitter> <j8r> nvm
<FromGitter> <j8r> than was 1.32M (755.75ns) (± 3.23%) vs 1.29M (774.28ns) (± 6.82%)
<FromGitter> <j8r> so 20ns and 3M diff
<FromGitter> <pynixwang> first has no bound check
<FromGitter> <pynixwang> and `[]` check
<FromGitter> <pynixwang> sometimes code is better than bench.
<FromGitter> <pynixwang> and why last is slow than `[-1]`
<FromGitter> <pynixwang> last is fast
<FromGitter> <pynixwang> sorry
ShalokShalom has joined #crystal-lang
return0e_ has quit [Ping timeout: 268 seconds]
return0e has joined #crystal-lang
<FromGitter> <r00ster91> Is it possible to convert `<b>html markdown</b>` to `*html markdown*` with `Markdown`?
<FromGitter> <Blacksmoke16> im thinking it goes from md to html not the other way around
<FromGitter> <r00ster91> aww
<jhass> fwiw any valid html is already valid markdown, no? :D
<FromGitter> <r00ster91> I need to convert it to \*\*this\*\* markdown because that's the only markdown Discord accepts
<FromGitter> <Prutheus> I am using Kemal: Problem: I have a post request with a lot of data (lot of images, base64 coded) .... but my Kemal is blocking this request, it is too large, how to fix that?
<FromGitter> <Prutheus> Please help me
Yxhuvud has joined #crystal-lang
<FromGitter> <jwoertink> @Prutheus You could use something like sidekiq, or mosquito to break up the action in to smaller background jobs.
<FromGitter> <j8r> ... or spawn fibers?
<FromGitter> <j8r> And/or use multiple posts then, if possible
return0e_ has joined #crystal-lang
return0e has quit [Ping timeout: 246 seconds]
<FromGitter> <mwlang> woah...is this for real? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ce2efa5d22ba766a2ce8461]
<FromGitter> <mwlang> if so, I don't even know how to begin to create the minimum code necessary to reproduce it.
<FromGitter> <Blacksmoke16> 😬
<FromGitter> <mwlang> ok, best I can figure, it's coming from the new shard I'm trying to use, "spec2" https://github.com/waterlink/spec2.cr
<FromGitter> <mwlang> (which implements some familiar rspec concepts like let and subject and expect
<FromGitter> <Blacksmoke16> 😐
<FromGitter> <Blacksmoke16> did you see when it was last updated :P
<FromGitter> <mwlang> That looks like a problem...last updated for Crystal 0.18.0, so it's been a while and it's own specs won't run...doesn't crash the compiler, but doesn't run, either.
<FromGitter> <mwlang> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ce2f7de7c363c75a7143fe4]
<FromGitter> <Blacksmoke16> i remember having this problem, sec
<FromGitter> <mwlang> That first overload of Time.new seems to match with > 6 parameters, so what gives?
<FromGitter> <Blacksmoke16> try moving the require in your spec helper to last
<FromGitter> <Blacksmoke16> but yea, its prob super outdated at this point
<FromGitter> <Blacksmoke16> would prob have to fork it and bring it up to date for each breaking change since .18
<FromGitter> <mwlang> wow, that solved it.
<FromGitter> <Blacksmoke16> :wizard:
<FromGitter> <mwlang> indeed.
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
ShalokShalom has quit [Remote host closed the connection]
bougyman has joined #crystal-lang
<FromGitter> <Blacksmoke16> @veelenga I was thinking it would be cool to add in some automation around validating projects in awesome-crystal
<FromGitter> <Blacksmoke16> didnt really look into it much, but idea would be like once a week/month? query travis/circleci apis (whichever they use) to determine latest build status and assert its passing within x days
<FromGitter> <Blacksmoke16> would help enforce the automated builds, and keep the list current, as removing unmaintained/failing projects would be easier
<z64> @Blacksmoke16 i think it might be enough to simply attach CI badges next to them. then informally, failing builds can be periodically reviewed, or others can see the failing badges as opportunities to contribute (maybe its just updating the lib for breaking changes)
<FromGitter> <Blacksmoke16> :vince
<FromGitter> <Blacksmoke16> that would prob be a much simpler solution :p
<FromGitter> <Blacksmoke16> good call
<FromGitter> <Blacksmoke16> ill make an issue for it
<z64> cool. what you suggest might be better for like, an actual shards registry like crystalshards.xyz that already has the infra to do automated things
<z64> (though tbf, i dont know how shards.xyz works)
<FromGitter> <Blacksmoke16> :shrug:
<FromGitter> <Blacksmoke16> do you know if there is a badge for like `last built`
<FromGitter> <Blacksmoke16> https://github.com/waterlink/spec2.cr for example is "passing" but that was only because it was built a year ago.
<z64> yeah. well, thats why running CI on a long cron can be nice.. but no, i'm not sure off the top of my head.
<FromGitter> <Blacksmoke16> all good, is a good start
laaron- has joined #crystal-lang
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
hightower2 has joined #crystal-lang
laaron- has quit [Quit: ZNC 1.7.1 - https://znc.in]
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
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
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
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
<FromGitter> <Daniel-Worrall> Can I use HTTP::WebSocket as an IO without defining a new class?
ShalokShalom has joined #crystal-lang
<FromGitter> <Blacksmoke16> it doesnt inherit/include any IO stuff so prob not
<FromGitter> <Daniel-Worrall> It has a private constructor for one
<FromGitter> <Blacksmoke16> :shrug: try it out and see?
<FromGitter> <dscottboggs_gitlab> `Socket` != `IO`
<FromGitter> <Daniel-Worrall> I'm using a TCPSocket as IO tho
<FromGitter> <Blacksmoke16> that is inherently an IO since it inherits from it
<FromGitter> <Daniel-Worrall> ye
<FromGitter> <dscottboggs_gitlab> maybe I'm wrong
<FromGitter> <dscottboggs_gitlab> `Socket` inherits `IO::Buffer` and `IO::Evented`
<FromGitter> <dscottboggs_gitlab> so yes you can use anything that inherits from `Socket` as an `IO`
<FromGitter> <Blacksmoke16> but websocket does not
<FromGitter> <Daniel-Worrall> Unfortunately
<FromGitter> <Daniel-Worrall> WebSocket uses Protocol
<FromGitter> <dscottboggs_gitlab> yeah that's weird
<FromGitter> <dscottboggs_gitlab> Oh, I see -- there are several types of messages that could be received
sz0 has joined #crystal-lang