Anyone you find in the real world under ~30 years old may not even be aware that you can pass a reference and modify it directly without having to make a method return a value.
It's super cool to have someone explain to you side effects yet you show them a method with a null return and run it for them showing that the value has changed and they are mesmerized.
Here in north-west EU C and C++ haven't been a part of the core curriculum for over 25 years (unless you do embedded work), and code with side-effects in desktop-class systems has been frowned upon for nearly as long due to the need for more cookie-cutter engineers to fill positions and write code that might still be OOP but has to be almost as side-effect free as functional code.
Basic/core languages are still (last time I checked when doing guest lectures ~ 6mo ago) Java, C#, Python and the mixed bag that is web languages.
This is also influenced by the core program required to be an accredited institution and the large amount of consultancies people end up working at straight out of college/school/uni. This even still happens in infrastructure-centric programs where you do lean a bit about TCP/IP and OSI layers, but then essentially get dumped into Juniper/Cisco/vmware/microsoft school which almost always gets them vendor-locked and unaware of the actual concepts and abstractions they implement.
So no, not knowing the difference between passing references or values, or pointers and dereferencing them is not as strange as you seem to think it is. It is not a piece of knowledge or experience that is seen as valuable enough by the people that create the curriculum or the companies that employ the largest quantities of inexperienced workers in this part of the world.
A lot of people seem to underestimate the prevalence of C/C++. I've had people tell me that C/C++ is completely dead and the future is machine learning entirely written in Python, but the machine learning models they're using still usually have parts hand-tuned in C/C++, or even assembly.
Intro to Programming 1 and 2 were taught in C++. Can't remember which one taught pass by reference, but it was definitely in one of those two.
Third class I took was Intro to Systems or something like that. The whole class was C and x86 ASM. Lots of binary operations in that one, used K&R a fair amount in that class (also learned debugging assembly in GDB and some other "low-level"-ish stuff).
Just looked it up, can't say 100% it's still C++, but the syllabus looks about the same as I remember for both class. It gets to pointers by week 7, and then in the second class goes deeper:
* https://web.cs.ucla.edu/classes/spring22/cs31/syllabus.html#...
* https://web.cs.ucla.edu/classes/spring22/cs32/syllabus.html#...
And again, I didn't even get a CS degree. This was all lower-div CS work at a public university, and I'm not even a career engineer.
> So no, not knowing the difference between passing references or values, or pointers and dereferencing them is not as strange as you seem to think it is. It is not a piece of knowledge or experience that is seen as valuable enough by the people that create the curriculum or the companies that employ the largest quantities of inexperienced workers in this part of the world.
This attitude is why you're getting flak in this thread. Your claim that "We don't teach pass by reference these days" was too absolute, and not accurate for a ton of people. Then someone came back and told you that, and you told them that their claim was too absolute.
I'll also say that it's something that was absolutely valued around the orgs I worked in at Microsoft (Azure, DevDiv, Windows, very roughly bottom half of the stack teams). If not C/C++ pointers, than __absolutely__ passing by reference in C#.
Point being: __knowing__ about pointers, passing by ref vs. value, etc. is not as strange as __you__ seem to think it is.
I think an operating systems course, or something approaching it, is a pretty standard piece of good CS curriculums in the US still from talking with other folks I've worked with. And I live/work very far from where I got my degree.
EDIT: in the US, not in the CS, lol
func swap(x *int, y *int) {
var temp int
temp = *x /* save the value at address x */
*x = *y /* put y into x */
*y = temp /* put temp into y */
}The canonical example is a function that swaps the variables passed to a function:
a, b = 10, 20
swap_fn(&a, &b)
a == 20 # true
Since the above are primitive data types (ints), in order to make this work, the language needs to generically support passing the address (reference) of the variables. Java¹/Python² etc. are not able to do this; they copy the value of the variable and send it to the function, which will operate on the copy.¹=at least, last time I've checked, which was long ago :)
²=funny to think that at least in Python, one can mess with the global register of the variables, and actually accomplish that
Python 3.10.8 (main, Oct 13 2022, 09:48:40) [Clang 14.0.0 (clang-1400.0.29.102)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> def f(d):
... d['foo'] = 'bar'
...
>>> a = {}
>>> f(a)
>>> a
{'foo': 'bar'}I've been developing for 25+ years in any language you can imagine, and know how to use pass by ref just fine, and know there are situations where it might be the best solution.
But I can't remember the last time I've used pass by ref. It's really just a coding style quirk for me, I find it "ugly" and it breaks my train of thought when reasoning through the flow of code. I certainly don't begrudge anyone who uses it though.
And OP's anecdote about the interview is certainly disheartening. You'd hope the interviewer would at least be open to the idea of learning something new. I've learned countless things from developers I've interviewed over the years, and I was incredibly happy about it each time.
Edit: In re-reading your comment and below replies it seems you may be misunderstanding what's being discussed. Yes, the things we pass into and out of functions tend to be object references by default. But when we say "pass by ref" (in some languages at least) we mean, essentially, modifying a value in a calling function without actually returning anything from the called function. That's a horrible way to explain it, but the MS documents for the "ref" keyword do a good job of showing examples:
https://learn.microsoft.com/en-us/dotnet/csharp/language-ref...
Like...duh?
I suppose that's why I find Golang less weird to work with than others in my cohort. I spent a semester in the depths of C and OpenGL so I'm intimately familiar with by-value vs by-ref.
One necessary (but insufficient) test you can use to determine if your language has call by reference or call by value is whether you can implement a swap function. In the languages you list, a swap function is not possible to implement, whereas in C++ it is, which tells you that those languages do not implement pass by reference.