🦋 Welcome to the former MAIN() IRC channel of the Raku Programming Language (raku.org). This channel has moved to Libera (irc.libera.chat #raku)
Set by lizmat on 23 May 2021.
avuserow If I have an arbitrary object, is there a builtin way to know whether it matches an interface (role or class, basically a list of methods)? 01:29
tellable6 2021-06-12T20:21:19Z #raku <codesections> avuserow the most direct Raku translation of `for x in a.get("a", []): print(x)` is probably `for %a.keys { say %a{$_}}`
tbrowder japhb: thnx, very helpful!
avuserow I can do this as a starting point, I guess: 01:30
m: class Foo {method a {...}; method foo {say "foo"}}; role FooR {method foo {...}; method bar {...}}; say so all([Foo.can(.name) for FooR.^methods])
camelia False
avuserow .tell codesections yeah, that only tends to be an issue when I'm subscripting without an intermediate variable, like `for %a<b>.keys {}` vs `my %b := %a<b>; for %b.keys {}` 01:32
tellable6 avuserow, I'll pass your message to codesections
moon-child avuserow: raku is structurally typed, not nominally typed, so that's not very idiomatic 01:43
err, is nominally typed, _not_ structurally typed
e.g. you couldn't say 'my FooR $x = Foo.new'
avuserow okay, that makes sense 01:47
and my code probably muddled things a bit. what I'm trying to do is say "I want an object as a parameter that has a `quote` method. probably a DBDish subclass of some sort, but I won't stop you from passing in another class" 01:48
might just leave it untyped for now and let things happen 01:50
moon-child in general it's better to not just assume that a method called 'quote' does what you want 01:57
somebody else might have reused the same name for a completely different purpose 01:58
avuserow I guess. Within some domains, we do make these assumptions all the time. Sometimes it works well enough (maybe like `close` on file-like objects), sometimes less well (like how some languages use `+` to do both addition and string concatenation) 02:13
though I looked, and this might be a moot point. Only one module in the ecosystem implements what I'm looking for, so this might just be better as a hard dependency 02:14
chronon I've been holding back from really taking Raku into my heart, waiting for the language to settle, and for a comprehensive book in the style of "Programming Perl" that I can just cover to cover and be confident that I have not missed anything an expert should know about the language. 12:59
As far as I can see there are a fair few out of date Perl 6 books, and a number of Perl->Raku conversion books, and a few speciality books, but nothing that I can recognise as the once and final definitive guide. 13:00
I know myself well enough to know that I will do the cover to cover read once only, and then won't slog though any other thick books. So I'd like to get my choice of book right. 13:01
Can anyone recommend a thorough and complete Raku book, or at least tell me that they are working on one? 13:02
moritz I don't think there is a thorough and complete book yet. 13:08
phogg It's hard to be thorough and complete with a language this big
chronon Maybe, but I would pay good money for one, even if it were a multi volume boxed set. Indeed I'd prefer a non-repetative set of smaller books than a single huge doorstopper to lug around. 13:13
Finding random bits of the puzzle online never works for me. I really appreciate well structured information like Programming Perl was. No fluff, no baby stuff, just solid well structured information that treated the reader like an adult. 13:16
Guest99 hi 13:20
MasterDuke chronon: i love Programming Perl (one of the only two programming reference books i've read cover-to-cover), but Raku is an even larger language. and with the ease of finding information online, i'm not sure how much of a market there is for a large printed reference book 14:20
chronon MasterDuke: So are we just living in a world where nobody values well structure well presented information? Are we now all just living in a forest of fragmented wiki docs and blogs none of which give the reader any understanding of the big picture? A world of cut&paste code fragments instead of anything approaching deep understanding? 14:53
ugexe its a huge effort for such a big language, and writing books isn't exactly lucrative or even profitable in many cases 14:54
of course we value those things... but there are other real world issues 14:55
chronon Would it be possible for a community driven book to work? Each small and specialised chapter written by an expert in that aspect? Overseen structurally by someone with complete understanding who can tie it all together?
I bet if we put money in a pot for that it could work. 14:56
IT'll be hard for the language to grow a userbase without solid books to give people the confidence. 14:57
ugexe if i was paid to write some chapters as an expert in some area i'd personally do it. definitely needs to be an inventive 14:58
moritz my one attempt at a multi-author raku book project was an abject failure
chronon Oh dear, why?
ugexe s/inventive/incentive/ 14:59
moritz chronon: people weren't delivering their chapters (too much else to do), and the project didn't have the right structure to replace those authors
chronon So was that a matter of insufficient incentives? 15:00
moritz also, after I felt I was one of maybe two authors who actually delivered, from a grand total of 5ish authors, I was getting frustrated
chronon Inequalit yis a fact of life. Best to accept it for the greater good. 15:01
moritz lack of incentives, lack of a deadlines and a way to deal with their expiry
chronon Right, so you now have a lot of valuable experience of how to set up such a project in future.
moritz some folks I really respected and liked working with didn't deliver, and I would have felt very weird going up to them and saying "you didn't write the chapter on $area-of-your-expertise, so I'm doing it, and you're not an author of this book anymore" 15:02
today, I would set up such a project very differently from the start, to deal more gracefully with such contingencies 15:03
chronon It would have to be like a contract (separated from one's personal feelings of friendship and admiration). If it were me, I'd want to offer some money on a quality and readability score, but also have a deadline beyond which it all halved, and a second deadline beyond which the author was assumed to have failed and got nothing. 15:04
But importantly, the amount of money offered would have to be quite decent, the kind of money that excites people to wake up and crack on with it.
Thhe kind of money one can put aside other work for, to prioritise the writing. 15:05
I wonder if the Perl Foundation would consider it worth funding. (Don't know anything about how that works.)
moritz that's not how it works, usually 15:06
writing a book is thousands hours of work
chronon I've written large book-like documents in a matter of weeks. But then I've known a lot about what I was writing, so it flowed. 15:07
moritz to be competitive with a good software engineer's salary, you'd have to raise in the order of 100..300k USD or so
that's not the order of magnitude that TPF deals in, nor that you can get funded by a kickstarter
nor from a publisher
it really needs to be a labor of love 15:08
chronon Well, perhaps the answer then is to give the actual writing to a lower level person who might not get such high salaries, but make sure they have access to pester a higher level expert for clarifications and proofreadings.
moritz and aligning enough authors to collaborate on such a labor of love is, well, difficult
chronon I am "between jobs" at the moment and enjoy writing. If I were just a little more knowledgeable about Raku I might volunteer. But with my current level of knowledge I'd feel like a baby teaching the prime minister about tax policy. 15:10
Well, if my goal is to become more knowledgeable, what is the best place to get reasonably well structure and comprehensive information about Raku? 15:11
[Coke] whees, power outage last night. 15:12
ugexe i learned from design.raku.org/ (which predates implementation so isnt entirely accurate although the spirit is usually correct) and from the raku source code (which used to be a lot less optimized/nqp and thus was pretty useful for even new people to learn from) 15:16
its also taken me like 10(?) years to get to my level of proficiency so those likely arent very good alternatives 15:17
moritz chronon: for well-structured I would recommend some of the books out there; they won't teach you everything there is to know about raku, but enough that you can do some projects on your own 15:18
ugexe speaking of... zef turns 8 years old in 3 days
moritz and then you can learn from the projects, docs, from here, stackoverflow etc. 15:19
chronon Hmmm, you perople make learning Raku sound like learning Japanese or all of the works of Shakespeare or something. 15:21
ugexe if you want to be an expert? perhaps
to learn it, no
chronon How much bigger and more complex is it than Perl 5? I thought Raku was in part at least a consolidation and tidy up of the warts. Which should make it easier to learn. 15:22
ugexe significantly bigger and more complex than core Perl 15:24
chronon Surely the basic language syntax, control flow, variables, types, operators, IO, and so on cannot be vastly bigger than Perl 5. Where is the complexity mostly? Is it in the regex grammar syntax, or Unicode handling, or async, or where?
ugexe that doesnt mean its harder to learn, just that there is more to learn that is core to the language 15:25
since I hope an expert perl programmer is not just using core Perl but the rest of their tools
well there is OO, threads, and non-ref counting GC 15:26
a beginner that is learning probably doesnt have to care about these things though
chronon One of the things I always love about Perl 5 was the fact that there was so much in the core, and it was well integrated using contextual behaviour that did what you usually wanted. 15:27
Raku is more of that, adn so must feel even more empowering.
ugexe honestly design.raku.org/ might be up your alley despite the disclaimer i made earlier 15:29
chronon Hmm, I'll definitely check that out. Thanks. 15:30
I'm not a big fan of IDEs (I'm a vim freak) but has anyone tried and enjoyed Comma? Would using the community edition be a good way to learn my way through Raku?
tonyo i use vim
chronon :) 15:31
[Coke] I think there's a vim plugin (don't use it), but Comma might help and let you introspect things in the IDE to see what's what. 15:32
sorry, I mean vim plugin: (*I* don't use it)
chronon Ah! 15:33
I was confuseed for a mo.
[Coke] yays, as all the computer hardware seems to have survived the 2 power outages.
chronon Don't you have UPS?
[Coke] nope. 15:34
chronon moritz, when you and your crew were writing books, what were the prefered formats to write in? Were people using lightweight markups and converting? 15:42
Does anyone have a lightweight markup favourite for writing very large documents? 15:43
chronon Well, does anyone know someone who might have an opinion on that? 15:51
moritz chronon: back in the days, we used some variant of POD; these days, I've mostly written stuff in Markdown 15:53
[Coke] Note that many of the crew here are on european time, so responses may be delayed.
moritz I love leanpub, which can render a book from markdown files in git, sell early versions, send updates to people when new version are avaialble etc.
[Coke] thanks chronon for the reminder to finally pick up a UPS. 15:54
chronon Should be late afternoon in Europe I think.
hehe
I used to have several UPS supporting my routers and wifi antennae for a community wifi I set up. Powercuts were frequent out there. Laptop batteries would last, but no good if the wifi is down. 15:55
Be sure to get a UPS that allows you to silence the beeper if you want to retain your sanity. Not all do. 15:56
Oh is leanpub a site, or service, or software? 15:57
ugexe easy enough to clip the speaker on them
chronon I actually did that in some of mine. Just got too fed up.
I like reStructuredText. It feels well designed. Not perfect, but I think it is better than Markdown for large documents as it has quite a few bookish features. 15:59
Ok, I found leanpub.com so it is at least a site, what else I wonder? 16:02
Looks like they use Markdown (or MSWord but that's crazy). 16:03
One other issue I have with Markdown is the large number of variants and lack of standardisation. Which kind of Markdown are leanpub using i wonder. 16:04
Ok, enough thinking out loud on a publically logged channel. Bye for now. 16:05
SmokeMachine Hi! sorry for insisting on this, but I really think `.reduce()` should be able to receive the aggregator as parameter... that would make it easier to fix something like this: 21:26
m: :{{"a" => 1} => {:10a}, {"b" => 2} => {:20b}, {"c"=>3}=>{:30c}}.reduce: -> |c ($_, %b) { say c; :{|%b, .value => .key} }
camelia \({:a(1)} => ${:a(10)}, {:c(3)} => ${:c(30)})
No such method 'value' for invocant of type 'List'. Did you mean
'values'?
in block at <tmp> line 1
in block <unit> at <tmp> line 1

\(({:c(3)} => ${:c(30)}, {:a(10)} => {:a(1)}), {:b(2)}…