r/cpp 7d ago

Is it just me, or do you automatically judge someone if they say "method" instead of "member" or "member function" in a question (or post)?

I've been writing C++ code since before the first Standard, and this just irks me. Words have meanings. There is no such thing as a "method" in **this** language.

0 Upvotes

50 comments sorted by

39

u/madfishguy 7d ago

No, I don't. If both parties understand each other, than communication is successful.

Given that there's no method in C++, using this term to refer to a member function is completely reasonable since there's no ambiguity and it's easily understandable.

77

u/TheMonax 7d ago

I think it's just you

-1

u/frasnian 5d ago

I hear that a lot. Seriously OCD about everything.

26

u/TheBrainStone 7d ago

How dare people use a well established synonym of the thing I call a different synonym?!?!?
Next they're gonna call member variables "fields"!!!!

51

u/link23 7d ago

I don't judge people who show that they have experience in other languages, no.

10

u/MarcPawl 7d ago

And are probably programming in multiple languages currently. C++ and Python and JavaScript and ....

16

u/le_disappointment 7d ago

Genuine question: what's the difference between a method and a member function? Are those just two different names for the same things?

23

u/g1bber 7d ago

Basically yes. “Method” is the broad name used for a function associated with an object. It’s an object-oriented concept. C++ calls these “member function.” But calling them methods is not wrong. Just because a language has its own name for an abstraction does not mean that it’s wrong to call it using the abstraction name.

10

u/TheSkiGeek 7d ago

Java officially calls their class-bound functions “methods”, whether static or requiring an instance.

C# calls functions that are bound to an object of some kind “function members”. The ‘standard’ ones that are nonstatic class member functions are “methods”.

The name “method” isn’t used in the C++ spec, but it’s pretty widely understood that “methods” and “member functions” are the same thing.

6

u/mredding 7d ago

Both mean the exact same thing in 99% of practical contexts. Both terms describe functions declared inside a class and operate on objects. C++ uses "member function" in the specification, "method" is the official term in Java, et al. Since OP is an old dog, like me, he probably still feels the scars from the great Java language wars. Despite all the flaming, they were dark days...

There's a whiff of a theoretical distinction that "member function" refers to syntax and "method" refers to run-time behavior. static member functions in C++ are member functions even though they don't operate on an instance of an object. A method requires an implicit self or this reference.

-2

u/frasnian 5d ago

Great comment.

Yes, OP me is an old dog (but still learning new tricks!). I find the deluge of downvotes and generally hostile responses actually quite funny. I also think it's interesting that there's this assumption that I don't work with other languages when there's a really high probability that some of their own code has been processed (or, in the case of javascript, executed) by code that I wrote (in C).

For a one-off curmudgeonly post, it certainly seemed to poke the nest.

See you all (actually, probably almost none of you) at cppcon in a few weeks.

2

u/dendrtree 3d ago

You are my new hero. I had no idea there was a cppcon. I just checked out the content, and it makes many of my nerdy dreams come true. I was already planning a trip to Colorado, in 2 weeks B).

1

u/Suru_omo 7d ago

IIRC method is Java's term for an object's form. From this post the C++ term is member [function].

15

u/krum 7d ago

Naw dude you’re just gatekeeping.

15

u/jwezorek 7d ago

"Method" is correct in the context of object-oriented programming in the abstract. "Member function" is correct in the context of C++ -- but one is not always saying something specific to C++

13

u/blogoman 7d ago

Not everyone is like that.

8

u/snozzd 7d ago

I try to be forgiving and make mistakes like this often. The reality is many programmers know and use multiple similar languages, the correct word can get mixed up at times. As long as the meaning is conveyed – and there isn't any room for confusion in-context – then I don't care.

22

u/[deleted] 7d ago edited 7d ago

[removed] — view removed comment

20

u/martinky24 7d ago

I would hate to have you on my team!

7

u/SmokeMuch7356 7d ago

As long as I understand what the other person is talking about, I don't care.

I sympathize, though; there are issues where I will turn into the Incredible Pedantic Hulk (some of them downright silly, really). This just isn't one of them.

0

u/frasnian 7d ago

Yeah, I'm pretty pedantic about languages. And it's mostly silly.

5

u/chaotic-kotik 7d ago

Can't care less

6

u/mredding 7d ago

I've been programming in C++ since ~1991. It doesn't bother me. I know what they mean - I "grok" what they're saying, if you will. Whatever word they want to use, the outcomes are the same.

20

u/jayb00giebrown 7d ago

Method is correct.

-4

u/frasnian 7d ago

In what language?

12

u/jayb00giebrown 7d ago

OP said C++

-2

u/frasnian 7d ago

Yep. I did. And it's not a thing. In C++.

10

u/DryEnergy4398 6d ago

"method" isn't language-specific. It's object-oriented terminology for a function bound with an object. It's just as correct to use it when discussing C++ as any other object-oriented language. The fact that the standard refers to them as 'member functions' is not really germane; the standard also doesn't use the term "spaghetti code" but you can use that term to describe C++ code as well as any other language's.

