Live data from Hacker News

Ask HN: What open source project, in your opinion, has the highest code quality?

news.ycombinator.com

141–150 of 294 posts

Re: Ask HN: What open source project, in your opinion, has the highest code quality?

#141
post #40

SQLite. and for this reason alone! https://www.sqlite.org/testing.html As of version 3.23.0 (2018-04-02), the SQLite library consists of approximately 128.9 KSLOC of C code. (KSLOC means thousands of "Source Lines Of Code" or, in other words, lines of code excluding blank lines and comments.) By comparison, the project has 711 times as much test code and test scripts - 91772.0 KSLOC.

Automated testing is useful and good. But I really feel it's reached a lever of fetishisation that is quite concerning. Testing code is code which needs to be written, read, maintained, refactored. Very often nowadays I have to wade through tests which test nothing useful, except syntax. Even worse, with developers who adopt the mock-everything approach, I often find tests which only verify that the implementation is…

While I agree in general I disagree here. If you read about the Sqlite tests you will find that they do test sensibly.

One suite I'm particularly impressed with will run tests from zero bytes with slowly increasing available memory until the program passes. The tests verify that at no point the DB is corrupted by an OOM event.

Re: Ask HN: What open source project, in your opinion, has the highest code quality?

#142
post #53

Can't say I've seen enough to be confident on the best library but redux ( https://github.com/reduxjs/redux ) is just so simple, and has great, readable/understandable code.

In Dan Abramov's excellent egghead redux course [0] he implements the `createStore` from scratch which is the core of redux, it's simple enough to post here:

  const createStore = (reducer) => {
    let state;
    let listeners = [];

    const getState = () => state;

    const dispatch = (action) => {
        state = reducer(state, action);
        listeners.map(listener => listener());
    };

    const subscribe = (listener) => {
        listeners.push(listener);
        // unsubscribe
        return () => {
            listeners = listeners.filter(l => l !== listener)
        };
    };

    // populate initial state
    dispatch({});

    return { getState, dispatch, subscribe };
  };

[0]: https://egghead.io/lessons/react-redux-implementing-store-fr...

Re: Ask HN: What open source project, in your opinion, has the highest code quality?

#143

Its older than some HN posters, but the GPLed DOOM source code was one I liked. The performance reached by the game was considered impossible until Carmack did show us otherwise. So I expected lots of ASM and weird hacks, especially as compiler optimization wasnt as good as it is today. Surprise, surprise, the thing was easy to read, easy to get going, easy to port, reasonablye documented . It has shown me what a goo…

The DOOM code is so straightforward. You don't ever experience that feeling of having zero understanding of the code when you look into a file.

Re: Ask HN: What open source project, in your opinion, has the highest code quality?

#144
post #40

SQLite. and for this reason alone! https://www.sqlite.org/testing.html As of version 3.23.0 (2018-04-02), the SQLite library consists of approximately 128.9 KSLOC of C code. (KSLOC means thousands of "Source Lines Of Code" or, in other words, lines of code excluding blank lines and comments.) By comparison, the project has 711 times as much test code and test scripts - 91772.0 KSLOC.

Automated testing is useful and good. But I really feel it's reached a lever of fetishisation that is quite concerning. Testing code is code which needs to be written, read, maintained, refactored. Very often nowadays I have to wade through tests which test nothing useful, except syntax. Even worse, with developers who adopt the mock-everything approach, I often find tests which only verify that the implementation is…

They actually have to test to that degree to follow aviation standards (DO-178b [0]) because they're used in aviation equipment.

Dr. Hipp said he started really following it when Android came out and included SQLite and suddenly there were 200M mobile SQLite users finding edge cases: https://youtu.be/Jib2AmRb_rk?t=3413

Lightly edited transcript here:

> It made a huge difference. That that was when Android was just kicking off. In fact Android might not have been publicly announced, but we had been called in to help with getting Android going with SQLite. [Actually], they had been publicly announced and there were a bunch of Android phones out and we were getting flooded with problems coming in from Android.

> I mean it worked great in the lab it worked great in all the testing and then [...] you give it to 200 million people and let them start clicking on their phone all day and suddenly bugs come up. And this is a big problem for us.

> So I started doing following this DO-178b process and it took a good solid year to get us there. Good solid year of 12 hour days, six days a week, I mean we really really pushed but we got it there. And you know, once we got SQLite to the point where it was at that DO-178b level, standard, we still get bugs but you know they're very manageable. They're infrequent and they don't affect nearly as many people.

> So it's been a huge huge thing. If you're writing an application deal ones, you know a website, a DO-178b/a is way overkill, okay? It's just because it's very expensive and very time-consuming, but if you're running an infrastructure thing like SQL, it's the only way to do it.

[0]: https://youtu.be/Jib2AmRb_rk?t=677 "SQLite: The Database at the Edge of the Network with Dr. Richard Hipp"

Re: Ask HN: What open source project, in your opinion, has the highest code quality?

#145

Earlier quoted context omitted.

Shouldn’t good performance be one of the goals of good code?

Depends on the design goals. If you want secure code, you'll make it readable. Here's true(1): : A single "noop" in a 755 file. A C true would be: https://cvsweb.openbsd.org/src/usr.bin/true/true.c?rev=1.1&c... Here's a much faster true(1) if you need it: https://github.com/coreutils/coreutils/blob/master/src/true....

I did say “one of the goals”.

I don’t see how those examples are relevant. Why would that last one be faster?

I agree that the OpenBSD code here is good, no more and no less than needed.

I assumed the grandparent was referring to cases where an O(n) algorithm is used where it might be O(log n) or O(1) with just a little more effort. It’s a tradeoff, sure, and in some cases linear searches can work surprisingly well, but in general I think this kind of thing should always be considered in good code.

Micro-optimizations like inline assembly for inner loops may or may not be a good idea, depending on the application. All else being equal, I’d certainly agree that good clean code would not use assembly.

Re: Ask HN: What open source project, in your opinion, has the highest code quality?

#146

Its older than some HN posters, but the GPLed DOOM source code was one I liked. The performance reached by the game was considered impossible until Carmack did show us otherwise. So I expected lots of ASM and weird hacks, especially as compiler optimization wasnt as good as it is today. Surprise, surprise, the thing was easy to read, easy to get going, easy to port, reasonablye documented . It has shown me what a goo…

These 666 forks can't be a coincidence, right?

Re: Ask HN: What open source project, in your opinion, has the highest code quality?

#147

Python: I really like requests, scikit-learn, the Path module from the stardard library, Keras, Django. C: Redis, SQLite, LUA. Java: Joda Time, Guava

Joda Time is one of my all time favourite libraries. After struggling with JVM stdlib time nonsense, JodaTime was a breath of fresh air and actually made programming with time fun.

Java 8 time module is now considered the replacement for JodaTime for new projects. It is separate from the older Java time libraries, and fixes many of the problems in Joda. Give it a try!

Re: Ask HN: What open source project, in your opinion, has the highest code quality?

#148
post #141

Earlier quoted context omitted.

Automated testing is useful and good. But I really feel it's reached a lever of fetishisation that is quite concerning. Testing code is code which needs to be written, read, maintained, refactored. Very often nowadays I have to wade through tests which test nothing useful, except syntax. Even worse, with developers who adopt the mock-everything approach, I often find tests which only verify that the implementation is…

While I agree in general I disagree here. If you read about the Sqlite tests you will find that they do test sensibly. One suite I'm particularly impressed with will run tests from zero bytes with slowly increasing available memory until the program passes. The tests verify that at no point the DB is corrupted by an OOM event.

Just to clarify, I wasn't criticising sqlite, I was criticising the idea of judging their code quality "for this reason alone!" - ie that they have so much test code vs implementation.

Re: Ask HN: What open source project, in your opinion, has the highest code quality?

#149

Earlier quoted context omitted.

Automated testing is useful and good. But I really feel it's reached a lever of fetishisation that is quite concerning. Testing code is code which needs to be written, read, maintained, refactored. Very often nowadays I have to wade through tests which test nothing useful, except syntax. Even worse, with developers who adopt the mock-everything approach, I often find tests which only verify that the implementation is…

They actually have to test to that degree to follow aviation standards (DO-178b [0]) because they're used in aviation equipment. Dr. Hipp said he started really following it when Android came out and included SQLite and suddenly there were 200M mobile SQLite users finding edge cases: https://youtu.be/Jib2AmRb_rk?t=3413 Lightly edited transcript here: > It made a huge difference. That that was when Android was just ki…

SQlite is very high quality software, but they use DO-178b "inspired" testing process. As far as I know they don't have version of software that is or can be used in safety critical parts despite their boasting.

They say in their site that:

> Airbus confirms that SQLite is being used in the flight software for the A350 XWB family of aircraft.

Flight software does not imply safety critical parts of avionics. It can be the entertainment system or some logging that is not critical.

Post reply on HN