News for hackers. Stuff that matters.
Re:How to store your app's entire state in the url by divbzero on Monday January 09, 2023 @02:10PM (#34314578)
App state in URL can be a good idea, but if possible I prefer readable path/query parameters instead of unreadable base64 encoding.

As one comparison, this is Google Finance encoding stock chart parameters:

  https://www.google.com/finance/quote/F:NYSE?window=5Y
Versus Yahoo! Finance doing the same:

  https://finance.yahoo.com/quote/F/chart?p=F#eyJpbnRlcnZhbCI6IndlZWsiLCJwZXJpb2RpY2l0eSI6MSwidGltZVVuaXQiOm51bGwsImNhbmRsZVdpZHRoIjo0LjM0ODY1OTAwMzgzMTQxNzUsImZsaXBwZWQiOmZhbHNlLCJ2b2x1bWVVbmRlcmxheSI6dHJ1ZSwiYWRqIjp0cnVlLCJjcm9zc2hhaXIiOnRydWUsImNoYXJ0VHlwZSI6ImxpbmUiLCJleHRlbmRlZCI6ZmFsc2UsIm1hcmtldFNlc3Npb25zIjp7fSwiYWdncmVnYXRpb25UeXBlIjoib2hsYyIsImNoYXJ0U2NhbGUiOiJsaW5lYXIiLCJzdHVkaWVzIjp7IuKAjHZvbCB1bmRy4oCMIjp7InR5cGUiOiJ2b2wgdW5kciIsImlucHV0cyI6eyJpZCI6IuKAjHZvbCB1bmRy4oCMIiwiZGlzcGxheSI6IuKAjHZvbCB1bmRy4oCMIn0sIm91dHB1dHMiOnsiVXAgVm9sdW1lIjoiIzAwYjA2MSIsIkRvd24gVm9sdW1lIjoiI2ZmMzMzYSJ9LCJwYW5lbCI6ImNoYXJ0IiwicGFyYW1ldGVycyI6eyJ3aWR0aEZhY3RvciI6MC40NSwiY2hhcnROYW1lIjoiY2hhcnQifX19LCJwYW5lbHMiOnsiY2hhcnQiOnsicGVyY2VudCI6MSwiZGlzcGxheSI6IkYiLCJjaGFydE5hbWUiOiJjaGFydCIsImluZGV4IjowLCJ5QXhpcyI6eyJuYW1lIjoiY2hhcnQiLCJwb3NpdGlvbiI6bnVsbH0sInlheGlzTEhTIjpbXSwieWF4aXNSSFMiOlsiY2hhcnQiLCLigIx2b2wgdW5kcuKAjCJdfX0sInNldFNwYW4iOnsibXVsdGlwbGllciI6NSwiYmFzZSI6InllYXIiLCJwZXJpb2RpY2l0eSI6eyJwZXJpb2QiOjEsImludGVydmFsIjoid2VlayJ9fSwibGluZVdpZHRoIjoyLCJzdHJpcGVkQmFja2dyb3VuZCI6dHJ1ZSwiZXZlbnRzIjp0cnVlLCJjb2xvciI6IiMwMDgxZjIiLCJzdHJpcGVkQmFja2dyb3VkIjp0cnVlLCJldmVudE1hcCI6eyJjb3Jwb3JhdGUiOnsiZGl2cyI6dHJ1ZSwic3BsaXRzIjp0cnVlfSwic2lnRGV2Ijp7fX0sImN1c3RvbVJhbmdlIjpudWxsLCJzeW1ib2xzIjpbeyJzeW1ib2wiOiJGIiwic3ltYm9sT2JqZWN0Ijp7InN5bWJvbCI6IkYiLCJxdW90ZVR5cGUiOiJFUVVJVFkiLCJleGNoYW5nZVRpbWVab25lIjoiQW1lcmljYS9OZXdfWW9yayJ9LCJwZXJpb2RpY2l0eSI6MSwiaW50ZXJ2YWwiOiJ3ZWVrIiwidGltZVVuaXQiOm51bGwsInNldFNwYW4iOnsibXVsdGlwbGllciI6NSwiYmFzZSI6InllYXIiLCJwZXJpb2RpY2l0eSI6eyJwZXJpb2QiOjEsImludGVydmFsIjoid2VlayJ9fX1dfQ--
In both examples, the only custom parameter is setting the time window to 5 years.
Re:How to store your app's entire state in the url by spullara on Monday January 09, 2023 @02:27PM (#34314784)
Here is it decoded:

{"interval":"week","periodicity":1,"timeUnit":null,"candleWidth":4.3486590038314175,"flipped":false,"volumeUnderlay":true,"adj":true,"crosshair":true,"chartType":"line","extended":false,"marketSessions":{},"aggregationType":"ohlc","chartScale":"linear","studies":{" vol undr ":{"type":"vol undr","inputs":{"id":" vol undr ","display":" vol undr "},"outputs":{"Up Volume":"#00b061","Down Volume":"#ff333a"},"panel":"chart","parameters":{"widthFactor":0.45,"chartName":"chart"}}},"panels":{"chart":{"percent":1,"display":"F","chartName":"chart","index":0,"yAxis":{"name":"chart","position":null},"yaxisLHS":[],"yaxisRHS":["chart"," vol undr "]}},"setSpan":{"multiplier":5,"base":"year","periodicity":{"period":1,"interval":"week"}},"lineWidth":2,"stripedBackground":true,"events":true,"color":"#0081f2","stripedBackgroud":true,"eventMap":{"corporate":{"divs":true,"splits":true},"sigDev":{}},"customRange":null,"symbols":[{"symbol":"F","symbolObject":{"symbol":"F","quoteType":"EQUITY","exchangeTimeZone":"America/New_York"},"periodicity":1,"interval":"week","timeUnit":null,"setSpan":{"multiplier":5,"base":"year","periodicity":{"period":1,"interval":"week"}}}]}