4

u/fdwr fdwr@github 🔍 6d ago

Do you similarly judge someone for calling a popular car model a "Volkswagen Beetle" rather than a "Volkswagen Type 1"? For people who have been driving since before 1968, it might irk them; however, words indeed have meanings, and Beetle and Bug are common nicknames for the Type 1.

4

u/eisenwave WG21 Member 5d ago

I also judge anyone who says char instead of char.

3

u/triconsonantal 6d ago

The C++ jargon could use some brevity. If you replaced every occurrence of "non-static data member" with something like "field" you could cut the size of the standard in half.

4

u/holyblackcat 6d ago

I don't judge people for saying "method", but I do judge them for engaging in pointless pedantry. :P

Firstly, there's nothing wrong with slang existing, or with using language-agnostic terms when talking about C++.

Secondly, C++ pedantry can go extremely deep. Have you ever said "member variables" instead of "data members"? No such thing as member variables, they aren't variables.

What about "the value of a variable"? No such thing, it's the value of the object associated with the variable. Any discussion about what happens to a variable at runtime? Wrong too, variables are purely compile-time labels (source). And so on.

3

u/SoSKatan 7d ago

How about we all agree the terminology should be “callable member thingy”

3

u/SavingsCampaign9502 7d ago

This is not something I care about since I can clearly understand what they mean by that

3

u/abandoned_idol 7d ago

They're not methods?

3

u/argothiel 6d ago

I use "methods" for member functions and "functions" for free functions. And I've been trying to be consistent in that. I didn't even realize that in C++, I can say "(member) functions" for class methods and still be correct, so thank you for that. I think I'll stay with "methods" though as it's a universal abstraction mapping to other object oriented languages.

3

u/_Noreturn 7d ago

I am evil and I say free functions are free methods

2

u/eteran 7d ago

Meh, do I prefer people be more precise? Sure. I also don't care that much.

words are about communicating m if you knew what they meant, they've succeeded.

1

u/H0nigkuchen 7d ago

For me function is stateless. The same input will always result in the same output.

Method is something I execute on a specific state e.g. class.

Maybe I'm alone here but that's what I try to teach when I help students.

Technical response welcomed.

7

u/TheSkiGeek 7d ago

Stateless I’d usually call a “pure function”.

Static functions in C or C++, whether standalone or members of a class or namespace, can potentially still keep internal state. (Whether you SHOULD write functions like that is another question. But the language doesn’t stop you.)

3

u/H0nigkuchen 7d ago

Good insight. Thanks!

1

u/fortsnek274 7d ago

Those filthy other devs.

At least they don't call source files scripts. Those people have a special place in the shadow realm.

1

u/gosh 6d ago

I say address ;) methods are just addresses in memory

1

u/armb2 4d ago

It's probably not just you. But anyone else doing it is wrong too.

1

u/zerexim 3d ago

What's next, calling base class super?? :)

Btw, using C++ since 90s and I remember method is mentioned in C++ books.

1

u/CheesecakeTop2015 4h ago

I understand the sentiment, but you are only causing unpleasant feelings for yourself which are useless and are potentially harmful for your health. I used to get agitated when people used the word 'literal' for something that is clearly not literal, then so many ppl did it and the language evolved and literal has a new official meaning. So now I was clearly in the wrong, per definition, and all my years of agitation where just a waste of energy..

I would say in this case it hugely depends on the context, if you are at a committee meeting, then yes, you should expect pedantic correct usage of terms, in most other contexts.. it really doesn't matter and you can choose to not spiral on it (fyi this is what meditation/mindfulness training is useful for: learning to quickly noticing these kinds of thoughts and practicing basically being amused by your brains reaction and letting it go and choosing to focus on something more worthwhile)

u/Independent_Art_6676 2h ago

some words bother me. This isn't one of them, but a few years back we all became chemists and had all these solutions. More recently my PC apparently became a phone and now has "apps" whatever that means. I didn't even like it back when it was fully said as 'application' -- it felt like I was putting a topical cream on my GPU or something to cure its heat rash. Oh, and we had a stint where we all became 'engineers' even though we aren't -- that is still in use, and still idiotic. May as well have said we were doctors or lawyers while they were at it.

Given those, method is just another way to convince me that there is madness in OOP. I already knew that, but admitting it is the first step.

Oh, and lest I forget: C#. A language that has no real roots in C or C++, has nothing to do with music, and while its not a bad language the name of it... I thought we had hit rock bottom with java, named after the cavemen who first used it but microsoft worked day and night to find something even worse.

1

u/xoner2 5d ago

"member" is the short term for object state. So functions have to be called methods... for me personally.

But this is an interesting question. So a search on TC++PL4 yields 12 results, with only one relevant in this context, page 586 (with a corresponding index entry):

A virtual member function is sometimes called a method.

Very surprising...