Win a copy of Spring Boot in Practice this week in the Spring forum!

Mark Summerfield

author
+ Follow
since Jun 20, 2012
Mark likes ...
VI Editor Linux Windows
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
9
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Mark Summerfield

Hi Junilu,

My reading is this.
The pow(3, 2, 10) call results in v being assigned 9 which is less than 10 so v (i.e., 9) is returned. Note that v's scope is the if statement in which it is declared (including all else if and else branches). The pow(3, 3, 20) call results in v being assigned 27 which is greater than 20 so the print statement should be executed and lim (i.e., 20) returned. So I'd expect it to print:

The reason that 27 >= 20 prints first is because that print statement occurs inside a pow() call. The fmt.Println() in main cannot execute until it knows what its parameters are, so the two pow() calls must be done first, and in one of them the 27 >= 20 line is printed. Once the pow() calls complete the fmt.Println() in main then prints. Flipping the pow() calls will make no difference (except to whether you get 9 20 or 20 9) since both pow() calls must be done before the main fmt.Println() and one of them outputs the 27 >= 20 line.

So the behavior is exactly as expected.
9 years ago
Go
Hi Igor,

I've been using vim (and then gvim) for 22 years---but it took me a decade to get really good at it (and I'm still merely an advanced not expert user). So while I love gvim and wouldn't use anything else, it requires a lot of effort to learn so you might prefer something easier...

Go comes with vim syntax highlighting files. In the Go distribution look inside the misc/vim directory.
9 years ago
Go
Hi Igor,

No, Erlang can't be considered to be

an example of a functional language successful outside academia

because it is a multi-paradigm language which includes a functional subset; it is not a pure functional language like say, ML or Haskell.
9 years ago
Go
Hi Igor,

Well, the Google App Engine itself. There are also some mentioned in the various Go Blog entries Go Blog, and of course there are various videos on YouTube and on the Go website.
9 years ago
Go
Hi Igor,

What would be some good beginning programs/tasks to learn Go?



Well, naturally the exercises in "Programming in Go".

But more generally, I'd think about writing programs that will bring you face to face with the particular paradigms that are uniquely Go's.

So, maybe take a program you have that makes heavy use of object orientation including inheritance and rewrite it from scratch (don't convert it!) to Go, using Go's inheritance-free approach. Then add a significant feature to the application and see which it is easier to change, the original or the Go version (but allowing for the fact that the original is in a language you're used to and the Go one isn't).

Another idea would be to take a non-concurrent program that has opportunities for concurrency and try doing a concurrent version in Go (and if you have time in its original language).

If you want more specific ideas then I think a good starting point are the Unix classics: grep, find, ls, and so on---the first two could be made concurrent.
9 years ago
Go
Hi Igor,

I think it depends on how much experience you have in general, and with the language your using and the problem domain in particular. If you're new to the language or problem domain I suspect that you'll find it hard to maintain a mental image of the program no matter what language its in; and easy if you are very familiar with the language and the domain.
9 years ago
Go
Hi Igor,

Yes, my book provides graded exercises and has solutions. The book's entire source code is available from Programming in Go.
9 years ago
Go
Hi Igor,

Go was originally designed as a systems programming language to succeed C, so there's nothing you can do in C that you can't do in Go---and Go is easier to write and maintain and is relatively speaking a safer language. However, right now Go doesn't have strong support for GUI programming or for mobile programming. It can certainly be used for low level systems programming---at least on Unix---but I'm not sure about device drivers.
9 years ago
Go
Hi Jitendra,

Yes, Go is good for writing server side applications.

I think Go is easier to learn than C, C++, or Java. However, Go does require you to think differently about object-orientation (so is probably easier for C programmers than C++ or Java). Also, since Go does memory management you don't have to worry about returning local objects.

Go has an active and helpful newsgroup golang-nuts@googlegroups.com.

There are far fewer tools/libraries for Go than for Java---after all Java's had a 15+ year start! You can see what's in the standard library here Go Packages and what's available from third parties here Go Dashboard.

You can interact with C++ or Java applications the same as you would between any applications that are written in different languages: for example, read/write files or use network connections, etc.
9 years ago
Go
Hi Rick,

Go was originally designed as a systems programming language but turned out to be far more general purpose. Go is used by some Google Web Apps (three languages are supported for that: Java, Python, and Go), and Go provides some pretty decent web functionality out of the box from its standard library. For example, the golang.org website is a Go application.

I'm not sure what you mean about its approach to HTTP, although I know that some very high traffic sites are using Go.
9 years ago
Go
Hi Atul,

Yes you're right math.Sqrt2 is a predefined constant.
9 years ago
Go
Hi Michael,

As I mentioned in another post there's no doubt that C++ and Java will get CSP libraries---but this isn't the same as having the facility built-in.
9 years ago
Go
Hi Junilu,

It is a chicken and egg: the more adopters the more tools will be developed. Because Go doesn't permit dynamic linking, pure Go programs are always a single executable---much easier to deploy than an executable and a bunch of libraries.

Go comes with a build tool called go, although there are also third party build tools such as gb; and of course you can teach existing tools (make, scons, etc.) how to build Go programs. Most of the other tools have plugin architechures although you'd have to do your own plugins.

Go provides its own JUnit like testing (and benchmarking) tools.

I can't predict how long (or even if!) there'll be more support for Go. But as I said in another posting, I think that Go will quietly be adopted, gradually displacing C, C++, and Java for systems, backend, and server applications as more developers discover how much easier to use Go is---especially for concurrent applications.
10 years ago
Go
Hi Junilu,

I think they chose the name purely to win the attention of Google to fund them to do what they wanted. It doesn't help much for searching with Google though! I tend to always include "golang" or "go language" in queries.

The JSON and XML types are very interesting as is the uniformity of their approach. My experience suggests that those types are very easy to use for easy data---and straightforward to extend for more complex data. (I give some coverage in my book, of course.)

Good luck as you go for it!
10 years ago
Go
Hi qunfeng wang,

You haven't really asked a question; you've just said that Go isn't interesting and isn't well designed. Both of which I disagree with!

If you prefer Erlang for concurrent programming by all means use it. Personally, I prefer Go's channels and goroutines approach to concurrency more than any other model I've seen.

You can do functional style programming in Go, but it certainly isn't a functional language. In fact, no functional language has proven to be successful outside academia.

Go's standard library is not as extensive as Java or Python: but then Go is a much younger language and its standard library will grow over time just as the Java and Python libraries have.

For most of its life Python has been a language used by those "in the know" and not considered an "enterprise" language (compared with C++ and Java). But in recent years with the pressure to deliver applications faster and for increased flexibility, there has been a certain amount of switching from Java to Python, and many new projects that would formally have been done in Java are being done in Python from day one. I suspect that Go will follow a similar trajectory with the tipping point coming when organizations need to make their applications work concurrently to take advantage of multicore machines and the development and maintenance cost of doing so in C++ or Java is too high. At this point, more savvy developers will switch to Go which will provide them with a competitive advantage because of its excellent concurrency support. (Of course, Go's approach to concurrency will be adopted by C++ and Java in the form of libraries, but whether that will happen before Go becomes the natural choice for writing concurrent applications is moot.)
10 years ago
Go