aspose file tools*
The moose likes Other Languages and the fly likes Question about the GO syntax Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Languages » Other Languages
Bookmark "Question about the GO syntax" Watch "Question about the GO syntax" New topic
Author

Question about the GO syntax

Barry Raczkowski
Greenhorn

Joined: Jun 22, 2007
Posts: 13
Hi;

Thank you for taking the time out to answer questions about the GO Language. I really no nothing about GO other than it is a GOOGLE product.

Is the GO language syntatically closer to C++ or Java. Is there dynamic class generation? Are variables dynamically assigned like in some of the scripting languages? Is there a swing type library?

Is it mobile ready?
Mark Summerfield
author
Ranch Hand

Joined: Jun 20, 2012
Posts: 37

Hi Barry,

Although Go is funded by Google it has a very liberal open source license so can be used for both open source and commercial projects.

Go's syntax is closer to C than C++ or Java (except for type declarations which are more like Pascal).

Go does not have any support for generics (which is what I think you mean by "class generation"?). However, there is far less need for generics in Go than in most other languages because of other language features.

All variables must be declared; however, Go supports a short variable declaration syntax:

This creates a new variable called x whose type and value are the same as y.

There is no GUI library, but there are bindings to some GUI toolkits (most notably Gtk+) available.

I'm not aware of Go being used on any mobile platform. My understanding is that Apple only permits iOS development with its own tools and Android is Java-based.


Mark Summerfield
"Programming in Go" - http://www.qtrac.eu/gobook.html
Barry Raczkowski
Greenhorn

Joined: Jun 22, 2007
Posts: 13
Can you access memory, using pointers?

So you talked about libraries that can be created for GO. Can we use integrate "C" libs witht eh GO code?

Finally, where do you see GO's fiting into the larger Eco system of languages? Is it good for writing drivers like "C"? Is it a scripting like language and GO for searching or system programing? Will it work on the WEB?

I am kind of disappointed that it cannot be used with the Android operating system. What is its utility? WHat would be a compelling case for me to go to my management and say we need to start using "GO".

I am sorry for sounding a little down on "GO", but GOOGLE has shown alot of fore sight with their inovations,I am not sure about "GO".
Mark Summerfield
author
Ranch Hand

Joined: Jun 20, 2012
Posts: 37

Hi Barry,

Yes, you can use pointers---but not pointer arithmetic. (Nowadays most compilers can optimize x[j] better than *(x + j) anyway.)

Yes, you can integrate C libraries. Go comes with a facility for doing this called cgo. It is also possible to use SWIG (e.g., to access C++ libraries).

I think that Go will replace: a small number of Python programs where concurrency and speed are paramount; a growing number of C programs (including system programs), particularly those that would benefit from concurrency; some C++ programs, especially backend systems and big systems where developers would rather rewrite in Go for clarity and compilation speed than put up with slow compilation and an increasingly complex language. Go is a compiled language that has many of the conveniences of scripting languages.

Go is a general purpose programming language---and the first significant language designed for multicore/multiprocessor systems out of the box. It is useful for any systems and backend programming, and for web programming. It doesn't (yet) meet the needs of GUI programmers except via some third party bindings (e.g., to Gtk+). I expect it will be ported to Android at some point.

As for a compelling case: that depends on what you're already using. I think that Go is easier and more convenient than Java---and much easier than C++.

I would advocate learning Go by getting a good book and writing some Go programs. By the end of that process you'll have much more of an idea of Go's strengths and weaknesses in relation to the kind of programs you are interested in.
Igor Mechnikov
Ranch Hand

Joined: Feb 13, 2011
Posts: 100

Mark Summerfield wrote:
I would advocate learning Go by getting a good book and writing some Go programs. By the end of that process you'll have much more of an idea of Go's strengths and weaknesses in relation to the kind of programs you are interested in.


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


String knock = "\u042F \u0418\u0433\u043e\u0440\u044c";
Mark Summerfield
author
Ranch Hand

Joined: Jun 20, 2012
Posts: 37

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.
Igor Mechnikov
Ranch Hand

Joined: Feb 13, 2011
Posts: 100

Mark Summerfield wrote:
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.


I will attempt this today. And I believe someone at the University of California already tried to redo Unix utilities in Go, so there is something to compare.
Thank you Mark for answering all my queries.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question about the GO syntax