News for hackers. Stuff that matters.
Re:Why Go? Use Racket by nine_k on Thursday March 12, 2015 @02:23PM (#9192707)
No. Because static typing.

However much Go's type system might lack some means of expression, the type system is there, and it prevents many bugs that can easily crop up while using a dynamic language.

I'd rather say 'use OCaml' or 'use F#' or even 'use Haskell'.

Re:Why Go? Use Racket by rdtsc on Thursday March 12, 2015 @02:53PM (#9192940)
Or Clojure or Erlang. Funny enough out of "functional" languages those have probably just as much (or even more) been used to develop distributed, fault tolerant systems than F# or Haskell. Just saying.

BTW both Clojure and Erlang allow a form a gradual typing.

From personal experience. I've used both static (C#, C++, Java) and dynamic typing (Python, Erlang), and have to say, the prevents-many-bugs excuse as the main problem with dynamic types just wasn't true.

Maybe my code is more complicated and dealing with distributed state, consistency, and protocols but what what kills everything is usually logic errors, network failures, files not being there, misconfiguration, segfaults, user-after-free, and the most evil ones, shared global states in a concurrent shared-heap environment.

Things like "oh I expected an int but got a string" are pretty trivial and easy discovered.

Moreover, in a recent service I implemented. I did in Python and I believe the faster development time and less code to write in general, gave me time to write better integration tests that exercises and covered the code a lot better. I would have had to write the tests anyway, even if this was written in Haskell.

Perhaps static typing helps a lot more in large code bases. Think of a large game, or a CAD application or some huge C++ back-end. But, if you buying into the whole micro-services fad, well, you shouldn't have large code bases if you can help it.

Another big motivation for types, which I think most people have in mind when they pick a strongly typed language is performance. Usually static typing and a very large performance increase would go hand in hand. Now with the effort put into v8 and PyPy we see that gap getting smaller.

Re:Why Go? Use Racket by lomnakkus on Thursday March 12, 2015 @03:08PM (#9193031)
> Or Clojure or Erlang. Funny enough out of "functional" languages those have probably just as much (or even more) been used to develop distributed, fault tolerant systems than F# or Haskell. Just saying.

(I generally agree with the gist of your comment, I think. This just stuck out.)

I don't believe Clojure belongs in that class (as "proven" for writing reliable software), but whatever.

If you want truly reliable software and have the budget, then you just need to throw process at the problem -- it doesn't matter much which language you use. Several (if not all) the Mars landers were programmed in C -- with very few critical flaws experienced/discovered[2]. The Ericsson switches that achieved previously-unheard-of reliability were programmed in Erlang, but they used process and a huge number of engineers to achieve that. (Plus they're mostly stateless and so can just reset if they do it fast enough and don't lose important state when doing so.)

For large-scale software which has to evolve fast, I belive strong type systems do win out. It's not so much that they prevent bugs which could be caught by test suites, but having a strong type system means that you can be certain that there are a lot of tests that you actually will never have to write or, more importantly, rewrite as the system evolves.

There have been actual studies which may be of interest[1], but even if I'm on the "winning" side, I don't think I would put too much stock in the methodology/analysis of this particular study. (E.g. concluding that JavaScript suffers from few concurrency bugs relative to other languages is kind of being oblivious of the fact that JS is single-threaded (semantically) and that all the other languages in the comparison permit "real" concurrency/parallellism, and that it should thus perhaps be excluded from the category or at least treated separately.)

[1] http://macbeth.cs.ucdavis.edu/lang_study.pdf

[2] https://www.usenix.org/conference/hotdep12/workshop-program/...

(Sorry, references out of order because edited-post-facto)

Re:Why Go? Use Racket by mietek on Thursday March 12, 2015 @04:21PM (#9193587)
> If you want truly reliable software and have the budget, then you just need to throw process at the problem -- it doesn't matter much which language you use.

I also generally agree with your comment, but I have to take issue with this statement. If this were true, Ericsson wouldn’t have had to abandon the AXE-N project.

Quoting from Joe Armstrong’s PhD thesis[1]:

“1995: The AXE-N project was a project to build a “next generation switch” to replace the Ericsson AXE-10. This extremely large project ran from 1987-95. After the AXE-N project collapsed a decision was made to “restart” the project using Erlang. This project eventually resulted in the development of the AXD301 switch.”

“During the period 1996–1997 a three-person group (myself, Magnus Fröberg and Martin Björklund) redesigned and implemented the OTP core libraries.”

“1998: Ericsson delivered the first AXD301. The AXD301 is the subject of one of our case studies in Chapter 8. At the time of writing (2003) the AXD301 has over 1.7 million lines of Erlang code which probably makes it the largest system ever to be written in a functional style of programming.”

[1]: http://www.erlang.org/download/armstrong_thesis_2003.pdf

Re:Why Go? Use Racket by lomnakkus on Thursday March 12, 2015 @04:34PM (#9193689)
Thanks for digging out the history. I don't think we can conclude from your excerpts that the deciding factor was Erlang. However, I accept that my statement that it was "just engineers and process" may have been exaggerated or mistaken.
Re:Why Go? Use Racket by mietek on Thursday March 12, 2015 @04:44PM (#9193760)
The deciding factor, as always, is the ability to manage complexity. There are many ways to improve this ability, and process is certainly one of them, however, the choice of programming language is, to my mind, the most important one.

XenSource/Citrix is another great example[1]:

“In 2002, members of Cambridge University released the open source Xen project to provide free high-performance virtualization technology for the masses.”

“In 2004, the team founded the company XenSource and began developing the enterprise-level distributed management software that would make virtualization easy and form the backbone of their products in the years to come. A team of thirty dedicated programmers in Palo Alto California began developing the software in C, Python and Ruby.”

“Two years later, the US team had succeeded in burning tens of millions of dollars funding but had failed to produce any product. So XenSource, under new management, took the bold step of replacing their large team of US developers with a team of only four British OCaml developers. Within months, all of the Python and Ruby was replaced, both reliability and performance were dramatically improved and the company shipped their first product. One year later, XenSource sold to Citrix for $500M.”

[1]: http://ocamlnews.blogspot.co.uk/2008/11/stunning-slides-abou...

Re:Why Go? Use Racket by lomnakkus on Thursday March 12, 2015 @04:54PM (#9193836)
Indeed. I must admit that my pro-FP inner geek giggled just a little bit at this bit of "money talks".

I think it's imperative to question the "reliability and performance were dramatically improved" kinds of statements with quantitative research. It's just that this kind of research is insanely hard.

(Disclosure: I'm definitely on the FP team, but I want do be able to argue objectively and quantitatively for the benefits of my approach.)

Re:Why Go? Use Racket by mietek on Thursday March 12, 2015 @05:09PM (#9193944)
I fully agree. Have you seen the 1994 Hudak study[1]?

“A simplified version of real-world problem was chosen by the Naval Surface Warfare Center (NSWC). This problem, a geometric region server (geo-server) is one component of a much larger system, NSWC’s AEGIS Weapons System (AWS), which NSWC is in the process of redesigning.”

“The participants, each considered an expert programmer in one of the programming languages being tested, was asked to write a fully functional prototype of the geo-server, while keeping track of software development metrics such as development time and lines of code and documentation.”

“The results indicate that the Haskell prototype took significantly less time to develop and was considerably more concise and easier to understand than the corresponding prototypes written in several different imperative languages, including Ada and C++.”

[1]: http://www.cs.yale.edu/publications/techreports/tr1049.pdf

Re:Why Go? Use Racket by lomnakkus on Thursday March 12, 2015 @05:52PM (#9194188)
Yes, indeed, I've read it. Unfortunately, I think we should regard the early studies (such as Hudak's) as basically preliminary and mostly not-well-founded. I know that's horribly conservative, but y'know...
Re:Why Go? Use Racket by sheepmullet on Thursday March 12, 2015 @04:16PM (#9193552)
In the study you linked to Clojure code is basically as bug free as Haskell and Scala code and Erlang code isn't far behind.
Re:Why Go? Use Racket by lomnakkus on Thursday March 12, 2015 @04:40PM (#9193729)
As I recall they conclude that the general stats show that "static-functional" is more bug-free than "dynamic-functional" which is more bug-free than "static-procedural/dynamic-procedural", which is more bug-free than...

As I said, I'm not sure I buy into the whole design/classification/statistical scheme of the study myself, so YMMV.

Re:Why Go? Use Racket by nine_k on Thursday March 12, 2015 @03:15PM (#9193068)
Of course everything is a tradeoff; using a static type system is not free. If anything, types also serve as always-in-sync documentation.

Gradual typing that Erlang and Clojure (both excellent languages) introduce is also a tradeoff: you usually want strict static checks on the outer interfaces of your modules, and/or along the most critical chains of computation. So you build it on top of your dynamic language; I've seen such things done in Python, too.

Re:Why Go? Use Racket by wtetzner on Thursday March 12, 2015 @02:24PM (#9192717)
Or 'use Typed Racket'.
Re:Why Go? Use Racket by nine_k on Thursday March 12, 2015 @03:07PM (#9193024)
Unfortunately, the article in question did not mention words 'typed' or 'static' at all.

I didn't know about Typed Racket; I suppose it might be a kind of gradual / optional typing somehow simila to what Clojure has.

Re:Why Go? Use Racket by michaelsbradley on Thursday March 12, 2015 @03:11PM (#9193045)
Clojure's gradual typing system is heavily inspired by Typed Racket, which preceded it.

https://twitter.com/ambrosebs/status/262387983339098113

For more information, see Ambrose Bonnaire-Sergeant' dissertation:

A Practical Optional Type System for Clojure

https://cloud.github.com/downloads/frenchy64/papers/ambrose-...