uli.pink ive never done object oriented programming before, i come from a functional & logic programming background, and im trying to wrap my head around the difference between a type and a class if i were to "instantiate" a new class using a constructor, and then introspect it i get the class name, but afaik classes aren't types since they contain more structure than even set-theoretic types permit so this sort of 00:04
challenges my notion of what it means to be a type, does a type have associated methods like a group or lattice or field would? or are types just classes and to make a judgement like my $x of Int = 1 does not mean 1 : int as you would write in ML but rather, "1 is an «instantiation» of the class Int"
and, if the latter point is indeed the correct way to view it, how could i make sense of subroutines? in ML they are defined strictly in terms of type constructors and lambda/function abstractions, however as far as im aware instances of subroutines contain no information about what they internally or external represent as a subroutine, they are just branded "Subroutine" with no descriptor, that information 00:15
is encoding in the Signature type/class, so is constructing a Subroutine also constructing a Signature? how tightly are these things bonded, can i instantiate a signature and build a subroutine from it?
SmokeMachine I would generically say that in raku classes and types are the same thing, and everything are instances of classes (objects) 01:35
uli.pink: ^^ 01:36
Subroutines are also objects, and they do hold information… they have a signature 01:37
m: sub bla(Int $i) { $i + 1 }; say &bla; say &bla.signature 01:38
camelia &bla
(Int $i)
SmokeMachine m: sub bla(Int $i) { $i + 1 }; say &bla.^name 01:39
camelia Sub
SmokeMachine m: class MySub is Callable { method CALL-ME($value) { say “just run my sub and received: $value” } }; my &bla = MySub.new; bla 42 01:43
camelia just run my sub and received: 42
uli.pink thanks very much, i appreciate it 02:14
08:58 dakkar joined
librasteve @uli.pink I practically learned OO in raku from Think Raku (used to be Think Perl6) ... I recommend highly - greenteapress.com/wp/think-perl-6/ ... when you have that covered (its only a chapter or two) then you can look at docs.raku.org/language/objects to get a deeper expanation of the "power tools" - roles, punning and so on 12:35
the great thing about raku is that the OO syntax is so natural with english words like has, is, does and so on so that even a total beginner can get code up and running and have a good feeling for what is going on ... 12:36
... the other great thing is that (even with a lovely OO syntax) raku provides almost all the power tools that the most OO centric languages do (mult-inheritance, roles composition, mult-methods, construction, fully private attrs, meta object protocol, etc) - I am thinking C++ without the pain if you ever want to go to the limits 12:38
antononcube I am not sure if someone can only Functional Programming (FP) features of Raku. My preferred way of using FP in Raku is through OOP syntax. (Which is analogous to monadic pipelines in Haskell.) 12:49
To be concrete, I no longer use map(func, data), 99% of the time I use data.map(func). 12:50
The method call operator, . , can be pipelined -- that is the monadic-analogy I reffer to. 12:52
Related to this, is my preference to using the forward feed operator, ==>, especially in documents or presentations.
lizmat and yet another Rakudo Weekly News hits the Net: rakudoweekly.blog/2025/01/06/2025-01/ 12:53
antononcube To conclude or add to my statements above: 1. Raku fully supports Functional Programming (FP). 2. I am not confident saying that Raku encourages you to think FP-wise. 3. Knowing Object-Oriented Programming (OOP) makes you a more productive Raku programmer. 4. Mixing FP and OOP in Raku works nicely (and I recommend it.) 12:58
17:19 Tirifto left 17:27 Tirifto joined 17:44 dakkar left 20:15 kjp joined 20:27 kjp left, kjp joined
uli.pink i would like the agree with all the above 21:05
is it helpful to understand OOP design patterns when working with raku? 21:06
antononcube I don’t think so. But certain patterns are fundamental — you will apply them even if do not know them. 21:09
23:13 jmcgnh left 23:21 jmcgnh joined