Forgot your password?
typodupeerror

Comment: Refutation (Score 1) 546

by jdennett (#32428590) Attached to: GCC Moving To Use C++ Instead of C

There are many problems with your example.

  • You can't do non-trivial initialization in the constructor because initializer syntax is not turing complete. Most C++ style guides (such as Google's) suggest using a separate init() function, so it isn't really less lines of code.
  • A constructor can't fail without throwing an exception. Assuming you don't allow exceptions, your class now needs an internal dead state. This is the case even if you use a separate init(), because the destructor needs to know whether init() was successful (unless of course you use a separate destroy(), making this pointless.)
  • A destructor can't fail at all. There is no way to indicate failure; you can't throw an exception because the destructor might be called during stack unwinding from another exception. What if the destructor fails to flush a buffer? The C version can simply return a boolean to indicate this.
  • There is no way to indicate that MyClass should not be inherited, so to allow deletion through a base class pointer (a requirement to satisfy the Liskov substitution principle), your destructor should be virtual. This adds overhead to the class itself, and adds a lot of overhead at the call site if the runtime type cannot be statically inferred.
  • You now need implement (or at least declare private) copy constructors and operator=. Developers expect C++ objects to be copyable, and standard containers require it.

Don't you see what is going on here? Even the most trivial feature of C++, constructors, are horribly ridden with complications. C++ is a language of never-ending surprises, gotchas, land mines. It's a trap.

Let's knock those down one at a time.

  • From the constructor's initialization list you can call arbitrary functions. Whether you should or not is another matter, but it's certainly possible.
  • You can make your constructor take a bool& succeeded parameter if you really can't allow exceptions. (Or even an Error reference.) No worse than C, often better.
  • Destructors can and do fail, but if you want to detect failure instead of ignoring it you should call a function explicitly. No worse than C, often better.
  • You can indicate in a number of ways that MyClass cannot be inherited from; documentation should suffice, but there is also a silly trick you can use if you think that technical solutions to social problems are a good idea. Even without that, you don't need to allow deletion through the base class; just make its destructor protected.
  • If you use resource classes to hold resources (which, it turns out, makes your code cleaner and simpler) then you don't need to do anything about implementing copy operations; the compiler just does the right thing. For your resource classes, you do need to implement them, but there are relatively few such classes, and they're simple.

Comment: Bitwise copy is C semantics, not C++ (Score 1) 546

