Re: [go-nuts] golang as ML backend v/s C++

2024-04-14 Thread Randall O'Reilly
https://github.com/go-python/gopy can manage the python bindings for you 
automatically.  The bigger issue for ML is GPU.  I wrote a gosl (Go shader 
language) package that converts Go to hlsl which can be compiled in vulkan for 
compute shaders -- works well for my needs: https://github.com/emer/gosl   The 
same approach should also work for generating CUDA code, but I was already 
using vulkan in Go so that was easier.

In any case, after doing all the work of making my Go-based models available in 
Python via gopy, almost everyone found it easier to just use the Go models 
directly :)  That's the thing about Go: you really don't need the python front 
end in the same way that you do for C++, which takes so much longer to build, 
and is so unpleasant to code in.

The rest of the world will almost certainly keep using python and its 
established toolkits, so there isn't much hope of changing the ecosystem, but 
if you have some specific use-case and enjoy coding in Go, you can most likely 
make it work for you and some of your close friends :)

- Randy

> On Apr 14, 2024, at 10:31 PM, envee  wrote:
> 
> "
> - python -> c++ is one less layer of complexity to reason about than python 
> -> c -> go 
> "
> But doesn't the numpy package already use ctypes, for example ?maybe not a 
> golang-nuts question, but I was just wondering what is it that C++ can 
> perhaps do that Go cannot when creating bindings for Python ?
> 
> On Mon, Apr 15, 2024 at 1:05 PM Matt Parker  wrote:
> - python -> c++ is one less layer of complexity to reason about than python 
> -> c -> go
> - the go runtime is great for developer ergonomics, but is going to cost more 
> flops than equivalent code in c++ because of features like garbage 
> collection. additionally the concurrent features of go are great but 
> concurrent ML backends will probably be used a lot more than they are read + 
> written, so probably a fair tradeoff to sacrifice readability for performance 
> here. 
> On Sunday, April 14, 2024 at 8:15:51 AM UTC-4 envee wrote:
> After reading briefly about ML and how Python is used as a "veneer" for C++ 
> code, I was wondering why Go is not used as the backend, given it's excellent 
> concurrency support and ease of use.
> Basically, I was thinking if the backend is written as a shared object in Go, 
> and then used in Python using ctypes.
> I have seen a huge number of libraries on the awesome-go website, but don't 
> know if they have Python bindings.
> Any views ?
> What really is a limitation which does not encourage developers to prefer Go 
> over C++ as the ML backend ?
> 
> -- 
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/dc8d6282-d1cf-43db-a0ee-a1347e345638n%40googlegroups.com.
> 
> -- 
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/CALFCev5_64WLaXJrxAT8e8EDr5ts7xXO47gc91vONedETUQ9rg%40mail.gmail.com.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/D9FF9D25-3877-4E11-AFFE-CAEFA8DFDEF9%40gmail.com.


Re: [go-nuts] Re: golang as ML backend v/s C++

2024-04-14 Thread envee
"
- python -> c++ is one less layer of complexity to reason about than python
-> c -> go
"
But doesn't the numpy package already use ctypes, for example ?maybe not a
golang-nuts question, but I was just wondering what is it that C++ can
perhaps do that Go cannot when creating bindings for Python ?

On Mon, Apr 15, 2024 at 1:05 PM Matt Parker  wrote:

> - python -> c++ is one less layer of complexity to reason about than
> python -> c -> go
> - the go runtime is great for developer ergonomics, but is going to cost
> more flops than equivalent code in c++ because of features like garbage
> collection. additionally the concurrent features of go are great but
> concurrent ML backends will probably be used a lot more than they are read
> + written, so probably a fair tradeoff to sacrifice readability for
> performance here.
> On Sunday, April 14, 2024 at 8:15:51 AM UTC-4 envee wrote:
>
>> After reading briefly about ML and how Python is used as a "veneer" for
>> C++ code, I was wondering why Go is not used as the backend, given it's
>> excellent concurrency support and ease of use.
>> Basically, I was thinking if the backend is written as a shared object in
>> Go, and then used in Python using ctypes.
>> I have seen a huge number of libraries on the awesome-go website, but
>> don't know if they have Python bindings.
>> Any views ?
>> What really is a limitation which does not encourage developers to prefer
>> Go over C++ as the ML backend ?
>>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/dc8d6282-d1cf-43db-a0ee-a1347e345638n%40googlegroups.com
> 
> .
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CALFCev5_64WLaXJrxAT8e8EDr5ts7xXO47gc91vONedETUQ9rg%40mail.gmail.com.


