DEV Community

Ben Halpern
Ben Halpern Subscriber

Posted on

Do they teach "pointers" in bootcamp? Should they?

The pointer is not a thing that every developer needs to know, but it's still a thing that exists. This question is kind of a stand in for concepts like pointers and not just that one thing.

I wonder: Do they teach this concept in bootcamp at all?

Should they teach stuff like pointers at all to a group learning, say, web development in JavaScript? If so, does it come early or late?

I imagine the course doesn't need to cover computer science from the ground up, but what should get detailed and when?

In computer science, a pointer is an object in many programming languages that stores a memory address. This can be that of another value located in computer memory, or in some cases, that of memory-mapped computer hardware. A pointer references a location in memory, and obtaining the value stored at that location is known as dereferencing the pointer. As an analogy, a page number in a book's index could be considered a pointer to the corresponding page; dereferencing such a pointer would be done by flipping to the page with the given page number and reading the text found on that page. The actual format and content of a pointer variable is dependent on the underlying computer architecture.

Top comments (34)

Collapse
 
tiguchi profile image
Thomas Werner

Joel Spolsky has a pretty radical point of view (not sure if I really share it, but it's interesting): The Guerilla Guide to Interviewing

Asking questions about pointers and recursion is apparently part of his interviewing routine, and one of the deciding factors for hiring someone

I’ve come to realize that understanding pointers in C is not a skill, it’s an aptitude. [...] Pointers require a complex form of doubly-indirected thinking that some people just can’t do, and it’s pretty crucial to good programming.

Now the question is, whether it's only crucial to good programming in C or higher level languages that abstract memory management away, but Joel seems to be saying: a good programmer understands pointers (and recursion). Bad programmers don't.

Interesting point of view, but not sure what to think about that 🀷

Collapse
 
waynejwerner profile image
Wayne Werner

I'm not terribly convinced that this isn't a skill. It might be a skill that's difficult to acquire, and perhaps a skill that's difficult to retain or even be really good at. And maybe some people are just better at thinking about really weird problems.

But pointers aren't a hard concept, and probably everyone has used a pointer at one point in their life, without realizing that's what they were doing.

a href? Pointer
Library card catalog? Pointer
Yellow Pages? Pointer
Address book? Pointer
Table of contents? Pointer
Index? Pointer

The problem is that most people who understand pointers don't do a good job of teaching what pointers are.

Collapse
 
miguelmj profile image
MiguelMJ • Edited

I agree with you. In my opinion, pointers scare starters because of their bad reputation. In reality, the scary thing of pointers is that the errors they produce are difficult to track and debug, so you need some solid good practices.

But conceptually, they are not more difficult to understand than other data types out there.

Collapse
 
yechielk profile image
Yechiel Kalmenson

When I was in bootcamp, we didn't learn about pointers per se, because the languages we learned (Ruby and JavaScript) didn't have pointers, but I do remember learning about the difference between passing by reference and passing by value, so when I learned Go and it came to pointers, the concepts were familiar to me.

Collapse
 
waynejwerner profile image
Wayne Werner

In every high level language you're going to have the idea of references, like in JS if you do

thing = {"foo": "bar"};
a = thing;
b = thing;
a.foo = 42;
console.log(b.foo);
Enter fullscreen mode Exit fullscreen mode

If you understand that you'll see 42, then you understand pointers.

Collapse
 
liaowow profile image
Annie Liao

This code snippet reminded me of a mental model I acquired from Dan Abramov via his Just JavaScript newsletter, where we learned to literally "draw" pointers to understand the concept of references in JS.

Collapse
 
defman profile image
Sergey Kislyakov • Edited

I think pointers are pretty fundamental in programming, so understanding them might be a good idea even if you don't use them NOW (and it's a pretty basic concept tbh). You can't be sure you'd be writing JS (or any other language without pointers being present to the programmer) for life. I thought that I won't face them, but then I've started programming in Golang and here we go.

