<crystal-gh>
[crystal] paulcsmith opened pull request #6146: Helpful error when constant not found (master...ps-6122-undefined-constant-error) https://git.io/vhZL1
<FromGitter>
<sam0x17> is it possible to run a shell command at compile time?
<FromGitter>
<sam0x17> want to zip up a directory for use with the baked_file_system shard
<FromGitter>
<bendietze_twitter> Hi there, i am wondering: kemal allows to disable logging just with two words "logging false" somewhere in Crystal code. What happens here? This aren't official keywords? These aren't vars? No assignment? Why is the compiler capable to understand this? Where can i read more about this (not kemal, Crystal and compiler)
<FromGitter>
<j8r> `logging` should be a top level method, and `false` an Boolean argument
<FromGitter>
<bendietze_twitter> Hehe, yes, you are right for sure :-) oh, it could be so easy
<FromGitter>
<bendietze_twitter> In Crystal are many percent-symbols, like %i, %q, %Q, ... and aliases like p for puts - are there tables or lists of them for better overview? I don't know where to find them all :-)
<FromGitter>
<yxhuvud> p is not an alias for puts
<FromGitter>
<bendietze_twitter> But I saw it and it works?
<FromGitter>
<bendietze_twitter> I tried it yesterday
<FromGitter>
<yxhuvud> Both prints stuff, but not the same stuff. p is meant for debug printing and is basically doing p something.inspect
<FromGitter>
<yxhuvud> *puts something.inspect
<FromGitter>
<bendietze_twitter> Ah, ok, also I have to look more at debugging to find such aliases I don't know? :-)
<FromGitter>
<bendietze_twitter> Thank you all
<FromGitter>
<bendietze_twitter> I asked this question about logging false on stackoverflow too, tagged with crystal-lang and kemal. An reviewer removed the crystal-lang tag and added a text tag. I wrote, this must be wrong, it must be a feature of Crystal, not of kemal and not of text - this happens everytime I ask there - someone changes my tags to the wrong... Don't understand stackoverflow... Thinking, they are tuning for tiobe
<FromGitter>
... and co. But, ok, the tag crystal-lang was right, for sure?
<FromGitter>
<vladfaust> @codenoid I know guy in the center, he's Kemal author, but who're on the sides?
<FromGitter>
<j8r> Quite sure it's Brian and Ary
<FromGitter>
<vladfaust> Oh nice
<FromGitter>
<hmans> What's going on, Crystal friends?
Ven`` has joined #crystal-lang
<faustinoaq>
@hmans Doing PHP this week at work :( Enjoying crystal in my spare time :)
<FromGitter>
<bendietze_twitter> Sounds hard :)
Ven` has joined #crystal-lang
Ven` has quit [Read error: Connection reset by peer]
<wuehlmaus>
i am exploring Go after a long time not looking at it. Crystal is sooo much shorter, but what really impresses me is the sheer speed of compilation of go.
Philpax has quit [Ping timeout: 276 seconds]
<faustinoaq>
Maybe we should check if `reuse_port` is working as expected on all CPU cores
<faustinoaq>
So, even crystal is single core, is faster than Ruby+Rust multicore :D
csk157 has quit [Quit: WeeChat 2.1]
<FromGitter>
<bew> Probably because of the ruby interpreter machine that needs to start and all
<FromGitter>
<bew> Try rust only? :P
<FromGitter>
<bendietze_twitter> Yeah, interesting - what's about Rust vs Crystal in this case? However, where is Crystal storing, stack or heap?
<FromGitter>
<yxhuvud> crystal can store in both
<FromGitter>
<bew> It depends on what you're storing
<FromGitter>
<S-YOU> I got upto 50% performance gain with Crystal + h2o on my machine, ... for Hello, World!
<FromGitter>
<bendietze_twitter> Yeah, sorry, just clicked wrong, Crystal stores BitInt as standard on heap, right? How do I choose between stack or heap, for example, with Int64?
<FromGitter>
<S-YOU> a = 1_i64 for stack? or Malloc(Int64).new(1)?
<FromGitter>
<HCLarsen> Anyone ever use the Hash.new function with a block? There's no documentation on how to use it.
Guest89592 has quit [Quit: Guest89592]
Ven`` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
johndescs has quit [Ping timeout: 240 seconds]
johndescs has joined #crystal-lang
<FromGitter>
<bendietze_twitter> And the source doesn't help?
<FromGitter>
<HCLarsen> Reading the source is the last resort. Asking a question comes before that.
<RX14>
reading the source takes little time
<RX14>
asking a question takes ages
<RX14>
I can't remember how Hash.new with a block works
<RX14>
i'd read the source lol
<FromGitter>
<HCLarsen> You might want to learn how to tell time then, because it took me less than a minute to type that question.
<RX14>
and it took you over 5 minutes to get an answer
<RX14>
looking at the source only takes a minute or two
<RX14>
but yeha its just a block that returns a default value if the key doesn't exist
<RX14>
it takes the hash and the key as arguments
<RX14>
and so you can insert to the hash inside the block if you want
<FromGitter>
<j8r> Reading the specs easier and more instructive than the implementation
<RX14>
depends
<FromGitter>
<j8r> *on how to use the method
<FromGitter>
<j8r> At least, for me, I'm more productive on directly reading examples for how-to
<RX14>
for learning how hashes work, yeah i'd look for examples
<RX14>
if I was learning this specific detail about hashes but I already knew how they work i'd go for impl
<RX14>
it all depends on the person anyway
<FromGitter>
<j8r> Nevertheless to get lost in the Crystal code is really instructive :-)
<FromGitter>
<j8r> Sometimes I see amazing piece of codes, hiding somewhere
<FromGitter>
<HCLarsen> But where do the key and value come from? Using a block is easy enough, but I don't see any indication of where these values come from.
<RX14>
when someone uses fetch on the hash and the key isn't there
<RX14>
fetch or []
<RX14>
[] calls fetch
<RX14>
so you use hash["foo"] and you'd normally get an exception
<FromGitter>
<HCLarsen> I meant for the block in the Hash#new method.
<RX14>
but with the block arg, the block is called instead
<RX14>
yes
<RX14>
that block
<RX14>
the block in the .new isn't called inside .new at all
<RX14>
it's just stored for fetch to use
<FromGitter>
<bendietze_twitter> Sorry, don't want to reduce you to read the source, but asking what would you do could take longer than asking, if
<FromGitter>
<HCLarsen> Ok then.
<RX14>
>> h = Hash.new { |hash, k| p hash, k }; h["foo"]; nil
<FromGitter>
<HCLarsen> Not really Ben. I asked the question, went on to other things, only checked back every few minutes when there was a reply. Overall, not much time spent at all.
<RX14>
I find switching tasks like that draining
<RX14>
so i'll always try and work it out
<RX14>
because "switching tasks for 5 mins until the question is answered" would ruin my hour
<FromGitter>
<HCLarsen> Besides, being human, I like talking to other humans. It's a funny little quirk.
<RX14>
>> h = Hash(String, Nil).new { |hash, k| p hash, k }; h["foo"]; nil
<FromGitter>
<bendietze_twitter> Ok Chris, we are going to discuss where we don't want to discuss. I am very new to Crystal and cannot help you a lot, but my first thought was to look at hash.cr and i thought it was easy to read. So I expected, you would answer: I looked the source but i cannot construct the following thing: ... I am here to ask questions too and I was only switching between your chat and the source to look if i can
<FromGitter>
... construct the following in my thoughts to learn it myself 😄 but, when I am blurring this textfeld here, it sends my half written text and so I stopped writing complete 😄
<FromGitter>
<bendietze_twitter> And please understand: my english is bad 😄
<FromGitter>
<HCLarsen> It's all good Ben, English isn't the easiest language in the world to understand. Blame the Welsh.
snsei has quit [Remote host closed the connection]
Nathanaelle has quit [Read error: Connection reset by peer]
Nathanaelle has joined #crystal-lang
<oprypin>
no
<FromGitter>
<vlazar> @S-YOU how are you using h2o with Crystal and what benchmark you run, something similar to plain text hello world from techempower benchmarks?
<FromGitter>
<vlazar> @faustinoaq looks like mruby in h2o should only be used for simple stuff https://h2o.examp1e.net/configure/mruby.html ⏎ ⏎ > With H2O, users can implement their own request handling logic using mruby, either to generate responses or to fix-up the request / response. ⏎ > The interface between the mruby program and the H2O server is based on Rack interface specification. ⏎ > It should be noted that as of
<FromGitter>
<vlazar> libh2o OTOH is more interesting, Crystal bindings might give some interesting benchmark results ;)
<RX14>
@Flaque you're looking for `skip_file`
<RX14>
@vlazar they'll be useless reasults
<RX14>
because it'll be impractical to use libh2o on a real crystal app
<RX14>
better to do something actually useful like optimize crystal's stdlib
<FromGitter>
<faustinoaq> @vlazar oh, ok 👍
<FromGitter>
<Flaque> Huzah thank you @RX14
<FromGitter>
<vlazar> @RX14 sure, the more Crystal the better!
<FromGitter>
<faustinoaq> RX14, I think you're right 👍
<RX14>
remember that benchmarks aren't a game
<RX14>
if the benchmarks aren't realistic they don't mean anything
<FromGitter>
<vlazar> lol, but it is (an interesting game)! :)
<FromGitter>
<faustinoaq> Yeah XD
<FromGitter>
<vlazar> seriously though, benchmarks are hard of course, correctly interpreting results is even harder
<FromGitter>
<vlazar> something like a set of standard benchmarks for stdlib and never(almost) slowing things down would be nice, but I don't think that should be high priority now, Cryystal is already very fast
<FromGitter>
<faustinoaq> Yeah, I think crystal can be "fast enough" :D
<txdv>
but can it beat go and rust?
<RX14>
no
<RX14>
it shouldnt aim to
<RX14>
it should aim to be as fast as it can for crystal's tradeoffs and crystal's level of abstrcation
<RX14>
for crystal, being fast isn't as important as being easy to read, and easy to maintain
<Yxhuvud>
it is surprisingly often it is possible to be fast though, while maintaining the other ones.
<RX14>
yes, for sure
<RX14>
but i don't think we will end up as fast as rust in some places
<RX14>
we'll always have some kind of GC with GC overhead
<RX14>
and we'll probably never have iterators as good as rust's
<FromGitter>
<bendietze_twitter> Yes, maybe, but - i am a newbie to Crystal - I can write my code in minutes - and without headache - and than? Yes, you are right - it's a very fast binary
<FromGitter>
<bendietze_twitter> 😜💪
<FromGitter>
<yxhuvud> What makes rust operators great?
<FromGitter>
<yxhuvud> Damn auto correct
vikaton has joined #crystal-lang
<FromGitter>
<Flaque> Hey could someone with more experience than I tell me if my library is a dumb idea? It's a little macro that checks if a c library exists on a user's system before running the compiler and then gives them a friendly error message in standard Crystal instead of defaulting to the underlying clang errors. See: https://github.com/Flaque/useslib
<oprypin>
idea is not dumb, implementation kinda is :|
<RX14>
@Flaque have you seen that 0.25.0 will annotate the linker error message with a helpful message?
<oprypin>
maybe it's fine, even, but it just seems like a risk of things not working in more cases than before
Nathanaelle has quit [Ping timeout: 256 seconds]
<RX14>
which is why annotating the linker error makes sense, because it's already failed lol
Nathanaelle has joined #crystal-lang
<FromGitter>
<Flaque> @rx14 I have not, Im glad I asked 😅