Which way, /g/?
>>106482732a.f() and f(a) are not the same thing.>t. Java enthusiast
what is f?what is a?
>>106482747FUCK ASS
>>106482732They are not the same thing and a UCS is retarded.
>>106482732apply(f, a)
apply(f, a)
>>106482732>dumb xitter poster doesn’t understand encapsulationyep, it certainly is a day of the week that contains the letter Y.
>>106482747f is a function, a is a variable, presumably.
>>106482732>IT'S ZOZZIN TIME
doesn't matter
>>106482732The second one is better also because in vim I can just doESC + A and start typingWith parenthesis, I have to navigate to TWO separate places if I wish to wrap an expression in one more function call.
>>106482732/g/ during European hours is so fucking dumb.What stupid bullshit thread even is this?
>>106482732But the function name is not just "f", is it? Class methods let you use contextual naming.It's more likefoo.barify()barify_foo(foo)
foo.barify()barify_foo(foo)
>>106482772wit amista azozin
>bikeshedding threadI expect it to reach post limit in 15 minutes.
>>106482777check 'em
>>106482777Making any kind of decisions about how you should structure your code just because of what you can do in your editor is not a good decision.
>>106482766>f is a function, a is a variable, presumably.if f is a function, then the second notation implies the function has at least an argument, while in the first one it has none. this is not coherent
>>106482777>coding in vim
>>106482732top one cannot be force inlined in ctsoding btfo
>>106482732(f a)
>>106482732>Which way, /g/?nope, these two don't do the same thing in powershell.a.f() would look inside the object and find the 'key' f and it's data.But since a doesn't have a $, it will just error out.f(a) would work.function a { return "fun a"}function f($inputFromA) { Write-Output "$inputFromA" Write-Output "function f"}f(a)
function a { return "fun a"}function f($inputFromA) { Write-Output "$inputFromA" Write-Output "function f"}f(a)
>>106482732who cares about how much you have to type? code readability is what matters (in this case there's no real difference in readability between both so whatever).
>>106482856>mental illness
>>106482780>Class methods let you use contextual naming.Basically every programming language has modules/namespaces that let you do similar without the drawbacks.
>>106482732> s-tier f a(f a)a :f -- a object with method f > good tier f(a) a |> f > retarded-tier a.f()
f a(f a)a :f -- a object with method f
f(a) a |> f
a.f()
Call f(a)
noun.verb makes more sense than verb(noun)
(f a)
>>106482745they are>t. Go grugneer
>>106482819Yes it is. You don't want to get demoralized. You want to enjoy coding. And also it is more readable if there are less parenthesis (assuming it is a C like language and not a lisp variant)
>>106483026not in english it doesnt>>106483028this is the way
>>106483028mental illness
> For people that actually want to learn something:They represent method call vs free function call. In many languages:>a.f() means f is a method bound to object a.>f(a) means f is a standalone function taking a as an argument.The caption jokes about developers preferring the method-call syntax (a.f()) because it triggers IDE autocompletion (you type a. and get a list of methods). With plain function calls (f(a)), you don’t always get context-sensitive autocompletion, so developers feel like they need the dot syntax even if both ways are logically the same.So the "one character per function call" is the extra . you add to make autocompletion work.
>>106483093kill yourself
>>106483050are(you, "retarded")
>>106483110>yourself.kill()
>>106483114kill | yourself
>>106483129pipe(self, kill)(you)
>>106483026noun.verb implies that for a verb to exist it must have a noun that "has" the function as an action it can perform. so now if you simply want to have a function to something you need to attach it to some pre-existing noun or make one from scratch, with all the design complications that come from that
your self killwhere are my RPN chads
>>106482732So a is a structure that hold a pointer to a function f?How does that function know what a is, and why does that function have to deal with an a that has a pointer to itself?
What about this?a.f().g().h()vsh(g(f(a)))
a.f().g().h()
h(g(f(a)))
>>106482745Kotlin enthusiast here laughing at you
>>106482732this is why kakoune is superior to vim.anyone who doesn't understand why narrowing early is better for completion is literally mentally retarded.
>>106482732a f
>>106483141that's how programming works though.you can't just define some top level get() and expect any noun to be accepted as a parameter.a good example of why verb-noun is retarded is looking at powershell.>Get-<TAB>>2 gorillian results to show>none of them relevant>actually needed List-MyNoun or Show-MyNoun insteadonly a fucking retard thinks verb-noun is better than noun-verb. it's basic hierarchical thinking in general.
>>106482824Don't worry it makes sense, you are just missing some knowledge
>>106482732That one extra character aids readability.
>>106482732a.f()f(&a)if you pass "a" as a reference (as you should) you get the same amount of characters, but of course he's a stinking lying pimple faced russian
a.f()f(&a)
>>106482732My oop mind thinks that a is a class and f is part of that class for the first one, and in the second one a is a function parameter
>Which way, /g/?All of them and I'll pick whichever I prefer, thanksa.f()f(a)a.ff a
a.f()f(a)a.ff a
>>106483365is the autocompleted list of parameters not typed?
>>106483479every language besides c doesn't need you to explicitly take a reference, and c doesn't have methods in the first place. (you could write a.f(a) if f was a property of a).
>>106483292>kotlin enthusiasti'm surprised you could laugh with that giant dildo shoved down your throat
>>106482931>PowerShell Shut the fuck up.
>>106483582Rust and C++, the only languages that matter. Webshitters need not speak.
[CODE]f(&a)[/CODE]
Python and c
>>106483676...both implicitly convert to references in the relevant context.
>>106483758Rust doesn't, and the C++ equivalent would be passing a pointer not a reference
>>106483629>Shut the fuck up.Shut up faggot.
>>106483758>implicitjeet coder
>>106483582Rust doesn't reference things implicitly, only dereferences if needed.Rust references aren't a special thing like in C++. It's just a non-null aligned pointer to a valid object with a lifetime.
>>106482732a.fIf you care about character count make a lang where empty parenthesis are optional and just don't allow property-method name conflicts. I think MATLAB allows this.
>>106482732there's literally no reason why they can't be the same thing, programming languages are religious slop for pseuds. I'm glad I wasn't mentally raped with these arguments at college, there are better topics like algebra and mathematical analysis to really get pedant. This are just pseud shit.
>>106483769>>106483828huh, fair enough. well sucks to be a troon i guess
>>106483365>you can't just define some top level get() and expect any noun to be accepted as a parameter.there is a difference between a.f() meaning that f() is a function inside namespace a, and f() being an action that the "object" a can perform. This is why the :: notation was created for OOP
>>106482732a.f() is more convenient because 'f' is scoped in the class of a, so 'f' can be a nice short name, whereas in f(a) f needs all the usual namespacing and lengthening to avoid collisions.
>>106482732userId.isValid()orisValid(userId)?
>>106483026Only person itt that gets it.>add(a, b)Means "computer, add a and b together". The arguments are the object of the verb.>game.update()Means "game, do the update". It reads as if the game is the subject.Besides, there's no language that ONLY has method syntax, that wouldn't even make sense. Everyone is free to use the way that's more natural to them, so I don't know why anyone would be seething about this. I guess that's how it is if your job is to ragebait webshitters on twitter.>>106483479This is also a good point. In Rust a mutating function actually needs f(&mut a), while with the method would still be a.f(). But that's a mostly self inflicted problem, I guess.
>>106482732obj.foo() >>> foo(obj)>it avoids naming collisions with other foo's>it's obvious foo belongs to obj and is not just some random function>cleaner syntax (personal preference)
>>106482780tbf some languages have function overloading.>>106482980Then you'd end up getting n.f(a) which is longer than both.
I like the bottom one even if it makes nested functions a pain because I prefer procedural programming over functional or OOP. Its nice because you lose the voodoo programming which sucks for some thing, but is better on the whole.
import svo: 2.add(5)import vso: add(2,5)import sov: (2,5).add.???. thanks
>>106484030in smalltalk this is just 2 add: 5
2 add: 5
>>106482732first one implies that function is part of object, second one implies that you pass the object to the functionthese are not the same
>>106482980Except you then don't get that object's data in scope without passing it in.
a.f() .g() .h() .i()Vsi( h( g( f(a) ) ))Which way, civilized man?
a.f() .g() .h() .i()
i( h( g( f(a) ) ))
>>106484361Sound like you're just working with a shit tier language.fun MutableList<Int>.swap(index1: Int, index2: Int) { val tmp = this[index1] // 'this' corresponds to the list this[index1] = this[index2] this[index2] = tmp}
fun MutableList<Int>.swap(index1: Int, index2: Int) { val tmp = this[index1] // 'this' corresponds to the list this[index1] = this[index2] this[index2] = tmp}
>>106484376>abstract factory builder/fluent modeversus>C modeSee yourself out.
>>106484412>he thinks you need a builder pattern or a factory to use extension functions >tells others to see themselves outKWAB
>>106482732Depends on context save(user) Or user.save()
>>106484426Who are quoting?
>>106484376neither. they're both bad. i want my code to be debuggable.f_result := f(a)g_result := g(f_result)h_result := h(g_result)i_result := i(h_result)
f_result := f(a)g_result := g(f_result)h_result := h(g_result)i_result := i(h_result)
>>106484479WHO ARE QUOTING SAR? WHO??
>>106484506Huh? How does this make the code more debuggable?
>>106484517how do you step with a debugger over the code you showed without it being annoying and confusing? even if you don't use a debugger, you will have to factor out some part of the chain to debug some intermediary value at some point.
>>106484533>debug some intermediary valueI mean for like printf debugging or whatever.
>>106484533>how do you step with a debugger over the code you showed without it being annoyingWelcome to the 21st century anon
>>106484506>wasting so much memory and time
>>106484576i dont understand what your pic is supposed to mean. it doesn't show a chain of operations like i(h(g(f(a)))), much less the intermediary values, like f(a), g(f(a)), etc.>>106484592do you realize that this is literally what your compiler is converting your code to in the background and that's it's not slow or wasteful at all actually? do you know what SSA form is?
f3 $ f2 $ f1 $ a
>>106484592bait used to be believable
>>106484576grabbing intermediate results from nested function calls is pretty annoying to do
>>106484604>>106484688is this black magic to you? be honest right now