TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Understand Go pointers

189 pointsby spaceyabout 8 years ago

9 comments

agentgtabout 8 years ago
I am still not sure why the language creators of Go decided to make pointers explicit (syntactically) instead of making references the default like most other languages. That is you still have pointers but you don&#x27;t have to put &quot;*&quot; all over the place. I suppose it is because the language designers came from C or maybe they wanted to be that explicit?<p>I understand the value of having pointers even in a GC but I&#x27;am actually more concerned with the resource I&#x27;m pointing to and its lifecycle than that is pointers. That is there should be different types of pointers depending on where the data is stored and how it is reclaimed (something Rust does nicely with generics).<p>I&#x27;m not trying to bash Go rather I must be missing something (I don&#x27;t know the language that well).
评论 #14204015 未加载
评论 #14205411 未加载
评论 #14204088 未加载
评论 #14204065 未加载
评论 #14203908 未加载
评论 #14209849 未加载
评论 #14206090 未加载
评论 #14206243 未加载
评论 #14203720 未加载
评论 #14203782 未加载
nottorpabout 8 years ago
I clicked the article thinking that Go pointers are something special... but this seems targeted at the &quot;programmers&quot; who only know javascript...
评论 #14202857 未加载
评论 #14202715 未加载
评论 #14203138 未加载
评论 #14202720 未加载
评论 #14203024 未加载
Aardwolfabout 8 years ago
Looks the same as C pointers. Maybe the title is more clear if it would be: &quot;Understand pointers, using Go&quot;. Then for a C programmer it&#x27;s clear from the title that &quot;pointers&quot; is the same concept, and Go doesn&#x27;t have a different type of &quot;Go pointers&quot;.<p>Or instead of starting with:<p>&quot;This post is for programmers coming to Go who are unfamiliar with the idea of pointers or a pointer type in Go.&quot;<p>It could start with:<p>&quot;This post is for programmers coming to Go from a language without pointers or a pointer type.&quot;
评论 #14203454 未加载
评论 #14204085 未加载
dmixabout 8 years ago
The article referenced &#x27;Cuneiform&#x27; which I had to Google. It&#x27;s neat to see that languages evolved the same way math was developed and similar to how software programs grow as a series of expanding abstraction:<p>&gt; Emerging in Sumer in the late fourth millennium BC (the Uruk IV period), cuneiform writing began as a system of pictograms. In the third millennium, the pictorial representations became simplified and more abstract as the number of characters in use grew smaller (Hittite cuneiform).<p>Software is very much a natural extension of the brain and how we processed the world around us.
评论 #14206716 未加载
pavlovabout 8 years ago
Are there actually programmers who need to be explained the following: &quot;...memory is just a series of numbered cells, and variables are just nicknames for a memory location assigned by the compiler.&quot;<p>What kind of programming can one do without even that level of mental model of what a computer does?
评论 #14202981 未加载
评论 #14202621 未加载
评论 #14202618 未加载
评论 #14202648 未加载
评论 #14202702 未加载
评论 #14203607 未加载
评论 #14202692 未加载
评论 #14204576 未加载
评论 #14202671 未加载
评论 #14204886 未加载
ohstopituabout 8 years ago
Thank you! This is extremely useful!<p>I&#x27;ve always wanted to break into Go, but pointers scare me after my experience in C in University. While I got the usefulness and it&#x27;s functions (and usage), it was not something I felt comfortable with.<p>This definitely it easier!
tapirlabout 8 years ago
The word &quot;Go&quot; is not essential in the title.
评论 #14202828 未加载
评论 #14202892 未加载
评论 #14203518 未加载
lspearsabout 8 years ago
&quot;Understand Go pointers in less than 800 words or your money back&quot;<p>There are multiple pictures each of which is worth 1000 words. Where is my money?
sddfdabout 8 years ago
This is a good explanation of what happens on the machine.<p>However, most languages (C, C++, etc) have different definitions of what pointers are, and many operations that seem reasonable on the machine model are in fact undefined behavior.<p>In C, for example, you cannot reference one object from a pointer to another object (there is one exception to this rule).
评论 #14208953 未加载
评论 #14203159 未加载