
GoPlus – The Go+ language for data science - dx034
https://www.github.com/qiniu/goplus
======
WoodenChair
IMHO these conveniences should just be in the language. List comprehensions,
dictionary comprehensions, and short-hand for literals are the kind of
syntactic sugar that have almost no downsides, save you some RSI, and make
code more readable. I'm surprised comprehensions in particular haven't spread
to more modern languages.

~~~
zmmmmm
> I'm surprised comprehensions in particular haven't spread to more modern
> languages.

I've come to dislike list comprehensions. Simple ones are ok but they do not
handle incremental complexity well. Invariably it means code slowly becomes
really unreadable as time goes by because nobody wants to rewrite the list
comprehension when one more little tweak stuffed in there will do the job.

I much prefer object-functional chaining style ala Scala, Groovy, Ruby etc:

    
    
        some_giant_list
          .findAll { it.foo > 20 }
          .groupBy { it.bar }
          .countBy { it.value.size() > 5 }
    

They scale much better over time as new constructs get inserted as functional
additions in the sequential pipeline.

~~~
ascotan
They're great until you find something like this in code:

[x for y in z for x in zz if y in x]

Then you begin to wonder how great they really are.

~~~
wenc
Also, most data scientists presumably have some advanced math background so
it's akin to reading set-builder notation (albeit with listcomps the sets are
sometimes nested). Your listcomp reads:

{x : y ∈ z, x ∈ zz | y ∈ x}

If you've read enough statistics/ML papers, this becomes second nature.

~~~
JNRowe
> If you've read enough statistics/ML papers, this becomes second nature.

As someone who breathes that style of notation, there is excellent support in
vim and emacs for custom display for readability. Conceal syntax in
vim¹(builtin for rust/help/$few_others and external such as vim-cute-python²),
and pretty-mode³ in emacs. I'm sure similar things exist in other editors too,
but I don't use those ;)

You don't get the exact representation in your example with the things I've
mentioned, but if you're used to a more "mathy"-style they really are quite
nice. YM[and taste]MV.

