Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Progressive JPEG
Feb 19, 2003

Athas posted:

Can you explain? This always seemed like a harmless if idiosyncratic design. I know of the ways people claim it can be annoying, but has it really been so in practice?

it just leads to bizarre gotchas. the original presentation iirc was rob pike using "capital" and "lower case" greek letters as an illustration

code:
package main

import ( "encoding/json"; "fmt" )

func main() {
	var jsonBlob = []byte(`{"poop": "butt", "turd": "toilet"}`)
	type GFY struct { poop string; turd string }
	var gfy GFY
	err := json.Unmarshal(jsonBlob, &gfy)
	if err != nil {
		fmt.Println("error:", err)
	}
	fmt.Printf("%+v\n", gfy)
}

$ go run main.go 
{poop: turd:}
whoops there goes your data

Adbot
ADBOT LOVES YOU

Progressive JPEG
Feb 19, 2003

to be clear i think go is fine for making cli tools since its easy to get cross compiled static binaries out of it

unless you want to use, for example, os.user from the standard library. you'd think that the library that provides platform-specific paths to things would be expected to work in cross-compiled builds, but no, it fails at runtime if the build was cross-compiled on a different OS (or did circa 9 months ago on latest)

so even in its ideal use case golang still finds ways to be obnoxious to deal with

Progressive JPEG
Feb 19, 2003

Blinkz0rz posted:

it's not silent, go is quite up front about exported and unexported fields. same deal with struct tags too. none of this is foreign to anyone who has read the documentation much less been through the learn go by example tutorial

so why should fmt.Printf("%v+") be able to retrieve unexported fields just fine when json.Unmarshal() cant find them? see above

redleader
Aug 18, 2005

Engage according to operational parameters

Progressive JPEG posted:

Jenkins implements rpcs by serializing Java objects and sending them over the wire to workers so you must have exactly the same jre across all Jenkins nodes

:eyepop:

Progressive JPEG
Feb 19, 2003

code:
/**
 * Convenient {@link Callable} meant to be run on agent.
 *
 * Note that the logic within {@link #call()} should use API of a minimum supported Remoting version.
 * See {@link RemotingVersionInfo#getMinimumSupportedVersion()}.
 *
 * @author Kohsuke Kawaguchi
 * @since 1.587 / 1.580.1
 * @param <V> the return type; note that this must either be defined in your plugin or included in the stock JEP-200 whitelist
 */
public abstract class MasterToSlaveCallable<V, T extends Throwable> implements Callable<V,T> {
there's also a SlaveToMasterCallable definition for when things get freaky and the slave wants to remotely execute some arbitrary code on the master (provided the jvms match)

for example:
code:
    /**
     * Obtains the string that represents the architecture.
     */
    private static class GetArchTask extends MasterToSlaveCallable<String,IOException> {
        public String call() {
            String os = System.getProperty("os.name");
            String arch = System.getProperty("os.arch");
            return os+" ("+arch+')';
        }

