-4

GO has embraced,

1)

JavaScript/Python language constructs,

Higher order function

Closure

Slicing

Range operator

Anonymous function(inner function)

Provides abstractions for map object

for..in as for..range

2)

C language constructs,

Non reference type('var a int')

Variadic functions

Overriding init() function

struct keyword

Pointers

typedef


Packaging feature of GO language provide package keyword


Question:

Did GO embrace any language construct that is introduced in Java?

  • 4
    Did Java introduce any language constructs? – CodesInChaos Jan 28 '17 at 10:21
  • 4
    To be pedantic, most of the features you mention were not introduced by these languages, but originated in older languages which are less well known today. (I would even argue pointers and ints are not introduced by any language, since they are native to processors.) I'm not sure if Java really introduced any new features at all. It was designed at the time as a pragmatic language, halfway between C++ and Smalltalk. – JacquesB Jan 28 '17 at 13:39
  • 2
    @CodesInChaos: No. It did not introduce anything that did not already exist before (GC 1950s, generics 1920s, OO 1960s, …). It did not even introduce any combination of things that already existed before: Eiffel already had everything in 1985 that Java had in 2005: statically-typed class-based OO with generics (which Eiffel had from the beginning and Java didn't gain until 2005) and automatic memory management. I'm not sure whether Eiffel had lambdas from the start, but it definitely had them before Java. So, Java didn't introduce anything novel, and it didn't have a novel combination. – Jörg W Mittag Jan 29 '17 at 0:44
  • @JörgWMittag You know PL history better than me; was there any precedent for turning every object into a monitor and providing built-in synchronized methods? Trying to solve concurrency issues by turning everything into a mutex seems to be Java's main “contribution”. Curiously, .NET copied this design decision. – amon Jan 29 '17 at 20:07
  • 1
    @amon: I did not think of that! It seems like this is widely considered to be a mistake, though, so the "contribution" seems to mostly lie in playing the guinea pig. So, it seems that the only original contribution Java had was a bad one. I've said this a couple of months ago already, but I'll repeat it here: it is absolutely astonishing how many brilliant people worked on Java (Guy Steele, Gilad Bracha, Phil Wadler, Martin Odersky, …) and what the end result was … – Jörg W Mittag Feb 3 '17 at 2:15
6

No, Go does not show any particular influence from Java. Go and Java do share similar goals, but took different paths to achieve these goals. The Go designers are of course aware of Java, C#, C++, JavaScript, and Python, and position Go as an alternative to these languages in certain cases, but did not borrow heavily from these languages.

A bit of context to understand why Golang is the way it is:

  • C is the common ancestor of modern “curly brace languages”. It is more or less a kind of portable assembly, with a weak static type system on top.

  • C++ started out as an extension to C, and adds better mechanisms for safety and abstraction, notably classes and templates. The result is an extremely powerful but still fundamentally unsafe language.

  • Java can be interpreted as “C++, the good parts” or as a “statically typed Smalltalk with C++ syntax”. It get rids of C/C++ features like pointers, const types, manual memory management, and templates, which results in a much safer and simpler language, at the cost of expressiveness. It also provides language-level support for concurrency (e.g. synchronized methods and blocks).

  • Go does to C what Java did to C++: simpler type system, simpler syntax, garbage collection. Like Java, Go provides language-level solutions for concurrency (goroutines, channels), but it chooses a very different set of features. Go rejects nominal, class-based OOP as in C++ or Java and instead uses structural typing for virtual functions, in a fairly novel manner.

Java, Go, JavaScript, and Python have one thing in common: their object systems and memory models are all heavily influenced by Smalltalk or its derivatives, but dress it in more C-like syntax. In the case of Go, the “static duck typing” through Go's interfaces makes it feel substantially more like Smalltalk or other dynamic languages than the nominally types of Java do. Go's nested functions are also akin to Smalltalk's blocks.

Go's package declarations might look like Java, but are probably inherited from the same language family where Java got it: Modula and Oberon, from the Pascal language family. Pascal also provides precedent the top-level declaration syntax (e.g. var). “Go's heritage is at least as much Oberon as it is C! (packages, imports, strict memory safety, garbage collection, dynamic type checks, etc.)”

I can see no influence from JavaScript on Go, except maybe for automatic semicolon insertion, where JavaScript serves as an example of how not to do it. But in fact, this feature is taken from C's predecessor BCPL.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.