Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

He calls file extensions cruft, but i've come to value them. They are a simple way to indicate file type - desired or offered - which is easily understood by machines and people.

I currently work with an API which does a bit of content negotiation using the Accept header, so clients can request data in various formats - application/json for a snapshot, text/event-stream for an updating feed, or text/html for an interactive dashboard. I wish it didn't. I wish we'd just used file extensions. Trivial to use in a browser or via curl, trivial to implement on either side.



That's fine (and already common) for images, JSON, etc.

But nobody wants webpage URL's that randomly end in .php, .htm, .html, .aspx, and so forth. That's just noise that is both gibberish and entirely irrelevant to the user.


.htm and .html is relevant just like .pdf and .zip etc etc

But I agree about .php, .aspx and other extensions that are telling something about the server side. That’s irrelevant for the user.


> .htm and .html is relevant just like .pdf and .zip etc etc

it's _kind of_ relevant, if it weren't for the fact that the absence of any extension implies .html >99% of the time


Wouldn't that also include JSON for the other 47% of the time?


Forever and always .html, because: AESTHETICS


For _APIs_ I prefer to use both - the only downside is that resource names need to be restricted to _not_ include trailing `.{EXT}`s (either at all or limiting EXT to things that aren't valid content types).

E. g. `/books` - looks at the `Accept` header. `/books.json` - sets the `Accept` header to `application/json`. `/books.xml` - `application/xml`, and so on.


> He calls file extensions cruft

I think that refers mostly to the .php and .asp of the time. Those don't tell a thing to the user.


I want users to know I use PHP! :D


And I judge people who use ASP, lmao.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: