Google release their own language: Go

A place for Ogre users to discuss non-Ogre subjects with friends from the community.
Post Reply
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 538

Google release their own language: Go

Post by Kojack »

http://golang.org

On wednesday Google released an open source programming language called Go. Apparently it's intended to be a systems programming language like C++.
Some features:
- extremely fast compile
- garbage collection
- supports google protocol buffers
- two compilers: gccgo (gcc backend) and 6g (plan 9 based)
- concurrent programming

Simple hello world style program in Go:

Code: Select all

package main
import fmt "fmt"
func main()
{
   fmt.Printf("Yay\n");
}

Here's some differences they list from C++:
* Go does not have classes with constructors or destructors. Instead of class methods, a class inheritance hierarchy, and virtual functions, Go provides interfaces, which are discussed in more detail below. Interfaces are also used where C++ uses templates.
* Go uses garbage collection. It is not necessary (or possible) to release memory explicitly. The garbage collection is (intended to be) incremental and highly efficient on modern processors.
* Go has pointers but not pointer arithmetic. You cannot use a pointer variable to walk through the bytes of a string.
* Arrays in Go are first class values. When an array is used as a function parameter, the function receives a copy of the array, not a pointer to it. However, in practice functions often use slices for parameters; slices hold pointers to underlying arrays. Slices are discussed further below.
* Strings are provided by the language. They may not be changed once they have been created.
* Hash tables are provided by the language. They are called maps.
* Separate threads of execution, and communication channels between them, are provided by the language. This is discussed further below.
* Certain types (maps and channels, described further below) are passed by reference, not by value. That is, passing a map to a function does not copy the map, and if the function changes the map the change will be seen by the caller. In C++ terms, one can think of these as being reference types.
* Go does not use header files. Instead, each source file is part of a defined package. When a package defines an object (type, constant, variable, function) with a name starting with an upper case letter, that object is visible to any other file which imports that package.
* Go does not support implicit type conversion. Operations that mix different types require casts (called conversions in Go).
* Go does not support function overloading and does not support user defined operators.
* Go does not support const or volatile qualifiers.
* Go uses nil for invalid pointers, where C++ uses NULL or simply 0.
They say that right now there's no safe way to call Go from C or C++ code, but there's a C compiler (Plan 9's GC) which can link with Go (so you can call C from Go). Also, there's pointers but no pointer arithmetic and no operator overloading.

Sounds interesting.

Unfortunately there's already been a programming language called Go! for around 6 years, Google should have probably googled the name first.
At the very least, anybody creating a language without checking http://99-bottles-of-beer.net (has 1304 languages) first is stupid, they've had an entry for Go! since 2005: http://99-bottles-of-beer.net/language-go!-289.html
User avatar
KungFooMasta
OGRE Contributor
OGRE Contributor
Posts: 2087
Joined: Thu Mar 03, 2005 7:11 am
Location: WA, USA
x 16
Contact:

Re: Google release their own language: Go

Post by KungFooMasta »

No function overloading! :(

Why do they have to use nil and not NULL.. and a 'slice' sounds really odd.
Creator of QuickGUI!
User avatar
mkultra333
Gold Sponsor
Gold Sponsor
Posts: 1894
Joined: Sun Mar 08, 2009 5:25 am
x 116

Re: Google release their own language: Go

Post by mkultra333 »

Hehe, "Google should have probably googled the name first." The very expensive Google lawyers will probably argue that "Go!" couldn't possibly be confused with "Go."

The three things that struck me, that I use all the time, are no function overloading, no pointer arithmetic, and no passing arrays. Although it sounds like there's ways around the last one.

Still, could be interesting. C++ has evolved into a pretty nightmarish beast, so something that takes the best of it but simplifies things might not be all bad.

Edit: Yeah, why "nil" instead of "NULL." And god help me, the arrays had better start at zero!
"In theory there is no difference between practice and theory. In practice, there is." - Psychology Textbook.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: Google release their own language: Go

Post by jacmoe »

Why not give some love to D instead ?
That's a great language.
I am unable to see the point - is this a joke? :)

<edit> But it is interesting. </edit>
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
Vectrex
Ogre Magi
Posts: 1266
Joined: Tue Aug 12, 2003 1:53 am
Location: Melbourne, Australia
x 1
Contact:

Re: Google release their own language: Go

Post by Vectrex »

jacmoe wrote:Why not give some love to D instead ?
That's a great language.
I am unable to see the point - is this a joke? :)