Re:How to store your app's entire state in the url by a_c on Monday January 09, 2023 @02:49PM (#34315051)
OT, we used to joke about LISP source code contains mostly brackets. Nowadays we literally store, transform and pass around willy nillily
Re:How to store your app's entire state in the url by hk__2 on Monday January 09, 2023 @06:01PM (#34317811)
Speaking about LISP and state in the URL, this is how OVH stores the state when you buy a domain from them:

    https://www.ovh.com/fr/order/webcloud/?#/webCloud/domain/options?selection=~(domains~(list~(~(name~'somethinghn.com))~options~(~'dnssec)))
Re:How to store your app's entire state in the url by TeMPOraL on Monday January 09, 2023 @07:23PM (#34318539)
That's Clojure's EDN encoded for ClojureScript isn't it? I recognize this syntax from briefly working on a CLJ/CLJS app.
Re:How to store your app's entire state in the url by bsima on Tuesday January 10, 2023 @07:55AM (#34324106)
Nope, edn uses square brackets and doesn't have a `list` keyword. This is some custom representation.

Probably written in Common Lisp? Based on some quick searching I found this reference https://docs.ovh.com/us/en/web-paas/languages-lisp/

Re:How to store your app's entire state in the url by mattpallissard on Tuesday January 10, 2023 @11:48AM (#34327626)
Or it could just be that s expressions are easy to parse.
Re:How to store your app's entire state in the url by TeMPOraL on Monday January 09, 2023 @07:26PM (#34318567)
I found that joke funny until I realized that, if you sum the count of round, square, angle and curly braces together, your typical piece of C++ or Java code has more brackets than equivalent piece of Lisp code...
Re:How to store your app's entire state in the url by spullara on Monday January 09, 2023 @08:40PM (#34319200)
Right, but having them all be the same is what people are joking about :) Although I might check the lisp/clojure vs java code on techempower or another rosetta stone like example.
Re:How to store your app's entire state in the url by moring on Tuesday January 10, 2023 @01:46AM (#34321358)
That, and the usual style of stacking all closing parentheses together at the end of the last line of a sub-expression / statement / whatever. People sometimes do this in Java and it's just as unreadable.
Re:How to store your app's entire state in the url by User23 on Tuesday January 10, 2023 @10:33AM (#34326333)
You read it by indentation not by counting parentheses.
Re:How to store your app's entire state in the url by WorldMaker on Tuesday January 10, 2023 @03:43PM (#34331196)
It's still very easy to make mistakes reading it that way. If you are reading it by indentation anyway you may as well use a parser that closes parentheses for you at indentation changes. (Like the ML family and Haskell and Python all decided to do.)
Re:How to store your app's entire state in the url by User23 on Tuesday January 10, 2023 @04:40PM (#34331904)
* * *
Re:How to store your app's entire state in the url by NavinF on Tuesday January 10, 2023 @02:55AM (#34321812)
Well yeah that's a major reason why most programmers hate LISP syntax. It uses a parentheses for everything even though every keyboard has round, square, angle and curly braces.
Re:How to store your app's entire state in the url by TeMPOraL on Tuesday January 10, 2023 @03:32AM (#34322034)
I somehow doubt it. I tutored quite a few people of all ages who started to learn programming, mostly C, C++ and Java - they all initially have been mostly confused by the different kinds of brackets. They quickly understood where the brackets go (scopes/blocks, function calls, array declarations and access, etc.), but took some time to internalize which bracket type is used in which context.

I suspect the main reason programmers dislike Lisp syntax is that they try or see an example of some basic arithmetics, get surprised by the prefix notation that's so "unnatural" compared to the "obvious" infix notation they learned in primary school, and write off the entire language as weird, not noticing the fact that infix math is an exception in programming languages, as otherwise almost all code they write in any other language is in prefix notation too, just with a parenthesis shifted to the left.

A somewhat mind-blowing observation to some people:

  (foo (bar baz quux))
  
  foo(bar(baz, quux));
The two lines above are both in prefix notation. You can go from the first to the second one by a) shifting each left paren by one token to the right, and b) adding commas between whitespace-separated tokens.
Re:How to store your app's entire state in the url by xmprt on Tuesday January 10, 2023 @03:58AM (#34322175)
I suppose beginner programmers might find all the different kinds of brackets in C++ confusing but after some experience, it helps a lot with readability. If I see `a[1]` then I know that `a` is probably an array. If I see `a(1)` then I know that `a` is probably a function. You could make the argument that those are terrible names for variables and methods and you'd be correct, but every small bit of context helps.
Re:How to store your app's entire state in the url by spullara on Sunday January 15, 2023 @10:26PM (#34396459)
Like most of the verbosity in those languages it benefits the reader more than the writer.
Re:How to store your app's entire state in the url by moonchrome on Tuesday January 10, 2023 @07:36AM (#34323901)
Clojure uses [] and {}, eg. :

  (defn fib [x, n]
    (if (< (count x) n) 
      (fib (conj x (+ (last x) (nth x (- (count x) 2)))) n)
      x))
Re:How to store your app's entire state in the url by reaperducer on Monday January 09, 2023 @08:40PM (#34319198)
we used to joke about LISP source code contains mostly brackets.

There was a programming language in the 1970's called SAM76 that didn't care how many closing parentheses you had, as long as it was more than the number of opening parentheses.

So, something like this was perfectly valid:

  a(1+r(em(2)))))))))))))))))))
Re:How to store your app's entire state in the url by bboygravity on Monday January 09, 2023 @10:15PM (#34320066)
That's genious IMO. Making sure the amount of opening and closing parantheses is equal is annoying and unnecesary.

It screams "trust me all good with the closing parantheses".

Re:How to store your app's entire state in the url by andreareina on Tuesday January 10, 2023 @12:12AM (#34320798)
paredit and rainbow parens makes it a non-issue for me.
Re:How to store your app's entire state in the url by paledot on Tuesday January 10, 2023 @12:18AM (#34320829)
I disagree. I would say when I get an unbalanced paren compiler error, it's more common for the omission to not be at the end of the line. Having the compiler silently swallow the error would lead to serious bugs very quickly.
Re:How to store your app's entire state in the url by tonmoy on Tuesday January 10, 2023 @12:55AM (#34321041)
What if I wanted to copy that expression and use is as part of a different expression?
Re:How to store your app's entire state in the url by NavinF on Tuesday January 10, 2023 @03:02AM (#34321854)
Interactive prompts already do that. Eg if you google "2+2)*3" it will correctly print "12". This effectively lets you append operations to an expression without editing both sides.

