19 ms·
The problem with vanilla JS is not APIs, API is the easy thing. The problem is building proper architecture, so code won't quickly turn into spaghetti. With fra
by vbezhenar 7y ago
The problem with vanilla JS is not APIs, API is the easy thing. The problem is building proper architecture, so code won't quickly turn into spaghetti. With frameworks like Angular or React, it's much easier, as the general structure is dictated by framework and developer just have to follow good practice. With vanilla JS it's the wild west.
- dexwiz 7y ago> just have to follow good practice Easier said than done when best practices shift every 6 months.
- bernardv 7y agoThe problem is that the Wild West and unnecessary complexity has just been shifted up a level or two as devs are now facing the Wild West of frameworks, de ops has turned into a monster with an unnecessary large toolbox.
- protonimitate 7y agoAgreed. This is my main issue with the "you don't need frameworks" rhetoric. If you're a small team or a solo dev working on a simple app, and you know the source code very well, frameworks might not be the best choice. However, if you've ever worked on a team of revolving contributors, constantly shifting requirements, or have any reason to reuse code across apps/repos, frameworks help immensely. The biggest benefit to using something like React imo, is that when we hire somebody familiar with React, they can hit the ground running and start contributing immediately. Unless your app is dead simple, you won't be able to have the same velocity in a homespun framework (and given enough time, most "vanilla" apps turn into homespun frameworks).
- mettamage 7y agoIsn't this also simply true in the corporate world in general? Frameworks and best practices of doing something means that things are standardized. Standardization means that a vocabulary is shared and people understand each other. You want to make people as swappable as possible. At least that's how I look at it from a management perspective (not a manager, but one can dream).
- x3haloed 7y agoNot necessarily. Using popular frameworks will always widen the pool of contributors you have access to, no matter what "sector" your project falls under.
- sgustard 7y agoWe've adopted a framework as a small team and it has nothing to do with onboarding new people. We adopted it became clear that if we stuck with vanilla JS, we'd end up re-building something like jQuery to keep our code and abstractions manageable. And then we'd build something like React, while doing a much poorer job of it. Once your app has some "click X and A, B and C should update" logic you quickly descend into a tangle of tracking dependencies by hand.
- mattmcknight 7y ago"descend into a tangle of tracking dependencies by hand." What is your definition of "by hand"? What constitutes by hand and what does not constitute by hand?
- sgustard 7y agoMy definition is declaring each dependency explicity. "A, B and C depend on D or E." Add a watcher on D and E to go update A, B and C. Repeat for every combination of dependencies. When app is complex enough I threw that away for a framework that tracked dependencies for me.
- mattmcknight 7y agoSorry, I don't understand. How would the framework know what the dependencies are if you don't declare them, even indirectly in some fashion? In what sense are they dependent?
- uk_programmer 7y ago> Once your app has some "click X and A, B and C should update" logic you quickly descend into a tangle of tracking dependencies by hand. I managed to deal with moderately difficult scenarios with about 7 files in typescript. I ended up using webpack but that is a dev-dependency which doesn't really count. I built this for me, but if you employ some basic patterns and use something that is a little more powerful than JavaScript it isn't that hard. I also very rarely ever use a DOM selectors in my JavasScript. I don't particularly like frameworks these days because you end up spending more time dealing with the framework than actually getting things done.
- ricardobeat 7y ago> when we hire somebody familiar with React, they can hit the ground running and start contributing immediately This is one of the selling points, but never really realizable in a large scale project. I've seen people become productive with an in-house template system, vanilla javascript + custom libraries even faster than on a "standard" React project. As they emphasize in their own docs, React is not a framework. The amount of moving pieces you need around it for a working project ends up being more complex than your cut-to-size custom framework. There are many other positives to adopting standard tools, but this one is a red herring.
- rajeev-k 7y agoHere's an example of a vanilla JS app with good architecture: https://github.com/Rajeev-K/eureka https://github.com/Rajeev-K/eureka
- x3haloed 7y agoLooks like you structured your own MVC framework?
- rajeev-k 7y agoYes, and the MVC framework is all of 500 lines of code and can be used with React too: https://github.com/Rajeev-K/mvc-router https://github.com/Rajeev-K/mvc-router
- x3haloed 7y agoNo disrespect, but I think you proved @vbezhenar's point. The right way to structure the code is with a framework of some kind, even if it's homegrown.
- rajeev-k 7y agoIf there is anything I am trying to prove it is that you don't need complicated frameworks like Angular or React. Those frameworks have gotten too complex for what they do.
- robertoandred 7y agoReact doesn't even have a router, so your framework is already more complex.
- grey-area 7y agoHow many lines is react?
- 7y ago
- XCSme 7y agoAgree, in the end you just end up creating your own custom framework.
- superkuh 7y agoThe problem is every dev thinking that every single project has to be resume buzzword compatible and super complex to hide the complexity they're sure is coming. But these requirements really only occur if you're forced into them by working on something in order to make money. The web is more than just the commercial web.
- Vinnl 7y agoI'm using far more ridiculous, buzzwordy and complex tools in my non-commercial projects though. (In fact, that's usually the point of those projects.)
- superkuh 7y ago>In fact, that's usually the point of those projects. And are you doing it because you truly enjoy the needless complexity or because the buzzwords would look good on your resume? If the later, again, that's profit motive and commercial web. Like how the only point of using kubernetes for personal stuff is to learn kubernetes for non-personal stuff.
- Vinnl 7y agoThe former :)
- austincheney 7y ago> With vanilla JS it's the wild west. In my experience in the corporate world it's just as much the wild west even with using popular frameworks. Frameworks aren't a substitute for discipline or organization.
- a_wild_dandan 7y agoI wonder if those chaotic corporate experiences would've been far worse if not for the frameworks. They're just so useful for significantly constraining the solution space that you can't get too far into the weeds even when lacking discipline/organization.
- DagAgren 7y agoThis, is my experience, tends to just chase the mess deeper into the architecture, which may not be a good tradeoff.
- corebit 7y agoMy experience is that velocity slows because devs get so lost in all the accidental complexity of these frameworks and their hidden lifecycles (that they only barely grasp from their 1 tutorials worth of experience) that their velocity of delivering real business value plummets. We are much less productive than a decade ago.
- whatarethembits 7y agoIn my experience, a framework atleast provides some ropes to hold onto while traversing the mess. Currently I'm stuck with a codebase with almost no documentation of a mess of legacy and new code with layers and layers of developers' opinions on top. The only way I'm able to figure anything is out is by tracing remnants of a light framework that's in place. I'm able to read the framework documentation and slowly unravel it, without it it'd be an even more monumental task! I googled/linkedin developers that have worked on this codebase for the past decade and most of them appear to have this "rockstar developer" thing going on. They are opinionated, had heated debates (from what I'm told), and often rolled their own solutions whenever possible. Now we see the result of these geniuses doing their thing. Just use a framework please, your homegrown solution is sucks. I guarantee it.
- x3haloed 7y agoI completely agree. What's everyone's favorite extremely lightweight view frameworks? And for those of us writing SPAs, favorite controller and routing frameworks?
- SimeVidas 7y agoCan confirm. Before I started using Preact, my client-side code was a large vanilla script. I would rather go work on a farm in Mongolia than go back to that.
- jimmaswell 7y agoThe vanilla API is still a problem. It feels pretty verbose and limited when you're used to jQuery. You really don't need any more than jQuery if you're just doing a few small things per page as opposed to a single page app or something.
- acephal 7y agodocument.querySelectorAll?
- jimmaswell 7y agoCompared to $ and .find(), yes.
- msla 7y agoAre transpilers included in Vanilla JS? If not, then IE 11 and Edge prior to 15 don't support async/await, which would mandate two codebases for lots of use-cases. Similarly, lots of other stuff has uneven support, hence polyfill, which also isn't "Vanilla JS" sensu stricto.
- aikah 7y ago> The problem with vanilla JS is not APIs, API is the easy thing. Then the problem is really the API, if one needs to write tons of helpers just to make that thing bearable. Never had to write a framework on top of QT or WPF just to develop apps on these platforms. Web Components tries to make things a bit easier by allowing people to write their own widgets that know how to clean up themselves when removed, but it's not there yet apparently. IMHO what the DOM needs is a good DOM diff API directly included in the browser. Right now it's either modifying DOM nodes themselves manually or just innerHTML string trickery, when wanting to update an entire tree of DOM nodes. events are already a solved problem thanks to event delegation. It's DOM modification that is still painful. This list of recipes doesn't solve the large front-end app at scale problem. So personally right now, all I need IS a DOM-diff library. Using external widgets is a bit trickier, but with event handlers I can do required instantiation and clean-up provided the third party widget has the necessary event hooks.
- cies 7y ago> Then the problem is really the API I think the problem of JS is not the APIs, it's the language itself. > IMHO what the DOM needs is a good DOM diff API directly included in the browser. Here you go, part of WebComponents: https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_shadow_DOM https://developer.mozilla.org/en-US/docs/Web/Web_Components/... > Web Components tries to make things a bit easier by allowing people to write their own widgets that know how to clean up themselves when removed, but it's not there yet apparently. WCs aims to replace a lot of what is now React. As is "just the view and some encapsulation. With a the litElements lib (or some other) you also get some life cycle callbacks. > This list of recipes doesn't solve the large front-end app at scale problem. It did not claim to either. My 2 cents: that problem is prolly going to be fixed by writing code that compiles to JS (or WASM). JS was the problem all along for big codebases; too quirky, too little safety, very easy to make mistakes.
- vince14 7y ago> part of WebComponents WebComponents do not have DOM diff APIs whatsoever.
- 7y ago
- spankalee 7y agoYou do the same with "vanilla" that you do with frameworks: organize your UI into components and everything into modules. You don't need frameworks for any of that.
- tarsinge 7y agoIn theory yes, but in practice even with frameworks codebases can turn into messes, and/or tends to become solid but completely frozen on a particular feature set. Small changes suddenly becomes daunting because the initial architecture needs to be changed to accommodate and surprise all is tightly coupled under the cover. With vanilla JS and spaghetti it's painful and boring but at least if I need to change a behavior on a page usually I'm done with a few lines of code. Edit: it's a tradeoff, but in early stages I found being able to make one the fly changes in a few minutes/hours to accommodate a customer instead of weeks (or never if it's too painful to evolve the perfect architecture) very valuable. It really depends on the use case, and sure frameworks are awesome in the right context, but I think the current "best practice" of defaulting to one in any project no matter the business trajectory, product market fit maturity and team size is misguided.
- Supermancho 7y agoAt my position, there are at least 5 different interpretations of how to do React. Each project has an overseer who enforces a particular philosophy/design. JS frameworks are frameworks. They don't make the problem easier, they just change the terminology and add new abstractions which inevitably turn into angel hair pasta.
- ng12 7y agoReact is not a silver bullet. It solves one problem and it solves it very well: dealing with dynamical updating DOM views. There are still many different ways to architect your application but it stops the bikeshedding and reduces the opportunity for bugs at the view layer.
- ThePhysicist 7y agoThe problem with frameworks like React is that the version you’re using and its API will become outdated in no time. We started using React in 2014 and their approach to state management changed at least three times since then. Not to mention build systems, tooling and libraries. In my experience that leads to a large fraction of developer time (10-30 percent I’d say) just going into often pointless refactoring that is necessary to keep up with the framework ecosystem, because you don’t want to run “legacy code”. Most large organizations seem to accept that but for smaller ones it can be quite a burden. The beauty of the native JS APIs is that they are relatively stable: things that worked 10 years ago still work today, and can be done in the same way. Also, standard adherence in browsers has become much better so if you do not need to support legacy browsers like IE you can get away with writing pure JS without any polyfills or frameworks.
- jtms 7y agoBrowser APIs have changed quite a bit in the last 10 years. Yes, the same approaches are still supported, but there have been many additions and modifications to core APIs. Ten years ago you would have never dreamed of trying to build complex front end behavior without something like JQuery, but now it’s totally unnecessary as all browsers mostly adhere to the standards. I guess my point is I don’t think React has changed any more or less than browser APIs - both have just steadily updated best practices just like any other piece of software since ever.
- dmitriid 7y ago> Browser APIs have changed quite a bit in the last 10 years. They really haven't. > Yes, the same approaches are still supported, but there have been many additions and modifications to core APIs. Once again, there really haven't been. Yes, there are many more APIs in general (audio, touch etc.), but on the whole it's the same old cumbersome poorly designed 90s-Java-style DOM API.
- danpeddle 7y agoIn 2010, browsers supporting rounded corners were considered exotic. It’s totally, totally different now.
- mosdl 7y agoDoing interviews I've heard a lot of this - react is more efficient than using the DOM directly, etc but no one can tell me why - they are just parroting what they hear or get taught at coding camps and make a fool of themselves.
- xyz0 7y agoThe virtual DOM. The DOM is only re-rendered in places where the next DOM tree (virtual, based on new state) differs from the current DOM tree. [0] [0] https://stackoverflow.com/questions/21109361/why-is-reacts-concept-of-virtual-dom-said-to-be-more-performant-than-dirty-mode https://stackoverflow.com/questions/21109361/why-is-reacts-c...
- gambler 7y ago>The problem is building proper architecture, so code won't quickly turn into spaghetti [...] With vanilla JS it's the wild west. This is a "problem" that I solved for myself years ago. It's not even that hard. I've started by noting that most of the issues with JS come from a few sources. - Managing code dependencies. - Navigating DOM. (Manipulating DOM is trivial.) - Managing events. - Synchronizing JS state with DOM state consistently. If you pause to think about those, each of them has a straightforward solution that does not require a framework. - Do not make libraries that directly depend on external code. Use DOM and HTML events for configuration and communication. - Use CSS queries. - Use timers or document-level events. They will continue to operate regardless of how elements change. - Use DOM as your state storage. (Custom attributes + occasionally symbols.) This way your code itself is completely stateless. There is more to it, but this is the foundation. One of my favorite libraries is one that checks for specific attribute that contains a CSS query, then runs it, then outputs the result as a parameter on the original element. Couple dozen lines of code, countless applications. Best of all, you don't have to write any page-specific glue code. You load the library and it just works.
- toastal 7y agoI disagree with storing your state on the DOM. Querying the DOM can be pretty slow, but also now you're state is going to be stringy-typed which will involve parsers and a whole mess of reasons you don't want that. If you want to keep the logic simple, a view should be a function from a state/model to some 'visual' representation (be it DOM, canvas, Qt, ASCII, a quilt pattern, etc).
- seangrogg 7y agoA DOM node's attributes are strongly typed, but it is an object and you can still set Node.foo = barObject if you're so inclined. Not saying it's not without it's tradeoffs, but if you want state housed in the DOM rather than another state manager it's not hard to conceptualize.
- whatarethembits 7y agoI hope then someone in your team is responsible for continuously documenting these patterns, however trivial they may seem to the author. I use frameworks for their documentation more than anything else. Maybe it's the UK developer culture but I haven't come across any codebase that has even remotely useful documentation in the past five years in three jobs. These "intuitive patterns" only exist in the senior dev's head. New comers have to either constantly ask or figure it out slowly by going through source files. Homegrown "simple and intuitive" solutions only benefit the rockstar who wrote them, not the other members of the team who are there now and who will come after the rockstar is gone. Please use well documented frameworks, otherwise we're trading away the entire teams productivity in favour of the rockstar to have his say.
- rimliu 7y agoFrom what I have seen React is not better. It may not be spaghetti but then it is an exercise in architecture astronautics with way too many layers of indirection that is might as well be that spaghetti bowl.
- lhorie 7y agoSometimes I question if people claiming vanilla is spaghetti have actually used vanilla in any meaningful way or if they are just parroting what others have said. I find that a lot of times, it's the latter... For example, something that I've come to find cumbersome about frameworks is that expressing things in terms of states makes it more convoluted to express mutations. For example: in vanilla, one sensible unit of organization would be something like this: const doThing => { input.value = value; input.focus(); sound.play(); } button.onclick = doThing Expressing `input.value = value` is what frameworks generally shine at, but expressing the method calls is usually clunky, since they represent effects and those can't really be expressed in terms of state snapshots. So, expressing them in a "frameworky" way usually just looks like some variation of this, but on top of some abstraction (think, e.g. React's useEffect nested anonymous functions + refs + probably context and a provider because you're not going to just initialize your sound manager in your component, right?). I think frameworks are about colocating things in some specific way, and whether the colocation structure is "good" is largely a matter of herd acceptance. W/ older frameworks like Backbone and Angular, the focus was on colocating things to fit a MVC paradigm. And people were totally on board with that. With Redux, one colocates actions for a particular piece of state. And people sing their praises about this structure too. With reaonably written vanilla JS, it's not that there's no colocation. One colocates mutations related to a single action. It may not be a "cool kid" organization structure, but it _is_ structure. Of course, one can write bad vanilla JS, but that's also true about any framework.
- bernawil 7y agoDid you mean something like this? const doThing = event => { input.value = event.value; input.focus(); sound.play(); } button.onclick = doThing
- deleted 7y ago[deleted]
- ng12 7y agoI would do this identically in React. const doThing = event => { const input = event.target input.value = value input.focus() sound.play() } ... <button onClick={doThing} />
- dntrkv 7y agoI'd say the bigger problem with vanilla JS or any other imperative UI framework is exactly that, the imperative nature of these tools. React introduced the frontend world to a declarative approach for keeping the DOM in sync with your state. Until we have something similar in the native API, React and co. will continue to exist.
- grey-area 7y agoIt really depends how much complexity you shift to js - if most of the work is done on the server, you really don't need to lean on js very much and you can have relatively simple js which just annotates certain elements and updates content in response to user actions. You don't need a framework if you're not trying to shift the entire view layer to js.
- daxfohl 7y agoThe problem with frameworks is that they tend to drive the functionality of the site itself. It's easy for developers to start thinking in terms of what fun new things the framework allows rather than what the site actually needs. I think frameworks are great, but you have to develop a self restraint from using every bell and whistle that's in it.
- sergiotapia 7y agoYou can use Svelte and get pure DOM manipulation (fast, tiny) and a great framework to collaborate under.
- MaxBarraclough 7y agoOn the topics of speed and lightness: does Svelte really have a proven track-record in real-world usage at this point? I understand that it has a neat compiler and some clever ideas behind it (no virtual-DOM), but still.
- dpcan 7y ago"and developer just have to follow good practice" Uhm, the exact same is true with vanilla js. If you write crappy code, your code will be crappy even if you use a framework.
- hinkley 7y agoI learned jQuery on a project where everyone was expected to be full stack but only 2.5 of us could do any deep work on the front end. I have done much, much harder things than convincing my coworkers to distinguish between 'important' nodes in a composition and incidental ones. Never put the incidental ones in your selectors. If I'm a "Select All" checkbox, I need to find all of the checkboxes in "my" block of HTML that are not me, and select or unselect them. I don't give a shit if that's two divs up, one over and three down. Or if some IE bug means now it's three divs up and two over. I care about some top level element, and any of its children at any depth. That's it. If I write my element selectors that way, I'm done and the layout people can put in a scrollbar later, or an expando. Also if I write my CSS the same way, it's easy to make these sorts of changes and it's easy to correlate the CSS with the Javascript that affects the same elements. So much simpler than spending all day in a debugger when you're not in bug triage. Most of those query selectors we relied on now have feature parity in the spec. I don't see why you couldn't use the same strategies in a vanilla situation today.
- nsomaru 7y agoCould you expand upon what you mean when you say a checkbox has "my" block of html? That a given element should not make changes in elements that are at a higher level in the tree? Also, what are important and incidental nodes?
- hinkley 7y agoThere are a bunch of elements we add to the page or remove to get certain visual effects to work well but they really have nothing to do with the logic of the page. Few if any interactive components ever care about them, or only for one specific interaction. Classic example of the 'only one interaction' situation: the coworker who thinks he can use string concatenation for query parameters and you know that if you just wrap it in a form element, all of that is cheap or free and you just have to hook the form submit event to turn it into an AJAX request instead of a navigation. But that means that you've wrapped all of his DOM in a form element and now all of the CSS and half of the handlers stop working because they're looking for body>div>div>option and now it's body>div>div>form>option and now you wish you hadn't even touched this stinking pile but it's the principle and by god you're gonna finish this. Or you had a block of elements on a page and now your boss wants it on the other side of the page, on another page, on every page, all over this page, or on a completely separate site. What you want to solve these problems in a way that mostly stays solved is to try for a query selector with the lowest specificity (and no IDs) that still exactly identifies the DOM elements you are looking for. So there is some titular 'owner' element that all of these interactions are contained in, and they find each other by walking up until they find a particular shared parent and call parent.querySelectorAll() to find their peers, and only their peers. Not some other random element halfway down the page. So for instance a click on .preferences .selectAll should find the first parent with class 'preferences', call querySelectorAll(".options"), and then invoke foo.selected = true on all of them. Not parent.parent.parent and then down through div>div>ul>li>input[type="checkbox"]
- gregkerzhner 7y agoFrontend development is a tricky beast because its hard to separate business logic from view logic. Since all your code relates to the view, its temping to just stick all your code into the view component or controller. This makes your components huge, untestable, and brittle. An great frontend developer will keep extracting models and business logic from view code until the view code is lean and really only renders. Some things are easy to extract like http calls or parsing logic. Other things are harder to see - like logic that might drive a step wizard. Even code like this can be expressed in plain models with plain functions, but its a lot harder to see and extract. Most people don't get there, or just don't care, so many frontend codebases end up with spaghetti view modules that you edit and pray things still work.
- deleted 7y ago[deleted]
- treespace89 7y agoI've been maintaining a complex web client for 14 years. Every single time we have used a framework it has made development harder, and more fragile. In addition within a few years either the framework is abandoned, or changed to be incompatible with what has been implemented. Staying away from frameworks completely would have saved us more time in the long run.
- nsomaru 7y agoCould you share some lessons learnt and architecture tips?
- ThomPete 7y agoOnly if you are building standard things IMO.
- rawoke083600 7y agoTHIS a x1000 THIS !! There will never be a perfect framework, and jquery for a multi-person big project. It WILL be a mess in due time ! a Framework(even the most of the crappy ones) at least give you some opinionated standard ways of doing stuff. You can't pay me enough to work in jquery straight... Not saying it can't happen with frameworks. Just saying if you do a 100 projects with jquery or 100 projects with frameworks... There will be more chance the jquery ones will be a mess.
- rikroots 7y ago> With vanilla JS it's the wild west The thing I really, really like about Vanilla JS is that it has 0 (zero) dependencies. If something breaks in Vanilla JS, you know with 100% certainty that it's your code that's failing. With a framework, it's mostly the fault of your code - but there's always an outside chance that it's somebody else's fault, buried deep in some 3rd party dependency that may-or-may-not have been maintained. I like React and Vue (I love Svelte!) - on a well-planned project they can perform miracles. But I see no reason to hate on Vanilla: it has its place too ... if you know what you're doing.
- bgirard 7y ago> If something breaks in Vanilla JS, you know with 100% certainty that it's your code that's failing. Or the browsers' code which is a bigger problem. I've been burned in the distant past by a blackbox framework that didn't work well with my use case (JSF) so I can sympathize with your position. These days I'd rather hit the occasional framework and polyfill bug than deal with a wide range of interopt issues.
- nicoburns 7y ago> If something breaks in Vanilla JS, you know with 100% certainty that it's your code that's failing. If you're lucky enough to have the same developers for the duration of the project. Otherwise it'll be your predecessor who worked at the company 4 years ago's code. I've had to do far too much "reverse engineering" of "we don't touch that" code. On the other hand, I've literally never encountered a bug in React. I guess it must have them. But I think not all that many.
- rikroots 7y agoI don't disagree. I still live in hope that one day I'll work on a project where all functions and variables have relevant and informative names and the Runbook is (accurately!) updated with latest changes on a weekly basis. The point I was trying to make wasn't about previous developers on a project. Rather, it's the way frameworks ask me to trust them about the choices made by unknown developers to include NPM packages by other unknown developers in the framework's build. That, to me, is the definition of "wild west". React is backed by Facebook. When it comes to frameworks I'm a lot happier to trust an open-sourced codebase backed by a company with a big vested interest in making sure that all the NPM modules they include (and all their dependencies, etc) are solid, safe and up-to-date. Even so, React's package.json file lists a devDependency for core-js - whose main developer is currently serving 18 months in a Russian jail[1]. How much trust we choose to put into other, unknown developers and their code is a risk to any project, is all I'm saying. [1] https://www.theregister.co.uk/2020/03/26/corejs_maintainer_jailed_code_release/ https://www.theregister.co.uk/2020/03/26/corejs_maintainer_j...
- danzig13 7y agoI think vanilla JS inside the components is the way to go.
- mythrwy 7y agoIt doesn't have to be wild west but I don't disagree it usually turns into that. Before frameworks I spent a lot of cycles learning (usually the hard way) how to organize jQuery/JS code so it wasn't a total mess. I like to think I finally got it fairly maintainable for reasonable sized code bases. But by that time existing frameworks made a lot more sense so that's a bunch of thinking I'll never get back. I would guess I'm not the only one in this situation either. Here's a really good book BTW if someone isn't aware of it. https://addyosmani.com/resources/essentialjsdesignpatterns/book/ https://addyosmani.com/resources/essentialjsdesignpatterns/b...
- the_cat_kittles 7y agothat sounds like a you problem, not a js problem. i always prefer vanilla libraries because i only need to know js, not js and a framework. if you need a framework to stop someone from designing something poorly, they are probably not very helpful to begin with.
- z3t4 7y agoA trick I use to make the JS code more maintainable is to wrap code into pure functions that returns an element. For example if you need an input that only accept numbers: var input = makeInputThatOnlyAcceptNumbers() where the function returns the element, and all nitty gritty state handling is done inside the function.
- tsukurimashou 7y agoWell at least with vanilla JS you know your skills will be useful again in the future. With frameworks such as Angular or React, they can disappear and be replaced by the next flavor of the month pretty fast.
- ehnto 7y agoThat's true of every language. It's the software developers job to build the architecture. I am an advocate for frameworks in commercial projects, for ease of knowledge sharing, speeding up onboarding and having a strong architectural philosophy built in. But we can't forget that we are the makers, we make the frameworks. React and friends are Javascript, anything they can do we can do too. I am happy to use them for work. But I find all frontend frameworks too tooling heavy and full of arbitrary details you have to learn once and promptly forget. In my personal projects I have a simple architecture I use to organise my code in vanilla JS, no tooling and it's simplicity lends well to small projects sprinkled with only some dynamic UI.