This channel is intended for people just starting with the Raku Programming Language (raku.org). Logs are available at irclogs.raku.org/raku-beginner/live.html
Set by lizmat on 8 June 2022.
ab5tract eek! is that the latest available from your package manager? 00:04
msiism That's right. 00:05
I think it's not unreasonable to hope for a new release of the OS in late 2025. So, I'll be on a more recent version in a bit. 00:06
I'll probably be tempted to use a later version before that, though. 00:07
ab5tract There's definitly been a fair amount evolution since December 2022, especially in terms of fixing small details 00:11
msiism Yeah, I like what I'm seeing with `div` there. 00:12
ab5tract If you have access to a compiler, rakubrew.org/ is a great way to stay up to date 00:19
what am I saying? you don't even need a compiler, it can download binaries for you
msiism Yeah, I've already had a look at it briefly. 00:20
ab5tract Anyway, none of that is as important as keeping it `-Ofun` 00:27
msiism The positional data types chapter of the Raku Course did have some pretty cool exercises. 00:32
librasteve I recommend rakubrew also … @msiim what platform are you on / how did you install raku? 08:25
msiism What, exactly, does it mean that hashes are not ordered in Raku? 12:42
lizmat that you cannot depend on the order of the keys in a hash from one run to the next run 12:53
nahita3882 when you iterate over a Hash, the key-value pairs it yields to you are not guaranteed to be in any particular order
lizmat except if there are no keys of 1 key in the hash :-)
*or
msiism Okay, thanks.
nahita3882 but that's okay because you are not "buying" this data structure for an ordered access; you are buying it as a fast lookup technology 12:54
one sometimes wants the insertion-order to be preserved, though (I for one do)
so if I have %(a => 1, b => 2), it would be nice if it gave me "a => 1" first then "b => 2", always
there is a third party module Hash::Ordered that does this 12:55
Python since 3.7 also enforces insertion-order preservation on the dictionaries on a language level, for example (which, again, I miss sometimes in Raku)
msiism I see. 12:59
antononcube Wolfram Language / Mathematica from the initial introduction of associations (i.e. hashes) in 2014 (version 10) supports preserving order in associations. 13:40
I understand the arguments for "not ordered hashes" in Raku, but I think there should be some sort of "global option" to have hashes "ordered" or "un-ordered". 13:42
@lizmat It is still in my TODO list to experiment / reproduce issues (or non-issues) in github.com/lizmat/Hash-Sorted/issu...2580676450 13:45
Sorry for the delay...
lizmat no worries... go plenty on my plate :-)
*got
antononcube Me too. And I got too distracted with Number theory, in general and in Raku. (Honestly, I should have known better...) 13:50
lizmat antononcube if you make an issue for it, then it won't fall through the cracks 13:53
I mean, the Hash / ordered / sorted issue
antononcube Hmm... I was planning to just make noise about it and commit into any other form of contribution. But, ok -- where that kind of issue should be filed? (Sorry to be ignorant.) Problem solving? 13:58
lizmat probably, but a Rakudo issue would be ok as well 14:00
antononcube How about "universal" random seed. (I.e. using the same random seed gives the same random things in different Raku sessions.) Should it be filed there too? 14:03
BTW, my current language design for those is kind of the same: use MAP_SEE_ORDER; use RAND_SEE_GLOBAL_SEED; 14:04
(Inspired from "MONKEY-SEE-NO-EVAL") 14:05
lizmat I'd say, let's keep those issues separate
antononcube Of course, separate! I was just giving an example using both... 14:06
BTW, I can "live" with the unordered hashes. For math computations, though, having reproducible random items sequences across sessions is really good. (Again, I can live with that issue, and there are packages for random numbers that can be used, etc.) 14:09
As for un-sorted hashes -- I was trying, and failed, to find the StackExchange or Reddit discussion on why it is a good idea to have unsorted hashes from security perspective. I found this blog post which provides and view on this: lemire.me/blog/2011/08/29/why-cant...r-of-keys/ 14:12
msiism When using `for keys(%hash) -> $key {…}`, is it considered bad practice not to check whether `%hash` has any elements at all in advance? 17:06
`for` will just return `Nil` in that case.
lizmat msiism: depends how much you want to optimize for speed relative to readability 17:21
msiism And which way of doing it would improve which of the two? 17:25
lizmat well, depends on your expected workload 17:34
if you often have empty hashes, then it probably makes sense to an additional if
if most of the time there are keys in the hashes, then the extra if may well be too much overhead 17:35
if you don't know, i'd generally wouldn't bother with an extra if
msiism Okay, thanks. 17:36
lizmat antononcube github.com/rakudo/rakudo/pull/5779 19:54
nahita3882 wow 20:20
librasteve_ www.irccloud.com/pastebin/0JkVdqa8 21:09
librasteve fwiw I quite like the semantic separation between Arrays and Hashes and imho Python and Mathematica have got it wrong to make ordered be the standard / default (I have no beef with Ordered::Hash (or maybe even ArrayHash as an Allomorph) 21:13
) 21:14
antononcube Well, Python gets things wrong often. 21:21
Wolfram Language (WL) -- aka Mathematica -- does not have wrong designs.
Associations in WL have to be considered in the larger context of set of functions for manipulating them and the computational workflows with associations. See functions like Sort, KeySort, Map, KeyMap. etc. Taking those into account makes preserving order in associations a "must have." 21:22
librasteve btw I support the idea of SEED pragma for repeatable generation of order for test reproducibility 21:29
i prefer the Raku pure Hash from an ordered one since it makes me reason more deeply about my code design (but I acknowledge that Ordered::Hash is also useful) 21:35
&afk