44 votes

Is it important to teach pointers in a first course using Java?

Learning about references is important, but I don't feel that learning about pointers is that important for beginning Java students. Certainly intermediate students will need to understand them. When ...
pojo-guy's user avatar
  • 998
31 votes
Accepted

Is it important to teach pointers in a first course using Java?

For a beginning course: no. I have helped clarify behavior for fellow students who got lost by an instructor who explained things in terms of pointers. I have programmed in C, and most of my current ...
CAD97's user avatar
  • 514
16 votes

Is it important to teach pointers in a first course using Java?

No Because of the way that you learn, you think of them as fundamental, to the way references work. They are not. References do not have to work this way. [I would still agree that pointers are ...
ctrl-alt-delor's user avatar
13 votes

Is it important to teach pointers in a first course using Java?

What is important is to teach students the difference between Java objects, and Java variables. There are thousands of questions on Stack Overflow asked by students and by junior developers who do ...
Solomon Slow's user avatar
11 votes

Is it important to teach pointers in a first course using Java?

A related (rhetorical) question: Should C students be taught the [machine language] idea of reusing a pointer as a CPU instruction if the value happens to line up? The speaker in a Functional ...
Wildcard's user avatar
  • 645
9 votes
Accepted

Explaining pointers to highschoolers

A prerequisite to understanding pointers is a basic understanding of memory. At least on the broadest level, students need to know that when they declare a variable in their programs, that variable is ...
Peter's user avatar
  • 9,102
9 votes

Is it important to teach pointers in a first course using Java?

As someone who learned to program with ruby, I think that the concept of how a reference to an object works under the hood is vital. Having the knowledge that "under the hood" my variables may be ...
thesecretmaster's user avatar
  • 4,795
8 votes

Simple Pointer Examples in C

I would teach the use of arrays and array indices first (with pictures of a long row of physical mailboxes, or school lockers, etc.) Then later explain that all of a computer's and/or C program's (...
hotpaw2's user avatar
  • 1,905
8 votes

Is it important to teach pointers in a first course using Java?

No, you don't need to talk about pointers in an introductory Java class. You should talk about references, but even then you should keep it at a very high level. The best tutorial on references I've ...
Kevin Workman's user avatar
8 votes

Why are pointers a key topic in a CS curriculum and oft cited as something people don't get?

This question is actually not so far off from asking why operating system memory management can be confusing to some students. Ultimately, we only have two fundamental tools for managing memory: ...
Ben I.'s user avatar
  • 33.6k
7 votes

Is it important to teach pointers in a first course using Java?

I think you're asking the wrong question. In my opinion the right questions are: Is it important to teach pointers at some point in the curriculum? If so, which courses in the curriculum are most ...
Peter Taylor's user avatar
  • 1,683
6 votes

Is it important to teach pointers in a first course using Java?

Pointers as used in C and C++ are a fairly specific implementation of a general concept. The details of that particular implementation are mostly irrelevant--even to people using C and/or C++, many of ...
Jerry Coffin's user avatar
6 votes

Simple Pointer Examples in C

What you have there is an excellent start, and is completely appropriate. I would go next into a puzzle to try to get them hooked. I would type the following code in front of them on your projector, ...
Ben I.'s user avatar
  • 33.6k
6 votes

Explaining pointers to highschoolers

I set the stage from the beginning. When we first do variables, I draw a big box and call it the computers memory and then draw a small box of memory and say "it's at some address" (having already ...
Mike Zamansky's user avatar
5 votes

Why are pointers a key topic in a CS curriculum and oft cited as something people don't get?

The problem with pointers isn't at the level you have described, but in the use. In languages like Java the "reference" variables are basically pointers but the usage has been made safe via a garbage ...
Buffy's user avatar
  • 36.3k
4 votes

Why are pointers a key topic in a CS curriculum and oft cited as something people don't get?

Answering "Why" people do the things they do is always a risky proposition. Be that as it may, I'll try my hand at answering your two-questions-in-one question. I believe that the answers are ...
Gypsy Spellweaver's user avatar
4 votes

Simple Pointer Examples in C

Yours is a fine first lesson, although it does not show the value of pointers. I would suggest also demonstrating how pointers can be used to implement a swap function. Ask the students (or step them ...
Ellen Spertus's user avatar
4 votes

Simple Pointer Examples in C

Obviously, beginners in C will have to deal with addresses and pointers really soon. First, you owe them an explanation about addresses for ...
Michel Billaud's user avatar
4 votes

Simple Pointer Examples in C

I would use more visual examples that target conceptual knowledge first. I would do a TON of memory diagrams with code tracing. Then, introduce the idea of pointers as memory addresses like you do in ...
nova's user avatar
  • 1,985
4 votes

Is it important to teach pointers in a first course using Java?

Here is what it is important to know early. Primitive type variables store their value directly (I say: "Primitive types point directly at their values.") Object type variables store the location ...
ncmathsadist's user avatar
  • 2,329
4 votes

Is it important to teach pointers in a first course using Java?

Maybe you are thinking about memory management and pointer arithmetics. There is no need for that in the first course. However I think that it is important to teach students that in Java object are ...
CodesInTheDark's user avatar
4 votes

How do I get students to look at course materials, rather than google?

TL;DR Alas, that won't happen. It's very hard for authors to make their information as accessible as Google or ChatGPT results. So, when competing with these resources, you'll always loose in the ...
Ralf Kleberhoff's user avatar
3 votes

Is it important to teach pointers in a first course using Java?

As someone who is self-taught with Python, I'd say it depends on where your students are at. If they're beginning students - no, I don't think you need too. But as your students advance, it becomes a ...
auden's user avatar
  • 4,724
3 votes

Is it important to teach pointers in a first course using Java?

This is a tricky issue and where I think using a bit of formal semantics may help. Of course you don't want to introduce Greek letters and inference rules for undergrads but the concepts should be ...
Kim Nguyễn's user avatar
3 votes

Is it important to teach pointers in a first course using Java?

No. Java and Smalltalk were designed as true object oriented languages. Bjarne Stroustrup who defined and wrote the C++ programming language also had the goal of object orientation but had to carry ...
0tyranny0poverty's user avatar
3 votes

Teach smart pointers to beginners with no knowlege of OOP or templates

I hate giving advice like this, but my honest advice here would be not to do so. Or, at least, don't do it without consulting with your colleagues first. Students (and your fellow teachers in future ...
Ben I.'s user avatar
  • 33.6k
2 votes

Is it important to teach pointers in a first course using Java?

Some people use the term "pointers" to describe Java references. References definitely do need to be described (though they should be called references rather than pointers). Fields, variables, and ...
supercat's user avatar
  • 199
2 votes

Why are pointers a key topic in a CS curriculum and oft cited as something people don't get?

Are pointers hard? Not really. They are just virtual memory addresses. What is hard is memory management. This is illustrated by the fact that browsers, run for a period of time, develop memory ...
ncmathsadist's user avatar
  • 2,329
2 votes

Why are pointers a key topic in a CS curriculum and oft cited as something people don't get?

As many others already wrote before, pointers by themselves are simple objects - in the C sense, not OOP - containing addresses of other objects. If you start with C, you meet them very quickly, ...
Michel Billaud's user avatar
2 votes

Teaching data structures with C++: should I go with smart instead of raw pointers?

In my view, C++ isn't a toy. It is a professional language that should be approached in a professional way. With that in mind, the latest versions are a vast improvement in safety over the earlier ...
Buffy's user avatar
  • 36.3k

Only top scored, non community-wiki answers of a minimum length are eligible