BYOJS (Bring your own JS)
byojs.dev
byojs.dev
I have never felt as powerful or productive with JS (as much as I love it) as I have with Ruby on Rails.
I’ve “almost built” countless projects that never actually shipped with Node. Whereas with Rails I have shipped so much I feel like I was cheated out of the first few years of my career not knowing Rails.
All that to say. I love JS (and especially TS), but they’ve got to find their “Rails” before I can truly come all the way back.
There’s a few contenders (Redwood, Adonis), but none of them have been battle tested the way Rails has—yet!
However, interestingly I don’t find I need libraries that much with Rails, which is part of what I love.
I started out hating the Ruby language but honestly I’ve begun to like it the more I use it.
I always just end up using express instead...
The more I work with MVC page-based apps in Rails, the more I’m convinced it’s an incredible default that you should deviate from only when it really makes a lot of sense.
I hope to move to TS in 2025
But, we still don't use a frontend framework, we just write components as classes. Each component takes a root node that the parent is supposed to "own", and that's kinda it. React is more productive short term, but I find this easier long term with complex UIs, keeping memory usage low, and less work keeping stuff upgraded.
It's basically a home-spun version of backbone, and the reason people don't do that so much anymore is the same that backbone fell out of favor- you don't naturally get composable components without lots of manual management and excess paints and reflows.
It's certainly possible to build what 75% of websites actually need with this approach, but I wouldn't consider it for a moment for any UI that I actually consider to be complex.
The only way to do home-spun stuff in JS/TS is to narrow the use-cases and components down religiously. The moment you'll require more than 2-3 bits of the website to interconnect... take one long hard look at the future and avoid the headache of writing your own JS boilerplate.
I love eschewing JS frameworks as much as the next man, but I also love my free time. Too much to waste it debugging problems coming from hundreds of different user stories and approaches. React's mature enough, as are most of the big libraries commonly leveraged on it.
React is on like version 18, you guys can keep getting paid to upgrade frontend libraries every year, I'll watch.
Mature software doesn't break things every other year.
As an illustration, try to make a website that has 1000 drag-and-drop elements that you can drag around the page. Getting it to render at 60-120 fps is hard and fragile.
Glad I always avoided react then, despite all the hype.
It really hasn't been a productivity issue for me... I wrote all of fastcomments (uis, backend), so... :P
There's very strong reasons a vast amount of people are switching to typescript. It can very easily compile to clean javascript, you can commit that to git, and you are much better off.
I'd still not go without React (or something similar) to manage DOM in the user-land, but there's something blessed about using barely any to no JS at all in an admin/moderator UI, or in dev tooling. Don't have to consider any of the compatibility/update headaches outside of the user space.
That rant aside, I feel that the best approach to JS is a static one. Build your code and your artifacts, package them long-term... serve them when needed and you're done. It's somewhat retro, SPA style, but it works like a charm and doesn't require building all the time, nor babying all the dependencies and build steps.
Paired with Claude Sonnet 3.5 and I'm more productive than I've been in years.
I've been thinking about making my own lit-html + honojs isomorphic "framework" and would love some inspiration.
On a positive note, it's a joy to compose my own framework.
Is yours shared publicly anywhere? I'd love to check it out for inspiration.
I wish we could get rid of "vanilla js must imply going back in time 10 years" ideology because it's so unnecessary. Using typescript doesn't mean you have to go react or other libraries.
It's just that instead of measuring those bugs in hours, they don't even exist to be measured.
hours beautifully wasted configuring, updating, getting beaten by a myriad of build tools, configs, breaking changes, wrong/any types all everywhere. No, thanks.
If you're prone to making easy to avoid errors in your code, then maybe Typescript will save you time. For me, that is not the case. YMMV.
But it's worth it because you're about to get a massive multiplier effect based on the scale of your user base.
So what if I'm not a "library author", what I do could still be non-trivial, and I could still do it without typescript like people have been doing for decades before. Typescript is not the only strong-typing game in javascript town.
>But it's worth it because you're about to get a massive multiplier effect based on the scale of your user base.
Using typescript is not a causal factor for this. What the library does, and what people need is.
And honestly I don't care who is using a library I make, life isn't all about likes and it isn't a popularity contest.
Anyway, this gets off-track. The metric is (time wasted on problems that only exist without typing) / (time it takes to configure TypeScript). Regardless of what your 10% figure is, learning TypeScript and configuring it for a project takes less time.
> If you're prone to making easy to avoid errors in your code, then maybe Typescript will save you time. For me, that is not the case. YMMV.
Putting aside the dig, it sounds like you're working alone, so use whatever you want. It matters a lot less when you control the data structures and hold the entire program in your own head.
Moderately sized polyglot orgs will have a specialist for this position.
storage for example:
https://github.com/unjs/unstorage vs byojs storage https://github.com/byojs/storage
most users are going to prefer autocomplete and types regardless of if they also use typescript.
you can try it here https://bwasti.github.io/mebm/
I plead guilty your honor
Explicit typing also helps show where code needs to be explicitly performant and of course where type strictness is valuable.
I'm assuming of course that types in js flavors has performance advantages a la asm.js, but admittedly I haven't tracked JavaScript evolution that closely.
If it isn't typed then that helps clue the programmer that looser dynamic techniques being used.
This way you can split the type checking from the actual bundling, as esbuild only does the latter.
edit: nevermind i get what you're saying. check types with tsc and dev work with esbuild
Yeah it is getting lost, more and more lost each year - you know why? The core JS language is bad. Note how the author uses the word 'core' instead of what they really mean: 'subset'. Use a subset or a small portion of the language, because if you use the whole breadth of language features, you will litter your application with so many landmines that you will eventually scrap it and re-write due to how awful most of the 'features' in JS are. Even using a subset you have no choice to resort to syntactical verbosity to get around bad language design, like === over ==, or const & let over var.
I wonder what the ultimate point of posts like these are; it's like someone trying to light a fire during a flood; and to what end? To pointlessly champion a bygone era of when people didn't know better? Let's be clear here, JS is popular because it is the only language shipped by default in browsers, since 1996. That's it; it's not popular because it's good; we're not using it in 2024 because it won out in a contest of merit. It's design phase was rushed and even its name betrays how stupidly conceived it was; 'JavaScript' - as if superficial association with an already trendy tech during the 90's was somehow enough to paper over it's obvious flaws as a language. Just laughable.
Seriously, it's 2024, we know better now - use TypeScript. It's actually kind of amazing how Microsoft released TypeScript only in 2012 and not years earlier.
To reacts credit, they started out heavyweight, but they knew it needed to be to address the problem in the manner they desired
I've done the whole "I'll write it all in JS by hand" to a ludicrous degree: https://luduxia.com/whichwayround (and the rest) and while there were advantages when this started I am now looking to port the useful bits over to saner ways for future maintenance.
I came from many years of compiled languages in the games industry. I would not assume the current state of React and TypeScript is bad, far from it. There are reasons this stuff has eaten away at more native approaches, or inspired things like SwiftUI.
Edit to add: To also add that in my time I've seen more WebKit added to games in order to do the UI. For instance, that Sim City which was always connected to the cloud, or big bits of the PS4 interface.
Versatility is one of Javascript's strengths, not a weakness. And with that versatility you get what seems like too many frameworks.
To put this in perspective one team I was on built their own Android NDK, until the normal one caught up.
I've been trying to emulate conditional compilation using multiple directories, but that runs into problems with each tool using different path lookup logic.
Many build tools will “tree-shake” unused code and support conditionals when compiling their bundles.
Build time varies considerably depending on the tooling you use and the size/complexity of the project, and is definitely much slower than many other languages, but while developing people will use incremental builds which can complete faster than you can type a new statement.
What other basics are “missing”?
If tree shaking is so good, show me how to write something like this:
* when targeting browser, use dom
* when targeting node, use process/fs
* typescript should bail out if a mixture of APIs is used. That is, the type-checking must be done twice - once for browser-only, once for node-only.
(nodejs is also rather abominable for implementing APIs that really, really only make sense in browsers, like `navigator`, breaking everybody's runtime detection, but all non-browser environments require evil hacks anyway)
It seems like you are trying to do something in a specific way instead of using the available tooling correctly. That’s not a problem with the tool. You just need to RTFM
As for the “massive vtable problem”, that’s not even a tooling issue. Why are you even using JavaScript if that’s a problem for you.
For case 2 you can use esbuild, not something like webpack. Sub second builds are completely normal if you pick the right bundler. Tbh esbuild is the killer thing that moved this mode of js development into being acceptable from a total mess.
`tsc` is so slow that it seems the least bad approach in use is "automatically run it asynchronously in the background", which is not confidence-inspiring.
The background asynchronous incremental typechecking is how most typescript devs are working anyway, as issues are immediately highlighted or otherwise output in your dev environment of choice (whether that be inline, or as output in the console).
Why this alienation?
9 out of 10 JS posts here are talk positively about typescript.
Let the 1 of 10 talk freely, could you?
How has TypeScript hurt you to this extent?
Typescript is obviously so related to Javascript that I wanted to understand more—technical reasons—why the author was excluding Typescript in such a way from any sort of treatment, even passing remarks that explains his stance. I may not have explicitly asked for a technical discussion, but this is Hacker News and I know better what my intentions and meanings are than you do.
You're the one who brought the complaints, and made it into a religious dispute.
Go into my comment history and find any discussions from me about Typescript or Javascript. You're superimposing a debate on me that I'm not part of. I did not know that debate was so omnipresent in the community that you deem it rational to extract such intent from my question, but I see that now.
Perhaps I was not privy to such a debate because Typescript has so obviously won.
Ok, that's what I understood from your post. Sorry if I got you wrong.
But the reason to exist of this thread is to talk about JavaScript, pure old JS.
Unfortunately, the mention of TypeScript got more attention than anything else.