Elouin has quit [Read error: Connection reset by peer]
Elouin has joined #crystal-lang
<FromGitter>
<melopee> @ImAHopelessDev_gitlab pretty great so far, finally a fast oop language with a clean syntax ⏎ I also like the pseudo-functional style
<FromGitter>
<melopee> but coming from a real functional language (haskell), some things like passing functions as arguments feels a bit weird
deavmi_ has joined #crystal-lang
<yxhuvud>
Yeah, that is usually only done when you need to save the function. The ideomatic way is usually to pass a block instead.
deavmi has quit [Read error: Connection reset by peer]
<FromGitter>
<melopee> Yes, but it makes writing higher order functions weird
<FromGitter>
<melopee> since there is this special rule for block
<FromGitter>
<melopee> I'm more concerned about inconsistencies in the syntax, for example
<FromGitter>
<HertzDevil> but you probably don't need it here, and also blocks are more than functions in that they could do control flow things
<FromGitter>
<HertzDevil> and since the block always goes after the other arguments, only the last parameter can have a `&`; it's a carry-over from ruby
<FromGitter>
<melopee> yeah with break control the method, this is so funky
<FromGitter>
<melopee> that makes sense, thanks
<FromGitter>
<melopee> I don't remember having seen it in the reference however
<FromGitter>
<melopee> Also, why is `.call` needed?
<FromGitter>
<HertzDevil> it's the same thing in ruby, although apart from `f.call(...)` and the `f[...]` above there's also `f.(...)`
<FromGitter>
<melopee> yeah, this is implicit application feels a bit weird, but I guess if you've used ruby before it makes sense
<yxhuvud>
yeah, it is optimized for the common case, which turns out to be blocks.
<FromGitter>
<HertzDevil> both ruby and crystal are oop-first, so method invocation is a more central concept than function invocation
<FromGitter>
<HertzDevil> thus the latter is implemented in terms of the former
<FromGitter>
<HertzDevil> `A -> B` is syntactic sugar for `Proc(B, A)`; there isn't a special "function" type that isn't an object
<FromGitter>
<melopee> it's interesting how OOP is extreme in ruby and crystal; at least the syntax reflects that
<FromGitter>
<melopee> Anyway thanks, I gotta go
deavmi_ has quit [Quit: Eish! Load shedding.]
deavmi has joined #crystal-lang
coderobe has quit [Quit: Ping timeout (120 seconds)]
coderobe has joined #crystal-lang
<raz>
it's about the cleanest OOP i've seen in any mainstream language (but i obv don't know all of them). smalltalk heritage is strong
chloekek has joined #crystal-lang
teardown_ has joined #crystal-lang
teardown has quit [Ping timeout: 240 seconds]
postmodern has quit [Quit: Leaving]
teardown_ has quit [Ping timeout: 240 seconds]
<raz>
first big sur impression: ugly & slow :|
<FromGitter>
<3n-k1> i don't mean to start a holy war, but isn't that the direction apple has been going lately? that's the impression i've gotten (from my admittedly biased) news feed
teardown has joined #crystal-lang
<raz>
i've actually been quite pleased with their recent updates on iOS etc. but big sur def needs more work. feels laggy and is an eyesore.
Liothen has joined #crystal-lang
<FromGitter>
<ImAHopelessDev_gitlab> @melopee nice!! I could never get into functional programming (tried numerous times, but my brain won't let me). so that's cool you are versed in both types of languages. glad you are liking crystal
<FromGitter>
<3n-k1> functional is hard if you don't learn it first imo. i love it, but i think it's nice that crystal focuses exclusively on oop instead of trying to add in functional as an afterthought
<riffraff169>
i didnt start with functional, but i tend make functions "functional"...it makes a lot of sense to me....some things are harder to understand like monads
<FromGitter>
<j8r> There are functional paradigms in crystal
<FromGitter>
<3n-k1> monads are absolutely amazing and i hate them lol. they're great for research in pure functional languages, but for anything non-trivial i prefer ocaml's style of just "ignore the side effect and hope it isn't an issue"
<FromGitter>
<ImAHopelessDev_gitlab> when i was around 13 years old i started with php and learned from looking at the source code of vbulletin and invision power board. this was way back in the "cracked forum software" days. i then went on to learn javascript, and used nodejs for a while. now, i found my happy place with crystal
<FromGitter>
<3n-k1> are there? i've seen some things for partial function application, but nothing really functional built-in
<FromGitter>
<ImAHopelessDev_gitlab> and i'm never going back. EVER
<FromGitter>
<3n-k1> understandable haha
<FromGitter>
<j8r> For example, one can define a module with `extend self`
<FromGitter>
<ImAHopelessDev_gitlab> @3n-k1 :D
<FromGitter>
<3n-k1> @j8r how is that functional?
<FromGitter>
<j8r> And `extend`, in a broader way
<FromGitter>
<j8r> Because it defined functions, not methods. They don't share a state
<FromGitter>
<j8r> They might with class vars, but you got it, no ivars
<FromGitter>
<ImAHopelessDev_gitlab> > Because it defined functions, not methods. ⏎ ⏎ my mind has blown
<FromGitter>
<ImAHopelessDev_gitlab> 😂
<FromGitter>
<ImAHopelessDev_gitlab> help @j8r :DDDDDD
<FromGitter>
<ImAHopelessDev_gitlab> i think i got it. when you say methods, you are saying methods for a class, and functions, you are saying just global/random functions in the abstract that can be called anywhere?
<FromGitter>
<ImAHopelessDev_gitlab> i think i have something similar in my code. i use GF.game_functionxxxhere() sometimes
<FromGitter>
<j8r> FileUtils is an example of a functional module
<FromGitter>
<j8r> I may be wrong, for me, a method having no side effects is a function. And Crystal have some features in this way. Few, but still some
<FromGitter>
<j8r> *global methods
<FromGitter>
<j8r> Yes @ImAHopelessDev_gitlab , that's this
<FromGitter>
<ImAHopelessDev_gitlab> i guess i use a bit of functional code then every now and then
<FromGitter>
<j8r> Also, is the `record` a concept coming from the functional world?
<FromGitter>
<j8r> Yeah, I use some too @ImAHopelessDev_gitlab . Notably, for helpers