Go101

polaris · · 1388 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>So I am quite interested in Go but can someone explain what it&#39;s actually used for? Strengths and weaknesses? And what&#39;s the deal with interfaces and does it support OOP? As for me I have an understanding of Java, Python and very basic PHP. I&#39;m interested in compiled languages and Go seems like an easier fit to start than C or C++.</p> <hr/>**评论:**<br/><br/>drvd: <pre><p>Take the Tour of Go <a href="http://tour.golang.org/">http://tour.golang.org/</a> and read the official FAQ <a href="https://golang.org/doc/faq">https://golang.org/doc/faq</a></p></pre>postman_: <pre><blockquote> <p>what it&#39;s actually used for?</p> </blockquote> <p>Its main area of usage is web services.</p> <blockquote> <p>Strengths and weaknesses?</p> </blockquote> <p>Strengths: compilation to native code, static type checks, N:M coroutine scheduler built into runtime with rich abstractions, such as goroutines and channels, garbage collection, mature standard library.</p> <p>Weaknesses: dumb type system, tedious error checking, no standard on dependency management.</p> <blockquote> <p>And what&#39;s the deal with interfaces and does it support OOP?</p> </blockquote> <p>Interfaces are a form of polymorphism chosen by Go. Whether it supports OOP depends on your definition of OOP.</p> <blockquote> <p>I&#39;m interested in compiled languages and Go seems like an easier fit to start than C or C++.</p> </blockquote> <p>It&#39;s certainly easier but I&#39;d urge you to learn C later anyway.</p></pre>flippynipz: <pre><p>Exemplary answer point by point thanks! But for OOP i mean structured like Java or even Python. Define class, set variables, constructors,define methods etc.</p></pre>YEPHENAS: <pre><p>You can define data structures with fields and you can define methods on these data structures. There are no constructors, but you can write functions that create and initialize instances of data structures, but you often don&#39;t need them. There&#39;s no inheritance, but you can embed other data structures into a data structure and have their methods promoted to the level of the outer structure. Interfaces provide polymorphism. They are satisfied implicitly: If a type has all the methods of an interface then the interface is considered implemented by the type. You do not have to declare explicitly &#34;X implements Y&#34;.</p></pre>flippynipz: <pre><p>Ahh alright. Thanks for the amazing answers.</p></pre>-Nii-: <pre><blockquote> <p>methods promoted to the outer level </p> </blockquote> <p>This is new to me. What is this called, so that I may read further information on it?</p></pre>theag3nt: <pre><p>Unfortunately I don&#39;t know if there is a separate name for the promotion of methods, but you can find out more about anonymous/embedded fields in the language specification:<br/> <a href="https://golang.org/ref/spec#Struct_types" rel="nofollow">https://golang.org/ref/spec#Struct_types</a></p></pre>srbufi: <pre><blockquote> <p>dumb type system</p> </blockquote> <p>Could you explain further, please?</p></pre>postman_: <pre><p>The most frequent complaint is the absense of generics. There are others, less frequent, such as questionable nature of multiple returns and nonvariance of the array type constructor.</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

1388 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传