I'm aware that Go is not C, and memory management was not one of the points I 
mentioned. Memory management is a thing that trips up even extremely skilled 
developers. But I've been programming in C since 1997 and Python since 2010, 
and I've been working in Go long enough (and teaching new programmers) that I'm 
still pretty confident in my assessment, especially after having run dozens of 
labs with hundreds of students at varying skill levels.

New programmers often have a lot of trouble being bombarded with lots of new 
things off the bat. We tend to think of "Hello, world!" as pretty easy, but in 
C, there are a number of "magic" things in even that which have to be in place 
to even work which don't get explained until much later:

#include <stdio.h>

int main(void) {
        printf("Hello, world!\n");

        return 0;
}

To wit:

- What does #include do?
- What on earth does stdio mean?
- Why does our program need to be a function (if they know what functions are, 
which is not a given)?
- Why does it need to return an int?
- What's with the semicolons?
- Why printf, not print?
- What is \n?

That's not even considering what happens when they inevitably transcribe things 
wrong and have to figure out why it's breaking several lines from where they 
left out a semicolon.

Go's intro is somewhat simpler:

package main

import "fmt"

func main() {
        fmt.Println("Hello, world!")
}

This simplifies:

- "import thing" is less arcane than "#include <thing>"
- No explicit newline needed with fmt.Println
- No explicit semicolons
- No return from main()

But:

- You still need to import something just to print a line, and it is 
confusingly (to the novice) named "fmt"
- You still need to declare a function called main(), and most brand-new 
programmers don't understand functions yet, so this becomes a "wave the dead 
chicken at it just right" thing
- Semicolons are still there under the surface, but they're inserted by the 
lexer, and when they get inserted can be really mysterious and trip a lot of 
people up

In contrast, in Python (3, in this case), it is:

print("Hello, world!")

There are no functions to create (you call one, which is universal in all these 
examples, but a lot easier to explain), execution just proceeds from top to 
bottom, variables are created much more easily (explaining the difference 
between = and := to someone who has never programmed before is quite a task), 
loops are far less complex, etc.

