First of all, thanks for taking the time to expand your comment.
On Friday, March 28, 2014 4:22:14 AM UTC-7, yiyus wrote:
(Replying to several messages)
The Rationale section first talks about the matrix support in other
languages. Then, it presents a treatment of them much more limited
than in these other languages, and it is implicitly assumed that this
is enough to make Go as convenient and fast as them. I think that
needs more proof.
>
Here's some more example code. I'm sorry I don't have a full implementation
of the algorithm. I started a Go implementation in the past, but my needs
changed and I no longer needed it.
http://play.golang.org/p/S00rP4KdoqThe code shows one method of a Gaussian Process implementation (a type of
regression algorithm). The method adds a new data point to the training
data, and updates the kernel matrix. The kernel matrix is an NxN matrix,
where the i, j th element contains kernelFunc(input_i, input_j). The
actual matrix math (and what makes it a gaussian process) happens in
different methods.
The two codes are roughly the same number of lines, but I would argue that
the table version is much better. Aside from the type definition, the table
version only relies on language features and built-ins -- concepts that
will be familiar to any reader of go. It stands reasonably well on its own
with minor comments, and it is easy to implement with only Go knowledge.
The implementation with the current version, is much trickier. Its use of
the matrix package is non-standard, and thus it must rely on subtleties of
the matrix package. The reader must have knowledge of the inner workings of
the matrix package in order to understand the code (possibly even with good
comments), making it harder to read and even harder to write. In addition,
the code author is incentivized to break the Matrix abstraction of the type
and instead work with the underlying data, not only because of speed, but
also because some of the operations are difficult to fit within the
workings of the current package.
There have been a couple of comments implying that the main goal is to
use Go for complex projects where performance is important. I'm
currently working on some projects like this, and the reasons I do not
use Go do not change with the introduction of tables. For some
context: I need to do lots of tensor algebra. Since the dimensions of
these tensors are usually fixed, I can just use arrays.
I also do a fair amount of matrix algebra. My sizes are almost never fixed.
Both cases are common, and depend on the domain.
These programs
are doing calculations for days in many processors, so every bit of
performance is important here. Currently, having to write loops for
matrix operations makes complex algorithms really unreadable (I've
fixed quite a few bugs just translating FORTRAN 77 code with loops to
array operations in Fortran 90). Using functions and methods is also
an option, but tables do not allow me to define a type for a column or
a row of a matrix (the options are to use a slice and make a copy or
use a 2d table, which are far from optimal). Also, although I admit
I've not run benchmarks, I doubt Go can achieve the performance of
Fortran compilers (I think it is naive to be optimist here).
Any reason in favor of skepticism? Go does not yet achieve the performance
of Fortran, but that's not the same as "can't" or "won't". I don't know
enough about compiler's or Fortran to have an opinion, but I've heard it
expressed on this list that certain properties of Go mean that
Fortran-style optimizations are possible (ones which are not possible in C).
Of course, I would like to have concurrency, the Go standard library, and
the confy development environment that Go provides in these projects,
but only if it doesn't imply a significant loss of readability and
performance.
Tables help improve readability and performance
All this said, scientific computing is a very general term, but the
particular problems each of us try to solve with it are usually very
specific. The fact that tables do not help with my problems does not
mean they cannot help with many others. Obviously, a matrix type will
help to write matrix algebra packages, but it doesn't look to me like
it is going to suppose a big improvement for the users of those
packages.
If all you want to do is multiply and do a linear solve, that's probably
true (assuming the chosen linear solve implementation is okay for your
problem; there are lots of ways to do it with different properties). If
your needs can't be expressed by common functions (or the implementations
don't suit your needs), then that's not true. Tables help speed,
legibility, and simplicity. Additionally, tables will probably find use for
much more than matrix math; a table represents any set of "rectangular" data
Its usage in image processing is a valid and strong point,
and I'm sure there will be other interesting ones. But I don't think
this change is going to suppose a significant boost in the adoption of
Go by the scientific community (though I'd like to be wrong), and the
cost is not low.
I disagree that it won't be a significant boost (as is probably clear).
One of the major selling points about Go is the standard library. "It's got
everything you need, look how easy it is to write an http server! Not only
that, but the standard library is very well written, well documented, and
easy to follow". The problem is that for numeric computing, there are only
the bare building blocks (math and math/rand mostly). It will be much
easier to sell Go once there is a stable, functional, and fast numpy
equivalent. Those of us who see the upsides to Go as a great language for
software have been working on building such a library. The lack of a table
type has made the code trickier to write and more error-prone, which slows
down the (volunteer-time) development. Additionally, it is harder to read
the internals of the matrix package (which is frequently useful as a user),
and it is often necessary to break the abstraction to get performance.
Tables improve legibility, usability, speed, and the ease of writing
correct code. It's hard for me to see how that isn't a boost, and again,
tables will likely find uses beyond [,]float64 and [,]cmplx128.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit
https://groups.google.com/d/optout.