Do you think Golang is a good language to teach a beginner programming ?

xuanbao · · 627 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>The thing is, a friend of mine wants to learn programming and he has asked me for help. </p> <p>There are many places recommending python as a first language. But I feel like golang is a good language to start learning programming. </p> <p>I want to hear your opinion so I know I am not alone (or alone) so that I could make a better judgement on my part. I am really excited my friend wants to learn programming and I want to teach him something he can be excited about. I really love golang and I have never felt happier programming in any other language there so many things I love about the community and the ecosystem around it. </p> <p>I just want to make sure I am not putting my friend at a disadvantage or I dont make him think programming is boring or something. </p> <hr/>**评论:**<br/><br/>MadPhoenix: <pre><p>IMO, it&#39;s easiest to learn programming when you have a project or use in mind. It may become clearer which language is appropriate based on that. Another thing to consider is picking a project (or three) and implementing them in both languages. Neither is hard to get started on.</p></pre>hukiki: <pre><p>Great point. Rather than trying to show him around the language use only, this really makes so more easier. Thanks. Now to think of something interesting to do haha </p></pre>dhdfdh: <pre><p>You can&#39;t start a project until you know which language you&#39;re going to use. Starting a project in more than one language will only cause confusion. </p></pre>MadPhoenix: <pre><blockquote> <p>You can&#39;t start a project until you know which language you&#39;re going to use.</p> </blockquote> <p>Truly, but that&#39;s not what I was suggesting. I was suggesting that OP&#39;s friend should focus first on what they&#39;re interesting in making, not which language is &#34;best to learn.&#34;</p> <blockquote> <p>Starting a project in more than one language will only cause confusion.</p> </blockquote> <p>I clearly am not suggesting they develop two programs in different languages in parallel to start. I&#39;m talking about implementing a program in Python and <em>then</em> in Golang, which is a very useful exercise.</p></pre>forgotmyusername3xx: <pre><p>You said this</p> <blockquote> <p>consider is picking a project (or three) and implementing them in both languages.</p> </blockquote> <p>That is what I&#39;m objecting to.</p></pre>abcded1234234: <pre><p>There was a discussion about teaching Go to young children: <a href="https://groups.google.com/forum/#!searchin/golang-nuts/learning/golang-nuts/FIRSDBehb3g/BFiHYVNCwzUJ">https://groups.google.com/forum/#!searchin/golang-nuts/learning/golang-nuts/FIRSDBehb3g/BFiHYVNCwzUJ</a>. A quote for the thread: &#34;And what I found was: Go is not only a good teaching language, it&#39;s an excellent one for first time programmers, including children.&#34;</p></pre>dhdfdh: <pre><p>Including young children with no interest in programming?</p></pre>Fwippy: <pre><p>Teaching someone who doesn&#39;t want to be taught is a difficult challenge, and the language you choose to teach them will only have a small influence over that. Regardless, the OP asked about teaching a friend of his who wanted to learn programming, so the question&#39;s entirely irrelevant.</p></pre>earthboundkid: <pre><p>I think it&#39;s a great second language. Pointers and static types are probably too much for first language though. </p></pre>hijinks: <pre><p>That&#39;s funny because when I went through college the first language we learned was C.</p> <p>I think it depends on the age. If they are 12 Python might be a good choice. I think go is a great choice if they are older</p></pre>boomshroom: <pre><p>I&#39;m currently in university and the first language we were taught was c if you&#39;re an engineer, otherwise you learn Java.</p></pre>dhdfdh: <pre><p>12-year olds should never be taught programming unless they want to learn.</p></pre>dilap: <pre><p>I think static types very likely clarify things for a beginner. Pointers are tricky for some, but not all, and I think the Go version is probably a bit easier than the C version, just because the syntax is more consistent.</p></pre>dhdfdh: <pre><p>When someone tells me they don&#39;t want to know about pointers, or struggle with the concept, it tells me they don&#39;t want to know how computers work. If they get into this business, they will never be good programmers and will, eventually, struggle or drop out.</p></pre>earthboundkid: <pre><p>Long term, you need to understand memory, pointers, stack v. heap, etc., but maybe not in your first language. </p></pre>marcm28: <pre><p>Go is good language to teach a beginner but Python is much more suitable to teach a beginner.</p></pre>kingmanaz: <pre><p>Along with python, scheme is also a good first language for the beginner, particularly for one learning theory. The book &#34;The Little Schemer&#34; is approachable and focuses on recursion and the functional programming style. From there, &#34;The Seasoned Schemer&#34;, then, if interested in segueing into common lisp, Graham&#39;s &#34;ANSI Common Lisp&#34; and &#34;On Lisp&#34;, and the underrated &#34;Let Over Lambda&#34;, or, &#34;Structure and Interpretation of Computer Programs&#34; if one wishes to continue on with scheme.</p></pre>seufert: <pre><p>Well, it depends.</p> <p>In most cases i would favor Python: - The dynamic typing makes it much easier to get started - The REPL makes it awesome to write line by line, to inspect and explore - The tooling for learning and application in many science areas is awesome. You can easily use it Math, Physics, Text Processing, for exploring public data sources. - Go IS a systems language. It&#39;s designed to be that. You have to be aware of memory, how pointers work. I found it hard to get for beginners to get how slices work.</p> <p>So in general no. But if the person for example has in mind to develop REST APIs, to learn networking/HTTP then Go might be a great fit.</p></pre>Christosgnosis: <pre><p>I&#39;ve always ended up finding the REPL feature to be much over rated. To me, fast compile/link (which Go has in spades) and good old print statements to see output do quite well.</p> <p>A REPL requires too much awkward context to establish to really be of much use for anything</p></pre>dbrecht: <pre><p>No it&#39;s not.</p> <p>The language spec is concise and should always remain that way, which is definitely one reason why it might be good.</p> <p>The downside, however, are:</p> <ul> <li>You /need/ to understand OO well. The tradeoffs between coding to an interface rather than an implementation</li> <li>You can&#39;t really demonstrate or learn functional programming to anyone with go. To do that, they&#39;d have to learn an entirely different language.</li> <li>Inheritance in go is quite different that most other common languages. IMO, a first language learned will be at least relatively familiar to other popular languages in order to help lower the barrier of entry. Go doesn&#39;t really give you that.</li> <li>It&#39;s far too easy to get into parallelism with go without really understanding what you&#39;re doing, which can lead to many a headache.</li> <li>Testing with mocks and such is easier in python instead of having to worry about DI</li> <li>Python (again IMO) is quite a bit easier to just hack on than go</li> </ul> <p>Then there&#39;s gdb. When teaching someone python (although I&#39;ve never taught someone from the ground up), one of the things I harp on is how tremendously useful a debugger is when wrapping your head around how systems work. gdb is not exactly the most simple or straightforward to debug with. True, pdb has a similar interface, but IMO is simpler and easier to grok.</p></pre>stone_henge: <pre><blockquote> <ul> <li>You /need/ to understand OO well. The tradeoffs between coding to an interface rather than an implementation</li> </ul> </blockquote> <p>You only need to understand OO to the extent that it is actually used in Go, and methods as functions belonging to structs and interfaces aren&#39;t exactly rocket science compared to popular teaching languages like Java.</p> <blockquote> <ul> <li>You can&#39;t really demonstrate or learn functional programming to anyone with go. To do that, they&#39;d have to learn an entirely different language.</li> </ul> </blockquote> <p>You can&#39;t really learn declarative programming with Python. Obviously every language will have some shortcomings with their scopes in this regard</p> <blockquote> <ul> <li>Inheritance in go is quite different that most other common languages. IMO, a first language learned will be at least relatively familiar to other popular languages in order to help lower the barrier of entry. Go doesn&#39;t really give you that.</li> </ul> </blockquote> <p>I guess it depends on what your goals are. If someone learns Go I&#39;d guess that they would probably have less of a hard time unlearning its simple data structure concepts and get into Java than having to unlearn the Java OO model and going to Go.</p> <blockquote> <ul> <li>It&#39;s far too easy to get into parallelism with go without really understanding what you&#39;re doing, which can lead to many a headache.</li> </ul> </blockquote> <p>I think that it is good for a teaching language to lower the barrier to that which you don&#39;t understand.</p> <blockquote> <ul> <li>Testing with mocks and such is easier in python instead of having to worry about DI</li> </ul> </blockquote> <p>And then your mocks fall out of phase with your actual code because you haven&#39;t formalized their interfaces and all the tests pass while the program breaks, or someone decides to pass your functions a type that isn&#39;t covered by the tests... I seriously think that there are many benefits to using Python over Go as a teaching language, but in my experience testing Python isn&#39;t easier than testing Go. You have a whole class of problems you need to take into account when testing that don&#39;t even exist in statically typed languages.</p></pre>dbrecht: <pre><p>All great points (especially re mocks, in hindsight probably not a strength for a teaching platform), cheers!</p> <blockquote> <p>You can&#39;t really learn declarative programming with Python. Obviously every language will have some shortcomings with their scopes in this regard</p> </blockquote> <p>Indeed. But go has an intentionally narrow focus, whereas a multi-paradigm language at least lets you play with more than one.</p> <blockquote> <p>I think that it is good for a teaching language to lower the barrier to that which you don&#39;t understand.</p> </blockquote> <p>I&#39;m not entirely sold on that (but I also understand that this entire question is wonderfully subjective ;)). I could just see someone using it because they&#39;ve seen it elsewhere in example code without understanding what it&#39;s doing. Goroutine prefixes aren&#39;t exactly the most obvious things. But then maybe you&#39;re right. Not being a teacher, I haven&#39;t exactly taken a look at any metrics to help me understand how people learn most effectively. My response is entirely gut reaction from someone who&#39;s spent a number of years in the trenches, so maybe I&#39;m looking at certain aspects with cracked glasses ;)</p></pre>hukiki: <pre><p>I am sorry people are down voting you. Thanks very much for this answer. </p> <p>I think I need to rethink about python a little bit more. Your point about parallelism sounds really convincing, it was one thing I was struggling with in the beginning. And for someone who doesn&#39;t know programming, this might actually be a hindrance.</p> <p>Aww man, this is hard :&#39;( </p></pre>dbrecht: <pre><p>Meh, it is what it is. Create a reply on a thread specific to go talking about anything negative and I can be pretty damn sure I&#39;ll be downvoted ;)</p> <p>Choosing a language to teach someone with definitely /is/ a tough thing. GL :)</p></pre>jussij: <pre><blockquote> <p>Then there&#39;s gdb. </p> </blockquote> <p>Delve seems to be working hard at fixing this and the latest release even has support for Windows :)</p> <p>I&#39;ve been playing with it on Windows and it works well. They seemed to have fixed many of the gdb/Go issues.</p> <p><strong>EDIT:</strong> As to the usability issue, many IDE/editors hide the debugger behind their own GUI so the complexity is reduced.</p></pre>: <pre><p>[deleted]</p></pre>gbitten: <pre><blockquote> <p>see there&#39;s a number of go fanboys downvoting with no argument.</p> </blockquote> <p>I downvoted you because some wrong statements like the below quotes.</p> <blockquote> <p>Inheritance in go is quite different that most other common languages.</p> </blockquote> <p>There is no class inheritance in Go, and object composition is not a &#34;quite different type of inheritance&#34; as you states.</p> <blockquote> <p>You /need/ to understand OO well</p> </blockquote> <p>No, you don&#39;t. Go allows to create any program without create any object.</p> <blockquote> <p>It&#39;s far too easy to get into parallelism with go without really understanding what you&#39;re doing, which can lead to many a headache.</p> </blockquote> <p>That happens with any language with multiprocessing features, including Python.</p></pre>jjolla888: <pre><blockquote> <p>It&#39;s far too easy to get into parallelism with go without really understanding what you&#39;re doing, which can lead to many a headache. That happens with any language with multiprocessing features, including Python.</p> </blockquote> <p>Yes, but Go makes it easy to get yourself setup to do parallelism. It&#39;s like not having to cut thru thick forest to get to the point where you have to then navigate a field of land mines. Most languages will stop you in the forest before you get to blow yourself up.</p></pre>dbrecht: <pre><p>FWIW, have an upvote. I always enjoy an intelligent debate :)</p></pre>dbrecht: <pre><blockquote> <p>I downvoted you because some wrong statements like the below quotes.</p> </blockquote> <p>And you have a couple valid points :)</p> <blockquote> <p>There is no class inheritance in Go, and object composition is not a &#34;quite different type of inheritance&#34; as you states.</p> </blockquote> <p>Right. I chose poor wording to get my thoughts across. Many languages offer both inheritance as well as composition. Go only offering composition is quite different. I&#39;m not saying I don&#39;t understand the reasoning behind it, I&#39;m just stating that it&#39;s quite different.</p> <blockquote> <p>No, you don&#39;t. Go allows to create any program without create any object.</p> </blockquote> <p>And how many projects of any consequence are you aware of that do not use any objects at all (I&#39;m genuinely interested in seeing some)? IMO having a sound understanding of at least interface abstractions of concrete implementations is vital (as well as understanding the oddity of interface{}.</p> <blockquote> <p>That happens with any language with multiprocessing features, including Python.</p> </blockquote> <p>I might be missing something about some languages, but it&#39;s /much/ less obvious in go than in other languages. For example, with python I&#39;d have to import the multiprocessing package and then explicitly kick off a child process. In other words, I&#39;d need to actually think about what I&#39;m doing and do it on purpose. Not so much with go.</p></pre>headzoo: <pre><p>I can&#39;t agree with many of the things you said. A beginner doesn&#39;t need to understand interfaces, and Go doesn&#39;t force you to use them. OP&#39;s friend doesn&#39;t need to learn parallelism or inheritance. Testing with Go is as simple as it gets (to the point of being overly simplistic), and it&#39;s easy to understand what the tests are doing. Why would a beginner even think about mocks or DI?</p> <p>Your points are only relevant to an intermediate programmer, and by the time OP&#39;s friend will be ready to learn the more advanced topics when they reach that level. You&#39;re probably being downvoted because your answer isn&#39;t particularly relevant to OP&#39;s question.</p></pre>stone_henge: <pre><blockquote> <p>A beginner doesn&#39;t need to understand interfaces, and Go doesn&#39;t force you to use them.</p> </blockquote> <p>Maybe if you don&#39;t intend to use the standard library. That said, I don&#39;t think it&#39;s exactly a hard concept to grasp, especially compared inheritance based OO. In general I don&#39;t think you have to be as tall to ride Go as you would Java.</p></pre>qu33ksilver: <pre><p>If you are not using interfaces or parallelism, then for a beginner, the Python syntax is much more easy to understand while learning to code for the first time. And also with a lot of higher order functions and simple data structures, its easy to get ramped up on Python. </p> <p>I think Go should come at a later stage when a person wants to learn the finer points in coding.</p></pre>zoweee: <pre><p>Dunno if this is helpful, but I came to programming relatively late in my career (or at least to programming in a structured, deliberate manner). I was a sysadmin and perl/bash/tcl was where most of my work was done, all very forgiving things to work in. Anyhow, the various traps and gotchas are still somewhat fresh in my mind.</p> <p>For me, python was a godsend. I appreciated (and still appreciate) how opinionated it is. Perl&#39;s forgiving nature is fantastic when you have to get something done <em>right now</em> but it&#39;s a disaster over the long haul, because it doesn&#39;t instill discipline. Python, I think, brings that to the table.</p> <p>As to Go, it&#39;s great and has become my language of choice, but I agree with <a href="/u/dbrecht" rel="nofollow">/u/dbrecht</a> that with Go the wrong things are easy (parallelism) and the wrong things are hard (testing, types, package management).</p> <p>Finally and, IMHO, most importantly: Go lacks a real REPL and, sorry, none of the existing options count. The ability to just type an expression and watch it evaluate in realtime is absolutely indispensable when you&#39;re trying to feel your way around unfamiliar concepts. </p></pre>nicerobot: <pre><p>Yes, it absolutely is. Avoid Python, and any dynamic language, as a first language.</p> <p>Go is a fantastic first language because of its simplicity and static typing. They don&#39;t have to focus on learning the language. They can focus on learning programming techniques. Go structs are a great way to learn about data structures. The syntax is simple, concise, and mostly obvious making it great for comprehension.</p> <p>With all due respect to @dbrecht, you don&#39;t have to learn OO nor touch goroutines and channels to learn to program using Go. Simply list the order in which they should learn, specifically, delay channels, goroutines, and interfaces, until they thoroughly have all the basics of variables, data structures, conditionals, flow control, and functions.</p> <p><a href="https://tour.golang.org/list">https://tour.golang.org/list</a></p> <p>That said, learning to program should not be tied to learning a programming language. The abstractions required for designing a program should not be tied to a specific language, at least, not for beginners. Beginners should learn how to think about solving problems algorithmically and learn different concepts and techniques to accomplish that. Most of that knowledge can then be applied to a wide range of languages for implementation.</p></pre>dbrecht: <pre><p>No, by all means I don&#39;t think that you /need/ to learn them immediately.</p> <p>My biggest gripe really is the lack of hackability with go. Having utilities like a REPL is really nice to have when learning programming, whether specific language features or fundamental system calls or algorithms.</p> <p>Next is the lack of any functional aspect to the language (personally, I wish I&#39;d leaned more about functional programming much earlier on). Having a single vehicle that you can use to teach abstract concepts in a practical manner helps those concepts stick (IMHO).</p> <p>That said, I do wholeheartedly agree with your last paragraph :)</p></pre>MoneyWorthington: <pre><p>Having a REPL is nice, and certainly a huge edge that languages like Python and Ruby have over Go, C, Java, etc., but very few mainstream programming languages have a strong functional aspect, so I think it&#39;s a little unfair to call out Go for it. I also did find a Go REPL called <a href="https://github.com/motemen/gore" rel="nofollow">gore</a> after a quick search, but don&#39;t have enough experience with it to say how well it works.</p> <p>I think Go would be a great first programming language, but to me the biggest issue would be its strictness regarding imports and unused variables. If first-year students think compilers are picky about semicolons, then they&#39;ll get really annoyed with Go&#39;s compiler.</p></pre>namesandfaces: <pre><p>If you&#39;re thinking about what kind of programming language can lead to something visible, I don&#39;t think that would be Go. It would be whatever lets you write apps with user interfaces on the browser, Windows, the Apple ecosystem, or Android.</p> <p>Of these, my biased intuition tells me that browser apps are the easiest to get up-and-running, despite the fact that the javascript world is tumultuous at the moment.</p></pre>WellAdjustedOutlaw: <pre><p>It&#39;s just as easy as starting with Python, ruby, Java, or c. Which is what most university students have or do start with.</p></pre>Athaba: <pre><p>It is pretty small in what functionality, keywords, etc. there are and very easy to read. Both of them enable people to learn quickly by reading existing code. The go tools make it extremely easy to not having to care too much about the surrounding topics. Also Go comes with a great stdlib which means someone new to programming doesn&#39;t need to first learn about various libraries out there to do something real.</p> <p>I think all those properties make Go an incredibly good first language.</p> <p>The only &#34;downside&#34; - depending on whom you ask - is that there is static typing. But compared to other static languages it is really an excellent first language.</p></pre>bytebreaker: <pre><p>Yes</p></pre>sw0r6f1sh: <pre><p>It&#39;s great to get things started because of the standard library. the language itself isn&#39;t that great.</p></pre>postman_: <pre><p>No.</p></pre>

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

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