I'm not claiming Python is a better language, or less confusing overall.  Once 
it gets more complex, Python starts to get in the way a bit more (I've never 
particularly liked the indent-based block structure, though actually students 
got a lot less tripped up by that than by brace matching, so there's that).  
But I steadfastly maintain that Go is not an ideal language to learn as a 
*first* programming language, simply because the amount of arcana you have to 
get right just to get simple things off the ground is far more than other 
languages like Python.  And I have a substantial amount of experience with 
students which indicates where the trouble spots would be that cause people to 
give up and decide programming isn't for them instead of realizing that they're 
not starting at the right level.

This isn't a call for Go to change, because I'm totally fine with it being a 
second language after the basics of programming have been mastered.  You don't 
start driving in a Porsche unless you want a very expensive and hazardous 
learning experience.  Similarly, I think most of us could agree that teaching 
Java as a first programming language should be a felony, because it takes all 
these early-learning challenges and amplifies them (not only does main() have 
to be a function, it has to be in a class (what's a class?) and it has to 
specifically be "public static int main(String[] args)").

My only contention, and my intent in answering the original question, is that 
there is a great first-party Tour of Go that is going to be great if you 
already know how to program, but somewhat opaque if you don't already 
understand the basic concepts. Python's own first-party tutorial is the same, 
actually; it's good, but it's set up as an intro to Python assuming you already 
know the basics and I wouldn't recommend it to a new programmer.  Since the OP 
didn't specify what level they were looking for, I provided both sides of my 
opinion.


- Dave


> On Mar 26, 2020, at 4:51 AM, Amnon Baron Cohen <amno...@gmail.com> wrote:
> 
> Go is not C. C programmers have to master explicit memory management, which 
> is a challenge to new and experience programmers alike.
> C is a beautiful language. But very low level.
> 
> Having spent several years programming in Python, I would say that it is much 
> more complicated than Go.
> It has a large and growing number of expressive features which add to the 
> cognitive load of those attempting
> to get up to speed on the language. When you learn Go, you don't need to 
> understand dict comprehensions,
> decorators, metaclasses, asyncio etc. Compare the breathtaking simplicity of 
> launching a Go routine
> with the convoluted mess of python threading.
> 
> The lack of strong static typing and a separate compilation phase means that 
> errors which in Go would 
> cause a compilation error result in run-time exceptions, when a particular 
> code path gets executed.
> 
> Python also has the "feature" that changes in invisible whitespace characters 
> change the programme semantics.
> I never really understood the rationale for the feature.
> 
> The Go 1 compatibility promise is also helpful. This means that course 
> materials or online code examples written 
> 8 years ago will still work today. The python community broke most existing 
> code when they moved from Python 2 to Python 3.
> (A decade on this transition is still ongoing).
> 
> On Wednesday, 25 March 2020 23:04:58 UTC, David Riley wrote:
> It’s just my opinion, and I’m willing to be wrong. :-) 
> 
> But having TAed a university introductory computer science course that was 
> first in C and then in Python (and having had several students who failed 
> when it was in C retake in Python and pass with flying colors), I will say 
> that a lot of the elements that tripped beginners up in C which were absent 
> in Python are present in Go. 
> 
> Most of those (e.g. separate compilation, static typing, a few other bits of 
> arcana) are features that make Go a much more effective systems language than 
> Python, but I do feel like it’s probably best to “take the bumpers off” AFTER 
> the student knows about loops, variables, functions, etc. 
> 
> Again, it’s only my point of view, and I do have some biases, but they do 
> have some basis. 
> 
> 
> - Dave 
> 
> > On Mar 25, 2020, at 17:08, Dan Kortschak <d...@kortschak.io> wrote: 
> > 
> > I don't agree that Go is intrinsically harder than python as a beginner 
> > programming language. There are things that are subtle, but these can 
> > largely be avoided in the beginner setting. 
> > 
> > Note that there have been discussions here about using Go as a language 
> > for teaching beginners, notably this one 
> > https://groups.google.com/d/topic/golang-nuts/FIRSDBehb3g/discussion 
> > 
> > Dan 
> > 
> >> On Wed, 2020-03-25 at 13:34 -0400, David Riley wrote: 
> >> If you are already a programmer in another language, the Tour of Go 
> >> (tour.golang.org) is absolutely the best. 
> >> 
> >> If you are not already a programmer in another language, I personally 
> >> don't recommend Go as a first language; it's an excellent language, 
> >> but I feel that people will do better with it once they already grasp 
> >> the fundamentals of programming and are ready for something with 
> >> slightly more arcana.  Python makes a pretty good first language. 
> >> 
> >> 
> >> - Dave 
> >> 
> >> 
> >>> On Mar 25, 2020, at 6:07 AM, Renato Marcandier < 
> >>> renato.m...@gmail.com> wrote: 
> >>> 
> >>> Hello guys, 
> >>> 
> >>> What's the best course to start with Go? 
> >>> 
> >>> 
> >>> 
> >>> Regards 
> >>> RG 
> >>> 
> >>> -- 
> >>> You received this message because you are subscribed to the Google 
> >>> Groups "golang-nuts" group. 
> >>> To unsubscribe from this group and stop receiving emails from it, 
> >>> send an email to golan...@googlegroups.com. 
> >>> To view this discussion on the web visit 
> >>> https://groups.google.com/d/msgid/golang-nuts/b2aa0e9a-921f-49de-a0be-729a6ca35f5f%40googlegroups.com
> >>>  
> >>> . 
> >> 
> >> -- 
> >> You received this message because you are subscribed to the Google 
> >> Groups "golang-nuts" group. 
> >> To unsubscribe from this group and stop receiving emails from it, 
> >> send an email to golan...@googlegroups.com. 
> >> To view this discussion on the web visit 
> >> https://groups.google.com/d/msgid/golang-nuts/18B2AF64-4888-4730-B282-FCB4C00AB697%40gmail.com
> >>  
> >> . 
> > 
> > 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/b43ecb5a-c043-44d4-92d6-f8c046dda7ff%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/21528ED2-C49B-4785-AD12-ED28B603D44B%40gmail.com.

Reply via email to