[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology

Name
Options
Comment
Verification
4chan Pass users can bypass this verification. [Learn More] [Login]
File
  • Please read the Rules and FAQ before posting.
  • You may highlight syntax and preserve whitespace by using [code] tags.

08/21/20New boards added: /vrpg/, /vmg/, /vst/ and /vm/
05/04/17New trial board added: /bant/ - International/Random
10/04/16New board for 4chan Pass users: /vip/ - Very Important Posts
[Hide] [Show All]


[Advertise on 4chan]


File: Untitled97.png (29 KB, 606x488)
29 KB
29 KB PNG
Which way, /g/?
>>
>>106482732
a.f() and f(a) are not the same thing.
>t. Java enthusiast
>>
what is f?
what is a?
>>
>>106482747
FUCK ASS
>>
>>106482732
They are not the same thing and a UCS is retarded.
>>
>>106482732
apply(f, a)
>>
>>106482732
>dumb xitter poster doesn’t understand encapsulation
yep, it certainly is a day of the week that contains the letter Y.
>>
>>106482747
f is a function, a is a variable, presumably.
>>
File: 1742644471294122.png (1 MB, 1092x923)
1 MB
1 MB PNG
>>106482732
>IT'S ZOZZIN TIME
>>
doesn't matter
>>
>>106482732
The second one is better also because in vim I can just do
ESC + A and start typing
With 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?
>>
>>106482732
But the function name is not just "f", is it? Class methods let you use contextual naming.
It's more like
foo.barify()
barify_foo(foo)
>>
>>106482772
wit amista azozin
>>
>bikeshedding thread
I expect it to reach post limit in 15 minutes.
>>
>>106482777
check 'em
>>
>>106482777
Making 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
>>
File: IMG_7502.jpg (37 KB, 343x375)
37 KB
37 KB JPG
>>106482777
>coding in vim
>>
File: msft-ai-lmaoo.jpg (129 KB, 828x983)
129 KB
129 KB JPG
>>106482732
top one cannot be force inlined in c
tsoding 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)
>>
>>106482732
who 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() 
>>
Call f(a)
>>
noun.verb makes more sense than verb(noun)
>>
(f a)
>>
>>106482745
they are
>t. Go grugneer
>>
>>106482819
Yes 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)
>>
>>106483026
not in english it doesnt
>>106483028
this is the way
>>
>>106483028
mental 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.
>>
>>106483093
kill yourself
>>
>>106483050
are(you, "retarded")
>>
>>106483110
>yourself.kill()
>>
>>106483114
kill | yourself
>>
>>106483129
pipe(self, kill)(you)
>>
>>106483026
noun.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 kill
where are my RPN chads
>>
>>106482732
So 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()

vs
h(g(f(a)))
>>
>>106482745
Kotlin enthusiast here laughing at you
>>
>>106482732
this is why kakoune is superior to vim.
anyone who doesn't understand why narrowing early is better for completion is literally mentally retarded.
>>
>>106482732
a f
>>
>>106483141
that'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 instead

only a fucking retard thinks verb-noun is better than noun-verb. it's basic hierarchical thinking in general.
>>
>>106482824
Don't worry it makes sense, you are just missing some knowledge
>>
>>106482732
That one extra character aids readability.
>>
>>106482732
a.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
>>
>>106482732
My 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
>>
File: 1746967724946869.jpg (158 KB, 1440x1438)
158 KB
158 KB JPG
>Which way, /g/?
All of them and I'll pick whichever I prefer, thanks
a.f()
f(a)
a.f
f a
>>
>>106483365
is the autocompleted list of parameters not typed?
>>
>>106483479
every 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 enthusiast
i'm surprised you could laugh with that giant dildo shoved down your throat
>>
>>106482931
>PowerShell
Shut the fuck up.
>>
>>106483582
Rust 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.
>>
>>106483758
Rust doesn't, and the C++ equivalent would be passing a pointer not a reference
>>
File: 1756421973154749.png (213 KB, 480x360)
213 KB
213 KB PNG
>>106483629
>Shut the fuck up.
Shut up faggot.
>>
>>106483758
>implicit
jeet coder
>>
>>106483582
Rust 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.
>>
>>106482732
a.f
If 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.
>>
>>106482732
there'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
>>106483828
huh, 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
>>
>>106482732
a.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.
>>
>>106482732
userId.isValid()
or
isValid(userId)
?
>>
>>106483026
Only 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.
>>106483479
This 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.
>>
>>106482732
obj.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)
>>
>>106482780
tbf some languages have function overloading.

>>106482980
Then 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
>>
>>106484030
in smalltalk this is just
 
2 add: 5
>>
>>106482732
first one implies that function is part of object, second one implies that you pass the object to the function

these are not the same
>>
>>106482980
Except you then don't get that object's data in scope without passing it in.
>>
a.f()
.g()
.h()
.i()

Vs
i(
h(
g(
f(a)
)
)
)


Which way, civilized man?
>>
>>106484361
Sound 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
}
>>
>>106484376
>abstract factory builder/fluent mode
versus
>C mode
See yourself out.
>>
>>106484412
>he thinks you need a builder pattern or a factory to use extension functions
>tells others to see themselves out
KWAB
>>
>>106482732
Depends on context

save(user)

Or user.save()
>>
>>106484426
Who are quoting?
>>
>>106484376
neither. 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)
>>
>>106484479
WHO ARE QUOTING SAR? WHO??
>>
>>106484506
Huh? How does this make the code more debuggable?
>>
>>106484517
how 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 value
I mean for like printf debugging or whatever.
>>
File: Breakpoint.png (61 KB, 1059x331)
61 KB
61 KB PNG
>>106484533
>how do you step with a debugger over the code you showed without it being annoying
Welcome to the 21st century anon
>>
>>106484506
>wasting so much memory and time
>>
>>106484576
i 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.
>>106484592
do 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
>>
>>106484592
bait used to be believable
>>
>>106484576
grabbing intermediate results from nested function calls is pretty annoying to do
>>
File: kek.webm (454 KB, 1686x406)
454 KB
454 KB WEBM
>>106484604
>>106484688
is this black magic to you? be honest right now



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.