Live data from Hacker News

Reading OpenBSD source code daily

blog.tintagel.pl

31–40 of 86 posts

Re: Reading OpenBSD source code daily

#31
Completely agree. But the tools don't make this very easy.

Back in college I was working on patches to OpenSSL, Chrome, Firefox, Apache, etc., to add support for TLS-SRP, and it was a huge pain to jump into these massive codebases and try to understand them. I was using Emacs and had all of the various language support modes configured, but go-to-definition and cross-references barely worked. Searching was slow, and if I wanted to discuss a piece of code with my CS lab partners, I couldn't just share a link.

A friend felt the same pain but then went to work at Google for a bit. At Google, they have some pretty amazing code reading/searching tools (see https://static.googleusercontent.com/media/research.google.c...), and these tools helped Google build a culture of thoroughly reading and reviewing code. The causality is bidirectional, but having good tools certainly played a role in Google's success.

That friend and I ended up building a product, Sourcegraph, initially for ourselves to make code reading easier. We've now built a successful business out of it with the help of an amazing team. Here it is pulling in the OpenBSD sources: https://sourcegraph.com/github.com/openbsd/src/-/blob/lib/li.... Sourcegraph has advanced features for several languages; see https://sourcegraph.com/github.com/mholt/caddy/-/blob/caddyh..., for example. If you love to read code (or want to), we hope you'll love our product. Email me if you have any feedback/requests.

Re: Reading OpenBSD source code daily

#32
post #3

I wonder where best to start for people who haven't taken an OS class before?

CS:APP 3rd (64bit) edition http://csapp.cs.cmu.edu/

Lectures for it are here: https://scs.hosted.panopto.com/Panopto/Pages/Sessions/List.a...

This teaches you C, x86-64 arch, stuff like two's complement integers and floating point, how memory and CPUs work, how the C compiler works (linking stage, preprocessor), and how to write/understand signals and processes, file I/O, network code ect.

After that you can just start reading the OpenBSD code and will figure it out or get an Andrew S Tanenbaum book on Operating Systems.

Note, if you buy the Pearson Global Edition of CS:APP (it's only 10% the reg price) there's a lot of errata you will have to check. I once got stuck reversing an assembly program into C that did an even/odd parity check because of a print error returning the final XOR'd value & 0 instead of & 1.

Re: Reading OpenBSD source code daily

#33
post #26

This is fantastic! I've recently decided to begin reading web browser source code, even though I understand very little of it at the moment. For now, what's been fun is to load up the same file in both Chromium and Firefox source, and compare the two and how both browsers work. Chromium source: https://cs.chromium.org/chromium/src/third_party/WebKit/Sour... Firefox source: https://dxr.mozilla.org/mozilla-central/sour…

Could also be fun to compare to the Servo source: https://github.com/servo/servo

Re: Reading OpenBSD source code daily

#34

I love this idea in part because it's the very opposite of the way I tend to work, which is to drive very hard to get a surface understanding of a thing in order to make a very targeted change. I learn lots along the way with this approach, but don't often get the deep, wholistic understanding of existing systems that only comes with repeated exposure over a long time. Some kinds of understanding involve a no shortcu…

Your process is very good at achieving results fast. But the problem is you always stay in the same "level" of achieving results, which of course in the beginning is a very low level.

What do I mean with "level"? Let's look at transportation in that regards. At first we just had walking/running. Then we learned how to use horses. Then we developed the wheel and could use horse wagons. Then we discovered the walking bike, etc.

If you are on a low level you may be the fastest on that level, but you may be dimensions slower than people on higher levels. Think horse riding vs car.

But that is not the biggest problem if you only use the approach. On a higher level you'll also be able to solve problems that you didn't even know where solvable. For instance if everybody walks you won't even consider visiting other continents. But if you have airplanes you can get there in a few hours and it becomes something people do at least twice a year.

In programming this "solving problems easily that you didn't even know that there were solvable" happens if you really learn software architecture from actual tools, apis, how standards work, etc. The biggest wow for me was when I started to put in the additional 20-50% overhead to becoming standard conform for a standardized API. In the end when I had a problem I didn't have to code anything, because the other tools were already working with the same API as my tool, and I could just connect them and be done. This way I solved 75% of a semester long software project in one weekend, and I wouldn't consider myself especially intelligent. I just put in the hours to become standard conform, because from learning open source tools I found out it's something that people really do and that it is possible to do that.

Re: Reading OpenBSD source code daily

#35
post #31

Completely agree. But the tools don't make this very easy. Back in college I was working on patches to OpenSSL, Chrome, Firefox, Apache, etc., to add support for TLS-SRP, and it was a huge pain to jump into these massive codebases and try to understand them. I was using Emacs and had all of the various language support modes configured, but go-to-definition and cross-references barely worked. Searching was slow, and…

> Here it is pulling in the OpenBSD sources

There is a note that shows up when viewing OpenBSD sources

"C/C++ is not yet supported (beyond basic code browsing and text search)"

In my experience, these two languages are the most difficult to find good tools for, to browse, jump, and manage large code bases. Yes, some exist, but I thought this was the point of "good tools matter"?

Re: Reading OpenBSD source code daily

#36
post #31

Completely agree. But the tools don't make this very easy. Back in college I was working on patches to OpenSSL, Chrome, Firefox, Apache, etc., to add support for TLS-SRP, and it was a huge pain to jump into these massive codebases and try to understand them. I was using Emacs and had all of the various language support modes configured, but go-to-definition and cross-references barely worked. Searching was slow, and…

I never got around to really testing it, but still remember when OpenGrok was announced, way back when - apparently it's still active. I've been wondering if it would make a good front-end/source-browser component for a trac[t]-like product (with something else for vcs and bug tracking etc):

https://github.com/OpenGrok/OpenGrok

There's also a list of similar tools at Gnu.org:

https://www.gnu.org/software/global/links.html

Thought it might be of interest for others looking at "source browsing" tools.

[t] https://trac.edgewall.org/

Re: Reading OpenBSD source code daily

#38
post #31

Completely agree. But the tools don't make this very easy. Back in college I was working on patches to OpenSSL, Chrome, Firefox, Apache, etc., to add support for TLS-SRP, and it was a huge pain to jump into these massive codebases and try to understand them. I was using Emacs and had all of the various language support modes configured, but go-to-definition and cross-references barely worked. Searching was slow, and…

I'm sure you know this but the code doesn't load for me in Firefox on Android.

Re: Reading OpenBSD source code daily

#39
post #31

Completely agree. But the tools don't make this very easy. Back in college I was working on patches to OpenSSL, Chrome, Firefox, Apache, etc., to add support for TLS-SRP, and it was a huge pain to jump into these massive codebases and try to understand them. I was using Emacs and had all of the various language support modes configured, but go-to-definition and cross-references barely worked. Searching was slow, and…

I'm sure you know this but the code doesn't load for me in Firefox on Android.

Works on Android 6.0.1 w/Firefox nightly for developers app.

Re: Reading OpenBSD source code daily

#40

Earlier quoted context omitted.

I'm sure you know this but the code doesn't load for me in Firefox on Android.

Works on Android 6.0.1 w/Firefox nightly for developers app.

Okay, good to know.

I just tried on two devices.

Nexus 5X, Android 7.1.2, Firefox 53.0.2

Samsung Galaxy Tab S3, Android 7.0, Firefox 53.0.2

The page loads and I get that little blue loading indicator but then nothing happens.

Post reply on HN