Hacker News new | past | comments | ask | show | jobs | submit login

Congrats on the launch, looks neat!

> and b) building my own frontend (probably via React, and then maybe via formik)

There's also a new technology called HTML. It comes with a <form> tag, <input> field tags, and even a <button> to submit!

Although new, they managed to get all browsers on board to support it.

You will not need to import 150kb of JavaScript, though, which is sad. And it's not shiny to speak about in the interview for your next job.

I guess the pros dont overweight these cons... Yes, "probably via React" is the way!




Let me tell you something about this fancy HTML tag you are talking about.

It has an "action" attribute that points to a server you need to own and run a code you need to code in order to validate the input and store it in the database. If you are comfortable doing this, which no doubt you are, then you are not the target audience of this tool.


Let me tell you something else.

If you read the comment again, you'll see I'm replying to OP's scenario of setting his own server and frontend.

I'm questioning the "probably using React" part of the frontend because... it's an overly complex solution to an already elegantly solved problem?


> It has an "action" attribute that points to a server you need to own and run a code you need to code in order to validate the input and store it in the database

Pure-HTML forms work exactly like React forms; React does the lifting but it doesn’t change anything to the fact that the data eventually needs to be sent to a server to be stored in the database.


> Pure-HTML forms work exactly like React forms

This should probably read "React forms work exactly like pur-HTML forms" seeing as HTML came first and react ultimately spits out either an HTML form or a form request.

The original point still remains though, reaching for react just for forms is really heavy handed. It works fine if everything on the site is react already, though that's an assumption that I wouldn't make and that I hope will die soon enough if devs finally start moving away from massive react apps.


Why do people here commonly imply downloading 150kb of data is an issue in the current year?


From the user perspective, forcing to download 150kb unnecessarily is a bad professional practice. Not everyone has 5G and an iPhone.

From the dev experience perspective, these 150kb of Javascript and the complexity you'll build upon it will come with bugs, security holes, updates, maintenance. Personally I wouldn't want this for me unnecessarily.


Because it is. It can be very frustrating not to be able to fill a form on mobile with a 3G connection just because some random dev decided that downloading 150kb of JS to render a simple form is fine.

I mean it’s a form; we already have all the HTML elements already; why do you need React for? This is why nowadays we end up with Electron apps that take 6GB of RAM to display a chat.


It's really not that simple.

What about complex validation rules? Do you really think it's user friendly to require them to send the whole form just to tell them "sorry no" 10 times over until they get it right?

What about multi-value selects, potentially with rules? E.g. form field like "choose up to 5 locations in the radius of 10km".

What about form fields like "pick a point on a map"?

Etc. Don't act like every form is 5 simple text inputs.


Doing validation in the frontend is a bad idea.

You'll have to do in the server, if you're sane.

I bet Retool Forms does in the server.

You're worried the page will refresh with an empty form, if it fails. It's simple, just collect the data and return the form pre-filled using the value attribute, along with the error message.

If you don't want to refresh the page, you could even use something like htmx, which is a LOT simpler than React, but really not necessary for simple form submission.


Of course you have to validate on the server. That's a given, always.

But you want to provide better UX to the user.

Htmx is not simpler than React. I can't deploy that without a server that knows everything about the frontend. React allows me to decouple. Templates are hell. I lived in it for many years, never again.


Detractors of the "html over the wire" movement are always talking about it as if the people working on this stuff didn't live through the jQuery days and are blindly repeating them.


What's wrong with jQuery? All my homies (favorite websites) are jQuery.


jQuery is still viable in many situations! My comment is directed at people who say you can't sanely build bigger things without React.


Sure, you do you. I spent 10 years working with jQuery and am very thankful to leave that very far behind me.

BTW: jQuery is 85.1 kB minified and 29.7 kB gzipped. Preact (same API/dev experience as React, minimal performance impact) is 11.4 kB minified and 4.5 kB gzipped. Who has the smaller JS bundle now?


So did I and you’re side-stepping my initial comment by responding to my response that people can use jQuery if they want. I no longer use it myself nor, btw, did I say anything about its size.



Yeah until a manager comes and says "well great, it works, now let's do a mobile app like that"



Why though? It's much easier to do a simple API (or use a pre-made one like this one) from the web and the app. And no need to change the backend code on design updates.

I just don't get what you're chasing after. All this seems more complex (to develop, to maintain, to operate, to manage) than what I'm doing with (P)React (Native) and APIs.

And where are the thousands of pre-made components like React has?


well, an extended answer is offered in the essays linked above, but, to take some numbers from https://htmx.org/essays/a-real-world-react-to-htmx-port/, here's why:

- no reduction in app ux

- code base reduced by 67% (21,500 LOC to 7200 LOC)