1\.
[http://vimdoc.sourceforge.net/htmldoc/syntax.html#conceal](http://vimdoc.sourceforge.net/htmldoc/syntax.html#conceal)

2\. [https://github.com/ehamberg/vim-cute-
python](https://github.com/ehamberg/vim-cute-python) (moresymbols branch for
er… more symbols)

3\. [https://github.com/akatov/pretty-mode](https://github.com/akatov/pretty-
mode)

------
maddyboo
I love the idea of main-less Go scripts for times where you just want to do
something simple, fast.

Neugram [1] aimed to make Go a better scripting tool, but unfortunately it
seems the project is dead. Although Go+ says its focus is on data science, I
think it could fill this niche too.

By the way: does Go+ have shebang support?

1: [https://github.com/neugram/ng](https://github.com/neugram/ng)

~~~
stevekemp
Go doesn't need to have shebang support, the kernel will provide that. But for
the record it will work:

    
    
            frodo ~ $ cat t.go 
            //opt/go/bin/go run $0 $@ ; exit
            package main
            import( "fmt" )
    
            func main() {
               fmt.Printf("Hello, world\n" );
            }
    
            frodo ~ $ ./t.go
            Hello, world
    

Otherwise there are a bunch of go-interpreters out there, which can be used
for adhoc scripting. I'm sure that in some circumstances they can be useful,
but I've only used them for providing extensions / scripting to host-
applications, rather than trying to use them interactively.

~~~
maddyboo
I’m specifically asking about Go+ (not Go) “having” shebang support in that
you can legally use the standard #! shebang. Yes, the kernel handles the
shebang, but if the shebang target doesn’t ignore the line and errors then
that’s where the problem lies.

The workarounds mentioned by you and the other commenter’s linked article are
sub-optional in that they require a system-wide modification, require wrapper
scripts, or are non-standard hacks.

------
cpgeier
I have a feeling languages like this have their niche cases however I'm not
getting a good reason for why this is need when compared to Python for data
science. Maybe I'm missing something but this is essentially a wrapper for
Golang code to make it feel more like Python.

~~~
DataJunkie
Agreed, but it might be useful for a full stack data scientist that is forced
to work in a Go systems environment.

That's why Python+PyData has had so much success. There are packages to
support data science, but the language itself can also be used to implement a
system, so integration is rather seamless. That's not true for, say, R.

~~~
techwizrd
I use Python and R for data science, and I've never had any issue with R. In
fact, I find that many tasks are much simpler in R than in Python.

~~~
DataJunkie
I am referring to using R to build systems. It's not common.

~~~
cepth
What would you consider a system? Python definitely has more market share than
R, but there's still name brand companies of various sizes that use an R stack
for data science.

RStudio lists dozens of example clients here:
[https://rstudio.com/about/customer-
stories/](https://rstudio.com/about/customer-stories/).

Use cases include collaborative model development, EDA tools, dashboarding,
printed report generation (PDFs and HTML), public facing websites, etc.

------
bumbledraven
_We introduce rational number as native Go+ types. We use -r suffix as a
rational constant. For example, (1r << 200) means a big int whose value is
equal to 2200. And 4/5r means the rational constant 4/5._

Nice! Coming from Python, I miss being able to use the normal arithmetic
operators on bigints in Go.

------
xushiwei
I'm founder of the Go+ project. And thanks for your attention. We run this
project very seriously. It will be released weekly until version 1.0 is
released.

~~~
dx034
Thank you so much for this! I submitted it here because I stumbled across it
and was really surprised that it hadn't been on HN yet! If we somehow get Go+
in a Jupyter Kernel that would be awesome!

------
yahyaheee
I feel where they are trying to go with this, I wrote
[https://github.com/aunum/gold](https://github.com/aunum/gold) in Go because
of all the nice parts of Go.

This solves some of the pain points but is still fatally flawed as any other
Go ML tool in that it can’t accelerate due to the Go<->C FFI.

Until that issue is resolved Go simply won’t be broadly accepted in data
science.

~~~
mleonhard
Would you please explain?

~~~
yahyaheee
So due to how Go handles memory, it needs to do something called "trampoline",
over to the C stack. This causes Go->C calls to have a substantial overhead
70-200ns/op. Most other languages that value is closer to 1ns. This means that
every call to a GPU suffers from this latency.

This isn't too much of a problem if your doing all supervised learning with
batch operations because the speedup of a GPU over a bigger operation
outweighs the FFI latency.

However, it's a problem that doesn't appear to have a solution due to Go's
memory management choices, and will hamper it ever being used for accelerated
computing problems. This is one of the reasons Rust moved to using ownership
rules.

You can read a bit more at [https://dave.cheney.net/2016/01/18/cgo-is-not-
go](https://dave.cheney.net/2016/01/18/cgo-is-not-go)

------
pjmlp
Nice improvement, but given the community's receptions regarding such kind of
changes, why not just make use of Julia, Ocaml, F#?

------
sk0g
This is very cool! I wonder what the chances of this being pulled into Go
proper is, and whether the lack of cgo is an intractable issue, which would
rule it out entirely.

~~~
maxmcd
The error handing is similar enough to a go proposal that was rejected:
[https://github.com/qiniu/goplus/wiki/Error-
Handling](https://github.com/qiniu/goplus/wiki/Error-Handling)

    
    
        foo()? // for goplus
        try(foo()) // the go proposal
    

[https://github.com/golang/go/issues/32437](https://github.com/golang/go/issues/32437)

------
waheoo
Why not gosci? Anything with plus in the name is awful to google. Then again,
go is a similarly awful thing to google so I guess youre in good company.

------
rhacker
I'm not a Go user, but is the important idea here that it can be run from a
scriptingish environment like Jupyter or something?

~~~
sk0g
It's significant syntactic sugar that brings it closer to Python, but no
notebook support from what I can see.

Do any notebooks support a compiled language?

~~~
pasokan
There is support for many languages Haskell ::
[https://github.com/gibiansky/IHaskell](https://github.com/gibiansky/IHaskell)
Rust :: [https://github.com/google/evcxr](https://github.com/google/evcxr)

[https://github.com/jupyter/jupyter/wiki/Jupyter-
kernels](https://github.com/jupyter/jupyter/wiki/Jupyter-kernels) will give
you a more detailed list

------
johnmc408
Is there any talk on changing garbage collection from standard go? Is that
needed in the data science world?

------
zshbleaker
Surprisingly to see my former employer on HN lol. Better than qiniulang in
many ways.

------
zactato
Can we try our best to not fork languages? Someone in 8 years is going to have
to refactor a bunch of this GoPlus code to be compatible the Go2 or Go3 and
it’s going to suck.

We already have Python and Scala

~~~
hombre_fatal
You're barking up the wrong tree.

------
svntid
I love it!

------
scared2
It will end up being like Google plus

~~~
xushiweizh
This project is not owned by Google.