by jdennett (#32428522) Attached to: GCC Moving To Use C++ Instead of C

C makes bitwise copies. C++ makes memberwise copies (and in simple cases, can optimize that to a bit copy). In C++ you'd hold a smart pointer, and copying that would do the right thing (whatever the smart pointer defines it to do: ref counting, causing a compilation error, making a copy of the target).

Copy operations in C++ would probably not be implicit, if it weren't for the fact that they're implicit in C.

Comment: Name mangling is deliberately different (Score 1) 546

by jdennett (#32428490) Attached to: GCC Moving To Use C++ Instead of C

Different name mangling between different compilers is deliberate, and a good thing: it stops you linking together code that uses incompatible ABIs, and then getting strange crashes.

Now, if you want to complain that it took too long to standardize ABIs for C++, and that it's too hard, and that they're not stable enough, then you might well be able to make a pretty strong case, but that's a different thing. If your ABIs don't match, you shouldn't make your name mangling match.

(Incidentally, if you code in a sane way then the implicit copy operations _almost_ always do the right thing. It would still be better if we had to explicitly enable them, but that would have broken C compatibility, or made struct vs class into two different worlds.)

Comment: const was in C89, aka ANSI C (Score 1) 546

by jdennett (#32428394) Attached to: GCC Moving To Use C++ Instead of C

The ANSI C committee adopted const from C++ in time for the first ANSI C standard, 21 years ago (sadly not calling it "readonly").

(You make a valid point about not having to use every C++ feature to get benefits from using some, and I believe that the plan is to be conservative in introducing features that are helpful while avoiding more controversial or complex features.)

Image

US Grants Home Schooling German Family Political Asylum 1324

Posted by samzenpus
from the come-get-you-some-learnin dept.
A US judge has granted political asylum to a family who said they fled Germany to avoid persecution for home schooling their children. Uwe Romeike and his wife, Hannelore, moved to Tennessee after German authorities fined them for keeping their children out of school and sent police to escort them to classes. Mike Connelly, attorney for the Home School Legal Defence Association, argued the case. He says, "Home schoolers in Germany are a particular social group, which is one of the protected grounds under the asylum law. This judge looked at the evidence, he heard their testimony, and he felt that the way Germany is treating home schoolers is wrong. The rights being violated here are basic human rights."

Apple Orders 10 Million Tablets? 221

Posted by ScuttleMonkey
from the pricepoint-better-be-right dept.
Arvisp writes "According to a blog post by former Google China president Kai-Fu Lee, Apple plans to produce nearly 10 million tablets in the still-unannounced product's first year. If Lee's blog post is to be believed, Apple plans to sell nearly twice as many tablets as it did iPhones in the product's first year."

Comment: Firefox bug 487638, fixed for Firefox 3.6 (Score 1) 387

by jdennett (#30275402) Attached to: Are Ad Servers Bogging Down the Web?

(Reposting, logged in this time.)

If you're using Firefox then this bug is/will be fixed in Firefox 3.6, so that it will report the correct website when things are slow instead of saying "Waiting for *.google-analytics.com. See https://bugzilla.mozilla.org/show_bug.cgi?id=487638 for the details; "status bar blames wrong resource when downloading slow responding resource" is the title of that bug.

If you're using other browser(s), let me know which.

Full disclosure: Google is my employer (and I care about making sure Google Analytics isn't slow).

Television

+ - TiVo as a s/w download for generic Comcast HD DVR

Submitted by evw
evw (172810) writes "TiVo and Comcast announced at CES that they would make TiVo software available for the generic Comcast HD DVR. "Working in concert with Comcast, TiVo has developed a software application that will enable Comcast to deploy the service for a modest monthly fee to existing set-top boxes without an additional in-home visit by a technician." The extra monthly cost has not been announced. Apparently they started doing trials of this at the end of 2006. This is great news because I love my TiVos but I'm fed up with DirecTV and was ready to look at a Series3 but it was going to be tough to justify the steep price vs. the generic cable company box."
Wireless (Apple)

+ - Nice List of iPhone Problems

Submitted by Anonymous Coward
An anonymous reader writes "The Mac fanboy site roughlydrafted.com has just released a post listing ten of the iPhones biggest problems (referred to as "myths"). It has the usual anti-microsoft, anti-palm and anti-cisco comments, but seems to be quite an accurate and complete list of how the iPhone is broken and what ridiculous explanation one might think of to defend it.
Myth Eight: An integrated battery is a significant problem for users
[...]
Having an extra battery to swap in makes sense on a laptop, but does not make sense for a phone, particularly one that has standard external battery packs that can be used via its dock connector.
"
United States

+ - How can we convert the US to the metric system?

Submitted by
thesolo
thesolo writes "Despite past efforts of the 1970s and 1980s, the United States remains one of only three countries (others are Liberia and Myanmar) that does not use the metric system. Staying with imperial measurements has only served to handicap American industry and economy. Attempts to get Americans using the Celsius scale or putting up speed limits in kilometers per hour have been squashed dead. Not only that, but some Americans actually see metrication efforts as an assault on "our way" of measuring.

I personally deal with European scientists on a daily basis, and find our lack of common measurement to be extremely frustrating. Are we so entrenched with imperial units that we cannot get our fellow citizens to simply learn something new? What are those of us who wish to finally see America catch up to the rest of the world supposed to do? Are there any organizations that we may back, or any pro-metric legislators who we can support?"

It is clear that the individual who persecutes a man, his brother, because he is not of the same opinion, is a monster. - Voltaire

Working...