ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.32.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
<alex``> is there a way to alias targets?
<alex``> in shards.yml
<alex``> I want to add a program with a shorter name
<FromGitter> <straight-shoota> alex, what do you mean with aliasing?
<FromGitter> <tenebrousedge> You can alias commands using the unix shell, but the binary should only ever have one name
<alex``> I have a target in shards.yml and want build another, the same recipe but with another name
<alex``> ouki
<alex``> will go with symlink
<FromGitter> <tenebrousedge> a shell alias is probably still a better idea. It's not uncommon to have install instructions that add things to `.bashrc`
<FromGitter> <tenebrousedge> if you do create a symlink, make sure that it gets removed when the app is removed
<FromGitter> <straight-shoota> Yeah, that's not shard's responsibility.
<alex``> I like to enforce a short name to refer to my program
<FromGitter> <PercussiveElbow> Ok thanks for the help all, my google fu was weak as it was already a reported issue https://github.com/crystal-lang/crystal/issues/8288 . Worked around it using same_thread.
<FromGitter> <tenebrousedge> @PercussiveElbow :plus1:
<FromGitter> <tenebrousedge> alex, if you want to enforce a short name, why not have that be the name of your binary?
blueberrypie5 has joined #crystal-lang
<alex``> not sure :X
Flipez6 has joined #crystal-lang
<FromGitter> <tenebrousedge> does it conflict with another package on the systems you're targeting?
<alex``> I don't think
<alex``> I want name it `cr`
<alex``> not sure if it is a good idea
<FromGitter> <tenebrousedge> ...I don't think that's taken, but that seems a bit truncated. What does it do?
<alex``> time manipulation
<alex``> chronic
<alex``> it is intended to integrate nicely with editors
<alex``> to do gtd
<FromGitter> <tenebrousedge> I think chronic is the better choice there. A little more memorable. The editors shouldn't care too much about how long the name is
<alex``> but cr is 2 letters from the command-line :(
<FromGitter> <straight-shoota> Yeah explicit name sounds better for users
<alex``> is it odd to have 2 names?
<FromGitter> <straight-shoota> yes
<alex``> ripgrep has a long name, but refer as rg
<alex``> still have one name though for the cli
<FromGitter> <straight-shoota> 2 names = 2 things to remember -- Crystal philosophy
<alex``> ouki
<alex``> so add a Configuration section with an alias to encourage using it?
<FromGitter> <straight-shoota> Power users can configure appropriate aliases if necessary
blueberrypie has quit [Quit: Ping timeout (120 seconds)]
Flipez has quit [Quit: Ping timeout (120 seconds)]
davic has quit [Ping timeout: 272 seconds]
Flipez6 is now known as Flipez
blueberrypie5 is now known as blueberrypie
woodruffw has quit [Remote host closed the connection]
<FromGitter> <straight-shoota> And they should now how to do that
<FromGitter> <tenebrousedge> you can add a note somewhere, in the readme or manpage, that says how to alias it. Some people don't know, or might not think to alias it
woodruffw has joined #crystal-lang
davic has joined #crystal-lang
<alex``> other than that do you have a name suggestion for the alias?
<alex``> or cr is good
<alex``> I will go with a sidenote like you suggest
<FromGitter> <tenebrousedge> clearly the best alias is ⌛
<alex``> lol
confact has quit [Read error: Connection reset by peer]
hpyc9 has quit [Quit: ZNC 1.7.5 - https://znc.in]
jetpack_joe has quit [Read error: Connection reset by peer]
<alex``> didn't expected it work
<alex``> XD
ur5us has quit [Ping timeout: 260 seconds]
jetpack_joe has joined #crystal-lang
<alex``> which editor are you using btw?
hpyc9 has joined #crystal-lang
confact has joined #crystal-lang
<FromGitter> <tenebrousedge> I use spacevim for Crystal and Ruby, and VSCode for JS
<FromGitter> <tenebrousedge> for writing PHP I use cheap rum and a forehead-mallet
gangstacat has quit [Ping timeout: 272 seconds]
ur5us has joined #crystal-lang
gangstacat has joined #crystal-lang
alexherbo2 has quit [Quit: The Lounge - https://thelounge.chat]
alex`` has quit [Quit: WeeChat 2.7]
<FromGitter> <dscottboggs_gitlab> 😂
<FromGitter> <watzon> Omg lol
<FromGitter> <watzon> Best thing ever
ur5us has quit [Ping timeout: 260 seconds]
<FromGitter> <Nicolab> @<alex``> `cr` is the alias of `crystal` in my .bashrc, it's risky (conflictual) to add an alias with your program. ⏎ I think that an example in your README is more wise
<FromGitter> <Nicolab> chronic is a "to do gtd"? It's useful! Do you have the project link please?
_ht has joined #crystal-lang
_ht has quit [Remote host closed the connection]
return0e has quit [Remote host closed the connection]
Human_G33k has quit [Remote host closed the connection]
Human_G33k has joined #crystal-lang
ur5us has joined #crystal-lang
ur5us has quit [Client Quit]
flaviodesousa has joined #crystal-lang
ur5us has joined #crystal-lang
<FromGitter> <oceanfish81_twitter> Who is interested to give a talk, on Sep 12 (13)?
<FromGitter> <oceanfish81_twitter> https://rubyc.eu
ur5us has quit [Ping timeout: 260 seconds]
<FromGitter> <KnappeGEIL> Hi, I'm new to crystal and type safe languages in general. Can someone please tell me how I can do this inside the while loop without writing to the variable `left` once before I do the loop or is this not possible like this? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e3bea1d73ddad4acd96d482]
alex` has joined #crystal-lang
alex` is now known as Guest33071
alexherbo2 has joined #crystal-lang
jetpack_joe has quit [Quit: Connection closed for inactivity]
DTZUZU has quit [Read error: Connection reset by peer]
Guest33071 is now known as alex``
DTZUZU has joined #crystal-lang
<FromGitter> <straight-shoota> @KnappeGEIL Technically, `left` is declared outside the loop, but it's nilable because a value is only assigned in the if branch. It's not possible for the compiler to prove that the loop body can only be reached when the if branch was executed, in which case the variable would have a proper value. You can mitigate this by moving the loop into the if branch. I assume that fits with the intended
<FromGitter> ... behaviour of this code. An even better alternative would be to scrap the if conditional entirely since it's essentially just another iteration of the loop. If you define `left = ""` before the loop, you don't need special treatment for the first iteration.
<FromGitter> <straight-shoota> Pro tip: Instead of concatenating strings with `+`, better use `String.build`. This removes your variable issue entirely: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e3c0615dc52c34ace4c4df6]
<FromGitter> <KnappeGEIL> @straight-shoota Wow, thanks for the detailed explanation. This is exactly what I was looking for.
sorcus has quit [Quit: WeeChat 2.7]
sorcus has joined #crystal-lang
<FromGitter> <confact> @straight-shoota very good explained indeed. A good read even for those who don't have the issue @KnappeGEIL have, just little bit on how Crystal work in some cases. Thanks!
confact has quit [Ping timeout: 248 seconds]
alexherbo27 has joined #crystal-lang
alex`` has quit [Ping timeout: 240 seconds]
alexherbo2 has quit [Ping timeout: 260 seconds]
alexherbo27 is now known as alexherbo2
alex`` has joined #crystal-lang
<FromGitter> <bajro17> Hello
<FromGitter> <bajro17> I dont be here for long time
<FromGitter> <bajro17> I need little help how to run system command
<FromGitter> <bajro17> I need to make for myself ffmpeg wrapper
<FromGitter> <tenebrousedge> backticks are usually a good bet
<FromGitter> <bajro17> simply like puts `echo "TEST"`
<FromGitter> <bajro17> ?
<FromGitter> <bajro17> \`\`
<FromGitter> <tenebrousedge> yes
<FromGitter> <bajro17> thank you so much @tenebrousedge
<FromGitter> <tenebrousedge> anytime
<FromGitter> <tenebrousedge> there are other ways to do it but that one is the simplest and generally most useful
<FromGitter> <bajro17> it work <3
<FromGitter> <tenebrousedge> :plus1:
confact has joined #crystal-lang
Andriamanitra has quit [Ping timeout: 265 seconds]
Andriamanitra has joined #crystal-lang
<FromGitter> <rurounijones_gitlab> Welp, I can write to konsole so fast with the crystal app I am writing I can crash it, couldn't do that with the Ruby version :p
<FromGitter> <rurounijones_gitlab> I don't think it is possible with the APIs we have but does anyone know a way of getting the current number of items in a `BufferedChannel`?
alexherbo2 has quit [Remote host closed the connection]
alex`` has quit [Quit: WeeChat 2.7]
<FromGitter> <manveru> is there a way to get the value of a Fiber?
<FromGitter> <manveru> without using channels, that is... i'm making an array of fibers and need to keep the order intact
<FromGitter> <manveru> or should i instead make a channel for each fiber, and put that in the array?
<FromGitter> <j8r> what's the goal @manveru ?
<FromGitter> <manveru> i need to process a text file, replacing various values with ones that are obtained from some pretty slow process
<FromGitter> <manveru> and i have to keep the order intact
<FromGitter> <j8r> the order of the values inside the file?
<FromGitter> <manveru> yeah
<FromGitter> <j8r> and the processing of each key is slow, that's why you would like to have concurency?
<FromGitter> <manveru> i used channels for now, was just wondering if there's an equivalent of `Thread.join` for `Fiber`
<FromGitter> <manveru> yes
<FromGitter> <j8r> Channel is the way to go
<FromGitter> <j8r> how do you keep the order?
<FromGitter> <manveru> i iterate the file, and put it into an array of `Channel(String) | String`
<FromGitter> <manveru> and finally iterate the array and call `receive` on all channels
<FromGitter> <manveru> luckily the files aren't very big, so i can keep it all in memory
<FromGitter> <j8r> the receives are out of order?
<FromGitter> <j8r> how the file is rebuilt in the order?
<FromGitter> <manveru> the receives would be out of order if i just have a single channel
<FromGitter> <j8r> I got this https://carc.in/#/r/8iqj
<FromGitter> <j8r> this uses one channel, and an intermediary `Hash`
<FromGitter> <j8r> I tried to put the counter inside the block before spawning a fiber, but didn't work
<FromGitter> <j8r> creating a method produces the expected result
_ht has joined #crystal-lang
alex` has joined #crystal-lang
alex` is now known as Guest73131
flaviodesousa has quit [Quit: KVIrc 4.9.3 Aria http://www.kvirc.net/]
Human_G33k has quit [Ping timeout: 240 seconds]
Human_G33k has joined #crystal-lang
duane has joined #crystal-lang
ur5us has joined #crystal-lang
duane has quit [Ping timeout: 260 seconds]
Guest73131 has quit [Ping timeout: 260 seconds]
ur5us has quit [Ping timeout: 252 seconds]
Guest73131 has joined #crystal-lang
ur5us has joined #crystal-lang
Guest73131 has quit [Ping timeout: 272 seconds]
Guest73131 has joined #crystal-lang
return0e has joined #crystal-lang
alexherbo2 has joined #crystal-lang
Guest73131 is now known as alex``
<FromGitter> <manveru> i guess that works too :)
<FromGitter> <manveru> next level is now detecting duplicates and avoiding processing them twice... guess i'll need a mutex for that
<FromGitter> <Nicolab> I wonder if there is an internal optimization: https://github.com/crystal-lang/crystal/blob/f4b01c807276804fd3f52a5e2316f4b6676ed004/src/compiler/crystal/codegen/primitives.cr#L968 ⏎ ⏎ At the performance level (or overhead) is there a difference between putting the keys of a Hash in literal string `" my_key "` and `: my_key.to_s`?
<FromGitter> <Nicolab> Ok I have my answer, I just discovered the benchmark module
<FromGitter> <Nicolab> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e3c820d433e1d40399dad5a]
<FromGitter> <Nicolab> Useful
<FromGitter> <tenebrousedge> 1) 0B/op is usually not a sign of a good benchmark
<FromGitter> <tenebrousedge> and writing code based on microbenchmarks is not generally preferable to writing clear, concise code, and then if necessary, changing it based on application profiling results
<FromGitter> <tenebrousedge> > "Programmers waste enormous amounts of time thinking about, or worrying about, the speed of noncritical parts of their programs, and these attempts at efficiency actually have a strong negative impact when debugging and maintenance are considered. We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our
<FromGitter> ... opportunities in that critical 3%."
<FromGitter> <Nicolab> I agree. However when it's just a choice, I prefer to start the right habits from the start
<FromGitter> <Nicolab> Otherwise ignore everything and do "foo" + "bar" etc But not
<FromGitter> <tenebrousedge> your benchmark is not likely to be useful for understanding what the "right habit" is
<FromGitter> <Nicolab> ok
<FromGitter> <Nicolab> It's also to find out what's going on under the hood
<FromGitter> <Blacksmoke16> prob better to use string versus symbol in hash keys
<FromGitter> <Blacksmoke16> for the likely possibility symbols as they exist get removed
ur5us has quit [Remote host closed the connection]
ur5us has joined #crystal-lang
_ht has quit [Remote host closed the connection]
<FromGitter> <Nicolab> Ok, good to know
<FromGitter> <tenebrousedge> @Blacksmoke16 link to the issue?
HumanGeek has joined #crystal-lang
Human_G33k has quit [Ping timeout: 265 seconds]
<FromGitter> <Blacksmoke16> they would essentially just be used for enum auto casting
<FromGitter> <Nicolab> Indeed, It seems to be replaced by enum
<FromGitter> <Blacksmoke16> yes
<FromGitter> <tenebrousedge> hmmm
* FromGitter * tenebrousedge shrugs
<FromGitter> <tenebrousedge> just as long as we don't remove the enum predicates, too
<FromGitter> <Blacksmoke16> that might change to like `.is? :red`
<FromGitter> <tenebrousedge> > _<
<FromGitter> <tenebrousedge> I downvoted that idea the last time I saw it raised
<FromGitter> <tenebrousedge> I think it's a stupid mistake
alexherbo21 has joined #crystal-lang
<FromGitter> <straight-shoota> Well, it's definitely two separate changes
alex`` has quit [Ping timeout: 260 seconds]
alexherbo2 has quit [Ping timeout: 268 seconds]
alexherbo21 is now known as alexherbo2
alex`` has joined #crystal-lang
<FromGitter> <j8r> If there are no Symbols at all anymore, it could even be `== :red`
<FromGitter> <j8r> Recently I noticed autocasting doesn't work for Procs
<FromGitter> <j8r> I have a mixed feelings about Enum methods and auto casting