On the other hand, auto closing parentheses in code is a terrible idea for obvious reasons. There are only like 7 languages used in industry and they all have excellent tooling that integrates with your editor to eliminate issues like this.

Re:How to store your app's entire state in the url by ajuc on Tuesday January 10, 2023 @03:16AM (#34321935)

    if ((v1.x()-v2.x())*(v1.x()-v2.x())+(v1.y()-v2.y())*(v1.y())-v2.y())+(v1.z()-v2.z())*(v1.z()-v2.z()) > distance*distance) {
        // collision
    }
Would you like this to fail to compile? Or would you prefer it to silently return the wrong value?
Re:How to store your app's entire state in the url by matthewmacleod on Tuesday January 10, 2023 @04:18AM (#34322286)
I'd prefer the compiler file an HR complaint against the author.
Re:How to store your app's entire state in the url by wstuartcl on Wednesday January 11, 2023 @12:25PM (#34341203)
if collisioncheck(v1,v2, distance) { // collision }

where you have defined an actually readable equivalent inside of collisioncheck would be my prerogative... I also agree paren matching failures should error, but your example is NOT why.

Re:How to store your app's entire state in the url by lIl-IIIl on Tuesday January 10, 2023 @02:24AM (#34321606)
Relevant xkcd: https://xkcd.com/859
Re:How to store your app's entire state in the url by _fat_santa on Monday January 09, 2023 @03:53PM (#34315864)
I suspect it's probably a global library that handles this. So refactoring it in one place would be difficult. If I had to guess their implementation looks something like this.

SomeUrlService.pushState(JSON.stringify({ foo: 'bar' }));

SomeUrlService.navigate('/some/url/here')

Likely, that "SomeUrlService" is also tacking on plenty of other shit to the URL that is passed along. I don't work for Yahoo and never have, so this is all pure speculation.

Re:How to store your app's entire state in the url by spullara on Monday January 09, 2023 @04:08PM (#34316095)
Having worked there years and years ago, I doubt it. All those parameters look like chart parameters to me, probably local to Y! Finance.
Re:How to store your app's entire state in the url by Altho00 on Tuesday January 10, 2023 @02:51AM (#34321785)
What is the point of the encoding ? Is it obfuscation for the common user ? What's wrong with http:// url.com/api/?interval=week&periodicity=1... since the encoded version is not shorter.
Re:How to store your app's entire state in the url by ninjanomnom on Tuesday January 10, 2023 @03:03AM (#34321860)
Encoding isn't usually to obscure but to allow using characters not allowed in a URL or wherever text is being stored. This makes it a bit easier to directly take that encoded text later and decode it into something like json.
Re:How to store your app's entire state in the url by Altho00 on Wednesday January 11, 2023 @07:51AM (#34337819)
That makes sense, thank you
Re:How to store your app's entire state in the url by deelly on Tuesday January 10, 2023 @02:58AM (#34321824)
> What is the point of the encoding ?

Absence of special characters. No need to escape symbols like {}:/\?& etc, etc.

Re:How to store your app's entire state in the url by rocho on Tuesday January 10, 2023 @03:20AM (#34321958)
They have a nested structure, it's a pain to encode that in query parameters.
Re:How to store your app's entire state in the url by anshumankmr on Monday January 09, 2023 @02:24PM (#34314746)
> https://finance.yahoo.com/quote/F/chart?p=F#eyJpbnRlcnZhbCI6...

Dear god... this link was real. I thought it was like a joke or something

Re:How to store your app's entire state in the url by xwdv on Monday January 09, 2023 @02:33PM (#34314857)
There are no jokes on HN.
Re:How to store your app's entire state in the url by 2ICofafireteam on Monday January 09, 2023 @02:44PM (#34314974)
I did once and was told off for adding noise to the discussion by someone who didn't see the irony of their complaint also adding to the noise.
Re:How to store your app's entire state in the url by macintux on Monday January 09, 2023 @02:48PM (#34315033)
If a one-time correction has its desired impact, the small addition to the noise reduces future noise.
Re:How to store your app's entire state in the url by ant6n on Monday January 09, 2023 @03:10PM (#34315296)
This is some sort of meta joke, right?
Re:How to store your app's entire state in the url by munk-a on Monday January 09, 2023 @03:18PM (#34315401)
Why are you assuming they work in FAANG?
Re:How to store your app's entire state in the url by gerdesj on Monday January 09, 2023 @05:44PM (#34317511)
There's no M in FAANG ...
Re:How to store your app's entire state in the url by throw10920 on Monday January 09, 2023 @04:06PM (#34316073)
It's not, and it's pretty clearly true.

The idea that "complaints about people violating the HN norms is somehow comparable to violating the norms" is trivially wrong if one thinks about it for more than a few seconds.

Re:How to store your app's entire state in the url by 2ICofafireteam on Monday January 09, 2023 @10:28PM (#34320164)
Presumably.
Re:How to store your app's entire state in the url by anotheraccount9 on Monday January 09, 2023 @02:49PM (#34315048)
Two chemists walk into a bar. The first says “I’ll take a glass of H2O.” The second says “I’ll take a glass of H2O too.”
Re:How to store your app's entire state in the url by valvar on Monday January 09, 2023 @03:58PM (#34315960)
Oh no...
Re:How to store your app's entire state in the url by xwdv on Monday January 09, 2023 @04:59PM (#34316805)
For many HN, telling someone off for making a joke isn’t noise but rather music to their ears.
Re:How to store your app's entire state in the url by anotheraccount9 on Monday January 09, 2023 @02:46PM (#34315015)
A horse walks into a bar.

Several of the patrons quickly get up and leave, realizing the potential danger in the situation.

Re:How to store your app's entire state in the url by nullsense on Monday January 09, 2023 @06:22PM (#34318000)
This has to be my favorite version I've ever heard.
Re:How to store your app's entire state in the url by TedDoesntTalk on Monday January 09, 2023 @06:50PM (#34318239)
Thank you for posting a joke to HN. Thank you for making me laugh today.
Re:How to store your app's entire state in the url by TeMPOraL on Monday January 09, 2023 @07:36PM (#34318665)
Since I wasn't sure whether it's meant literally or if I'm missing some context, I decided to do a web search with this joke as a query, and was rewarded with a recording of it (apparently) playing out in real life:

https://old.reddit.com/r/gamegrumps/comments/9kgeqg/a_horse_...

Re:How to store your app's entire state in the url by dhosek on Monday January 09, 2023 @10:09PM (#34320028)
A priest, a rabbi and a minister walk into a bar.

The bartender say, “What is this, a joke or something?”

Re:How to store your app's entire state in the url by dspillett on Tuesday January 10, 2023 @03:57AM (#34322170)
A priest, a rabbit, and a minister, walk into a blood donation clinic. The rabbit says "I think I might be a type-o".
Re:How to store your app's entire state in the url by scott_s on Monday January 09, 2023 @02:55PM (#34315119)
There are. We just have a high bar. I wrote this, but others have also pointed to it: https://news.ycombinator.com/item?id=7609289
Re:How to store your app's entire state in the url by BlueNorth on Monday January 09, 2023 @04:29PM (#34316372)
There are different languages. The jokes are symptomatic of the differences. I'm not Indian but English is laughable for many good reasons. Without damage...
Re:How to store your app's entire state in the url by PUSH_AX on Monday January 09, 2023 @02:51PM (#34315074)
Genuinely curious to hear why you are so shocked. Long, ugly, user unfriendly urls are really prevalent. Arguments can be made even query params are pretty ugly.. Are urls expected to be a good UX these days? What's the big deal?
Re:How to store your app's entire state in the url by munk-a on Monday January 09, 2023 @03:21PM (#34315449)
Just because a thing is prevalent doesn't mean it's good. I have a hard time believing all those parameters are completely necessary for the amount of data being displayed. Often times it feels like people just base64encode(page.state) and call it a day.

I think it's advantageous to keep the complexity and specificity of information in URLs to a minimum outside of what's needed to retrieve the data set as it can make backwards compatibility easier - it is valuable (for long lasting tools) to have URLs that users can favorite and share for their common searches.

Re:How to store your app's entire state in the url by PUSH_AX on Monday January 09, 2023 @03:39PM (#34315682)
> Just because a thing is prevalent doesn't mean it's good.

I agree with this sentiment. I'm not sure I've ever seen a url referred to as "good", I was just a bit confused as to why someone would baulk at a URL. In my opinion everything after the host portion of the url is to serve the apps needs, so it knows where to go or what to do, it's not really an interface for the user as obviously there are better ways to present that.

Re:How to store your app's entire state in the url by MereInterest on Monday January 09, 2023 @04:32PM (#34316413)
I’d say everything after the host is part of the UX, and should serve the user needs. For example:

* Should be book-markable.

* If searching with a query, should have a clear query parameter for ease of browser integration.

* If the URL contains slash dividers that can be read as categories (e.g. storefront.com/department/category/product), then deleting everything after a given slash should go to that category’s page.

* The link should be short enough to be sent over a plain-text conversation without becoming a wall of text.

* The link should be short enough that it cannot hide a malicious subdomain (e.g. Google.com.flights.malicio.us/more/elements).

Re:How to store your app's entire state in the url by hinkley on Monday January 09, 2023 @05:51PM (#34317630)
* I should be able to guess if you're sending me a link about composting or a Rick Astley video

Opaque slugs are problematic in a low-trust world. Phishing attempts are easier when the parameters are indecipherable. I'm not clicking on that shit in a text message or an email. I've seen what happens to people when they do.

Re:How to store your app's entire state in the url by pixl97 on Monday January 09, 2023 @07:11PM (#34318440)
Eh, I mean URL shorteners are a thing and all kind of things redirect on the web. The length of the URL doesn't really tell you much.
Re:How to store your app's entire state in the url by TeMPOraL on Monday January 09, 2023 @07:31PM (#34318623)
URL shorteners are a menace. I'm not clicking on the link if you send me a shortened one, especially not when on mobile. These days, shortened links have two primary applications: forcing you to go through a tracking/analytics gate, and serving single-click exploits. Neither of those is serving the user (unless you read it in "To Serve Man" sense).
Re:How to store your app's entire state in the url by whatusername on Monday January 09, 2023 @05:55PM (#34317705)
No - but they have been referred to as "cool" before. Gotta love the early 90's.

https://www.w3.org/Provider/Style/URI

Re:How to store your app's entire state in the url by ben0x539 on Monday January 09, 2023 @09:02PM (#34319381)
The point of a URL is that I can copy+paste it into IRC so my friends can look at the thing I want to share with them.

If the URL has a bunch of goop in it, people are going to make fun of me for it, especially if it's super long and doesn't fit in a single line. Or if there's stuff in there that's specific to me and not the thing I want to show them.

Re:How to store your app's entire state in the url by depressedpanda on Tuesday January 10, 2023 @05:24AM (#34322757)
Where I work, we consider URLs part of the UI. Users should be able to share links with each other without pasting a wall of text. We also try to make all URLs human parsable so that they know what they are sharing.
Re:How to store your app's entire state in the url by bbarnett on Monday January 09, 2023 @07:45PM (#34318758)
I can say that many, many times, I have zoomed in, picked date ranges, added options, then pasted the yahoo finance url to others... and they have all those same configs passed.

It's awesome and incredibly handy.

Yahoo is on the ball here.

Re:How to store your app's entire state in the url by tempestn on Tuesday January 10, 2023 @01:21AM (#34321205)
Agreed. However they could still simplify the urls a ton by including only non-default parameters, and still achieve the same thing.
Re:How to store your app's entire state in the url by itssumitrai on Tuesday January 10, 2023 @03:29AM (#34322016)
Everything in chart is customizable, so no, its not possible to achieve the same thing in the way you are saying
Re:How to store your app's entire state in the url by tempestn on Thursday January 12, 2023 @01:42AM (#34350013)
Yes, but anything that hasn't been customized doesn't need to be included in the URL, so most URLs will be much shorter by only including non-default values.
Re:How to store your app's entire state in the url by dncornholio on Tuesday January 10, 2023 @03:56AM (#34322159)
And what problem does this solve? Hint, it doesn't. Long URL is ugly but who cares. Life is too short. Nice or ugly is relative. It stops nobody from using the tool or sharing links. It's a non-problem really.
Re:How to store your app's entire state in the url by hunter2_ on Monday January 09, 2023 @03:21PM (#34315441)
I don't think people care so much about a messy address bar as a messy chat/email message after pasting a URL. Shorteners and vanity URLs exist, but that's more friction than just copying from the address bar as-is.

This can be overcome with html, markdown, and other rich text formats that let you specify the visible link text (missing from many chat apps*), but that's also friction to compose compared to automatically linking from just a URL.

*Slack's implementation is awesome: type the link text, highlight it, and paste a URL.

Re:How to store your app's entire state in the url by owl57 on Monday January 09, 2023 @03:59PM (#34315973)
It's not even only about messiness. "https://news.ycombinator.com/item?id=34315441" isn't some horrible long base64, but it's not a good UX either: when you paste it in a messenger, or in your notes, by default the reader can't tell what's it about without clicking.

> *Slack's implementation is awesome: type the link text, highlight it, and paste a URL.

Yes! Matches my vision of hypertext perfectly: I usually type a message in normal human language and then paste links all over it for the reader who needs to dig deeper.

Re:How to store your app's entire state in the url by TheBrokenRail on Monday January 09, 2023 @05:44PM (#34317513)
> by default the reader can't tell what's it about without clicking.

Most chat apps like Discord will automatically include an embed generated from a URL's metadata when present in a message.

Re:How to store your app's entire state in the url by owl57 on Monday January 09, 2023 @08:48PM (#34319274)
At least in Telegram, this works for at most one link per message, and quickly fills the screen if you send multiple such messages.

And I believe that there is no standard API to get previews of non-public websites in a work chat, you need to develop site-specific bots or something like that?

Re:How to store your app's entire state in the url by hunter2_ on Monday January 09, 2023 @11:38PM (#34320574)
> previews of non-public websites

It would be interesting if browsers / OSes / apps offered a way to use the browser's cookie jar / basic auth headers / whatever sessioning scheme in whatever apps the user decides should display authenticated previews.

Re:How to store your app's entire state in the url by withinboredom on Tuesday January 10, 2023 @01:45AM (#34321354)
I just include a screenshot. It’s not that hard.
Re:How to store your app's entire state in the url by gdprrrr on Tuesday January 10, 2023 @02:03AM (#34321475)
Plesse no
Re:How to store your app's entire state in the url by efreak on Wednesday January 11, 2023 @12:52AM (#34335459)
Examples of why this is bad:

* http://example.com/settings/transferownership?to=efreak * http://example.com/settings/deleteaccount?confirm=true * http://example.com/sendmoney?to=efreak&amount=10000

Might need a redirect. Do previews follow redirects? Does your poorly-written chat app filter urls by protocol, or does it just look for a token with '://'? A good app will allow me to link to things like steam://connect/IP so I can invite you to a game.

* tel:9005555555 (call a phone number. Fortunately, this requires confirmation these days, but what if you're on desktop or the app that does texting can directly make calls without invoking the dialer?) * steam://exitsteam (steam will exit if it's running)

Re:How to store your app's entire state in the url by WorldMaker on Tuesday January 10, 2023 @03:53PM (#34331305)
There is a standard for this. It's called oEmbed: https://oembed.com/

The chat host still likely needs access to the "non-public website" to discover and call its oEmbed API, so that's something you'd have to figure out, but any website anywhere can offer oEmbed metadata if it wishes.

Re:How to store your app's entire state in the url by OJFord on Monday January 09, 2023 @06:25PM (#34318032)
> I don't think people care so much about a messy address bar as a messy chat/email message after pasting a URL.

But it's painful how few care about that!

I always clean them up before I send them (just manually - typically meaning all query parameters, e.g. with Amazon the text description after the actual ID) rarely even feel the need to check they still work, it's pretty easy, but maybe I shouldn't bother because it's only me that cares; they don't seem to notice that their links occupy half the screen and my don't!

Re:How to store your app's entire state in the url by pacifika on Tuesday January 10, 2023 @08:08AM (#34324262)
Pipe that into bash (ie: the user doesn’t know if they’re loading malicious state)
Re:How to store your app's entire state in the url by anshumankmr on Tuesday January 10, 2023 @11:39AM (#34327488)
I Just like to keep query params simple and readable. I understand the possible use case for this obfuscated url which would make it difficult to scrape the site
Re:How to store your app's entire state in the url by everforward on Wednesday January 11, 2023 @12:36PM (#34341408)
> Are urls expected to be a good UX these days? What's the big deal?

I think they are. If I want to go back to some page I was looking at earlier, it's really nice to be able to find that page in my history. That Yahoo URL is going to be hard to differentiate if you looked at a few stocks.

It's also handy if the URL's are predictable enough that I can hit one directly rather than having to go through search. Good for me because I don't wait on page load, good for them because they don't have to serve my search request.

It's pretty low on my list of UX annoyances, but it is there.

Re:How to store your app's entire state in the url by 1vuio0pswjnm7 on Monday January 09, 2023 @04:22PM (#34316262)
I have seen even worse, on some internal web-based software that most of the outside world will probably never see. I was quite shocked but the crazy thing was that it worked. It was pushing the length limit of browsers for URLs. Unlike this Yahoo! example, the URLs in this non-public software were human readable and editable. As an end user, I always prefer short URLs that are easy to type and edit. The web has improved in terms of URLs IMHO. In the early days, there was not widespread use of descriptive "slugs" and many URLs aimed at "dymanic" content were long, nondescriptive and brittle.
Re:How to store your app's entire state in the url by hot_gril on Monday January 09, 2023 @02:30PM (#34314818)
I decoded that, gzipped --best, then re-encoded and got something that's shorter at least

H4sIAAAAAAACA7VU3W7TMBS+5ykmcxuNdOlGyd3QmECCIdYWNKYKnSanqVfHNrbTNqoq7QF4Sp6EYyfpaMYtdz7H5/vOz3fsHePSoVmDYCnbIK5YxDQarnKecVezdBAxx0ucSu5YKishIpaBzAV+47lbsnR4mgxHF+dv4jgZJYPh4PV5xBaCa405SxcgLEZsrUTlKXI0AojTmYq8kD90x8woa5fAzcGxBOMmtUaqSnCJVBVuHRLDE2sJZoVujNZyJS1Ld3viLAqDBTjytGi1FBlrCccZiI4RDHmtq3KOHst+P/6iMk8qmRs6eo9rCDovhXOpKxeiOZXRh0Qs51aHBvtXVJmqXAee6pOvYSIU+DKO5/HFgMBXaiP/8i8WSZKAR2qQ6NUJLXh5wECJJFog23gZriFzioYXnw7P215vIPA0oP2+4wmYxkkHUjpD6YLKT8Vfs39x+PZz3FKSiNWXWx6Y5HGEVpb72TebQjlroMCP78csvZ+11m2wDpDepGa+UkuyUrU+QVkJx7XgSN1Ra3OwPl/dyHe0qLvWDM30l9qzetXbpT3z0htOO/oWslVhFKXvVg/XNBF7WEQl/GC9TqPB4ow9Ax7jPoEOA1ZGKwMOvZHz9YGORsw7ct8oL65w7VeXjKyyTpW3IAvsXpqty7nymt3v2nMrT2N8nj9gFoQ8uvxZKYft+r/7Mv0wuQvPhyZO1BN6zN+V9HeXJQ0sg1c3uPlxp8wqLFvv7T//Hfq/wf8Qaz/bv/gDbvc6N5oEAAA=

Re:How to store your app's entire state in the url by dyno12345 on Monday January 09, 2023 @02:37PM (#34314915)
you could come up with a better compression scheme given that the dict keys and many of the values are probably common across everyone even if they don't repeat multiple times for a given user. a lot of flexibility would be lost though, and you would need to always update the scheme in a backwards-compatible way.
Re:How to store your app's entire state in the url by hot_gril on Monday January 09, 2023 @02:41PM (#34314957)
Could start with a smaller original payload. Use single-length keys, or better yet use protocol buffers or even ASN1.
Re:How to store your app's entire state in the url by waynesonfire on Monday January 09, 2023 @02:43PM (#34314969)
would it be feasible to include the compression dictionary along w/ the data? And, maybe just send it once on the initial request and store it on the client?
Re:How to store your app's entire state in the url by gnramires on Monday January 09, 2023 @07:05PM (#34318385)
> would it be feasible to include the compression dictionary along w/ the data

In theoretical terms (in particular Kolmogorov-complexity perspective), I believe the inclusion of a dictionary wouldn't help, it would strictly increase size. It can help (specially from a Shannon information perspective) if the compression is too computationally demanding to build the data model (which is kind of what all compressors do); but it almost certainly doesn't help in the case of something as small as an URL. But then it's possible to just pack a common compressor with the website (and just refer to it with a version code).

I think the web in general would benefit greatly from some kind of standard compression libraries. Compression tends to have a significant cold start cost to work well, if that were mitigated certainly something like an url could be far shorter.

I believe HTTP2 has header compression (RFC 7541)[1] with 'static tables', which seems to be a form of dictionary, but surprisingly to me no html compression with such shared dictionaries. There is caching libraries (unfortunately cross-domain caching seems to be deprecated[2] due to security concerns) I believe which helps in other ways, but I think a true dictionary-style compressor would bring huge bandwidth savings.

Major web entities should get together to develop those standard dictionaries (and which algorithms to use them with), so they are reasonably fair for everyone (maybe even language specific dictionaries should be used).

Security seems indeed a concern, but I think the key would be carefully preventing that a content were decoded with the incorrect dictionary (meaning the server could serve a different web page than the standard decompression) -- but overall it doesn't seem like a big issue (similar to cache, less problematic than cross-domain caching).

In the future maybe even one of those fancy neural network (or otherwise machine learning inspired) methods could be an option, specially useful for highly bandwidth constrained like rural or satellite internet (although of course performance is always a priority with mobile devices being major users).

[1] https://httpwg.org/specs/rfc7541.html#static.table.definitio...

[2] https://www.stefanjudis.com/notes/say-goodbye-to-resource-ca... Is this still accurate?

Re:How to store your app's entire state in the url by gnramires on Tuesday January 10, 2023 @08:11AM (#34324294)
> would benefit greatly from some kind of standard compression libraries

Correction: standard compression dictionaries

Re:How to store your app's entire state in the url by WorldMaker on Tuesday January 10, 2023 @04:02PM (#34331445)
> I believe HTTP2 has header compression (RFC 7541)[1] with 'static tables', which seems to be a form of dictionary, but surprisingly to me no html compression with such shared dictionaries.

To my understanding, that static table in HTTP2 is directly in context of recommending and discussing Brotli compression, which does use a table like that as a standard static dictionary in HTTP2+ scenarios including other static dictionary inclusions derived from a corpus of HTML documents.

https://en.wikipedia.org/wiki/Brotli

Re:How to store your app's entire state in the url by gnramires on Wednesday January 11, 2023 @09:00AM (#34338506)
Thanks, I didn't know Brotli! Indeed it seems to include a dictionary in its compression which seems to help significantly with small pages. I hope compression continues to improve in this way.

> To my understanding, that static table in HTTP2 is directly in context of recommending and discussing Brotli compression

It seems separate, that would be a header compression for HTTP2 header itself, while Brotli encodes content (usually html, css or js).

Re:How to store your app's entire state in the url by robryk on Wednesday January 11, 2023 @09:15AM (#34338691)
The header compression in http2 has atypical requirements places upon it: contents of different headers in a single request must not impact each other's compressed size[^], lest an attacker able to manipulate one of them can use that to guess the other. Thus, LZ77-style compression is out of the window, as well as using Huffman codes selected based on _all_ the header values. In essence, each header value (in a single request) has to be compressed independently. IIUC the dictionary you reference is used for header keys (as opposed to values).

[^] this statement is a bit of a lie for reasons of simplification

Re:How to store your app's entire state in the url by mikepurvis on Monday January 09, 2023 @02:55PM (#34315126)
Once you've already given up on human-readability, it probably doesn't much matter how long/gross the result is. Rather than spending effort and adding complexity, just provide a built in URL shortener.
Re:How to store your app's entire state in the url by hot_gril on Monday January 09, 2023 @03:13PM (#34315327)
I agree, same reason people use json in the first place despite the inefficiency, it's easier.
Re:How to store your app's entire state in the url by wtetzner on Monday January 09, 2023 @07:51PM (#34318794)
Well, there are limits to the lengths of URLs in much of the internet’s infrastructure, so better compression could still be useful.
Re:How to store your app's entire state in the url by jsvaughan on Tuesday January 10, 2023 @05:35AM (#34322836)
This is the critical point to make. Paste a few long texts into the boxes and the url goes into the hundreds of thousands of characters long, whereas this says that anything more than about 2000 chars puts you into uncertain territory:

https://stackoverflow.com/questions/417142/what-is-the-maxim...

Re:How to store your app's entire state in the url by p1necone on Monday January 09, 2023 @08:57PM (#34319343)
Isn't storing state in urls and then using a url shortener just a key/value store with extra steps?
Re:How to store your app's entire state in the url by taneq on Tuesday January 10, 2023 @02:36AM (#34321671)
But with added session id energy too!
Re:How to store your app's entire state in the url by mikepurvis on Tuesday January 10, 2023 @11:10AM (#34327035)
True, though I think the differences around shareability matter— a mapping-table entry is immutable, whereas even a non-logged-in session token is probably not.
Re:How to store your app's entire state in the url by BurningFrog on Monday January 09, 2023 @02:26PM (#34314772)
The possible advantage of the encoding is that it that it can be encrypted and make parameter hacking impossible.
Re:How to store your app's entire state in the url by hot_gril on Monday January 09, 2023 @02:38PM (#34314926)
Would have to do the signing server-side, predicated on the server checking the entire state to ensure validity. Such effort being put into preventing parameter-hacking would suggest there are serious vulnerabilities in that website. The URL is meant to be modified by the client.
Re:How to store your app's entire state in the url by hot_gril on Monday January 09, 2023 @05:06PM (#34316908)
> The URL is meant to be modified by the client.

Clarification, the human user probably won't want to modify the URL, but the client will.

Re:How to store your app's entire state in the url by thomasahle on Monday January 09, 2023 @07:09PM (#34318419)
With something nice like the Google url, I would happily modify it myself.
Re:How to store your app's entire state in the url by PetahNZ on Monday January 09, 2023 @02:32PM (#34314852)
You don't need to encode it to do that though. You can just sign the URL
Re:How to store your app's entire state in the url by A4ET8a8uTh0 on Monday January 09, 2023 @02:37PM (#34314912)
Harder. Not impossible. Harder. I don't want to make it sound like I am being disagreeable just for the sake of being disagreeable. If there is one thing the past decade has shown, it is that hacking is just a matter of time and whether a determined person is willing to direct resources at it.
Re:How to store your app's entire state in the url by rsync on Monday January 09, 2023 @03:05PM (#34315259)
I see you, and raise you:

What if they encrypted the parameters with a one-time pad ?

Re:How to store your app's entire state in the url by A4ET8a8uTh0 on Monday January 09, 2023 @03:39PM (#34315679)
Hmm. Most likely ( if not only ) way to counter that would be social hacking ( because I assume the pad is generated automatically from some source ), which seems like the best way to obtain it. Then again.. I am not an expert in this field ( but we do sometimes use parameters from link for some projects ). Is it refreshed after some time passes ( if so, maybe there is an easier way to just observe what changes )?
Re:How to store your app's entire state in the url by naasking on Tuesday January 10, 2023 @08:17AM (#34324370)
One-time pads have to be stored server-side. If you're going to do that, you might as well just store the data itself under a GUID server-side so you avoid network transfers and then put the GUID in the URL.
Re:How to store your app's entire state in the url by rattlesnakedave on Monday January 09, 2023 @05:58PM (#34317756)
Yeah, why not just base64 encode, shove that into a db with a shorter key? I'm pretty positive this is how tiktok works for sharing videos.
Re:How to store your app's entire state in the url by StevenNunez on Monday January 09, 2023 @06:20PM (#34317977)
Probably don't want to pay for space for unauthed users.
Re:How to store your app's entire state in the url by orasis on Monday January 09, 2023 @02:42PM (#34314962)
Another reason to not base64 encode is that many URLs with base64 strings will break in iMessage do to strings randomly matching various keywords that iMessage looks for. I think ‘usd’ is one such substring to look out for.
Re:How to store your app's entire state in the url by secondcoming on Monday January 09, 2023 @03:41PM (#34315702)
Surely that's something that Apple should fix, rather than everyone else working around it?
Re:How to store your app's entire state in the url by hk__2 on Monday January 09, 2023 @06:08PM (#34317864)
Yes, but even if Apple fixes it, you still have to deal with old devices. Better have something that works everywhere rather than "this website is optimized for IE/Chrome".
Re:How to store your app's entire state in the url by depressedpanda on Tuesday January 10, 2023 @05:38AM (#34322859)
This isn't at all comparable. It's purely an Apple problem.
Re:How to store your app's entire state in the url by slivanes on Monday January 09, 2023 @02:44PM (#34314985)
base64 does not have the problem here, iMessage has. Frustrating.
Re:How to store your app's entire state in the url by jimbokun on Monday January 09, 2023 @03:33PM (#34315596)
Agreed, iMessage should have URL detection that supersedes any other string parsing.
Re:How to store your app's entire state in the url by 71bw on Tuesday January 10, 2023 @03:07AM (#34321880)
The fault doesn't lie in iMessage, it lies in Apple in general. Google's AOSP keyboard will IMMEDIATELY detect that you are writing a link when you'll put http(s):// in front of whatever else you're currently writing and will just shut up and let you finish without interrupting every 2 seconds with autocorrection suggestions. This does not happen on Apple's i(Pad/O)S keyboard, where typing a link will usually leave the user with an excercise in frustration, trying to fight over the autocorrection, which, for the 17th time, has decided to convert your URL into "normal words". Not even changing the keyboard seems to fix it, as, from what I remember, Gboard still uses Apple's prediction engine...
Re:How to store your app's entire state in the url by nanidin on Monday January 09, 2023 @03:21PM (#34315448)
Curious if English is your mother tongue, and if so, which locale?

As a native speaker of en-US, I would write this as "base64 does not have the problem here, iMessage does."

Re:How to store your app's entire state in the url by slivanes on Monday January 09, 2023 @03:55PM (#34315905)
Originally en-AU. I was trying to match the "have" with a "has". My sentence has a truncated " the problem" in my head.

Your version reads more correct, thanks for pointing it out.

Re:How to store your app's entire state in the url by elteto on Monday January 09, 2023 @05:31PM (#34317334)
Right before I was forked my parent did “export LC_ALL=C” and here I am.
Re:How to store your app's entire state in the url by hot_gril on Monday January 09, 2023 @02:43PM (#34314972)
I think the other params are custom too. There's probably other state not being stored in that URL. If users want to send charts to each other and have them show up the same, this actually seems like a reasonable way to do it.
Re:How to store your app's entire state in the url by michaelmior on Monday January 09, 2023 @03:33PM (#34315600)
In your example, absolutely the first URL is better. But if as in the case of the OP, you're trying to encode an entire flowchart, I would argue it's a bit of a pointless exercise. Maybe you could come up with something reasonably readable, but I don't think anyone would care. It really depends on what kind of state you need to store.
Re:How to store your app's entire state in the url by moffkalast on Monday January 09, 2023 @07:21PM (#34318528)
Whoever needs to copy that long intestine of a url definitely cares.
Re:How to store your app's entire state in the url by michaelmior on Tuesday January 10, 2023 @05:08AM (#34322644)
If you can shorten the URL, sure. But if data stored in the URL means it needs to be incredibly long, I don't think most users care whether it's readable or not. Of course, at a certain length, it's worth reconsidering whether storing all the data in the URL is a good idea.
Re:How to store your app's entire state in the url by pifm_guy on Tuesday January 10, 2023 @04:58AM (#34322564)
A flowchart can be encoded as simply the name of the state you're currently in.
Re:How to store your app's entire state in the url by michaelmior on Tuesday January 10, 2023 @05:06AM (#34322628)
How do you know what all the other states in the chart are and how they are connected?
Re:How to store your app's entire state in the url by wildrhythms on Tuesday January 10, 2023 @08:57AM (#34324863)
How would you predefine a state to include the flowchart nodes that the user creates?
Re:How to store your app's entire state in the url by voidmain0001 on Monday January 09, 2023 @03:45PM (#34315769)
Pass that super duper long Yahoo URL to Tinyurl and shrink it down to https://tinyurl.com/bdfepwar

It seems like storing state in the URL could benefit from URL shortening techniques so long as the secret sauce logic is both client and server side.

Re:How to store your app's entire state in the url by stnmtn on Monday January 09, 2023 @03:47PM (#34315791)
This loses all the benefits of storing all state in the url, which is that it's inspectable by the client. Using a URL shortener still makes all the data stored somewhere in the server
Re:How to store your app's entire state in the url by voidmain0001 on Monday January 09, 2023 @05:56PM (#34317713)
Okay that's not exactly what I had in mind. My suggestion was to implement the same hash both server and client side so that the query string is small and manageable. Don't worry about the state not being fully legible because you will implement the hash decode on the client too. The code will be there for you to peruse.
Re:How to store your app's entire state in the url by vikramkr on Monday January 09, 2023 @07:27PM (#34318571)
How would you decode the hash? Amy of infinite states could map to the hash
Re:How to store your app's entire state in the url by voidmain0001 on Monday January 09, 2023 @08:24PM (#34319062)
I've lost my mind. I literally just implemented a dictionary web API the other week and have completely forgotten how I did it. Just forget what I wrote.
Re:How to store your app's entire state in the url by lsaferite on Tuesday January 10, 2023 @12:26PM (#34328278)
The primary benefit of storing all the state in the URL is that the server can be stateless. Using a shortener just moves the state to a different server. A user being able to inspect the state is just a side benefit.
Re:How to store your app's entire state in the url by thewisenerd on Monday January 09, 2023 @03:56PM (#34315923)
ah, azure does the same for generating the "share" URL for their cost dashboards.

it additionally gzip's the data to compress it futher, with.. some savings..

in the above example you've shared, gzip would've,

  orig=1177
  base64=1572
  gzip(orig)|base64=768
Re:How to store your app's entire state in the url by galaxyLogic on Monday January 09, 2023 @08:03PM (#34318891)
Right no need to put it all in the URL, it could be just a random key pointing to local storage for instance, if not some cloud database.
Re:How to store your app's entire state in the url by thunky on Monday January 09, 2023 @08:53PM (#34319313)
If it points to local storage then it's not shareable.

If it points to a cloud database then you need a cloud database to do what a url could do.

Re:How to store your app's entire state in the url by galaxyLogic on Tuesday January 10, 2023 @01:11PM (#34328982)
Good point
Re:How to store your app's entire state in the url by __derek__ on Monday January 09, 2023 @08:44PM (#34319235)
In a similar vein, I've long been a fan of Kayak's URL structure.[1]

[1]: https://www.kayak.com/flights/SEA-IND/2023-01-10/2023-01-14?...

Re:How to store your app's entire state in the url by thunderbong on Tuesday January 10, 2023 @01:23AM (#34321224)
I used to obsess over URLs as well, until the day I realised that there's no web page with the URL gmail.com!
Re:How to store your app's entire state in the url by itssumitrai on Tuesday January 10, 2023 @03:25AM (#34321989)
In this case, its actually required. The state is actually for the entire chart. It has lots of settings not just the time duration but type of chart, crosshair should be set or not, then there are several types of chart studies which could be applied on chart along with their own settings. And also the chart drawings with their own settings. This feature is there so that people can share their own customized chart in full with others, and not a generalized chart.
Re:How to store your app's entire state in the url by OOPMan on Tuesday January 10, 2023 @09:33AM (#34325398)
I feel like you're ignoring the context of the linked post while also trotting out the most obvious comparison of all times.