<edit> But it is interesting. </edit>
yeah, it's a bit unfair of them to say that no systems level languages have been made in decades..
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 538

Re: Google release their own language: Go

Post by Kojack »

D rocks. I just wish it was easier to use with VC libs so I could actually do stuff with it.

Nil is pretty common in scripting languages (such as Ruby and Lua), I'm used to using both nil and NULL (although I'm trying to get into the habit of changing the latter to 0).

Arrays do start at zero. :)
Arrays require a compile time constant size, (I haven't found a way yet to allocate a randomly sized array).

Strings are constant. You can't modify the contents of a string. I guess if you wanted to do something like change the case of the first letter, you'd have to create a new string by concatenating the changed case letter with a slice of all of the string except the first letter. I prefer having direct per letter access to change a string.

Enums are done using const blocks and the iota keyword.
Here's an example:

Code: Select all

const (  // iota is reset to 0
	c0 = iota;  // c0 == 0
	c1 = iota;  // c1 == 1
	c2 = iota   // c2 == 2
)
The keyword iota is set to zero when a const word appears, and it adds 1 to itself every time a semicolon is passed.

It has ++ and --, but they are post only (no pre form) and they are statements, not expressions.That means you can't use them inside of another expression (like a = b++), they have to stand alone.

There's a built in map class, but it can only use built in types (ints, strings, etc) as the key. You can't use a user made struct/class as the key.

I'm still trying to get my head around the class system. Go is kind of object oriented, but has no inheritance. It uses interfaces, anything which matches an interface is considered compatible with it or something.


I just don't get a good vibe from the syntax of the language.
But this is google we're talking about. If they really embrace this it will end up all over the place.

(I wonder how long it will be before one of the Go developers turns up in this thread... that seems to happen around here a bit)
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: Google release their own language: Go

Post by jacmoe »

Sounds pretty much like Delphi interfaces?
Much better than C++, I agree.
Kojack wrote:I just don't get a good vibe from the syntax of the language.
But this is google we're talking about. If they really embrace this it will end up all over the place.
Yep.
We already have .NET all over the place ..
That reminds me of why Microsoft invented C#: because their programmers can't use C++.
Maybe Google has the same problem? And came up with Go! ?
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 538

Re: Google release their own language: Go

Post by Kojack »

No, it's probably because Microsoft has C#. Google doesn't want to miss out on any market Microsoft is in.
Browsers, mobile phone operating systems, programming languages, maps, google and MS are always competing.
I'm surprised that Google hasn't bought out X-Plane yet to compete with MS Flightsim (although MS fired them all so there's no point now).

Maybe Android will start using it instead of java? :)
User avatar
wacom
Gnome
Posts: 350
Joined: Sun Feb 10, 2008 2:07 pm

Re: Google release their own language: Go

Post by wacom »

This topic is not OGRE related! Close it at once!

;)
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 538

Re: Google release their own language: Go

Post by Kojack »

This topic is not OGRE related! Close it at once!
Well, this IS the Off Topic board.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: Google release their own language: Go

Post by jacmoe »

Wacom is slightly annoyed that I didn't allow him to advertise his modeling expertise.
I just had to be consequent on our policies - I am sorry I moved you out of sight from the Recruitment forum. :)
Nothing wrong with your work or anything.. :wink:
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
Nauk
Gnoll
Posts: 653
Joined: Thu May 11, 2006 9:12 pm
Location: Bavaria
x 36
Contact:

Re: Google release their own language: Go

Post by Nauk »

Promissing and looking at other google products I bet it will be pleasant and performant to work with and yeah I agree with jacmoe, D needs more love and attention, especailly someone fixing the linker and object format mess, such an awesome language.
Post Reply