Archive for June 30, 2017

Friday, June 30, 2017 [Tweets] [Favorites]

Web Form Data Sent Before You Click “Submit”

Kashmir Hill and Surya Mattu:

But it’s too late. Your email address and phone number have already been sent to a server at “murdoog.com,” which is owned by NaviStone, a company that advertises its ability to unmask anonymous website visitors and figure out their home addresses. NaviStone’s code on Quicken’s site invisibly grabbed each piece of your information as you filled it out, before you could hit the “Submit” button.

[…]

In yesterday’s report on Acurian Health, University of Washington law professor Ryan Calo told Gizmodo that giving users a “send” or “submit” button, but then sending the entered information regardless of whether the button is pressed or not, clearly violates a user’s expectation of what will happen. Calo said it could violate a federal law against unfair and deceptive practices, as well as laws against deceptive trade practices in California and Massachusetts. A complaint on those grounds, Calo said, “would not be laughed out of court.”

Chris Lattner on the Realm WWDC 2017 Swift Panel

Ole Begemann:

Chris Lattner was a guest on a Swift panel during WWDC a few weeks ago. Here are some quotes I found interesting, edited for brevity and clarity. (Iʼm focusing on Chris Lattner here, but the other panelists — Kamilah Taylor, Kevin Ballard, and Jesse Squires — also had interesting things to say. You should really watch the whole thing if you can.)

Previously: WWDC 2017 Links.

Writing a Really, Really Fast JSON Parser

Chad Austin (via Hacker News):

Here are the optimizations that mattered:

  • Moved the input and output pointers into locals instead of members, which helps VC++ and Clang understand that they can be placed in registers. (gcc was already performing that optimization.) 71078d3 4a07c77
  • Replaced the entire parse loop with a goto state machine. Surprisingly, not only was this a performance win, but it actually made the code clearer. 3828769 05b3ec8 c02cb31
  • Change an 8-entry enum to a uint8_t instead of the pointer-sized value it was defaulting to. 799c55f
  • Duplicated a bit of code to avoid needing to call a function pointer. 44ec0df
  • Tiny microoptimizations like avoiding branches and unnecessary data flow. 235d330 002ba31 193b183 c23fa23
  • Store the tag bits at the bottom of the element index instead of the top, which avoids a shift on 64-bit. e7f2351

[…]

An iOS team at Dropbox replaced JSONSerialization with sajson and cut their initial load times by two thirds!

Previously: Parsing JSON Is a Minefield.

Swift 4: JSON With Encoder and Encodable

Greg Heo:

Rather than pore through all the source code for encoding and decoding, let’s take a different approach and step through a simple example: how does a single Int instance wind its way through JSONEncoder and become JSON data?

[…]

To summarize: our Swift values get turned into their Foundation object equivalents by JSONEncoder and friends, then these objects get JSON-ified by JSONSerialization.

[…]

Now what about the reverse, decoding? And how can you write custom encoders and decoders for formats other than JSON, say protocol buffers? Stay tuned for more, or why not dig into the code and see what you find?