I'd suggest to learn as much as you can because every day it gets harder for your brain to learn, memorize and understand information.

Collapse
 
kallmanation profile image
Nathan Kallman

Pointers in the sense of managing memory locations are probably not critical unless the language you use presents that interface.

But "pointers" in the more general sense of having a piece of data that refers to the "real" data in another location is fundamental and appears all over. (Think foreign keys in databases, URLs, file systems, compression formats, etc.).

You really can't do anything interesting on a computer without this idea.

I'll also throw in the concept of a pointer to a pointer. Which at first seems like a silly extension; but on second look can actually allow surprising simplifications of problems.

Collapse
 
dwd profile image
Dave Cridland

"All problems in computer science can be solved by another level of indirection" - David Wheeler.

Collapse
 
zenulabidin profile image
Ali Sherief

No, people should not have to learn pointers if they are studying a high-level language because that is an internal feature in those languages - kind of how you have a transmission in a car but you don't need to know about it to drive.

Collapse
 
valterm profile image
Martin Valter

Yes and no. Using your car analogy, the developer would be a mechanic working in the engine bay. They might be able to get by working only on parts not directly related to the transmission, might even be great at it, but would you not prefer a mechanic that understands all of the engine mechanics?

Similarly, abstract memory management might be obfuscated away in high-level languages, but it still happens. Understanding the mechanics of it will improve the efficiency of your code. Most high-level languages don't require you to manage the memory yourself, but that doesn't meant you don't need to keep memory usage in mind.

Collapse
 
markerikson profile image
Mark Erikson

My first programming course was an Engineering-track "Intro to C++" class, back in 2000, as part of a CS major.

If I remember right, we didn't even touch pointers in that class - they were covered in the second course, "Object-Oriented Programming with C++".

I think pointers are a valuable concept to understand for anyone doing programming.

At the same time, I wouldn't teach C++ as a first language to anyone getting started today - I'd go with JS or Python. Along with that, no, I'd never try to throw a beginning programmer straight into pointers.

I do see some value in trying to cover something sorta-kinda like this somewhere in the process. After all, "references" in JS, Java, Python, and C# are just pointers that have been hidden a bit so you can't modify them yourself, and it's certainly important to know that this code:

let a = [];
let b = ;
Enter fullscreen mode Exit fullscreen mode

just creates two variables pointing at the same array in memory.

Mmm... I'm actually kinda talking myself back and forth on this one a bit here as I write :)

Eh... if we're going to stretch the definition of "pointer" to "references in GC-based languages", then yes, I can see the importance of covering that at some point in the semi-early-ish learning process.

Collapse
 
kspeakman profile image
Kasey Speakman • Edited

I think what people are trying to imply when they value pointer experience is knowledge of how the code controls the hardware memory. You do not have to use pointers to understand this, although the minutia of dealing with pointers does provide you with significant hints.

But the short-term benefit of being instructive does not outweigh the long-term maintenance hassle of being fiddly and error prone. Even garbage collection can teach you the memory model eventually, because you have to dig deeper when you run into its limitations.

Collapse
 
sarahcodes_dev profile image
Sarah πŸ¦„

Pointers, I would think no as you don’t really have to worry about those in higher level languages, however there are foundational programming paradigms that I think should be taught like separation of concerns, dependency injection etc, essentially how to write clean code.

Collapse
 
gypsydave5 profile image
David Wickes

No they don't (personal experience). Yes they should - incredibly useful concept. I'm of the opinion that a good code bootcamp should pivot to teaching Go; a simple language, but one that is explicit about the use of pointers/references.

Collapse
 
linaran profile image
Deni • Edited

Even in C++ people probably won't juggle complicated pointers. But they might cause a memory leak in Java. They should understand why and how.

If not the above, they should understand linked lists and I'm not sure how to explain that without talking about references which are basically pointers that are automatically dereferenced when being accessed.