GO, c's younger copycat brother?

Pages: 12
closed account (Dy7SLyTq)
i was bored so i started to learn go from http://tour.golang.org/#1. since go is google and ive never been unhappy with google i thought i would give it a try. correct me if im wrong, but it feels like a combo of c(++) and java. yet somehow it is still trying to be different, like with the variable declarations. so anyways, is it just me or is it a backwards, more-complicated c.

on a side note, what does it offer that other languages dont?
The syntax is similar to C, C++, C#, Java but one thing I've notice is the lack of variable declaration, sort of like Python/Ruby.

I don't really have time to look into it right now, but I'm curious to know how they handle more complex things (templates, classes, pointers or delegates) and if the language is compiled directly or if it goes through an intermediate language.
I haven't played with Go since it was first demoed and only available on linux.

I think i'll check it out again :P
closed account (S6k9GNh0)
I really do need to start looking into other languages than C/C++/ASM. I'm driving myself mad with redundancy and complexity.
I don't know go, but from what I've seen, it seems to be about as far from C as one procedural language could ever be from another.
As for syntax, a language developer tries to strike a balance between being familiar looking, visually distinguishable from other languages and not ugly. Syntax is the least important part of the language though.
If you want to see a different language, you'll have to leave procedural paradigm. Try haskell, or even better, prolog.
It's supposed to be a combination of C and Python, I think. I don't like it because it has even stricter stylistic rules than Python does, and I'm opposed to languages that enforce a certain style. At least Python only requires that you indent your code and do so consistently; from what I've heard, Go actually enforces certain brace styles. Haskell semi-requires a layout of sorts for the parser to figure out scope and stuff and it has some rules, but you can bypass that by using braces and semi-colons or certain operators. The only annoying thing about Haskell is that it assumes anything starting with a capital letter is a monad, data type, module or constant, while anything starting with a lowercase letter is assumed to be an identifier, but it's really not a big deal.

I've probably said it before, but I highly recommend that anyone learn Haskell. Especially if you like languages without redundancy (it's very expressive). Complexity may be an issue because although the language itself is simple and elegant, learning it is really, really hard if you've never learned a functional language before (but if you haven't, you really ought to, and once again I recommend Haskell).
my problem with functional languages is that they are not used widely in real world businesses of in most programming competitions. Also I have heard that a lot of times functional languages are much slower than procedural languages.
they are not used widely in real world businesses

Erlang is; it was created at Ericsson for telecommunications. It's really cool because it has threading build right into the language and you can actually hotswap code (that is, you can update parts of a program while they're still running). They're only going to get more prevalent because they're much better-suited to multicore and parallel programming since they don't need thread synchronisation and don't suffer from deadlocks due to not allowing mutable data. Processors aren't really getting much faster in terms of clock speeds, instead, they're adding more cores, but to take advantage of extra cores you need extra threads.

I have heard that a lot of times functional languages are much slower than procedural languages

Not really, Haskell and Erlang are quite fast. Not as fast as C, usually, but the development time is much shorter (which is good, because programmer time is more valuable than CPU time) because of the high-level features, which leaves you time to implement better algorithms. A better algorithm is always likely to be faster than a worse one, no matter how optimised the worse one is. As well as better multithreading potential (which can provide a large performance boost, especially with multiple cores), functional languages can do lots of optimisations that procedural ones can't, partly because, again, they don't allow mutable data, but also because they have other high-level features that other languages lack. In Haskell, for example, you can memoise a function (meaning the result will be cached in memory rather than being calculated again every time, which can massively cut down the time required to compute recursive functions) by literally typing "memo". Another one of my favourite things in Haskell is lazy evaluation, where expressions won't be evaluated until the result needs to be used, which has three main benefits: (1) you don't waste time computing values that don't get used, (2) you can evaluate expressions in batches, and (3) you can operate on infinitely-sized lists. And this is all with a single thread. With multiple threads, Haskell can be much faster.
Last edited on
they are not used widely in real world businesses. Erlang is

The why do you recommend people learn Haskell?
Go's main prominent "I'm different" feature is its Duck Typing. Watch the inro video on the home page to get a good idea.

I don't think it's meant to be used for the same things as C/C++/C#/Java. They claim they have already running code that is actually doing useful things.
@Script Coder
I just like Haskell. If you know one, it's easy to learn the other, it's like going from C to Python.
@chrisname I see your point.

Is go interpreted or compiled? Also, how popular is it (i.e. are there any real world programs made in it)?
It's compiled, but it's not very popular.
Also, after reading the words "garbage collection", I am put off. It is the same reason I dislike using java. I want to be in control, without the language inserting code to check to see if it believes that I am done with something.
I've yet to see a garbage collection system that can compete with the various auto pointers. I'm also sick and tired of languages that mix and match the stack and the heap and you can never really tell if you're dealing with a pointer, reference, actual variable, pass-by-value, pass-by-reference, etc. - it's why I stick to C++.
Why do you people want to know this stuff? It's better just to be able to say "Hey computer, here are some functions. Have fun." because you can write much more concise, elegant and bug-free programs and in less time. I don't want that level of control unless I need it; I don't want to be worrying about the content of cell 0xBF00A611, I want to do some actual work. I don't want to be thinking "Did I remember to free all my pointers? Did I leave any hanging pointers?", I want the computer to do something useful and I don't care how as long as it's fast enough to suit my needs. Sometimes you have to go low-level, and sometimes it's fun (hence OS development), but for most real programs, it's a total waste of time.
@chrisname I agree, which is why I mentioned auto pointers, but when you take away certain features for the sake of simplicity you make some things more difficult. I'm constantly having to do things in a roundabout way in languages like Java because the way I normally do it does not exist.

I also hate languages that don't have destructors, or that don't have objects that die at the end of a scope. Why do you think java had to introduce the try-with-resources statement? To me it looks like a replacement for scoped objects.
@chrisname I see what you mean, I have been trying out clojure today, its awesome :)

@L B at the risk of sounding like a total noob: what is an auto pointer?
closed account (Dy7SLyTq)
i think its an pointer to an address with type auto (I think its new in c++ 11) which the compiler figures its type out at run time. so auto *str = "Hello, world!"; would become char i think
Pages: 12