News for hackers. Stuff that matters.
Re:Things You Should Never Do, Part I (2000) by bdw5204 on Thursday February 29, 2024 @07:37PM (#39557121)
The main reason why developers do rewrites is because it is easier to read your own code than it is to read somebody else's code. Doing a rewrite means you only have to work with code that was written by your current coworkers or by yourself.

This is also the core motivation behind all of the schemes to force a single coding style on all developers at the cost of performance and usually with an extremely complicated design for seemingly no reason. Usually, these turn out to be unreadable messes as well a generation later once everybody has moved onto the latest and "greatest" coding style trend.

Instead of doing rewrites, you can just refactor code. That means, among other things, deleting obsolete code for platforms you no longer support and, in the case of C/C++, converting macros to functions. You can also document the codebase (with comments not commit messages) so that developers understand what the code does and why it is there. But a full rewrite is usually a bad idea that will just introduce new bugs and remove existing functionality.

Refactor vs rewrite is basically the software development equivalent of reform vs revolution in political science and everybody with even a minimal knowledge of history knows that revolutions usually end badly with an even worse regime taking power. Likewise, the failure to accept the need for reform (i.e. refusing to allow refactoring) inevitably leads to revolution.

Re:Things You Should Never Do, Part I (2000) by SoftTalker on Thursday February 29, 2024 @11:49PM (#39558624)
In 2000, refactoring was not really a thing as few projects had many automated unit tests and any change to the code had to be tested manually.
Re:Things You Should Never Do, Part I (2000) by ehnto on Thursday February 29, 2024 @11:55PM (#39558655)
This is why I recommend using a framework in commercial projects, and following it's idioms as closely as makes sense for your project.

It means there is a shared idiomatic approach across your team and all the documentation for it is just the framework documentation. It is also easier to hire devs, if you can vet their ability to write idiomatic code in a specific framework then you can better assume they will mesh well with yor codebase.

It is a communication and empathy problem at its heart. You are being empathetic to future devs and future you by acknowledging the knowledge they would need to work on your code. Then the communication of your idioms is baked into the framework ecosystem and docs.

Re:Things You Should Never Do, Part I (2000) by lisper on Friday March 01, 2024 @12:36AM (#39558870)
Using a framework doesn't help at all because a framework is still somebody else's code. There is nothing special about somebody else's framework that makes it any easier to deal with that somebody else's non-framework.
Re:Things You Should Never Do, Part I (2000) by zubairshaik on Friday March 01, 2024 @12:52AM (#39558946)
The idea is that frameworks are generally designed to be used by other people, leading to greater focus on documentation, developer ergonomics, community support and generally more versatile code (scales with number of contributers/users; many will report obscure bugs and edge cases you may never consider testing but would impact your end users). Another huge benefit is you don't have to rewrite an entire system from scratch, saving time and mental load.

I'd say there's quite a bit "special" about all of these attributes, at least enough to warrant careful consideration.

Re:Things You Should Never Do, Part I (2000) by RedShift1 on Friday March 01, 2024 @04:16AM (#39560078)
Until $framework decides to rewrite everything too, and now you're stuck on an old unmaintained version or waste time migrating to the new version.
Re:Things You Should Never Do, Part I (2000) by zubairshaik on Friday March 01, 2024 @03:59PM (#39566736)
s/$framework/$any-coding-project-written-ever

Don't let bad frameworks represent all frameworks. That is a faulty generalization [0].

[0] https://en.wikipedia.org/wiki/Faulty_generalization

Re:Things You Should Never Do, Part I (2000) by lisper on Friday March 01, 2024 @01:06AM (#39559023)
Just because something is designed to be used by other people doesn't mean it's good. There are lots of things designed to be used by other people, leading to all of the features you list: documentation, community, other people finding bugs, yada yada yada... languages, operating systems, libraries... and many of those things still suck. There is nothing inherent about being designed for use by other people that makes things suck less, and there is nothing magical about "frameworks" that makes them suck less than all the other stuff designed to be used by other people but still sucks.

If you qualify this advice to the point where it actually becomes useful it turns into, "Use code written by other people that doesn't suck." And that, of course, is indeed a good idea, but it's a lot easier said than done.

Re:Things You Should Never Do, Part I (2000) by zubairshaik on Friday March 01, 2024 @04:20PM (#39566925)
Absolutely; most frameworks will not fulfill their design goal. Most ambitious open source programming efforts tend to wither away due to loss of interest, a failure to gain contributors, lack of experience, lack of time or energy and many other factors.

But despite that caveat, there do exist frameworks out there today that speed up development for some developers. Whether one has the time or energy or will to audit them to find one that works best for them (or learn that none of them do) is up to the individual.

I bring this up because many of us on this website are at times infected by NIH syndrome and think we can do better than a dedicated team of experienced front-end developers. And it's likely true for many frameworks, but not all. Additionally, we may want to extend that attitude to our workplace where our peers and bosses likely value development speed and cross-project consistency over code performance.

I used to eschew any and all frameworks, but now I realize that my values have changed. Projects like Svelte give me hope for a better future for front-end development.

Re:Things You Should Never Do, Part I (2000) by lisper on Friday March 01, 2024 @07:56PM (#39568775)
> But despite that caveat, there do exist frameworks out there today that speed up development for some developers.

Of course. But there also exist frameworks that will slow development down. For any X in {frameworks, languages, operating systems, libraries} there exist X's that will be helpful and X's that will not, and so "use an X" by itself is not helpful advice for any X. You have to use a good X, but that isn't helpful either because it just begs the question.

Re:Things You Should Never Do, Part I (2000) by zubairshaik on Friday March 01, 2024 @11:46PM (#39569900)
Absolutely true.

I just intended to push back against the notion that frameworks should not be considered.

Re:Things You Should Never Do, Part I (2000) by ehnto on Friday March 01, 2024 @04:25PM (#39566979)
I'll address both your comments here if that's alright,

It's not about code quality at all, it actually doesn't matter that much if the framework is excellent or just okay to reap the main benefit, which is knowledge diffusion through the team and having a set of agreed upon idioms that there's no need to bike shed over. Not every team has a software architect skillset so it's a bit of a risk hedge as well.

There's no need to argue over implementation details, you waste less time onboarding new staff and you have that rich ecosystem of docs and community of solved problems.

That's all. There are great reasons to build your own software but if you're working in a team I feel it's an easier experience to use a known framework. Also a bit more responsible from a business risk management perspective, since you don't have as big of a "bus problem". Only your business logic is trapped inside your org.

Re:Things You Should Never Do, Part I (2000) by lisper on Friday March 01, 2024 @08:03PM (#39568815)
That's a sound argument under certain circumstances. If you're building a standard product using relatively unskilled labor then yes, using a framework -- any framework -- can be helpful. But if you're doing something where rewriting an existing code base is even an option you would consider then you almost certainly are not operating under those circumstances. For starters, you probably have people on your team who are plausibly capable of rewriting the existing code, and under those circumstances, hemming those people in with a bad framework can do a lot more harm than good. So I stand by my original statement: "Use a framework" is not good advice in general. It can be the right thing under certain circumstances, but the art is in recognizing those circumstances, not in the use of a framework. Blindly following "use a framework" with no further qualification is a PHB move.
Re:Things You Should Never Do, Part I (2000) by justinator on Friday March 01, 2024 @12:43AM (#39558910)
>The main reason why developers do rewrites is because it is easier to read your own code than it is to read somebody else's code.

LOL: so did you read TFA, or just come up with this yourself?

Re:Things You Should Never Do, Part I (2000) by billpcs on Friday March 01, 2024 @04:20AM (#39560098)
'Minimal knowledge of history'?

Should Spartacus have tried reforming the Roman society? Should the French have tried reforming the feudal society? Should the Greeks have tried reforming the Ottoman Empire? Should the Russians have tried reforming the Tsarist regime?

Sometimes in history, the thing is just rotten. There is no way to keep going forward without a clean slate, without completely throwing away the things that are keeping you back.

Re:Things You Should Never Do, Part I (2000) by circlefavshape on Friday March 01, 2024 @04:39AM (#39560190)
I only have surface-level knowledge of any of these things, but I don't think most people would consider a defeated slave rebellion or a war of independence as "revolutions"

As for the other two ... maybe the people of those countries would have endured less suffering afterwards if they had reformed rather than revolted?

Re:Things You Should Never Do, Part I (2000) by jhbadger on Friday March 01, 2024 @06:52AM (#39560891)
>war of independence as "revolutions"

The war of independence the 13 American colonies waged against Britain is generally called "The American Revolution", but yes, for some reason most other wars of independence aren't called revolutions -- for instance while there was a Mexican revolution in the early 20th century, the earlier war of independence against Spain is just called the "Mexican war of independence" (Guerra de Independencia de México)

Re:Things You Should Never Do, Part I (2000) by Joker_vD on Friday March 01, 2024 @12:09PM (#39563890)
> Should the French have tried reforming the feudal society?

Well, the English AFAIK have done exactly that, haven't they?

Re:Things You Should Never Do, Part I (2000) by throwthrow5643 on Friday March 01, 2024 @04:23AM (#39560115)
> The main reason why developers do rewrites is because it is easier to read your own code than it is to read somebody else's code.

Did you read the article? He says what you wrote explicitly, in fact there is an entire section on it.