[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


Thread archived.
You cannot reply anymore.


[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
>>
>>106482824
>>106482745
>>106482763

The first one takes a as implicit argument you niggers
>>
.f() implies the function is a member of an object, f() implies that it is a regular function. they are not the same. you could in theory call f(b) and not b.f(), assuming b does not share any inheritance with a.
>>
>>106485766
>.f() implies the function is a member of an object
depending on the language. Same syntax can have different meanings in different languages
>>
>>106485766
no it doesn't unless you're talking about a specific language
but in another language f may or may not be a method of a and only use virtual dispatch if a is an indeed object and f is indeed a virtual member
>>
>I dont know what this is, the thread
>>
>>106482856
>>106483028
BASED SEXPCHADS
>>
>>106482732
it's actually used for transforming
f(a, b)
to
a.f(b)
and so on. it is no more charcters
>>
>>106482819
lmao tell that to SQL fags who still don't have autocomplete after 50 years because they can't start a statement with FROM like a normal language would
>>
>>106485791
>>106485800
that is the syntax in all oop languages. there are maybe some meme langs i am unaware of, but the example was
a.f()
f(a)

this is clearly in reference to objects, hence why in the "f(a)" a is being passed as an argument, and not being passed in "a.f()". inb4 rust function chaining.
>>
>>106485736
then why isn't it a.f ? why the empty parenthesis?
>>
>>106482732
my compiler does both because #1 is just syntactic sugar in the parser
>>
>>106485918
because sometimes you need more parameters you absolute retard
>>
b.f(a)

is what you want, because a rarely has enough context, and
f(b, a)

means passing an ever growing context through your system, which sucks. let your framework construct b out of the pieces it needs and you'll get individually testable units for free
>>
>>106482732
>stupid opinion
>snownigger moonspeak runes
checks out
>>
>>106482732
Those should not be the same thing.
>>
>>106482732
Ada actually uses both styles, the former is optionally available if you're working with Objects.
>>
>>106486038
for what reason
>>
>>106482732
#2 is a limitation of C
#1 is a million languages without that limitation
>>
>>106485736
They are most definitely not the same in Java.

'a.f()' is calling method 'f' of object 'a' with no arguments

'a(f)' is calling static method 'a' on 'f'.
>>
>>106486082
yes, java is a shit language thanks for reminding us. it's why civilized people use kotlin
>>
>>106486061
Because they don't look the same.
>>
File: quotation-marks.gif (63 KB, 640x480)
63 KB
63 KB GIF
>>106482732
a.f() <- C++ OOP
f(a) <- C FP

what I like about the a.f() approach is that, you already know the "domain" of functions you could use for a.

I'll say a.f(), but most of those C neckbeards are going to hate me for that.
>>
>>106485944
>already have the f(a, b c) notation
>make a new one that "makes sense" as long as you have stuff like a.f()
>but the moment you need to do a.f(b, c, d, e) it's basically a more retarded version of f(a, b, c, d, e)
>>
>>106486144
yes, it stops making sense on such scenarios

like, you can't decide if the function must belong to a, or b, or c, or d, or e.... since such function requires all those 5 different types, so to whom it even belongs to?
>>
>>106486125
that's some big brain thinking
>>
>>106486136
>f(a) <- C FP
that has nothing to do with "functional programming" you retarded sack of shit
>>
File: Ilulu.jpg (2.11 MB, 1654x2339)
2.11 MB
2.11 MB JPG
>>106486173
Please be nice when posting to the Dra/g/on Maid Board. Remember that everybody here is a cute maid who likes computers just like you.
>>
>>106486144
look anon, you don't have to gloat about never having had a job but here's a simple example
val newRectangle = rectangle
.scale(xFactor, yFactor, padding)
.transform(xOffset, yOffset)
.color(gradient, opacity, brush)

now lets look how retards like you would write this:
val scaledRectangle = scaleRectangle(rectangle, xFactor, yFactor, padding)
val transformedRectangle = transformRectangle(scaledRectangle, xOffset, yOffset)
val coloredRectangle = colorRectangle(transformedRectangle, gradient, opacity, brush)
val newRectangle = coloredRectangle
>>
>>106486240
You are the retard who doesn't understand that a.f() does not in any way imply that we are dealing with object oriented programming. OP's vague question simply confronted two notations without any context. Nowhere is was said that a is an "object" that has "methods" and other bullshit. We are talking about purely syntactical
>>
>>106486267
>he thinks this is only possible with objects
KWAB
>>
>>106486188
good post
>>
>>106486274
I literally don't care though which implementation that notation can be put to use, OP's questionis not about that, and that is the point of the post you cluelessly just replied to because you have the reading comprehension of a nigger
>>
>>106486293
>accuses others of having bad reading comprehension and seethes incessantly
>can't understand a simple example of a pure syntax based scenario where .f() is superior (chaining)
Name for this mental illness?
>>
>>106486240
The first one is methods of rectangle.
The second one is public functions.
They are not, and should not, be the same.
>>
>>106486317
val rectangle = scale(rectangle, xFactor, yFactor, padding)
rectangle = transform(rectangle, xOffset, yOffset)
rectangle = color(rectangle, gradient, opacity, brush)
>>
>>106486381
>ambiguous function naming where you have to infer what it does from the fucking parameters
Oops, you failed
>>
>>106486389
Kek this
>>106486381
Also enjoy having your IDE suggest this completely unrelated function each time you start typing "scale"
>>
>>106486389
>>106486397
>Regardless of the implementation, my a.f() syntax is nice and clean
>N-NO YOU CANNOT PRESENT A CLEAN EXAMPLE OF f(a) SYNTAX IT WOULD BE HEKKIN CONFUSING IN ITS REAL WORLD IMPLEMENTATION
A perfect bait for spotting bad faith arguing and it worked flawlessly
>>
>>106486425
Even with all your copes, you wrote twice as much slop in your "clean" example kek
>>
>>106482732
a.f
>t. Scala enthusiast
>>
>>106486458
Based fellow scalachad
Don't tell the retards ITT about infix, they might unironically lose their minds kek
>>
>>106482732
f(a) is more functional and will bite you in the ass less often. a.f() is object oriented slop that will ruin your life.
>t. sex having Haskellchad
>>
>>106486522
>a.f() is object oriented slop that will ruin your life.
It's not object oriented slop. In a non-OOP language `a.f()` is just sugar syntax for `f(a)`. Only in OOP does it start to involve virtual tables and more leg work, ultimately doing the same as `f(a)` just a lot more hidden behind the scenes to handle calls to the superclass (if needed)
>>
>>106486522
>haskellchad
>that post
On a scale from 1 to 10, how retarded are you? Half of haskell syntax is infix and function composition
>>
>>106486381
>var
Fucking yikes.
>>
>>106482732
f(x=6, y=6, z=6), a
>>
for me, it's
std::invoke(f,a)
>>
(F a)

Dot notation doesn't allow multimethods
>>
>>106487467
>another sexpchad has entered the thread
>>
>>106482732
f(a) is the only sane way to do it
>>
>>106482856
We've got a high class gentleman and pillar of the community in the thread
https://www.youtube.com/watch?v=voNEgCKzves&list=RDvoNEgCKzves&start_radio=1&ab_channel=RHINO
>>
>>106487467
>Dot notation doesn't allow multimethods
wat
>>
>>106482732
OOP BAD IT JUST IS OK
>>
>>106487795
The dot notation is not necessarily an OOP concept, though.
It could just be an associated function of a type.
>>
>>106482732
First one is namespaced.
If you go with the second option you'll have to do
fA(a), fB(b), etc as more structs use f function.
Also fuck whoever uses a single character for their functions. A dot is 50% of the characters when your function is a single character but normally they are at least 4, so more like 20%, less of a deal
>>
>>106482732
The benefit of method call syntax is that the function doesn't have to be in the root namespace. If you want to use traditional function call syntax, you either have to fully qualify the namespace of the function, or import the function into the root namespace. So it actually looks more like:
T.f(a)

or
import f from T
f(a)
>>
>>106487682
(F a b) can be a method specialised on both a & b instead of a method specialised on a alone in a.f()
>>
>>106486082
But the actual difference is a(f) will jump to where a is.
a.f() will have to go to function call table of a and find f then jump there.
>>
>>106487937
C++ was right to discourage this shit by forcing you to type out uncomfortable double colons if you really want to be a dumbass.
>>
>>106488234
Like function overloading in C++?
>>
>>106488234
>>106487467
You can do this in Beef with autocomplete.
(a,b).F();
>>
>>106482745
https://en.wikipedia.org/wiki/Uniform_function_call_syntax
>>
concatenative: x f g h
>>
>>106482732
a f
>>
C: no method syntax, shit
Java: no free function syntax, shit
>>
>>106486082
have you never written JNI before? lol
>>
>>106486108
kotlin is trash. no low level control

garbage language for shitting out boilerplate webdev frameworkslop
>>
>>106482745
>>106486082
JNIEXPORT void JNICALL Java_path_to_package_MyClass_myMethod
(JNIEnv *, jclass);
yes they are
>>
>>106489402
>muh Heckin low level controllerino!!
Nobody cares about your pointerslop
>>
>>106489402
>>106489521
There is actually Kotlin/Native. It has a GC but you can use any C library and manual memory management, if you want. It's kinda in a limbo right now, though.
>>
>>106489521
enjoy your 1GB of dependencies (assuming the security manager is disabled so it even works) to do something i can enjoy in 100 lines with or without the security manager
>>
>>106489540
>can enjoy in 100 lines
Why are you lying to yourself
It's gonna be 20k lines and you'll spent two years working on it but you'll be oh so proud that it's hyper efficient and only takes up 1mb instead of 40mb kek
>>
>>106489549
it's the java side that is 20k lines kek
>>
>>106489555
Is that the cope Cshitters tell themselves?
>>
>>106489586
no, it's my project you fucking retard
>>
>>106484376
extremely dishonest
disgustingly so, even

the second one should be
f(a)
g(a)
h(a)
i(a)

bc its all methods form a single class
>>
>>106489657
(clarif.)
(and so its procedural equivalent should be functions sequentially applied to one object too)
>>
>>106489657
>bc its all methods form a single class
That's an assumption you made retard, nowhere does it say that assumption is true.
So no, the only one being disingenuous is you
>>
>>106489698
thats what the syntax says, oop trany
you lost
>>
>>106489721
>>106489698
to clarify
a.f()
.g()
.h()
.i()

>umm achksually
>in the middle of that shorthand notation the target object gets swapped away
i will do unspeakable things to your computer, ooptrany
>>
>>106489721
val x = 5
x.factorial()
println(x) // 5
println(x.factorial()) // 120

What's your cope now?
>>
>>106489750
>doesnt even realize factorial is a method of x
such is the power of oop, huh?
early onset dementia?
>>
>>106489755
Yes and x is a primitive. So I'll repeat, what's your cope here? Your "should be" wouldn't work whatsoever
>>
>>106489765
what cope?
no amount of digression is gonna help now that you made a retard
you fucking scald
we should put a muzzle on you
>>
>>106483225
>>106482732
func(value) any time the value determines the output of the function
obj.member any time it doesn't
mix and match accordingly
>obj.memfunc(obj.members.memfunc(absouteValue(math stuff))



[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.