I would bet the challenge of a Java programmer learning C/C++ pointers is
more about semantics. Java doesn't have an analogy to pointers on purpose.
Python hides the fact that pretty much everything is a pointer. C++ can be
extra confusing because & references are sort-of like pointers but
syntactically look like references.

The most important thing to remember about C/C++ is that the language
specifically does exactly what you tell it to do, regardless of your
intention. Languages like Java and Python and especially Perl try to "do
what you mean" and not necessarily "do what I say".

So in C you can do really stupid things like this:

   int * i = 0;
   i = 5;

Which happens to write a 5 to NULL. But you can also do things like this:

  int * i = malloc(sizeof(int) * 10);
  for (int j = 0; j < 10, *i=j; j++, i++)

Which happens to be a really unmaintable way to make an array of 10 numbers,
0-9. But there are times when that's really handy. And double-dereferencing
is a breeze, so sparse arrays can be efficient (e.g., dealing really big
numerical solutions with millions of variables - like a lot of raster
analysis).

I learned C after writing Intel 8051 assembly. Pointers are very natural
when you are actually moving things in and out of memory. With Python, I
find myself "playing" with syntax until it does what I want. For instance,
what really does this mean:

   myArray = []

And my biggest gripe about Python is that you aren't even allowed to declare
your variables if you wanted to. I've spent many hours chasing typos in
Python code.

For psuedo-code, however, you just want to avoid language-specific
constructs- like pointers in C unless you are writing psuedo-code for
low-level stuff - or the myArray = [] thingy in Python.

-Eric

On Jan 21, 2008 5:39 PM, Landon Blake <[EMAIL PROTECTED]> wrote:

>  Anslem wrote: Granted one can understand indirection simply by using
> array indexes...  but somehow understanding memory seems to be slightly
> different from simply understanding indirection.
>
>
>
> One of the hardest things for me to understand about C/C++ as a Java
> developer was pointers. I spent three days reading every article about
> pointers that I could get my hands on.
>
>
>
> Learning about computer memory management, including pointers, did help me
> tackle a problem OpenJUMP had in running out of RAM with large datasets. If
> you don't know the basics about memory management you could easily write
> programs that greedily devour RAM. I would think this would be especially
> easy when working with geospatial datasets, which tend to be very large.
>
>
>
> Landon
>  ------------------------------
>
> *From:* [EMAIL PROTECTED] [mailto:
> [EMAIL PROTECTED] *On Behalf Of *Anselm Hook
> *Sent:* Monday, January 21, 2008 4:35 PM
> *To:* [email protected]
> *Subject:* Re: [Geowanking] RE: Geowanking Digest, Vol 50, Issue 33
>
>
>
> Straying away from geo completely.... I will say that I've taught a few
> people how to program using Ruby and it was instructive to see that they
> didn't really 'get it' ; have a deep sense of what was going on - until they
> learned C and pointers...
>
> The abstraction away from the underlying hardware architecture seems to
> hinder understanding...  It is hard to say if that is good or bad...
>
> There was a hilarious thread here that somebody pointed out a while back,
>
>   http://news.ycombinator.com/item?id=87348
>
> (It seems like having an intuition about indirection is so simple, trivial
> and obvious that it is hard to imagine that somebody wouldn't understand it,
> and the resultant choices and limits that reality imposes.)
>
> ( Granted one can understand indirection simply by using array indexes...
> but somehow understanding memory seems to be slightly different from simply
> understanding indirection.  )
>
> There was one slightly geo related issue in language choices - to find an
> excuse to draw geo back into this:
>
> I was monkeying around with building a cellular automata simulation (of
> rainfall) and I found java to be horrifically wasteful - hard to conserve
> against cache misses.  You can't express a series of "structs" like in C or
> C++ or C# .  If you wanted to build a sparse matrix implementation, like
> lapac uses etc - you have to do it in C as an external library.
>
> Since I had a mental model of how I wanted the cpu and the bus to stride
> across memory, minimizing de-references and maximizing cache coherence, I
> knew that Java was inexpressive...  This actually made it hard for me to
> write the code - knowing how bad it was underneath slowed 'just getting it
> done'.
>
> It was an instructive example of where knowing too much was not helpful,
> and where the gap between the high level languages and say C exist...   ( As
> well, there's a possibility that the optimizers might surmount these issues;
> so in fact the presumed mental model I had might in fact be wrong... )
>
> On a vaguely related note - this language is accessible to small children
> - if you want to inflict knowing how to program on them:
>
>   http://www.playfulinvention.com/rcx/software/index.html
>
> If there's a broader relevance, it is perhaps that most people will
> eventually probably be expected to have a basic literacy in programming ...
> seems like the new lingua franca ... and perhaps a best way to straddle
> cultural divides - more so than say all learning esperanto...
>
> - a
>
>  On Jan 21, 2008 4:05 PM, Landon Blake <[EMAIL PROTECTED]> wrote:
>
> I've got a lot of respect for the guys that code in languages like C and
> C++. Using one of those languages is right up there with brain surgery.
> (To think programmers used to be responsible for memory management all
> on their own. Where is my garbage collection!)
>
> I think I could learn and use C if I needed to, although I'm always
> tempted to implement a system for managing "objects" whenever I use C
> code.
>
> I avoid C++ like the plague. :] It's a darn shame too, because Inkscape,
> one of my favorite FOSS programs, is written in C++. I bought a 900 page
> book on C++, and I've even read it a few times, but I never successfully
> used the language. It did teach me a lot about how object-oriented
> programming languages run under the hood. I never understood basic
> memory management in computer programs until I read it in a C++ book.
> That is a gem I'll treasure for a long time.
>
> I guess I'm just addicted to the syntax sugar in languages like Java,
> Python, and even Ruby. (I couldn't believe how easy it was to open a
> text file in Ruby.)
>
> Landon
>
>
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] ] On Behalf Of Brandon
> Whitehead
> Sent: Monday, January 21, 2008 4:00 PM
> To: [email protected]
> Subject: [Geowanking] RE: Geowanking Digest, Vol 50, Issue 33
>
> >I'm in my late twenties, and my languages of choice are Java and
> Python.
> >(I dabble in Ruby for customization of Google SketchUp.)
>
> >I'm guessing the old farts are using C, C++ or maybe Perl?
>
> >I wonder what younger people are using?
>
> I'm in your boat.  Late 20's - Python & Java.
>
> -Brandon
> _______________________________________________
> Geowanking mailing list
> [email protected]
> http://lists.burri.to/mailman/listinfo/geowanking
>
>   Warning:
> Information provided via electronic media is not guaranteed against
> defects including translation and transmission errors. If the reader is not
> the intended recipient, you are hereby notified that any dissemination,
> distribution or copying of this communication is strictly prohibited. If you
> have received this information in error, please notify the sender
> immediately.
>
> _______________________________________________
> Geowanking mailing list
> [email protected]
> http://lists.burri.to/mailman/listinfo/geowanking
>
>
>
> _______________________________________________
> Geowanking mailing list
> [email protected]
> http://lists.burri.to/mailman/listinfo/geowanking
>



-- 
-=--=---=----=----=---=--=-=--=---=----=---=--=-=-
Eric B. Wolf                          720-209-6818
PhD Student          CU-Boulder - Geography
_______________________________________________
Geowanking mailing list
[email protected]
http://lists.burri.to/mailman/listinfo/geowanking

Reply via email to