golang OO removal, benefits. over python?

flebber flebber.crue at gmail.com
Mon Mar 10 07:45:17 EDT 2014


> Also, is there anything seriously lacking in Python, Java and C?
> 
> 
> Marko

>From their FAQ:

Go was born out of frustration with existing languages and environments for systems programming. Programming had become too difficult and the choice of languages was partly to blame. One had to choose either efficient compilation, efficient execution, or ease of programming; all three were not available in the same mainstream language. Programmers who could were choosing ease over safety and efficiency by moving to dynamically typed languages such as Python and JavaScript rather than C++ or, to a lesser extent, Java.

Go is an attempt to combine the ease of programming of an interpreted, dynamically typed language with the efficiency and safety of a statically typed, compiled language. It also aims to be modern, with support for networked and multicore computing.

>
Although Go doesn't have exception handling either which is odd. http://blog.golang.org/error-handling-and-go
http://uberpython.wordpress.com/2012/09/23/why-im-not-leaving-python-for-go/
Or you can use defer http://blog.golang.org/defer-panic-and-recover
func CopyFile(dstName, srcName string) (written int64, err error) {
    src, err := os.Open(srcName)
    if err != nil {
        return
    }
    defer src.Close()

    dst, err := os.Create(dstName)
    if err != nil {
        return
    }
    defer dst.Close()

    return io.Copy(dst, src)
}

> That's a strange locution: You are suggesting that go had OOP and it was > > removed 
Although Go has types and methods and allows an object-oriented style of programming, there is no type hierarchy. The concept of "interface" in Go provides a different approach that we believe is easy to use and in some ways more general. There are also ways to embed types in other types to provide something analogous--but not identical--to subclassing. http://golang.org/doc/faq#Is_Go_an_object-oriented_language

sayth



More information about the Python-list mailing list