Live data from Hacker News

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

isc.org

81–90 of 136 posts

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

#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 better (that is, safer) than C++ native MM just building a reference counting system on top of your C "objects". This is trivial and it is what Redis, Tcl, C-Python, and many others are doing.

With Redis memory leaks or memory management never was a big issue.

> Error handling is optional and cumbersome.

Exceptions mostly suck, and in system software the only sane way to deal with errors is C-alike IMHO, that is, check the return value / error returned by every function and act accordingly.

> Encapsulation and other object-oriented features must be emulated.

This is not an objective point since many thing that this features are actually a problem.

Weak points IMHO, and C++ and Python with the minority of Python looks like a design error.

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

#82

Earlier quoted context omitted.

>but often C is a technical risk as there's so much more that can go wrong. That is objectively incorrect. There is much less that can go wrong with C, as there is much less period. Everything that you can do incorrectly with C, you can do incorrectly with C++, plus 10 times more things that C++ introduced. The idea that C++ is safer because "we just won't do dangerous stuff" is silly, as any language is safe if you…

Alright, I probably phrased it wrong. C++ was written with specific safe guards against a number of common issues than can occur in C code, still it's more than possible to go horrifyingly wrong in C++ but the language has been designed (well, 'ish', it's still C++) to help avoid simple issues. The issues then come from the fact it's still is a fairly complex language and developers are often going to make mistakes.…

And with C you can use static analysis tools to avoid simple issues as well, plus you get a simple language so you aren't making the mistakes that you get with a huge complex language. OpenBSD is entirely C, and they have a far better track record than most C++ software.

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

#83

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…

> as there's so much more that can go wrong

Uh. Everything that can go wrong in C can go wrong in C++ by definition.

C++ also adds a lot of extra things that can go wrong which don't exist in C. There are plenty of arguments to be made for C++ over C but "so much more that can go wrong in C" is not one of them.

The C++ FQA is strongly recommended reading: http://yosefk.com/c++fqa/

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

#84

> "C lacks good memory management" C lets you manage memory without possibly inefficient or even broken magical black box automated processes or garbage collectors. Maybe what the author meant to say was "C lacks easy memory management."

Consider realloc. Seems like a sensible function, with its ability to extend memory blocks in-place. Except, you can't try to extend a memory block in-place, but not move it if it can't be extended. malloc and friends really are a quite poor way of managing a memory space if you want to do even slightly clever things I find, unfortunatly

There are plenty of malloc alternatives (tcmalloc,jemalloc, etc)— and yet I'm not aware of any that has bothered with a realloc_only_if_you_dont_need_to_move(). I'm not aware of any higher level language construct that reduces to that— where your program flow changes depending on details of the systems memory management. If this were an interesting case, I would have thought someone would have implemented it somewhere.

Seems to me that you're making a weird strawman argument there.

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

#85
post #72

Earlier quoted context omitted.

>but often C is a technical risk as there's so much more that can go wrong. That is objectively incorrect. There is much less that can go wrong with C, as there is much less period. Everything that you can do incorrectly with C, you can do incorrectly with C++, plus 10 times more things that C++ introduced. The idea that C++ is safer because "we just won't do dangerous stuff" is silly, as any language is safe if you…

C++ allows to you to - use safe arrays with bound checking if you feel like to - use automatic memory management - pass arguments by reference and being sure they point to valid data - use proper strings without caring if the null character is missing C++ is only dangerous thanks to the C compatibility legacy. Don't use C'isms and the application will be a lot safer than doing pure C coding.

I am not sure about the reference passing, but the rest you can do in pure C, too.

You can bound-check your arrays at run-time, by wrapping them in a struct and only accessing them with functions.

There's even a proper (although conservative) garbage collector for C, while C++ usually boils down to reference counting.

Even in C you are not restricted to the standard library to handle strings. C doesn't have to mean null-terminated strings. (And in C++, too, string literals give you the old-time bad strings.)

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

#86
post #75
post #59

Earlier quoted context omitted.

I'm not sure that I'd call dynamic languages like Python safer, it depends on context. Compared to C/C++ you lose static typechecking but gain a safer memory model.

Anything is better than C.

You haven't used PHP much? Or MUMPS?

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

#87
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…

> With C you can easily get better (that is, safer) than C++ native MM just building a reference counting system on top of your C "objects".

Why build your own when C++ has std::shared_ptr.

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

#88
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…

> With C you can easily get better (that is, safer) than C++ native MM just building a reference counting system on top of your C "objects". Why build your own when C++ has std::shared_ptr.

I was referring about how to do it with C.

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

#89
post #76
post #62

Earlier quoted context omitted.

Which ones? I'd say DNS is probably the most important parts. I also don't believe that core routing equipment is running in the JVM. Apparently you are talking about the "Web", i was talking about the internet or networks in general.. I'm aware that tomcat may have a very large installation base. There is no use for your tomcat if the DNS is down, though :P

What about missile radar systems? http://www.militaryaerospace.com/articles/2009/03/thales-cho...

Very cool, but not really related to core internet functionality.

The truth is, Java is viewed as "not Unix friendly" by many people, whether deserved or not. I suspect the ISC folks fall squarely into this camp. My personal and thus purely anecdotal experience is near-universal hostility from network admins.

Despite this, there is a fair amount of network management software written in Java. OpenNMS and Cisco Prime Networks (an absolute beast) both spring to mind.

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

#90

Go seems like it would have been perfect here, but of course, the language wasn't even a glimmer in Robert Griesemer, Rob Pike, and Ken Thompson's collective eye yet.

Obviously I can't speak for these guys, but if I were designing it the fact that Go uses a garbage collector is a pretty strong minus. I like GC'd languages for a lot of tasks, but if I care about performance to the extent that they need to with BIND, I'm not going near it.
Post reply on HN