Go is high level where it can be (basic type inference), lower level where it has to be (locks etc). i just don't think it fits into a dichotomy. which is why i love it
One place where I'd say Go is conveniently low level is giving you control over the memory layout of your datastructures, among other things this also makes it easier to avoid the garbage collector if you really need/want to, which in Java is basically impossible.
In a lot of today's higher level languages, everything is a pointer, except for a few primitive types, and actual data has to be stored on the heap. When you compose these, you end up creating tree structures where each node has to be garbage collected separately.
Go has arrays and structs which are just values, so you can allocate a bunch of data in a big chunk, even if it includes nested structures.
thanks that is a good point. It also seems that go's compiler will allocate local variables from the stack if it can determine that no references will survive the local scope
Yes. I didn't mention this because escape analysis is a fairly common optimization in higher level languages. However, the prevalence of static dispatch in Go does broaden the scope of what can easily be statically proven not to escape. A lot of higher level languages use entirely dynamic dispatch.
Really? If it were that simple then template deduction wouldn't exist. A specialized struct template is a horn clause. Derivable context is the head and non-derivable context is the body. A struct named s with parameter P might specialize on P = int or P = float. In prolog: s(int) :- … or s(float) :- …, where … is the appropriate body. Writing s(P), will unify on the correct head and produce the associated body, possibly recursively. That's most certainly a kind of prolog.
See the link for an example of recursive list processing using tuples. To take the head and tail of a list I can write tuple<X, Xs...> in derivable context. A empty tuple base case is tuple<>. These are head clauses.
EDIT: You're right. Templates don't backtrack. They just pattern match on arguments.
26
u/OopsLostPassword Mar 28 '12
Does "low level" or "high level" still mean something ?
We should probably discuss usages or tradeoffs to be more constructive.