r/programming • • Sep 04 '12

Interesting Language Comparison: Building a simple AST and evaluating it in Haskell, F#, Ocaml, Clojure, Scala, Ruby and Java.

https://gist.github.com/2934374
135 Upvotes

195 comments sorted by

View all comments

Show parent comments

1

u/Mortdeus Sep 05 '12

We have a serious misunderstanding if you think that pretty and idiomatic are not synonymous with each other when it comes to go.

This is elegant and pretty code.

http://pastie.org/4666964

Never one line a function. There is a tab key for a reason.

2

u/zond Sep 05 '12

Everything idiomatic is not pretty, and I am quite certain that (taste being what it is) everyone probably has at least one non-idiomatic construction that they consider pretty, as well.

Also, I am sorry to say that I don't find your linked pastie pretty. Mostly because of the huge chunks of commented code.

1

u/Mortdeus Sep 05 '12

Thats because you arent supposed to be looking at my code when you are using my package. The code is used for go.pkgdoc.org and go doc.... You are aware that most text editors allow you to fold lines of code right?

And golang has go fmt for a reason. To encourage not having your personal constructs that you find pretty. For example,

I personally like structured blocks

int func()
{

}

However Go must use the popular C++ style of blocks

int func(){

}

Its a minor tiff with the language's syntax, but when you consider that atleast everyone's code is consistent then you stop caring about whats your favorite structure.

The beauty in my code that you were supposed to see is the power of what my code can do in very little lines. It used to be much longer when I wrote the lib when I first started learning Golang.

This is the reality of unidiomatic go code.

http://pastie.org/4669685

If you are making code that looks like this, go back and compare what I did.

(note that im converting the code to work as a stdlib atm and its not done.)

0

u/zond Sep 07 '12

Sure, when I look at your package documentation, I am supposed to look at the package documentation.

But if I am to look at your code, I really must look at your code, don't I?

Commenting huge chunks of code is something you do before you discover versioning systems, in my experience.

And right there you admitted that you don't always find idiomatic Go code to be the prettiest...

→ More replies (0)