5 ms·
I can't help but feel like this article is a good summary of what's wrong with the modern internet. It's not a bad article, it just feels like a parody. 'Ok gu
by grawprog 6y ago
I can't help but feel like this article is a good summary of what's wrong with the modern internet. It's not a bad article, it just feels like a parody.
'Ok guys, now here's the modern way to make one of the more simple things from yesteryear.
First, lets bust out react....
A few hundred loc later...
Ok guys the database...
Sign up for account
Several more hundred loc later...
'Now to actually write our functions'
Download some dependencies
Several hundred loc later...
And...here's your hit counter guys...
This whole article just captures perfectly the essence of all the things we complain about with the modern web.
Overengineered, convoluted solutions to simple problems.
Honestly, it would be nice sometimes if modern solutions remembered sometimes, it's ok to just keep it simple.
I did have a quick look around to see if i could find a simple, 'modern' hit counter.
https://www.codementor.io/@jamesezechukwu/how-to-create-a-simple-counter-using-javascript-html-css-bxcjgbbxa https://www.codementor.io/@jamesezechukwu/how-to-create-a-si...
Personally, I prefer the simplicity of this to the article myself.
- jedimastert 6y agoThe one you've linked to doesn't seem to actually store the count anywhere, which seems to be the hard part.
- tyingq 6y agoAgree with a lot of what you wrote, but the example is weird. It's a client side counter with no persistence.
- grawprog 6y agoYeah, i realize that, it was just something quick I found after about a 30 second search. I wasn't trying to complain about the original article itself, it's obviously a production ready example whereas my linked one not so much. It's just the general idea that, such things are required even for something so simple just seems over the top when you look at something like a hit counter alone. It's just overall, if we tried to simplify, the simple things, would all the rest of the frameworks and apps end up being so convoluted and overengineered?
- tyingq 6y agoYes, I imagine there's some example that uses Redis or similar with a proper increment and locking somewhere, perhaps in an eventually consistent way that doesn't block the page load.
- joshwcomeau 6y agoThis article is meant for folks who already have a static React site, and want to dip their toes into doing some backend stuff. It isn’t really meant to be the simplest way to build a hit counter. That said, I challenge the assumption that this way is _that_ much more complicated. I’ve built similar things with PHP, a long long time ago, and it was a lot of the same pieces. The only part that feels truly more complex is the re-render necessary in React, since the data comes in async, but this is hugely beneficial since it means the page doesn’t need to be server-rendered / the user isn’t staring at a white page waiting for the RPC to the database. Edit: realizing that there are ways to do this in PHP that aren’t blocking, like if you use an image tag that resolves to the right image, but honestly that way seems wayyy more complex to me, especially when factoring in accessibility / screen-reader-friendliness.
- oefrha 6y ago> ... it means the page doesn’t need to be server-rendered / the user isn’t staring at a white page waiting for the RPC to the database. React-based frontend didn't invent XHR. In the old days you just do <script>$("#hit-count").load("/path/to/hit/count");</script> Edit: Not saying old hit counters are implemented using XHR.
- joshwcomeau 6y agoReally??? Who knew My point is that my example is complex because some client-side code is necessary. The snippet you shared is nice pseudo-code but a real implementation would be comparable in complexity. Either way you need to learn some stuff, and then it’s a few lines of code.
- desmondl 6y agoI understand where you're coming from, but I'm going to play devil's advocate and think through everything that needs to be considered for a simple, "back in the day" solution that involves apache, php, and a mysql database: 1. Provisioning the server, either via VPS or setting it up on your local machine and exposing port 443. 2. Installing Apache on your operating system 3. Installing a cert, getting it signed by an authority 4. Installing php, enabling it in apache 5. Installing mysql At this point you'll have to write your php from scratch or use something like wordpress. Assuming we want to keep it as simple as possible and write php from scratch, you'll want to consider file permissions so your database credentials aren't accidentally leaked. 6. Creating the schema and tables on your database 7. Distributing your site's static content through a CDN And this doesn't even involve automated deployments, which these services give out of the box. My point is that a "traditional" approach can appear just as overengineered and convoluted if we want to replicate the scalability, stability and security of solid PaaS services like Vercel and Fauna. I get that a hit counter is very simple, but I assume the point of this article is to provide a simple "hello world" example that uses these PaaS services, which again, provide a lot of benefits over manually configuring infrastructure.
- cj 6y agoYour point is valid, but only in cases where you don’t already have everything you listed set up. I think the OP’s comment was coming from a perspective of someone adding a hit counter to an app that already has app servers, etc, already in place.
- bryanrasmussen 6y agoif that's the case then the OP's comment should take into consideration the perspective of someone who already has most of the things listed in those steps setup. In which case - as an example - you don't need to set up a serverless account and have several hundred loc for that because you've got that in your app already, and probably only need 1 loc to call what you need. Now I'm arguing on the side of serverless, sheesh.
- coffeemaniac 6y agoThis is a blog about building static sites with Gatsby. Doesn't feel like the author was endeavoring to do this in the "simplest" way possible, but rather to demonstrate some of the tooling to put dynamic content into an otherwise static site. Does every other article about serverless technology provoke this kind of ire on HN?
- bryanrasmussen 6y agoyeah, but what you link to isn't a real hit counter? It makes something that looks like a hit counter without any of the backend stuff you need for a real hit counter. As far as how simple it was back in the day https://news.ycombinator.com/item?id=24618580 https://news.ycombinator.com/item?id=24618580 already said.