Live data from Hacker News

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

isc.org

131–136 of 136 posts

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

#131
post #80

Earlier quoted context omitted.

You can look at the source yourself. I don't understand either, randomly opening parts of both the Python and C++ and it's certainly not complicated and they write the Python in a C style anyway. I'm not a C++ coder and I only play with Python now and then, but can't say the code impressed me much. It's actually pretty hard to skim the code because it's massively over-commented and there are far too many tiny 2-line…

In general, abstracting code out into functions can be useful, even when the new functions is only called once. That is because functions are a well understood abstraction. And having code separated into functions makes it easier for the reader to deduce the coupling points: two blocks of code after another can have all kinds of weird dependencies, e.g. the first blog might set some local variables that the second on…

Obviously.

I've found in my experience working with other people's code and maintaining large code bases you find that overly nesting functions causes a lot of problems when you're trying to read or debug code.

You often also see problems where the essentially dependant functions start to separate in the code as people accidentally add new functions between them.

The article I linked is good, John describes it well. It's a nightmare to work with when you get triple or quadruple nesting of tiny functions, like in the code of this program. It's totally unnecessary.

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

#132
post #128
post #123

Earlier quoted context omitted.

PHP is not a compiled language for systems programming. As for MUMPS I know it is something used only in US it seems.

Oh, I wasn't aware that you only talked about those. MUMPS is also not for systems programming, as far as I know. To nitpick a bit, compiled or not is more a property of the implementation than of the language itself. Of course, some languages are more commonly compiled than others. But, don't Facebook have a PHP compiler?

> But, don't Facebook have a PHP compiler?

Yes, but I don't see PHP as a possible systems programming language, even with a compiled implementation.

Uhm, dreams of device drivers written in PHP...

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

#133
post #80

Earlier quoted context omitted.

In general, abstracting code out into functions can be useful, even when the new functions is only called once. That is because functions are a well understood abstraction. And having code separated into functions makes it easier for the reader to deduce the coupling points: two blocks of code after another can have all kinds of weird dependencies, e.g. the first blog might set some local variables that the second on…

Obviously. I've found in my experience working with other people's code and maintaining large code bases you find that overly nesting functions causes a lot of problems when you're trying to read or debug code. You often also see problems where the essentially dependant functions start to separate in the code as people accidentally add new functions between them. The article I linked is good, John describes it well.…

I guess it also depends a bit on the language you are working in. Some languages have an easier time dealing with functions. In, say Haskell, having quadruple nesting of tiny functions isn't too much of a problem---and if you are pedantic, is the only way to create a function with four arguments.

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

#134
post #124

Earlier quoted context omitted.

C allows those things too, that's the point. Saying "I choose to code unsafely in C, and safely in C++, therefore C++ is safe and C is dangerous" is dishonest. And C++ has plenty of its own dangerous aspects, not just C compatibility.

> And C++ has plenty of its own dangerous aspects, not just C compatibility. All of them would go away if C++ wasn't made to be C compatible.

I guess you might as well use D, then?

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

#135
post #111

Earlier quoted context omitted.

>in our coding style we're caching begin iterators on the line before the loop Can you give an example of what this looks like?

python: for face in mesh.faces(): faceCentre = Point() for v in face.vertices(): faceCentre.add(mesh.getPoint(v)) faceCentre.div(len(face.vertices())) C++: std::vector ::const_iterator itFace = mesh.getFaces().begin(); for (; itFace != mesh.getFaces().end(); ++itFace) { const Face& face = *itFace; Point faceCentre; std::vector ::const_iterator itVertex = face.vertices.begin(); for (; itVertex != face.vertices().end()…

That's 163 vs 486 characters, so, as I expected you'd need about three times the amount of code to do the same thing in C++.

And just look at the difference in readability/simplicity. I can explain the Python code to my 12 year-old cousin, the C++ version though...

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

#136
post #81

Quoting from the article, with my replies: > String manipulation in C is a tedious chore. Use a dynamic strings library, like Postfix for instance, and everything else. > C lacks good memory management. So strange that you went for C++ for most of your code that is not immune of problems from this point of view. I could understand that point if you were opting for a language with GC support. With C you can easily get…

So I used to agree with you, but I've done extensive performance critical C development at Facebook (memcached, a new thing we are about to talk about) and I have also done extensive performance critical c++11 development (our layer 7 load balancer for http) and I'd have to say that c++11 is the far superior option if you really, truly understand what the compiler is doing to your code (a huge caveat). Unique_ptrs ar…

"Unique_ptrs are a total game changer"

You meant that a linear type system is a total game changes. Unique_ptrs are an ugly hack to emulate a linear type system in an inadequate language.

Post reply on HN