7 ms·
JSON, interfaces, and go generate
- sago 12y agoIn case anyone else is sitting looking at the first slide, clicking, scrolling and so on, and seeing nothing else. Press left and right arrow keys.
- jaytaylor 12y agoThanks for that. Any tips on how to get past the 3rd slide? ;)
- coldtea 12y agoOne would expect people have figured online slideshows by now. It's the 10,000 one that's posted on HN for example...
- sago 12y agoMiaow, nice passive aggression. It's the first one people have come across with no way to navigate without a keyboard. It seemed to people a very odd UI, given that many web connected devices don't have them. s/people/I/g
- coldtea 12y ago>Miaow, nice passive aggression. I think you conflate passive aggression with open derision. Regarding the former "passive-aggressive behavior is characterized by a habitual pattern of passive resistance to expected work requirements, opposition, stubbornness, and negativistic attitudes in response to requirements for normal performance levels expected of others". I don't think a snarky response qualifies. >It's the first one people have come across with no way to navigate without a keyboard. Lots of web slideshows only navigate with a keyboard. I've seen the same question/answer several times in the past on HN. It's not like it should take more than 5 seconds to try to press "->" and see what happens....
- shanemhansen 12y agoWorks just fine on my keyboard-less phone.
- garfij 12y agoI dunno, seems like clicking on the next slide, or the edges of the current slide works just fine for navigation as far as mouse controls goes, and swiping is also working fairly well on my mobile devices, though I can't claim to have tested all possible mobile devices, so your mileage may vary.
- moe 12y agoThis is something I really don't like about Go. 80 lines of code to parse some JSON? Meanwhile, in ruby... foo = JSON.parse(STDIN.read)
- Zikes 12y agoMeanwhile, in Ruby...foo could contain any conceivable data structure, which you'll have to reflect on and test against extensively in a production environment if you don't want your application falling flat on its face at the first sign of unexpected input. Go would have similar problems with unexpected input, it just frontloads the work, so if you do something stupid then you'll know it up front.
- moe 12y agowhich you'll have to reflect on and test against extensively if you don't want your application falling flat on its face Even with full blown JSON schema validation we'd arrive at 2 lines of ruby code plus ~5 for the schema.
- Zikes 12y agoSo 2 lines of Go and ~5 for the struct. Is your argument that the schema is defined outside of Ruby and therefore doesn't count as LOC?
- contingencies 12y agoNot the same due to types... the win being reliability and security due to more precise input validation. The loss is programmer time and overall code bloat/complexity, both for the spec and the handling. Architecturally, it would have been better to separate the spec. When I saw the intro I thought they were going to generate Go from a JSON Schema (which would have been at least more cross platform and reusable). Instead, we got more Go. Meh.
- jweir 12y agoIt is no where near 80 lines required to parse JSON. http://play.golang.org/p/H5yFV6VYaT http://play.golang.org/p/H5yFV6VYaT There is some boiler plate, since you have a typed system, so you must define your types. Beyond that two lines of Go will parse a JSON blob. people := []Person{} json.Unmarshal(json, &people) The article is giving examples of using an Unmarshal interface to convert the JSON code into typed Go objects. Hence more lines of code. Such as the example of converting the JSON time string into a Time type. edit: updated the example link
- deleted 12y ago[deleted]