Live data from Hacker News

Why is BIND 10 written in C++ and Python?

isc.org

41–50 of 136 posts

Re: Why is BIND 10 written in C++ and Python?

#42
post #9

Earlier quoted context omitted.

I can see what you're saying but it's worth contemplating what percentage of the total codebase that Python code would represent if it were replaced by C++ code.

I often convert python code to C++ and you'd be surprised how often the difference in loc is not that much. Certainly no hassle to do so. Not that I'm suggesting that one always should. Several boost libraries are inspired by python and C++11 features all help to write C++ code that is surprisingly similar to python, with a bit of extra type sepcification. If you think otherwise I'd suggest you're probably thinking o…

Thanks, this is interesting. I'm thinking of getting back into C++ after being forced to work on (of all things) a C project. It's hard to know where to dig in, since actually working with existing code means not playing with C++11.

Re: Why is BIND 10 written in C++ and Python?

#43

This doesn't look good for Python: "Whenever possible, we use Python" "When necessary, we use C++" "As of right now, it ends up that about 75% of our code is C++ and 17% is Python (link) since it turns out that a lot of BIND 10 is performance-critical."

Generally you start with Python and 1) get the code correct (hardest part) and then 2) port the performance critical parts to C/C++. So even they ended up with 0% in Python, it wouldn't "look bad". You got the benefit in part 1.

(And as others have said, 17% of LOC in Python might still mean majority of the functionality in Python).

Re: Why is BIND 10 written in C++ and Python?

#44
post #2

A good overview of BIND 10's architecture: http://jpmens.net/2012/12/21/completely-different-bind-10/ It seems that all apart from the performance critical parts are written in Python 3.1

Wow! Someone at the ISC has finally learned what Unix means. I've not used Bind for years after being burned by it's security issues back in the 90's. The 'one big monolithic' program was a terrible idea. I had used DJB dns for years, even with its shortcomings in areas, the modular design caused a bug or security issue in one area not to kill the entire system. Hopefully with bind 10 we'll be able to use user separation (or at least enough selinux) to keep each program in its own security 'domain'.

Re: Why is BIND 10 written in C++ and Python?

#45
post #36

Earlier quoted context omitted.

Probably because of memory usage and garbage collection and the fact that java needs to be installed on most systems whereas C++ needs no dependencies Well, GCC (as in the compiler collection) has had a ahead-of-time compiler for ages: http://gcc.gnu.org/java/ There is also work in the LLVM camp on AOT Java compilation: http://vmkit.llvm.org/ Atleast i wouldn't sleep well if i know that the heart of the internet was…

Those implementations have quite weak garbage collection implementations (boehm conservative, but I'm not sure), which would just kill the performance. Hotspot JVM has a very sofisticated Incremental Generational garbage collector, which does have a _very_ good performance. I'm pretty sure they had their reasons for not using Java (I actually do have mine too), but, garbage collection is not one of those.

Indeed. I was arguing against the 'you need the JVM as a dependency'. But then Go is all the hype these days, and people also use Go for network applications, which also has a weak GC ;).

Re: Why is BIND 10 written in C++ and Python?

#46
post #23

Earlier quoted context omitted.

Probably because of memory usage and garbage collection and the fact that java needs to be installed on most systems whereas C++ needs no dependencies and python comes preinstalled on the usual linux server (probably not python3 but i assume it will be some years before bind10 sees adoption for such critical infrastructure). Also he mentions specialized data structures and memory management. Atleast i wouldn't sleep…

Probably because of memory usage and garbage collection and the fact that java needs to be installed on most systems whereas C++ needs no dependencies Well, GCC (as in the compiler collection) has had a ahead-of-time compiler for ages: http://gcc.gnu.org/java/ There is also work in the LLVM camp on AOT Java compilation: http://vmkit.llvm.org/ Atleast i wouldn't sleep well if i know that the heart of the internet was…

What parts are running on the JVM that are as vital as BIND?

Re: Why is BIND 10 written in C++ and Python?

#47

I think it's interesting that they did consider C and then decided it was too much of a risk. There's a constant theme of 'why use C++? C is faster and doesn't suck as much!' especially due to Linus' statements on the language, but often C is a technical risk as there's so much more that can go wrong. I'm not saying C++ is a better language than C, but it's definitely different and given the language is structured to…

It's a tangent, but: has Linus ever given a presentation that involved actually discussing code? Perhaps code projected on a screen, even part of a slideshow?

It's odd that he's such an accomplished engineer but every presentation I've seen him give involves saying outrageous things while starry-eyed geeks stare at him adoringly. If it weren't for the fact that he's arguing from a position of (very great) authority, he would persuade very few people of anything.

Re: Why is BIND 10 written in C++ and Python?

#48
post #9

This doesn't look good for Python: "Whenever possible, we use Python" "When necessary, we use C++" "As of right now, it ends up that about 75% of our code is C++ and 17% is Python (link) since it turns out that a lot of BIND 10 is performance-critical."

I can see what you're saying but it's worth contemplating what percentage of the total codebase that Python code would represent if it were replaced by C++ code.

I'm working on a project right now where we're replacing a Qt interface written in Python (PyQt) with C++ Qt as it's way too slow (interface is really laggy), and other than things like having to occasionally delete objects manually (often, if you just add a widget to a layout, Qt does the deletion for you), it's pretty much a 1-1 mapping.

We're also replacing core op-graph and geometry processing from Python to C++, and again it's close to 1-1 - there's a bit of overhead in the loops - in our coding style we're caching begin iterators on the line before the loop, but other than that it's very close.

And the speed of the app is so much faster it's not even funny.

Re: Why is BIND 10 written in C++ and Python?

#49
C/C++ and python is a nice combination, and from what I hear, even a best practice when dealing with python optimization. I strongly recollect hearing python developers promoting the idea of first analyze performance, and then rewrite the biggest resource hogs to C code and thus get the best from both worlds. I assume that c++ will have the same usefulness here.

It would be very interesting to see the code paths being run in python vs C. I suspect that the 17% python code is actually is around 80% of all possible code paths, but that the 75% C code is just like 5-15% of possible code paths. A possible way to check that could be by looking at the test suites and see which one is bigger, python tree or the c++ tree.

Re: Why is BIND 10 written in C++ and Python?

#50
post #5

Earlier quoted context omitted.

Why doesn't it look good for python? As far as I'm aware, Python has never been advertised as a top-performance language, and part of the advantage has always been that you can rewrite performance-critical paths in c. Adding to this, the fact that BIND is something pretty performance-intensive, I don't think this makes it look bad at all.

Because the stated goal was to use Python "whenever possible" and judging by the python2 bashing at the end of the article, the author is a true believer yet the best he could do was 17% of the total code. This also clashes with the belief in the Python community that performance is not an issue because you just rewrite those few critical sections in C/C++. How's 75% as one possible definition of "few"?

If they're comparing by lines of code, the 17% that's in python may well contain most of the logic.
Post reply on HN