Live data from Hacker News

Go by Example

gobyexample.com

121–130 of 130 posts

Re: Go by Example

#121
post #95

Earlier quoted context omitted.

I've learned enough 'Go' to write a small 3D framework in OpenGL, and after doing so, I have no desire to go back for most of my projects. Making go-routines map to OS-level threads is a pain. And as much as I hate to trot out this old chestnut, the lack of generics is also a real pain. I've gotten too used to having generic containers to go back, and the various hacks available just aren't worth it. I still can't be…

You might like nimrod. Similar performance characteristics (or better) than Go, with Generics and meta-programming. Library situation is a little iffy, but there are full SDL and OpenGL bindings.

> Similar performance characteristics (or better) than Go. Nope. It's without a doubt 100% better. The GC is brilliant and realtime with deterministic properties. The community has outperformed C++ in ray tracers and games, Ada in text manipulation, etc. It's absolutely freaking blazing since it compiles to really tight C and takes advantage of the 50 years of C compiler research & design.

> Library situation is a little iffy. Libraries are hardly iffy. Any C code be called, and most c++ code can be called very, very easily and with little boilerplate. The standard library has a huge pure section, and for almost everything else it has dozens of bindings to C libs. And there are plenty of existing libraries in the babel library manager, such as SFML.

Re: Go by Example

#122

Earlier quoted context omitted.

> it's true that writing generic containers in Go isn't so great That's one hell of an understatement. > is it really sufficiently horrible to warrant that? A number of people obviously and repeatedly say that yes, a statically typed language without parametric polymorphism is sufficiently painful to use something else instead.

I'm curious what programs people are writing where parametric polymorphism is so crucial. I've written hundreds of thousands of lines of Go code (servers, web apps, data processing, etc.), and there's probably been maybe O(hundreds) of lines of code that were annoying or tedious because of a lack of parametric polymorphism. My suspicion is that what's more likely is that lots of people don't want to consider writing…

Parametric polymorphism is crucial in an API like jOOQ's:

http://www.jooq.org

In fact, it is one of the fundamental cornerstones of internal DSLs

Re: Go by Example

#123
post #107
post #102

Earlier quoted context omitted.

"But maybe there's a whole class of problem (actual problem, not a sub-problem like "I want to implement a container") that I don't come in contact with." i want to apply a transformation to every element in a collection i want to select the elements from a collection for which some predicate holds true

Those are both sub-problems.

of every software problem in history

Re: Go by Example

#124
post #95

Earlier quoted context omitted.

You might like nimrod. Similar performance characteristics (or better) than Go, with Generics and meta-programming. Library situation is a little iffy, but there are full SDL and OpenGL bindings.

> Similar performance characteristics (or better) than Go. Nope. It's without a doubt 100% better. The GC is brilliant and realtime with deterministic properties. The community has outperformed C++ in ray tracers and games, Ada in text manipulation, etc. It's absolutely freaking blazing since it compiles to really tight C and takes advantage of the 50 years of C compiler research & design. > Library situation is a li…

You're overselling it. While you can call C code, the interface is often not very Nimrod-y and it's not automatic, you have to declare prototypes, and there are absolutely holes in the stdlib - the lack of any arbitrary precision/bignums library for instance.

Re: Go by Example

#125
post #112

Earlier quoted context omitted.

I'm curious what programs people are writing where parametric polymorphism is so crucial. I've written hundreds of thousands of lines of Go code (servers, web apps, data processing, etc.), and there's probably been maybe O(hundreds) of lines of code that were annoying or tedious because of a lack of parametric polymorphism. My suspicion is that what's more likely is that lots of people don't want to consider writing…

I think the biggest advantage of parametric polymorphism comes from program analysis, not just increased capability. The notion of parametricity depends crucially on parametric polymorphism and is super useful. Parametricity is the property that says greater polymorphism means lesser variation in implementation. Highly parametric functions can be almost completely described by their types along meaning it provides in…

