jhass changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | Crystal 0.35.1 | Fund Crystal's development: https://crystal-lang.org/sponsors | GH: https://github.com/crystal-lang/crystal | Docs: https://crystal-lang.org/docs | Gitter: https://gitter.im/crystal-lang/crystal
gangstacat has quit [Quit: Ĝis!]
gangstacat has joined #crystal-lang
<FromGitter> <Blacksmoke16> Added factory support to the DI component ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5fadf2cedc70b5159a0b9ad2]
<FromGitter> <Blacksmoke16> neat :p
f1reflyylmao has joined #crystal-lang
f1refly has quit [Ping timeout: 240 seconds]
chachasmooth has quit [Ping timeout: 260 seconds]
chachasmooth has joined #crystal-lang
avane has quit [Quit: ZNC - https://znc.in]
avane has joined #crystal-lang
duane has quit [Ping timeout: 258 seconds]
duane has joined #crystal-lang
_whitelogger has joined #crystal-lang
postmodern has joined #crystal-lang
ua has quit [Ping timeout: 256 seconds]
yukai has quit [Ping timeout: 260 seconds]
ua has joined #crystal-lang
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> <melopee> I don't understand why
<FromGitter> <melopee> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5fae99abbf955735eb790981]
<FromGitter> <melopee> works
<FromGitter> <melopee> ``````
<FromGitter> <melopee> which errs outputing
<FromGitter> <melopee> ``````
<FromGitter> <HertzDevil> you don't need a block
<FromGitter> <HertzDevil> `def apply(f : A -> B, x : A) : B forall A, B`
<FromGitter> <HertzDevil> `puts apply(->succ(Int32), 0)`
<FromGitter> <melopee> (are modified messages resend to the irc?)
<FromGitter> <melopee> oh right
<FromGitter> <HertzDevil> having a block allows you to do ⏎ ⏎ ```puts apply(0) do |x|``` [https://gitter.im/crystal-lang/crystal?at=5fae9a7906fa0513ddae5b56]
<FromGitter> <HertzDevil> ``` succ(x) ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5fae9a87bf955735eb790b89]
<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> <melopee> e.g. why ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5fae9bd174152347c230d33c]
<FromGitter> <melopee> fails to compile with ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5fae9becf2fd4f60fc6fbc0b]
<FromGitter> <HertzDevil> because, well, there are no true functions in crystal
<FromGitter> <melopee> `.[]`'s array method is sugared into normal indexation
<yxhuvud> FWIW it is the same in ruby. There it would also work to do f[0] though.
<FromGitter> <melopee> why couldn't application with `()` brackets have the same trick?
<FromGitter> <melopee> > there are no true functions in crystal ⏎ then what are they?
<yxhuvud> dunno. I'm not sufficiently knowledgable of the parser to answer that.
<FromGitter> <HertzDevil> if you have ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ then it's not known whether `fn` on the last line refers to the proc itself or an invocation with no arguments [https://gitter.im/crystal-lang/crystal?at=5fae9d4406fa0513ddae6240]
<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
<FromGitter> <ImAHopelessDev_gitlab> "for helpers", hold my beer (https://i.gyazo.com/6a69267a9dbdcc34f5a5aff075a52800.png)!
<FromGitter> <3n-k1> @j8r does crystal have record types now?
<yxhuvud> the record macro has existed for a long long time, but hasn't been very documented
<FromGitter> <3n-k1> oh nice, i never even saw that. that's cool as hecc
<FromGitter> <3n-k1> i really need to just memorize the top-level namespace
<FromGitter> <j8r> That's a shortband for struct: it defines the initialize + getters
<FromGitter> <j8r> it acts like one, as yxhuvud said, it is a macro: https://crystal-lang.org/api/master/toplevel.html#record(name,*properties)-macro
Liothen has quit [Quit: Liothen]
Liothen has joined #crystal-lang
duane has quit [Ping timeout: 240 seconds]