News for hackers. Stuff that matters.
Re:The JavaScript ecosystem is a hot mess and so is software... by nayuki on Saturday October 16, 2021 @09:19PM (#28893122)
I'm embarrassed to admit that for web development, I'm afraid to try frameworks like React/Vue/Angular as well as package managers like NPM/Yarn. So I settled on writing raw (X)HTML code and using only vanilla JavaScript APIs provided by the browser (ECMAScript standard library, DOM, multimedia, etc.).

Because of this, I can't bang out complicated software quickly and easily like the stereotypical front-end developer. In exchange, the techniques that I learn essentially don't go out of date and don't randomly break. I settled for only applying what I understand.

I made an exception for TypeScript; I acknowledge the compiler is enormously complicated and requires Node.js to run. But static type checking has saved me from my own silly mistakes very often. And if armageddon ever comes, I can always strip out the annotations from existing TypeScript code and continue with plain JavaScript.

Re:The JavaScript ecosystem is a hot mess and so is software... by recursivedoubts on Saturday October 16, 2021 @09:34PM (#28893200)
I work on a dependency-free, build-less library called htmx:

https://htmx.org

It's more an extension of HTML than a JS library. It might be a good way to gently introduce more dynamic behavior without blowing out the complexity of your projects.

Re:The JavaScript ecosystem is a hot mess and so is software... by pixelgeek on Saturday October 16, 2021 @09:43PM (#28893246)
I am with you. Don't be embarrassed. I spent a lot of time looking at Vue, React and the others and frankly I don't see how the time and effort are worth it unless you work in a large firm that has a lot of developers working on a large project.

I use npm and node because it allows me to write local tools that I write to help me manage data and convert it. I have a lot of other tools that I have access to but I can thankfully access it via CodeKit on my Mac so I don't have to waste time installing and learning them all.

Re:The JavaScript ecosystem is a hot mess and so is software... by dimgl on Saturday October 16, 2021 @09:26PM (#28893163)
> I made an exception for TypeScript

I was nodding my head until TypeScript. I still don't like it even after years of people telling me it's the future. Maybe this is what it feels like to be older.

Re:The JavaScript ecosystem is a hot mess and so is software... by handrous on Saturday October 16, 2021 @09:38PM (#28893225)
TypeScript's the first thing that's made JS tolerable, if I have to touch or use anyone else's JS code. It's pure misery, otherwise.

Writing solo and using no libraries, plain JS is... OK. Anything else, TS is the only thing that keeps me from hating life the whole time I'm working in JS.

FWIW I'm a huge curmudgeon who's usually (eventually) proven right when I hate some new thing that everyone else seems to think is great. TypeScript is wonderful.

Re:The JavaScript ecosystem is a hot mess and so is software... by Tesl on Saturday October 16, 2021 @09:31PM (#28893187)
Nah you're probably just wrong. Generally speaking it's the older more experienced developers who demand typescript in my experience.

Writing raw javascript is genuinely painful, I literally don't understand how people can even do it. Like, how do you even refactor code safely?

Re:The JavaScript ecosystem is a hot mess and so is software... by FpUser on Saturday October 16, 2021 @09:52PM (#28893297)
>" I literally don't understand how people can even do it."

While I definitely appreciate types and normally work with the languages like C++ sometimes I do some front end JS libs and frankly do not have any mental troubles using plain JS. As for whether it is "safe" - all that matters to me if it works to specs and the customers are happy. Since I am programming since like forever I guess I've got enough discipline, common sense, knowledge and experience to produce decent code.

Re:The JavaScript ecosystem is a hot mess and so is software... by dimgl on Wednesday October 20, 2021 @08:50PM (#28938879)
> Like, how do you even refactor code safely?

I've never had issues doing huge refactors in JS. But thanks for telling me I'm just wrong.

Re:The JavaScript ecosystem is a hot mess and so is software... by ryohkyo on Saturday October 16, 2021 @10:39PM (#28893488)
I think that’s where unit tests come in. In Typescript, I have seen “any” type everywhere that doesn’t make things any clearer.
Re:The JavaScript ecosystem is a hot mess and so is software... by holler on Saturday October 16, 2021 @11:38PM (#28893736)
> Like, how do you even refactor code safely?

for me I make sure to write thorough unit tests along with clear, concise code

Re:The JavaScript ecosystem is a hot mess and so is software... by steve_adams_86 on Sunday October 17, 2021 @12:29AM (#28893953)
I think you can combine that with static types and come out further ahead.

To each their own though. I wrote code without any kind of autocomplete or tooling for a very long time because I felt like it. Sometimes when you don’t have something helping you all the time, it keeps you sharper.

Re:The JavaScript ecosystem is a hot mess and so is software... by grishka on Saturday October 16, 2021 @10:01PM (#28893339)
As someone who has mostly the same approach, I too use TypeScript. It makes JS saner and brings it closer to its more advanced cousin from the past, ActionScript. It also adds proper Java-like classes with inheritance, which I, as primarily a Java developer, appreciate a lot.
Re:The JavaScript ecosystem is a hot mess and so is software... by arrow7000 on Saturday October 16, 2021 @09:30PM (#28893179)
What don't you like about it?
Re:The JavaScript ecosystem is a hot mess and so is software... by moron4hire on Saturday October 16, 2021 @09:52PM (#28893296)
I'm a huge TypeScript proponent, but it took me a long time to get on board because getting it into an existing project structure is not easy. I don't even mean the translation portion (which you're also probably doing as you first learn the language), but the configuration of the tool. There are a lot of options and none of them are labeled "please just find my missing dependencies. I can see them right there".
Re:The JavaScript ecosystem is a hot mess and so is software... by spurgu on Saturday October 16, 2021 @09:34PM (#28893207)
Sounds like a solid/healthy strategy to me.

With ignoring package managers, do you mean that you instead of running "npm/yarn install/add <package>" you inspect said package (which does what you need) and cherry-pick the functionality into your own codebase (or just outright copy it if its functionality is elementary to you), or that you try to write/reimplement it yourself?

Re:The JavaScript ecosystem is a hot mess and so is software... by 1ark on Saturday October 16, 2021 @11:50PM (#28893790)
The browser environment enables you to do that, so why not. No dependencies. But do you build everything in house then (time unlimited), or the apps are not that complex? It is the same mindset as writing assembly or small Win32 in C, which I both admire and respect btw.
Re:The JavaScript ecosystem is a hot mess and so is software... by taurath on Saturday October 16, 2021 @09:26PM (#28893161)
To get a good setup in JS there’s a ton of things that are nativeish in other languages (at least via IDE) that are wholly exposed via the package management stuff. The upside of the configurability is you can mix and match, and build something that works great for your needs and your project. Different framework, different test system, different linter, different SQL wrapper, etc. The downside is that it’s overwhelming, even when experienced with it.

I would suggest starting with a bundle created by create-react-app - you will get most of the cool tooling out of the box, and discover the usefulness of some of the libraries.

Having a live loading web app is a really neat and productive way to develop - but getting there can be daunting.