Introduction to Golang
altdevblogaday.com
altdevblogaday.com
There is a lot to love about go and it is very quickly starting to look a lot more interesting than other languages like ruby for future projects.
http://clojure-doc.org/articles/content.html#clojure_tutoria...
Coming from Python and Ruby, being able to just deploy a jar is a dream.
(Although, as I happen to use mostly Debian-based systems, I prefer not using Python packages directly but build .deb out of them with stdeb and use system package manager to deploy. Just dput the built package to company's private apt repo, and Puppets pull the update.)
It's a mess, there are multiple factions and implementations, and until people started consolidating there were 4-5 concurrent popular approaches to packaging Python libraries.
I've lost tangible shards of my sanity to Python packaging and some of my poor coworkers are fighting the terribly useless fight regularly still to this day.
Worse, most Python projects that have any non-trivial dependencies usually entail NumPy, SciPy, or Cython.
Have you ever packaged something that's using multiple C and Fortran dependencies for automated deployment? It's horrific.
Meanwhile, back when I'm at home and I use jBlas or any other Clojure, Java, or Scala library here's what I have to do:
Add dependency to project.clj:
[bulwark "0.0.3"]
Ship the jar. lein deploy $maven_repo
Writing Clojure code at home is incomparably more pleasant not just in pure code, but in all the accouterments and tooling as well.You can also package all your code and its dependencies into a single jar, then copy that jar to your to your provider and run it.
It's pretty easy basically, and more advanced options are available, but even if it was more involved, I think the benefits you get with Clojure are big enough that I'd be willing to put up with quite a bit more difficulty than there is.
I just can't do anything like `data Tree a = Leaf a | Node [Tree a]` there.
(Edit: okay, my mind swayed a bit, that was trees, not graphs. I had different ideas on data structure to use, and my memories are a bit messy. Sorry about this. The problem should still hold, it applies to both trees and graphs, and I think many other data structures too.)
class HashMap[A, B] extends AbstractMap[A, B] with Map[A, B] with MapLike[A, B, HashMap[A, B]] with HashTable[A, DefaultEntry[A, B]] with CustomParallelizable[(A, B), ParHashMap[A, B]] with Serializable
If that's what the type system is going to end up being with generics I'd rather just cast things. Sometimes less is more.
http://commandcenter.blogspot.com/2012/06/less-is-exponentia...
Class HashMap is parametrized over two types, A and B (presumably, key and value types). The rest seems to be implementation details, that play no importance unless you're going to actually use them. Just as integers are totally ordered, but unless you have use to that fact (i.e. comparing those integers), you can safely ignore that.
Same as with interfaces - if there's a interface Foo { ... } somewhere, you don't have to care your types implement it unless you're actually using it.
Even if you stuff the algorithms into the same type you have your data in (like most generic languages seem to encourage you to do), you still only have to type-cast/type-switch on getters and callbacks. And the only major missing requirement I can think of is that your nodes aren't guaranteed to be of homogeneous types (and you can hack that with a callback if you want).
Which is precisely why he wants generic types.
> "Consider your algorithms as functions which act on an interface."
How would he write a function that explicitly expects a graph whose nodes contain ints, and not, say, strings? What kind of interface would that function act upon?
> "you still only have to type-cast/type-switch on getters and callbacks."
The whole point is not having to do that.
The up-to-date Go Users page is at http://code.google.com/p/go-wiki/wiki/GoUsers
> "Strongly typed (with dyamic casting)" > "while Go is statically typed, it has a strong system for dynamic casting and reflection".
This is not even wrong. The whole point to using types is to make strong guarantees about the meaning of programs without even having to run them. Dynamic casting and reflection destroy the usefulness of these guarantees, by virtue of their semantics depending on information only avaluable at runtime. Strong typing with dynamic casting and reflection is like a safe knife whose handle is a blade!
> "Really good at concurrent stuff, pretty fast"
Give me a break. Concurrency support is all about compartmentalizing the use of resources as much as possible, reducing sharing between the concurrent units of computation (processes, tasks, goroutines, whatever you want to call them) to the bare minimum required for the program as a whole to serve its goal. How does Go's shared memory model help in this regard? This fundamental inadequacy has negative consequences both for correctness (synchronization is a convention, it is not actually enforced) and for performance (Go needs a stop-the-world garbage collector).
===
Go might have been barely interesting ten or fifteen years ago, but in 2013, this kind of design has to be rejected as mediocre.
I have nothing against Google, but their programming languages (at least, the ones that I know of), Dart and Go, are really mediocre and uninspiring. For all their bad reputation, Microsoft at least has F# and is indirectly involved in the development of Haskell. Even Microsoft's take at an objected-oriented language for the uneducated masses, C#, is much better than the Google- and Apple-endorsed alternatives (Java and Objective-C).
It does not force you to check, but if you wanted to "catch" the "exception" (really, "recover from the panic"), here's how you would do that. Note that this is admittedly a somewhat unidiomatic use of recover(): http://play.golang.org/p/dAQ01dus9Y
http://play.golang.org/p/vEmiqUyPag
Division by zero in floating point is well defined and useful, and does not produce a runtime exception. So why is this a compile time error?
Edit And it produces the wrong result for division by negative zero: http://play.golang.org/p/DKoVG0Vlaf It should be -Inf, not +Inf. Go's floating point math is whack.
If you divide by a literal 0, this is a compile-time error, so there's no panic (and no need to recover()): http://play.golang.org/p/E0jSDAHwtg
Golang has a GUI tool kit: the "net/http" and "html/template" packages. While I personally hate EcmaScript with a passion, I have to admit every single GUI tool kit or windowing system I've worked with had serious fundamental design flaws not unlike JavaScript and the DOM. The entire scenario is not unlike the Tcl\Tk days. People will bitch and whine but will do so while using it until something better comes up.
The article is written from the point of view of a game developer. He means UIKit or WPF. Most games used to write their own UI controls.
I just find this somewhat frustrating given that we also have the massive NSA surveillance scandal unfolding. Because I'd like to think that intelligent, free-thinking hackers would opt for using products & technologies from companies & organizations not so directly, deeply, and intricately involved in said scandal.
Anyway, kudos to Dan for his detailed article - I'm sure he could care less about the political alignment of the corporation he is getting his tools from - and really it should be about technology first; so if Golang fits his needs most optimally then by all means that's what he should be using. Just saying, don't forget about the alternatives ;)
I'd love to hear evidence of this relationship instead of your speculative fear mongering.
I guess it's what passes for valid to the politically naive.
Like I said, I share your concerns about PRISM but singling out Google seems like losing the forest for a tree when we have abundant evidence that all the US tech giants have been forced to comply with NSA requests.
Besides that, why give them the benefit of the doubt anyway?
I have no qualms about singling out Google. Of all the 'giants' this is a company that has the most volume, quality, and relevant information on all of us. They need to be held accountable & scrutinized to the highest degree in the handling of said data. The fact that they are the company most active in their business relations & engagements with the intel sector should be ringing alarm bells.
And indeed, other tech giants should share the blame for being involved in PRISM - I tend to single-out Google because of their long & documented history in doing business with the NSA and other intelligence agencies like the CIA.
http://english.pravda.ru/opinion/columnists/17-06-2013/12484...
And there is plenty of other reading material to review regarding Google's history with the NSA (see my other links posted in the nested comment below).
Perhaps I should not have said "directly, deeply, and intricately involved in said scandal" in the tone of 'matter of fact' - because it is indeed an opinion, but I'm just drawing what I feel are logical conclusions. IMO Google is the NSA's primary Trojan Horse into the free market. I am in no means declaring this as fact, like I said originally - just wanted to drop my '2 cents' if that's OK.
[0] https://plus.google.com/app/basic/stream/z13qvvpjivahzpnbo04... (Yonatan Zunger [Chief Architect, Google+] denies PRISM wholesale)
In all fairness, before today my last comment was 46 days ago. And before that there are only handful of comments regarding this issue - looks like all within the same week of the NSA news breaking.
Anyway, next time perhaps I can simply write an article and submit it as a separate thread; rather than speaking out in the thread itself. Thanks again.
Hell, NodeJS is backed by Joynet.. does that mean I shouldn't use that platform since I don't plan on hosting with Joyent?
I think it's pretty important to at least try to keep the politics out of certain technology decisions. Sometimes it may well become important, sometimes it is less so.
Also we can't constantly deal with the NSA, we do have work to get done and things to learn.