The last part is backwards -- when F is a functor, the only law we need to check is the identity law, but checking the composition law isn't enough. For example,

  fmap _ _ = []
satisfies fmap f . fmap g = fmap (f . g), but not fmap id = id.

Re: Go by Example

#126
post #112

Earlier quoted context omitted.

I think the biggest advantage of parametric polymorphism comes from program analysis, not just increased capability. The notion of parametricity depends crucially on parametric polymorphism and is super useful. Parametricity is the property that says greater polymorphism means lesser variation in implementation. Highly parametric functions can be almost completely described by their types along meaning it provides in…

The last part is backwards -- when F is a functor, the only law we need to check is the identity law, but checking the composition law isn't enough. For example, fmap _ _ = [] satisfies fmap f . fmap g = fmap (f . g), but not fmap id = id.

Whoops, that's correct.

Re: Go by Example

#127

Earlier quoted context omitted.

I think a big part of the issue is that in Java and C++, you really need generics a lot more than in Go. Without templates, you would not have any easy way of doing maps and lists in C++. There are no builtin types for those like in Go. The way the type system works in those languages also makes things very difficult if you don't have generics. Think about the sorting example I wrote earlier: https://news.ycombinator…

> It's also why std::string is actually std::basic_string , std::allocator > Actually, that's not a band-aid. It allows strings to be generic over allocators without suffering the performance penalty of a virtual call on every malloc and free. Go's solution would be to just take the penalty of a virtual call (as interfaces require virtual calls everywhere) and try to make it up with devirtualization optimizations and…

It's certainly true that Go doesn't currently support compile-time polymorhpism, and C++ does. In that sense, Go interfaces are not a replacement for C++ templates, as you correctly note.

However, compile-time polymorphism is a mixed bag because of how it tends to blow out the icache by generating many copies of similar code. Java does away with it completely, and nobody seems to be protesting. The Linux kernel is written in C, and nobody seems to be protesting that the lack of compile-time polymorphism makes his/her job impossible. Clearly, the decision as to whether to include compile-time polymorphism in a language is something reasonable people can disagree about.

With regard to a type system for Lisp: it's been done before. Check out Qi.

Re: Go by Example

#128

Earlier quoted context omitted.

> it's true that writing generic containers in Go isn't so great That's one hell of an understatement. > is it really sufficiently horrible to warrant that? A number of people obviously and repeatedly say that yes, a statically typed language without parametric polymorphism is sufficiently painful to use something else instead.

I'm curious what programs people are writing where parametric polymorphism is so crucial. I've written hundreds of thousands of lines of Go code (servers, web apps, data processing, etc.), and there's probably been maybe O(hundreds) of lines of code that were annoying or tedious because of a lack of parametric polymorphism. My suspicion is that what's more likely is that lots of people don't want to consider writing…

heh, interesting. as somebody mucking about with containers in Go, i also recognize it to be a sub-problem, and not one really worth having a language-level debate over.

perhaps odd, because i come from a crappily-typed PHP background. but if PHP teaches you anything, it's that you can accomplish just about anything with arrays (maps/slices).

Re: Go by Example

#129
post #66

The documentation format is a revolution of simplicity and comprehension. I can see this list format (and content) working for any/all languages.

I'm in the process of making a clone of the site for node.js [here]( https://github.com/L8D/nodebyexample )

Throws a 404. Is it a public repo?

Re: Go by Example

#130
post #66

Earlier quoted context omitted.

I'm in the process of making a clone of the site for node.js [here]( https://github.com/L8D/nodebyexample )

Throws a 404. Is it a public repo?

Yeah, I trashed pretty quickly because I realized I didn't have time to work on it, nor did I have the creativity to write good examples. It would have better suited to be about JavaScript rather than Node, and there are already plenty of better ways to learn good JavaScript on the internet. I might do 'Haskell by Example' which would be really fun, if I ever have time for it.
Post reply on HN