News for hackers. Stuff that matters.

Ask HN: Base new open-source library on an existing one, or start from scratch?

One of my projects uses a BSD-licensed C library which works fine but is too slow for my needs. The developers of the library have told me that they are not interested in making the major internal changes necessary to improve its speed.

I would therefore like to write an alternative to this library which focuses on performance. I will also be writing in C and am happy to use the BSD license, however I don't think I will end up re-using much of the original library's code.

There are two possible approaches to writing my library:

1. Start with the code from the existing library and make changes, replacing sections of the code at a time.

2. Begin writing my library from scratch, using the existing one only for reference.

Most conventional wisdom about rewriting code (such as Joel Spolsky's famous "Things You Should Never Do, Part I" [1]), strongly recommends taking the first approach.

Is it always better to start from existing code, or are there situations in which it would be better to start from scratch?

[1] https://www.joelonsoftware.com/2000/04/06/things-you-should-never-do-part-i/

( 1 comment | on HN )
Re:Ask HN: Base new open-source library on an existing one, ... by itamarst on Wednesday May 24, 2017 @12:40PM (#14411322)
What about the third approach, find another existing library that provides similar functionality but is faster?

Or fourth approach, pay for faster hardware (cheaper than your time, usually!).

Or fifth approach, refactor the code and submit a change request? Even if they are not interested in doing the work, maybe they'll accept it.

Probably other approaches you can take as well.