12

Why is Tor implemented in the C programming language? Was that decision a matter of luck or taste of Tor's inventors? Are there any advantages of implementing this kind of technology in C?

weasel - Peter Palfrader
  • 5,158
  • 1
  • 24
  • 39
alaf
  • 2,536
  • 3
  • 17
  • 26

1 Answers1

17

It's a complicated question.

The main reason is historical. When we started out, Roger was only really comfortable in C and Perl. I knew more languages, but I didn't join Tor as a serious contributor until Roger had already been working on the project for a while. (Even if I had been doing as much of the initial work as Roger did, I'm still not sure I would have gone with something else. Back in 2002, Java wasn't so mature, and .)

That said: in my opinion, there are some parts of a program like Tor that you really must implement in C or some other compiled low level language. I'm thinking of cryptography in particular: in order to do fast, safe, efficient cryptography, you really need access to the CPU instruction set. (Some people would argue that C is too high-level for good cryptography, and all crypto should be done in assembly.)

But that doesn't mean that C is the best implementation language for all of Tor today. I'd prefer to move to an architecture where only the core networking module and a bit of glue code would be implemented in C, and the rest would run sandboxed in other processes, written in more high-level memory-safe languages.

nickm
  • 361
  • 2
  • 3