Re: [go-nuts] TestCopyNWriteTo

2024-04-14 Thread Ian Lance Taylor
On Sun, Apr 14, 2024 at 8:05 PM Stephen  wrote:
>
> https://github.com/golang/go/blob/c0a0ba254c48fc855f9501b0bd3b78e6847ca923/src/io/io_test.go#L167
>
> I was walking through this code, and it didn't seem to hit [WriteTo] 
> (https://github.com/golang/go/blob/c0a0ba254c48fc855f9501b0bd3b78e6847ca923/src/io/io.go#L410-L412)
>  because of LimitReader
>
> Is this intended behavior?

The purpose of the test is to make sure that CopyN does the correct
thing even if the source type implements WriteTo.  So, yes, this is
intended behavior.

Ian

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcXL%3DctU1qa%3DjdVpFudSEfGcH3aTt-c860mjoiyeEOBWnA%40mail.gmail.com.


[go-nuts] Re: golang as ML backend v/s C++

2024-04-14 Thread Matt Parker
- python -> c++ is one less layer of complexity to reason about than python 
-> c -> go
- the go runtime is great for developer ergonomics, but is going to cost 
more flops than equivalent code in c++ because of features like garbage 
collection. additionally the concurrent features of go are great but 
concurrent ML backends will probably be used a lot more than they are read 
+ written, so probably a fair tradeoff to sacrifice readability for 
performance here. 
On Sunday, April 14, 2024 at 8:15:51 AM UTC-4 envee wrote:

> After reading briefly about ML and how Python is used as a "veneer" for 
> C++ code, I was wondering why Go is not used as the backend, given it's 
> excellent concurrency support and ease of use.
> Basically, I was thinking if the backend is written as a shared object in 
> Go, and then used in Python using ctypes.
> I have seen a huge number of libraries on the awesome-go website, but 
> don't know if they have Python bindings.
> Any views ?
> What really is a limitation which does not encourage developers to prefer 
> Go over C++ as the ML backend ?
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/dc8d6282-d1cf-43db-a0ee-a1347e345638n%40googlegroups.com.


[go-nuts] TestCopyNWriteTo

2024-04-14 Thread Stephen
https://github.com/golang/go/blob/c0a0ba254c48fc855f9501b0bd3b78e6847ca923/src/io/io_test.go#L167

I was walking through this code, and it didn't seem to hit [WriteTo] 
(https://github.com/golang/go/blob/c0a0ba254c48fc855f9501b0bd3b78e6847ca923/src/io/io.go#L410-L412)
 
because of LimitReader

Is this intended behavior?  

1. TestCopyNWriteTo does not assert if `WriteTo` is called.  It should 
either add this or test should be renamed.
2. WriteTo not called using CopyN,
 
```
func TestCopyNWriteTo(t *testing.T) {
rb := new(writeToChecker) // implements WriteTo.
wb := new(Buffer)
rb.WriteString("hello, world.")
CopyN(wb, rb, 5)
if wb.String() != "hello" {
t.Errorf("CopyN did not work properly")
} else if !rb.writeToCalled {
t.Errorf("CopyN does not use writeTo")
}
}
```

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/a79a8234-2223-44cd-81f4-d93ee3e45516n%40googlegroups.com.


Re: [go-nuts] Is json.Marshal deterministic?

2024-04-14 Thread Matt Parker
one of my favorite examples of this is google's protojson package, where 
the output of `json.Marshal` is [deliberately 
nondeterministic](https://protobuf.dev/reference/go/faq/#unstable-json) to 
prevent users from attempting to rely on that property
On Tuesday, April 9, 2024 at 9:10:42 AM UTC-4 Nagaev Boris wrote:

> Hi Juliusz,
>
> I don't know if JSON serialization is deterministic, but I know a couple 
> of cases when it is not.
>
> If the type or some type inside it has a custom JSON marshaller (method 
> MarshalJSON), then if that function's output is not deterministic, the 
> whole JSON for the type is not deterministic. Custom marshaller can do 
> whatever it wants, e.g. traverse maps without ordering keys, resulting in 
> non-determinism.
>
> Another common pitfall with JSON: nil vs empty slice. E.g. []string{} is 
> encoded as "[]", while []string(nil) is encoded as "null", while they both 
> mean an empty slice in Go (though NOT considered deep equal according to 
> reflect.DeepEqual). The workaround is to add `omitempty` to the JSON tag to 
> remove such fields from the encoding. Otherwise you need to make sure that 
> empty slices are always nil or always non-nil in the code producing 
> structures that are serialized.
>
> Boris
>
> On Tue, Apr 9, 2024 at 9:27 AM Juliusz Chroboczek  wrote:
>
>> Hi,
>>
>> Suppose that I call json.Marshal on two structures that are deep equal,
>> or on the same structure at different times.  Are the outputs guaranteed
>> to be bytewise identical?
>>
>> (The reason I'm asking is that I'm sending JSON over HTTP, and I need to
>> know whether it is correct to send a strong ETag with my reply even
>> though I'm generating new JSON every time.)
>>
>> Thanks,
>>
>> -- Juliusz
>>
>>
>>
>> -- 
>> 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...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/golang-nuts/87h6gag1qk.fsf%40pirx.irif.fr
>> .
>>
>
>
> -- 
> Best regards,
> Boris Nagaev
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/238bf301-a116-438a-a897-f0595596f9f9n%40googlegroups.com.


[go-nuts] Re: new in golang

2024-04-14 Thread Robert Solomon
I'm a hobby programming that's been using Go for a few years.  I'm willing 
to help; others here will likely also answer questions for you

On Sunday, April 14, 2024 at 1:47:32 PM UTC-4 leonardo lima peixoto wrote:

> Oh nice, I'm a beginner and I want to learning golang as well.
>
> Em sábado, 13 de abril de 2024 às 21:42:39 UTC-3, mokwa moffat escreveu:
>
>> I would like to have partner for learning golang. Am a beginner thank You
>>
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/f3fc3fac-b0f2-4885-99c2-2f900eb7d6e5n%40googlegroups.com.


[go-nuts] Re: new in golang

2024-04-14 Thread Robert Solomon
I'm not clear on what you're asking.  I'm a hobby programmer, and I've been 
using Go for a few years for my own purposes.

On Sunday, April 14, 2024 at 1:47:32 PM UTC-4 leonardo lima peixoto wrote:

> Oh nice, I'm a beginner and I want to learning golang as well.
>
> Em sábado, 13 de abril de 2024 às 21:42:39 UTC-3, mokwa moffat escreveu:
>
>> I would like to have partner for learning golang. Am a beginner thank You
>>
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/2a2cf88e-dbe1-4198-8a28-feeac489d888n%40googlegroups.com.


[go-nuts] Re: golang as ML backend v/s C++

2024-04-14 Thread David Green
Yeah, You are right.
I has experience of developing backend with Golang.
But it was difficult because it has no bigcommunity.
I want to make a big community of golang backend.

On Sunday, April 14, 2024 at 9:15:51 PM UTC+9 envee wrote:

> After reading briefly about ML and how Python is used as a "veneer" for 
> C++ code, I was wondering why Go is not used as the backend, given it's 
> excellent concurrency support and ease of use.
> Basically, I was thinking if the backend is written as a shared object in 
> Go, and then used in Python using ctypes.
> I have seen a huge number of libraries on the awesome-go website, but 
> don't know if they have Python bindings.
> Any views ?
> What really is a limitation which does not encourage developers to prefer 
> Go over C++ as the ML backend ?
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/f4eabfda-e899-4fcd-bfbf-5564eb14aba3n%40googlegroups.com.


[go-nuts] Re: new in golang

2024-04-14 Thread leonardo lima peixoto
Oh nice, I'm a beginner and I want to learning golang as well.

Em sábado, 13 de abril de 2024 às 21:42:39 UTC-3, mokwa moffat escreveu:

> I would like to have partner for learning golang. Am a beginner thank You
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/b612cc8e-8259-4086-90a8-8a9beee28610n%40googlegroups.com.


[go-nuts] golang as ML backend v/s C++

2024-04-14 Thread envee
After reading briefly about ML and how Python is used as a "veneer" for C++ 
code, I was wondering why Go is not used as the backend, given it's 
excellent concurrency support and ease of use.
Basically, I was thinking if the backend is written as a shared object in 
Go, and then used in Python using ctypes.
I have seen a huge number of libraries on the awesome-go website, but don't 
know if they have Python bindings.
Any views ?
What really is a limitation which does not encourage developers to prefer 
Go over C++ as the ML backend ?

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/63a67354-d5a3-48b6-8625-9aef819a5fe9n%40googlegroups.com.