        private static final long serialVersionUID = 1L;
    }
this is all via "hudson remoting", a library that is only used by jenkins afaict (thank god)

Blinkz0rz
May 27, 2001

MY CONTEMPT FOR MY OWN EMPLOYEES IS ONLY MATCHED BY MY LOVE FOR TOM BRADY'S SWEATY MAGA BALLS

Progressive JPEG posted:

so why should fmt.Printf("%v+") be able to retrieve unexported fields just fine when json.Unmarshal() cant find them? see above

Printf doesn't use the same mechanism for accessing fields as json.Unmarshal()? Be pedantic all you want but like, this isn't complicated stuff. It's certainly opinionated, but 1 of 2 changes would have indicated what was wrong and both are very clearly documented.

1.
code:
package main

import (
	"encoding/json"
	"fmt"
)

type GFY struct {
	poop string `json:"poop"` // Adding field tags is pretty standard when dealing with structs that are going to be deserialized
	turd string `json:"turd"`
}

func main() {
	var jsonBlob = []byte(`{"poop": "butt", "turd": "toilet"}`)

	var gfy GFY
	err := json.Unmarshal(jsonBlob, &gfy)
	if err != nil {
		fmt.Println("error:", err)
	}
	fmt.Printf("%+v\n", gfy)
}

$ go vet
./main.go:9:2: struct field poop has json tag but is not exported
./main.go:10:2: struct field turd has json tag but is not exported
2.
code:
package main

import (
	"encoding/json"
	"fmt"
)

type GFY struct {
	Poop string `json:"poop"`
	Turd string `json:"turd"`
}

func main() {
	var jsonBlob = []byte(`{"poop": "butt", "turd": "toilet"}`)

	var gfy GFY
	err := json.Unmarshal(jsonBlob, &gfy)
	if err != nil {
		fmt.Println("error:", err)
	}
	fmt.Printf("%+v\n", gfy)
}

$ go run main.go
{Poop:butt Turd:toilet}
The same semantics are at play here when we talk about package accessibility and really none of it is particularly confusing.

Cybernetic Vermin
Apr 18, 2005

i mostly agree that there is no real problem with go making what seems like naming conventions into semantics, improved brevity while also communicates the accessibility of the field in every place it is used. to some extent it is made ok only because go enshrines conventions a lot more deeply than other languages *anyway* though (i.e. the very real gofmt advantage)

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
the way the go json deals with missing fields totally owns it's a great time love it thanks rob

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
using the go json package is a constant parade of footguns and unhandled 'edge cases' that actually apply to every non trivial struct, 'read the documentation' is not an excuse for this

my homie dhall
Dec 9, 2010

honey, oh please, it's just a machine
pea brain: semantic whitespace

galaxy brain: semantic capitalization

Soricidus
Oct 21, 2010
freedom-hating statist shill
suggestion: a language where all symbols are exported by default, but can be marked as non-exported by including a zero-width-non-joiner character somewhere in the name

i don't see any problems with this. it wouldn't be confusing because ides could display non-exported names in a different color, and auto-complete would solve the problem of typing the non-joiner in the right place

Captain Foo
May 11, 2004

we vibin'
we slidin'
we breathin'
we dyin'

Soricidus posted:

suggestion: a language where all symbols are exported by default, but can be marked as non-exported by including a zero-width-non-joiner character somewhere in the name

i don't see any problems with this. it wouldn't be confusing because ides could display non-exported names in a different color, and auto-complete would solve the problem of typing the non-joiner in the right place

:shuckyes:

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
is there a way to customize (de)serialization for a type at all, or does go just assume that that’s only useful for builtin types

pseudorandom name
May 6, 2007

🚨 white smoke from the rust conclave 🚨

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

rjmccall posted:

is there a way to customize (de)serialization for a type at all, or does go just assume that that’s only useful for builtin types

yeah: https://golang.org/pkg/encoding/

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

quote:

I’m working actively on drafting a stabilization report to propose stabilizing a minimum viable version of async/await in the 1.37 release of Rust. 1.37 will be released in mid-August

i declare May 28th, 2019 to be "the end of programming language history."

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?
is there a Rust implementation of L4 yet

I suppose the Rust rewrites of Mach and BSD start in August

pseudorandom name
May 6, 2007

eschaton posted:

is there a Rust implementation of L4 yet

I suppose the Rust rewrites of Mach and BSD start in August

https://fuchsia.googlesource.com/fuchsia

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

there's also a unix-like hobby os written in rust out there

sometimes i wonder if rust will be a Pixies to some Nirvana that hasn't been invented yet

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

ah right, makes sense. so this public-fields-only stuff is just the default behavior for structs that don’t define custom encoding?

Xarn
Jun 26, 2015

Blinkz0rz posted:

Printf doesn't use the same mechanism for accessing fields as json.Unmarshal()? Be pedantic all you want but like, this isn't complicated stuff. It's certainly opinionated, but 1 of 2 changes would have indicated what was wrong and both are very clearly documented.

1.
code:
package main

import (
	"encoding/json"
	"fmt"
)

type GFY struct {
	poop string `json:"poop"` // Adding field tags is pretty standard when dealing with structs that are going to be deserialized
	turd string `json:"turd"`
}

func main() {
	var jsonBlob = []byte(`{"poop": "butt", "turd": "toilet"}`)

	var gfy GFY
	err := json.Unmarshal(jsonBlob, &gfy)
	if err != nil {
		fmt.Println("error:", err)
	}
	fmt.Printf("%+v\n", gfy)
}

$ go vet
./main.go:9:2: struct field poop has json tag but is not exported
./main.go:10:2: struct field turd has json tag but is not exported
2.
code:
package main

import (
	"encoding/json"
	"fmt"
)

type GFY struct {
	Poop string `json:"poop"`
	Turd string `json:"turd"`
}

func main() {
	var jsonBlob = []byte(`{"poop": "butt", "turd": "toilet"}`)

	var gfy GFY
	err := json.Unmarshal(jsonBlob, &gfy)
	if err != nil {
		fmt.Println("error:", err)
	}
	fmt.Printf("%+v\n", gfy)
}

$ go run main.go
{Poop:butt Turd:toilet}
The same semantics are at play here when we talk about package accessibility and really none of it is particularly confusing.

The amount of stockholm syndrome in this post is amazing.

Bloody
Mar 3, 2013

rust is laying the groundwork for the inevitable rust#, which will be the greatest general-purpose programming language of all time. the only important design decision difference between the two is that while rust is all about those zero-cost abstractions, rust# will accept nonzero-cost abstractions, allowing it to become the greatest language in the world

Bloody
Mar 3, 2013

just imagine: a real language like c# or java but with a borrow checker

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?
the greatest language already exists though, thanks to John McCarthy

prisoner of waffles
May 8, 2007

Ah! well a-day! what evil looks
Had I from old and young!
Instead of the cross, the fishmech
About my neck was hung.

Bloody posted:

just imagine: a real language like c# or java but with a borrow checker

future so bright, I gotta post using amberpos

champagne posting
Apr 5, 2006

YOU ARE A BRAIN
IN A BUNKER


akadajet posted:

oracle doesn't want the message to get through. java is a trap.

this is every oracle product

heck even some DBAs i've worked with insist OracleDB is the hottest poo poo and best performing in the world. I mean sure but nanoseconds don't really count for much when you only need to call it once or twice per day.

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

rjmccall posted:

ah right, makes sense. so this public-fields-only stuff is just the default behavior for structs that don’t define custom encoding?

yep and iirc you can override the json packages behavior by implementing your own encoders but i may be wrong there. if go were awful at serialization i don't think stuff like grpc would be so popular. the issue is just that the user friendly json package is annoying in a very go way.

Progressive JPEG
Feb 19, 2003

DONT THREAD ON ME posted:

yep and iirc you can override the json packages behavior by implementing your own encoders but i may be wrong there. if go were awful at serialization i don't think stuff like grpc would be so popular.
grpc is a retooled version of stubby, which started with java/c++/python

DONT THREAD ON ME posted:

the issue is just that the user friendly json package is annoying in a very go way.
epic thissery

its weird that go went with shoehorning capitalization into access handling in order to keep things "succinct", leading to weird side effects like the json module's behavior, while at the same time requiring incredibly clunky and verbose error handling everywhere else

Blinkz0rz
May 27, 2001

MY CONTEMPT FOR MY OWN EMPLOYEES IS ONLY MATCHED BY MY LOVE FOR TOM BRADY'S SWEATY MAGA BALLS

Xarn posted:

The amount of stockholm syndrome in this post is amazing.

do i wish public/private keywords existed? hell yeah

do i feel the need to rehash language idiosyncrasies like they're not tools that have their uses and that honestly who gives a gently caress? nah life is too short

the talent deficit
Dec 20, 2003

self-deprecation is a very british trait, and problems can arise when the british attempt to do so with a foreign culture





Blinkz0rz posted:

do i wish public/private keywords existed? hell yeah

do i feel the need to rehash language idiosyncrasies like they're not tools that have their uses and that honestly who gives a gently caress? nah life is too short

and yet here we are

leftist heap
Feb 28, 2013

Fun Shoe
that go stuff looks like poop

Notorious b.s.d.
Jan 25, 2003

by Reene

Fiedler posted:

the code authored by microsoft is better but nobody's going to knife miguel's baby, so...

the mono standard library is a real fuckin mess

Vanadium
Jan 8, 2005

rjmccall posted:

ah right, makes sense. so this public-fields-only stuff is just the default behavior for structs that don’t define custom encoding?

your custom marshal logic (eg implementing a MarshalJSON method) can do w/e you want, but I think the public fields only stuff falls out of a restriction that the reflection package imposes, so the arbitrariness isn't quite within the encoding/json package

Fiedler
Jun 29, 2002

I, for one, welcome our new mouse overlords.

Notorious b.s.d. posted:

the mono standard library is a real fuckin mess

yes. that's why it's marked for death. only the mono runtime survives.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

Vanadium posted:

your custom marshal logic (eg implementing a MarshalJSON method) can do w/e you want, but I think the public fields only stuff falls out of a restriction that the reflection package imposes, so the arbitrariness isn't quite within the encoding/json package

yeah, i mean, that's obvious, but i don't get why someone thought it was a good idea to default types into non-custom serialization using reflection in the first place. sure, you don't want people to have to hand-write the marshaling code, but that's why basically every language that's ever looked at this ended up at "require the type to declare that it's serializable, but synthesize the serialization code automatically if it isn't provided"

Fiedler
Jun 29, 2002

I, for one, welcome our new mouse overlords.
that is perhaps where the languages started, but i think you'll find a lot that today take the position "look just turn this loving object into json (and vice-versa) with the least possible amount of developer effort"

Progressive JPEG
Feb 19, 2003

now that I think about it, I do at least prefer go's encoding/json quirks to java's latest trend of submersing everything in annotation hell

it didnt work? did you forget to mark all your fields @UndiscoverableUntraceableBullshit? ugh you moron dont sign

ColTim
Oct 29, 2011
Does anyone have any links to intrinsics code like the stuff here? (ideally not using wrapper libraries that abstract them out)

the talent deficit
Dec 20, 2003

self-deprecation is a very british trait, and problems can arise when the british attempt to do so with a foreign culture





Progressive JPEG posted:

now that I think about it, I do at least prefer go's encoding/json quirks to java's latest trend of submersing everything in annotation hell

it didnt work? did you forget to mark all your fields @UndiscoverableUntraceableBullshit? ugh you moron dont sign

one of my okrs was making sure our api was 100% documented with swagger autogenerated from the code so i spent like 75% of the quarter adding annotations to data classes in kotlin. was a great use of my time

Adbot
ADBOT LOVES YOU

Plank Walker
Aug 11, 2005

the talent deficit posted:

one of my okrs was making sure our api was 100% documented with swagger autogenerated from the code so i spent like 75% of the quarter adding annotations to data classes in kotlin. was a great use of my time

speaking of swagger, can anyone recommend some sort of formatter for making swagger documentation actually readable? product i'm working on consumes a horrible mess of deeply nested data structures and the default swagger view is horrible, but i can't for the life of me find anything that would consume the swagger api json and turn it into something nicer like msdn pages

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply