Live data from Hacker News

Websites have evolved back to static HTML/CSS/JS files

paramaggarwal.substack.com

291–300 of 313 posts

Re: Websites have evolved back to static HTML/CSS/JS files

#291
post #256
post #238

Earlier quoted context omitted.

Backends are still a hassle? In what way do you feel Spring (Boot), ASP.NET Core and the like don't solve the problem adequately?

You still have to write one at all? And it's an entirely separate process from the frontend, and usually in an entirely different language? And many places hire different developers to do it? Maintaining a static site is easy and places like github pages will host it for free; you can put a "SPA" in there if you like for no additional cost. But as soon as you need a backend it gets more complicated and expensive. Sti…

Give someone an excel file and they are perfectly happy. Give them a web app to do the same process and suddenly their "needs" forces you to completely abstract all of the concepts to something entirely unrecognizable from the start.

It seems to me I see more and more a growing distance between how data is stored in a sql db and how the data is actually rendered or represented in the application.

Re: Websites have evolved back to static HTML/CSS/JS files

#292
post #256
post #238

Earlier quoted context omitted.

Backends are still a hassle? In what way do you feel Spring (Boot), ASP.NET Core and the like don't solve the problem adequately?

You still have to write one at all? And it's an entirely separate process from the frontend, and usually in an entirely different language? And many places hire different developers to do it? Maintaining a static site is easy and places like github pages will host it for free; you can put a "SPA" in there if you like for no additional cost. But as soon as you need a backend it gets more complicated and expensive. Sti…

I use Dokku, which is like Heroku, but on my own server. To setup a backend, I just write the code with whatever I want (I use Elixir) and I use a local DB to test, using an env var to get the DB host. Then, I create an app on Dokku, a server, and deploy:

Dokku install:

    $> wget https://raw.githubusercontent.com/dokku/dokku/v0.19.13/bootstrap.sh;
    $> sudo DOKKU_TAG=v0.19.13 bash bootstrap.sh
Now, go to the server's IP or the domain you have setup previously and configure it with an SSH key and some other options.

Create an app:

On the server:

    $> dokku apps:create application_name
    $> dokku postgres:create application_db
    $> dokku postgres:link application_db application_name
Deploy the app:

On the client:

    $> git remote add dokku ssh://dokku.servername.tld:22/application_name
    $> git push dokku master
Once more on the server, to get TLS certs set up and auto-renewal (only the first time per application):

    $> dokku letsencrypt application_name
    $> dokku letsencrypt:cron-job --add
Then it just builds automagically, and as long as you use some sort of took to coordinate your database schema (for my use I use ecto migrations), then you don't need to do any more than this, really. You might have to do some limited configuration in your repo, but not much (add a .buildpacks file, then maybe a buildpack.config and a app.json).

For a static site, you literally push a repo with a `.static` file and an `index.html` in the root dir (you can do more complicated things, too).

It's not quite as powerful as k8s or whatever, but it can run small to medium sites easily, and it does have an Alpha-quality scheduler to push to k8s that I haven't tried yet, but should work as well as the Docker backend, eventually (and I'll switch to that when it's fully capable, too).

With DigitalOcean, I hear you can do 1-click Dokku servers if you don't want to do it yourself (I haven't tried this).

Re: Websites have evolved back to static HTML/CSS/JS files

#293

There's nothing wrong with static HTML/CSS/JS. There's also nothing wrong with a rich SPA. And again, there's nothing wrong with using some kind of dynamic server-side HTML/CSS/JS presentation (like WordPress). Where there is a problem is the culture of software engineering, and the tendency to select the newest technology stack of the day for inappropriate applications. I think any seasoned software engineer has acq…

Wordpress is awesome except for gutenberg. They shouldn't have gone down that route.

Re: Websites have evolved back to static HTML/CSS/JS files

#294

There's nothing wrong with static HTML/CSS/JS. There's also nothing wrong with a rich SPA. And again, there's nothing wrong with using some kind of dynamic server-side HTML/CSS/JS presentation (like WordPress). Where there is a problem is the culture of software engineering, and the tendency to select the newest technology stack of the day for inappropriate applications. I think any seasoned software engineer has acq…

Wordpress is awesome except for gutenberg. They shouldn't have gone down that route.

Users love it though.

Re: Websites have evolved back to static HTML/CSS/JS files

#295

Earlier quoted context omitted.

I don’t understand how anybody can like gmail’s interface. It’s so convoluted and unintuitive.

Quite the opposite, it does its job pretty well for me. It has good keyboard shortcut support, and the UI is only lagging if I go into 80-100 long email threads otherwise pretty good. What's unintuitive about a list of emails and few simple features? You also bog my mind :)

I don't like how it is formatted for starters. Also the reply button is impossible to find- since its not at the time like it logically should be. Reply all and other options are hidden instead of being exposed. When clicking on reply, it takes me to the bottom, away from the content so its impossible to read and response.

It also doesn't have proper mailboxes, and rules are impossible to make.

I do not like it at all.

Re: Websites have evolved back to static HTML/CSS/JS files

#296
post #294

Earlier quoted context omitted.

Wordpress is awesome except for gutenberg. They shouldn't have gone down that route.

Users love it though.

If by "users" you include developers who spend most of their time with the system, the two thousand 1-star reviews ¹ will beg to differ.

¹ https://wordpress.org/plugins/gutenberg/#reviews

Re: Websites have evolved back to static HTML/CSS/JS files

#297

Earlier quoted context omitted.

> How is that not the definition of a function or a method? It basically is and that's the point. With SPA's you generally structure it so your entire app is just a function. The same cannot be said of traditional server/client apps which consist of multiple moving parts (PHP backend / jQuery frontend) which do not have an explicit contract with each other, you're just taking shots in the dark hoping your jQuery sele…

> The same cannot be said of traditional server/client apps which consist of multiple moving parts (PHP backend / jQuery frontend) which do not have an explicit contract with each other, you're just taking shots in the dark hoping your jQuery selectors match up with what the PHP backend spits out. If you don’t know how your code will work, that’s an issue with the quality of the code. > What? There is only one sense…

> If you don’t know how your code will work, that’s an issue with the quality of the code.

No, it's a fundamental difference between declarative and imperative programming. With imperative programming (e.g. PHP + jQuery) you cannot know what's in the DOM resulting from PHP-generated HTML you are working with, you need to either make naive assumptions about the DOM or litter your code with conditions checking the state of the DOM before operating on it. With declarative programming you declare the structure you want, so you know exactly what you have, because it's what you've declared. There's no need to check that the PHP backend rendered some element to the DOM to enhance with JS functionality, because I already declared that element is in the DOM in my JS directly.

> With a language like PHP, if you call a function twice with the same input, why would the function return 2 different outputs?

Again, this has nothing to do with languages and is purely about programming paradigms. What you're referring to is one of the possible "islands of functionally pure, declarative code" I previously mentioned. Pure functions in PHP can be deterministic, and pure functions in JS can be deterministic, but the overall application behaviour of how your front-end (jQuery) handles the output of your back-end (PHP) results in the application being non-deterministic. For example, say you have some form that submits data and on the posted page, displays a green thankyou message in a div. Say you want to animate this div message with jQuery. You cannot safely make any assumptions about the presence or prior presentation of the div, because from the context of jQuery you don't even know if the form has been submitted and the div rendered by PHP. You need to either: - Imperatively check the current state of anything you wish to change prior to changing it. - Naively make assumptions about prior state resulting in non-deterministic behaviour.

jQuery makes this easier by solving that problem on node "existence" with their selector-based API which simply doesn't run your function if the targeted nodes aren't found, but the problem still remains for general state, any jQuery code needs to either explicitly check the state of everything it touches (brittle code, hard to reason about and maintain) or make naive assumptions and be non-deterministic (which seems to have been the norm).

> The output of this is deterministic. Given jQuery works, the element will resize and change color.

False, it is non-deterministic because the ultimate outcome (what you see) depends on implicit state from side effects. For example if you toggle the resize control, the resulting display is based not only on your action (input) but also whether the colour change button was already pressed (an unrelated side-effect not a concern of the logic for resizing), or if PHP initially rendered it in a different size/colour, or maybe PHP decided to not render it at all because the user's session ended? From the context of jQuery you can't determine any of this, the only way you could come close to deterministic behaviour is by explicitly checking every single bit of stateful DOM before working on them, which I've never seen done in a large project (and would be hell to maintain).

> If something is deterministic is dependent on the algorithm it has.

Yes and any algorithm which has its outcome impacted by side-effects or unmanaged state (i.e. pre-rendered HTML/DOM from PHP, changes to DOM from other side-effect causing callbacks) is inherently non-deterministic. For an algorithm to be deterministic it needs to take every single thing that could affect it's outcome into consideration as input, and I have yet to see any jQuery apps which parse the entire DOM and use it as input to achieve deterministic behaviour

> The assumption here is that declarative is deterministic and anything else isn’t and that’s just not true.

No my point isn't declarative being inherently deterministic, rather that imperative is almost always inherently non-deterministic. By the nature of imperative programming you are making assumptions about your environment (i.e. there's DOM nodes to work with) which makes it intrinsically non-deterministic (those DOM nodes could not even be there)

Re: Websites have evolved back to static HTML/CSS/JS files

#298

Earlier quoted context omitted.

To word it more technically, building an SPA allows you to build applications as declarative composable functions which are deterministic, as opposed to the spaghetti code commonly seen in the days of jQuery and PHP which is harder to read, reason about, debug and maintain due to their imperative and nondeterministic nature.

Well, I'd argue that old fashioned PHP sites are structurally really similar to modern declarative client-side UIs, in that in both cases your're basically just constructing a series of functions that (deterministically) convert the current state to HTML. Client-side rendering without declarative framework (say jQuery or vanilla) is different, in that you also need to consider state transition. This gets complicated…

Yeah fair call and it's more the combination of PHP + jQuery I'm referring to as being non-deterministic rather than either on their own - you can definitely write deterministic PHP and jQuery code, but the implicit integration between them (PHP rendering HTML which becomes a DOM which jQuery imperatively operates on) is what I'm saying makes it non-deterministic. I'm mostly talking about the part you mentioned in managing client-side state using a non-declarative paradigm, where you either end up with a stupid amount of unnecessary complexity (conditions checking the prior state of literally any and everything you touch, I've never really seen this in a production project) or making naive assumptions about the DOM which means non-deterministic and potentially unexpected behaviour.

> If you can get away with it, I'd say the old fashioned approach takes less development time because you don't need to handle asynchronous (and possibly failing) state syncs. The database containing any state you might want to access is available synchronously!

Fair point but there's also a flip-side to this though. You can write a client-side PWA with all your async state and data persistence magically handled by a service like Firebase Cloud Firestore, so just writing the UI declaratively and not having to worry at all about servers or databases, which generally requires a lot more upfront planning (figuring out models/schemas to represent your data, service architecture etc) than just slapping a UI together and wiring inputs up to a production-ready persistence layer API in front of a schemaless NoSQL DB like Firebase.

Re: Websites have evolved back to static HTML/CSS/JS files

#299
> Playing football is very simple, but playing simple football is the hardest thing there is

This quote is from Johan Cruyff - A football legendary. I feel it also true with programming.

Nothing wrong with the technical stacks, in my opinion: Do the right work, at the right time, with the right tool.

Re: Websites have evolved back to static HTML/CSS/JS files

#300
post #272

Earlier quoted context omitted.

I'd rather Janine ping me three times a year to change some string than deploy PHP with mysql.

Php with mysql is amazing. I don’t get the “i’d rather have Janine ping me three times an year”. What if you leave work? What if you are too busy with your next hobby project that you don’t give a shit about Janine? What if she wants to update brochures every now and then and your manager says you’re too expensive to help Janine. Tech is about automation. Php + mysql still serves well in this era. Wikipedia still run…

>What if you leave work?

Next dev will have easier time changing string in plain, straightforward code or static site generator than migrating plugins from PHP 5.3 or whatever.

>Tech is about automation.

Tech isn't about "automating" things that ultimately cause you to do more work to maintain status quo. Tech isn't about spending week to automate things that take you 1 minute three times a year.

Post reply on HN