- total JS dependencies reduced by by 96% (255 to 9)

- web build time reduced by 88% (40 seconds to 5)

- Time-to-interactive reduced by 50-60%

- htmx allowed them to display much larger data sets

- memory usage reduced by 46% (75MB to 45MB)

the essays above also discuss why to split your apis (disentangle web app churn from your general purpose data API) and how to avoid duplicating logic (the mvc essay)

i take pains to reiterate in the essays and book that htmx isn't right for every application, but it is a good architectural choice for some, and many more than most web developers who are used to reactive-style programming would think

there are not thousands of pre-made components for htmx because there are no components for htmx: there are rather components for HTML. those components should integrate with htmx in the HTML-standard manner: events & form participation


Sorry but this sounds like they just didn't know how to write React and didn't take the time to learn it. You can write React and have 2 runtime dependencies in total - react and react-dom. Or you can go for preact and have exactly 1 runtime dependency - preact. Everything you need is there.

Time-to-interactive has never been a problem for me. My code-splitted bundles are so small they're pre-loaded quicker than the server-rendered HTML code. And builds? My apps - even big ones - build in single digit seconds (using swc or esbuild), and small ones like forms we're talking about in less than a second. The only thing that takes long time is TypeScript typechecking, I do that in a separate task in my CI while the build is long done and tests are in progress at the same time.

I'm not saying all this is super easy - obviously it's the product of using React literally since it's first public beta release. But it's also not impossible to do, and setting up a htmx and a server to run it on is IMHO similar complexity.

The biggest mistake people do - they use stuff like create-react-app with a bunch of absolutely unnecessary cruft. And then they follow some tutorials made by a dude who knows React for 2 months. Just read the React docs (except for the create-react-app part) and you're good to go.

BTW: jQuery is 85.1 kB minified and 29.7 kB gzipped. Preact (same API/dev experience as React, minimal performance impact) is 11.4 kB minified and 4.5 kB gzipped.


¯\_(ツ)_/¯

there's always gonna be a hypothetical objection if you want there to be

maybe read the essays and/or book, maybe try it out on a simple project

or don't, doesn't really matter much


> Don't act like every form is 5 simple text inputs.

Well to be honest 99% of forms are 5 simple text inputs with a select. What was the last time you had to implement a "choose up to 5 locations in the radius of 10km", really?

> What about form fields like "pick a point on a map"?

Same thing: of course there are rich forms for which you need JS, but they are the exception, not the rule.


React isn't required for client-side validation or non-spec form inputs.

Doing form validation in event handlers for DOM events works very well, and a simple script tag or custom element is all that's needed to build a multi-value select.


It's not simple. I made multi-page forms with dozens fields where your suggestion would lead to intangible mess of spaghetti code - I know because I worked with the web way before React. Even with the best coding standards and a team of seniors it's just too hard to maintain - and seniors usually don't write forms.

I really don't want to go back to the jQuery days. You do you, but don't say it's easier - it really isn't.

BTW you can just use Preact if you're worried about the bundle size. I do that, it's perfect and just a little performance impact, usually not visible in small apps.


Oh that's interesting, multi-page forms are actually my least favorite form use case for react.

I reach for a state machine whenever possible to manage the complex flow of the multi-page or multi-step form, even if react is still used for custom inputs.


Check out XState, it's really great!

But it's not that necessary in my case, my forms are usually not complex statecharts, just a lot of individual and largely decoupled complex form controls - multiselects with rules, map pins, tag inputs with autosuggest, data grids etc.


> What about complex validation rules?

I wpould use my server-side form and database library, Bozen[1] to do this.

>

[1]: https://github.com/cabalamat/frambozenapp


So the user would have to submit the form and be met with 10s of errors? I'd rather tell them immediately.


Sure, and React is the best way to show a message in response to an input in a web form, right?

Let me tell you some news, they just launched an integration of this new HTML <form> thing with javascript, so you can have JS listening to inputs and displaying information anywhere on the page. Cool, isn't it?

Ah, but the sad part, again, is you don't get to download an unnecessary library for that. It comes baked and activated into all browsers by default. It doesn't make your resume shine, either...


(P)React is the best way to do it in a maintainable, easy-to-reuse, easy-to-understand, extendable fashion, indeed. Show me something better and I'll jump on it.

I don't care about resumes, I own my consultancy. I care about quickly solving business problems for my clients, not making new problems in the process, and reusing the solutions. I am not paid hourly, I don't make money from fixing spaghetti code broken by adding a stateful form control elsewhere.


Just saying: You can do input validation without JS using the pattern attribute.


If people typically get 10s of errors on a single form, it might well be better to split it up into several sub forms.




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

Search: