5 ms·
I am a backend engineer by trade, and I have been trying to learn me a little React because I decided I should learn new tech (not the stuff I use on a daily ba
by fb03 5y ago
I am a backend engineer by trade, and I have been trying to learn me a little React because I decided I should learn new tech (not the stuff I use on a daily basis, which is Python) on side projects. So the backend is being done in Rust, and frontend is using React.
I had this moment where I thought "well, I need Typescript, because I want nicely typed interfaces and contracts, and I need React". Turns out it's not easy like that. To cobble everything together you need a proper template for webpack. and there's Babel and that also needs to be caressed in the right React-y way. You can't just "hop in". You have to use cookiecutter-styled tools to bootstrap because the whole thing just got so complex so that even a Hello World styled project needs a mindboggling amount of tools all orchestrated and plugged into each other in the right way or it all blows up in your face. Also, there are more than one cookiecutter-styled tools and you have to choose the right one. "But don't fret you can always run eject to see the whole machinery inside".
It's saddening and tiring.
- lsalvatore 5y agoYou didn't need TypeScript. That was your first mistake. If you had chosen Create-react-app (the official boilerplate) - that's all you need. Hello world right out of the box. Nothing blows up in your face. Nothing mind-boggling. I've never had to ever run eject. Nothing saddening, nothing tiring. In fact- just the opposite. Happiness, joy, energizing React productivity.
- tclancy 5y agoYou can literally pass a flag to that command to get all the same stuff in Typescript. Don’t yuck someone else’s yum.
- dragonwriter 5y agoCreat-React-App has a TS option (and, IIRC, it's not that hard to use TS on a CRA app that wasn't created with that option, but it's been a while since I did that.) Manually setting up React (with or without TS) isn't all that hard, either.
- RedShift1 5y agoSame experience here, I wouldn't be able to get off the ground without those templates. Plus updating can be a nightmare, if you regularly update and the build breaks then it's easy to find out what caused it, however a few months down the line be prepared to spend significant time figuring out what broke again and how to fix it.
- deleted 5y ago[deleted]
- iamleppert 5y agoWhy do you need types to learn React? You really need a compiler to tell you when you have made a mistake that bad? Your first mistake is trying to add typing on a dynamic language that works just fine without types. You won’t really learn the underlying language that well that way, and you therefore won’t have a good understanding of it. TypeScript makes sense in large projects, with many developers where you need to catch a class of problems that compile time type checking can catch. It doesn’t offer a lot or add much in the way of actually learning the fundamentals of frontend development and is a distraction when viewed through that lens. Are you sure you weren’t actually avoiding the scary unknowns of actual learning and doing a bunch of busy work to bring familiarity into an otherwise unfamiliar space? I catch myself doing that a lot, especially if I need to learn a completely new language to learn something. I wasted a lot of time trying to make OpenCV work with native JavaScript when I should have just learned enough C++ to get by.
- programmarchy 5y agoI used to think like this, but TypeScript has saved me massive amounts of time. If you ever refactor your code, the compiler will help you trace all the dependencies, so you don't end up with subtle bugs or broken code. In other ways, TypeScript deepens understanding of JavaScript. For example, TypeScript forces you to think explicitly about the differences between undefined and null, helping you to know the difference and to avoid a whole class of JavaScript pitfalls. You can also look at a function signature and know exactly what inputs and outputs it requires, rather than having to memorize or search docs. Even for smaller projects, I start with TypeScript now.
- dragonwriter 5y ago> You can't just "hop in". You have to use cookiecutter-styled tools to bootstrap because the whole thing just got so complex so that even a Hello World styled project needs a mindboggling amount of tools all orchestrated and plugged into each other in the right way or it all blows up in your face. Manually setting up React isn't all that hard, but it's extra friction you don't need when learning to code React (and probably 999 out of 1000 times using it in anger, either.) So, yeah, using CRA or another template is generally a good idea. > Also, there are more than one cookiecutter-styled tools and you have to choose the right one No, you really don't.
- dwild 5y ago> Turns out it's not easy like that. To cobble everything together you need a proper template for webpack. and there's Babel and that also needs to be caressed in the right React-y way. You can't just "hop in". I would tell the exact same story if I was to decide to use Python as backend, just with different technologies. Maybe you just tried to do too much too quick. I can build a Python script, just like you can probably build a JS script, it doesn't means that I can just jump into Django head first like it was nothing. You can't just "hop in", you need to learn each step, and that's fine. The number of times I thought it was as simple as a "pip install"... lost quite a bit of time in various CTF while trying to use some Python scripts. You also can stop at any steps, and that's fine too. I know that HN is good at "THIS IS THE ONLY RIGHT WAY", even this thread if filled with people arguing that "web0" is the "right way", but you know what, the right way is the one that works for you, even if it means that some page will take more time to load, or takes more data transfer, or is missing interactivity, or has a less optimal UX, or can be done faster in another way, or any other downside.
- kaz_sadeghi 5y agoYou _can_ just hop in with Flask. That's kind of the main selling point.