Slashdot is powered by your submissions, so send in your scoop


Forgot your password?

Comment Re:Refutation (Score 1) 546 546

Yes, you've managed to find workarounds to all of these issues. There are of course ways to work around them. People do use C++ to get real work done; I have used it successfully many times in the past.

The point is that you have to *know* about all of these issues in order to use just this one feature effectively, without introducing subtle bugs, performance issues, or design problems.

Your solutions will mostly work of course but they are not terribly compelling. We might as well keep going:

  • Calling arbitrary functions in constructors might work, but you can't return multiple values to use as different constructor arguments, so there are more hacks to be done there.
  • Taking a bool& is pointless; you still need a dead-state for the destructor, so you may as well make a separate method to test for the dead-state after the constructor is run. (Good style also generally dictates you should never use non-const reference parameters; use pointers for out parameters to highlight that they will be written to.)
  • Making its destructor protected prevents the class from being destroyed at all unless it is subclassed; the example GGP gave would longer work. I'm not sure what you meant be this. I do agree that documentation should suffice, but tools like -Weffc++ will still warn about it (and rightfully so.)
  • I am not sure what you mean by resource classes. All I'm saying is that if MyClass contains a pointer and you forget to create a copy constructor, the compiler will do so implicitly, and your class will break horribly somewhere down the line.

Again, these are not insurmountable issues. They are just many things you need to be aware of in order to use constructors effectively. No other language has such land mines in such a simple feature as object constructors.

Comment Re:Safe subset (Score 1) 546 546

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.

Comment Re:Soem of the complaints aren't valid (Score 1) 477 477

Unless you're coding in Java, I definitely don't agree with the Java-style getRisk(), because the 'get' is redundant. Accessor methods usually take no arguments and return a value, so the fact that they 'get' something is obvious. Google's C++ style advocates risk(), as does Apple with Objective-C (the default accessors for properties even work this way).

I would call it calcRisk() if it is not const, i.e. it modifies the Investment object somehow (and calc is common short form for calculate). If however it's a const method that just returns the risk, then putting calculate in front is unnecessary. In fact I'd argue that advertising the fact that it is calculated on the fly is a violation of encapsulation. What if you find out that calculating the risk is slow, so you'd like to pre-calculate it, and just return the stored value? calculateRisk() is now mis-named (and you get your grubby hands all over everyone's code and logs if you rename it.)

Comment Re:Android already conver that market (Score 1) 108 108

Of course, there were a lot of computer makes around in the 80s, but the other difference is that these phones today do support a common standard, mainly thanks to Java, and also due to functionality being offered on websites). It's not perfect, but it's way better than the bad old days of computing where you needed a different version for every make and model on the market. Now a single application runs on pretty much any phone.

What universe do you live in? You've obviously never been a mobile developer if you think this even remotely resembles reality. Having been a mobile developer for over 2 years, I can tell you that Java has done absolutely nothing to solve device fragmentation. The language doesn't matter; it's the libraries, of course.

Every carrier has a hundred devices, and every single device has a different bug in its implementation of MIDP. With the strict size requirements for J2ME, for all but the simplest applications you can't even attempt combined builds. You are forced to make a different build for each device. Just wait until you try something *really* broken, like say, playing audio...

And smartphones of course use different APIs. MIDP, Android and BlackBerry have entirely different windowing toolkits. How do you expect an app to be magically portable between them? Even BlackBerries, where RIM has tight control over the devices and API, exhibits lots of fragmentation between devices and OS versions. Java is quite hostile to incompatible libraries, giving classloader errors for the slightest inconsistencies. When you buy a BlackBerry app from a third party site, especially for games, you almost always need to specify the exact model of your phone.

What is needed to reduce fragmentation is a rigorous certification process to strictly enforce the requirements of the platform. Sun had their chance; they could have required extensive testing to put that J2ME/MIDP logo on a phone. Unfortunately Sun failed, and Android seems to be deliberately going down the same path. I don't see the landscape getting better any time soon.

Comment Re:High performance of C++ equal to D??? (Score 3, Interesting) 404 404

>> D did another thing right: it did not remove destructors, like Java did. Instead, when there are zero references to an object, the GC calls the destructor *immediately*, but deallocates the memory previously occupied by that object whenever it wishes (or it reuses that memory). This way RAII is possible in D, which is very useful for things like scoped thread locks.

First of all, Java does have destructors. It's called finalize().

Second of all, calling destructors on a modern GC are extremely costly. Sure, your example implementation of destructors seems simple, but it is only possible in a reference counted garbage collector, which is so primitive as to be nearly useless.

Modern Java GCs are generational copying collectors. They have a young heap, where objects are allocated, and an old heap, where objects are moved when they survive an allocation. Object retention is done by tree search from a root node.

This means you can do fun things like allocate a linked list, then drop the reference node. When a collection happens, anything living is rescued from the young heap, and then it's simply wiped clean. No computation is performed regardless of how large it is or how many links it has, because there's no such thing as deallocation on the young heap. When you drop that first link, it's like the VM doesn't even know it's there anymore; the whole list just gets overwritten on the next pass over the heap.

If, however, you write a destructor for your links (or in Java, finalize()), the destructor then needs to independantly keep track of all of your destructable objects. It needs to remember that they're there so it can call their destructor when they do not survive an allocation. Furthurmore, if you impose your hard requirement of calling the destructor immediately, then the implementation of such a collector is impossible for your language. Even a primitive mark sweep collector, or anything not reference counted is impossible.

This example is discussed in detail here:

You should familiarize yourself with modern garbage collectors. I don't know much about D, but if D really is tied down to a reference-counting collector due to its destructor requirements, that makes it extremely unnatractive as a language. Here is more information on various collector implementations:

It's funny.  Laugh.

Bill Gates' Plan To Destroy Music, Note By Note 659 659

theodp writes "Remember Mr. Microphone? If you thought music couldn't get worse, think again. Perhaps with the help of R&D tax credits, Microsoft Research has spawned Songsmith, software that automatically creates a tinny, childish background track for your singing. And as bad as the pseudo-infomercial was, the use of the product in the wild is likely to be even scarier, as evidenced by these Songsmith'ed remakes of music by The Beatles, The Police, and The Notorious B.I.G.."

Sleep Mailing 195 Screenshot-sm 195

Doctors have reported the first case of someone using the internet while asleep, when a sleeping woman sent emails to people asking them over for drinks and caviar. The 44-year-old woman found out what she had done after a would be guest phoned her about it the next day. While asleep the woman turned on her computer, logged on by typing her username and password then composed and sent three emails. Each mail was in a random mix of upper and lower cases, unformatted and written in strange language. One read: "Come tomorrow and sort this hell hole out. Dinner and drinks,,. Bring wine and caviar only." Another said simply, "What the......." If I had known that researchers were interested in unformatted, rambling email I would have let them read my inbox. They could start a whole new school of medicine.

Esther Dyson Grudgingly Defends Internet Anonymity 516 516

An anonymous reader writes "In an interview, Esther Dyson, chairman of EDventure Holdings, describes anonymity on the Internet as similar to abortion: a bad practice that people should still have rights to. Calling anonymity one of the greatest disappointments of the Internet's evolution, Dyson said: 'I'm pro choice, but I think abortion is an unfortunate thing. I think the same thing about anonymity: Everybody should have the right to it, but it's not something one wants to encourage.'"

Submission + - EU Investigates Microsoft's OOXML For Anti-Trust->


158 Pages of Microsoft's Dirty Laundry 296 296

KrispyRasher writes "Even internally, Microsoft couldn't agree on what the base requirements to run Vista were, but that didn't stop it from inaccurately promoting the OS as running on some hardware. 158 pages of Microsoft internal emails reveal scandalous truths about the squabbles that took place in the lead up to Vista's launch."
The Courts

Microsoft Internal Emails Show Dismay With Vista 662 662

bfwebster writes "Microsoft is currently facing a class-action suit over its designation of allegedly under-powered hardware as being 'Vista Capable.' The discovery process of that lawsuit has now compelled Microsoft to produce some internal emails discussing those issues. The Seattle Post-Intelligencer has published extracts of some of those emails, along with a link to a a PDF file containing a more extensive email exchange. The emails reflect a lot of frustration among senior Microsoft personnel about Vista's performance problems and hardware incompatibilities. They also appear to indicate that Microsoft lowered the hardware requirements for 'Vista Capable' in order to include certain lower-end Intel chipsets, apparently as a favor to Intel: 'In the end, we lowered the requirement to help Intel make their quarterly earnings so they could continue to sell motherboards with 915 graphics embedded.' Read the whole PDF; it is informative, interesting, and at times (unintentionally) funny."

FreeBSD 7.0 Release Now Available 229 229

cperciva writes "The first release from the new 7-STABLE branch of FreeBSD development, has been released. FreeBSD 7.0 brings with it many new features including support for ZFS, journaled filesystems, and SCTP, as well as dramatic improvements in performance and SMP scalability. In addition to being available from many FTP sites, ISO images can be downloaded via the BitTorrent tracker, or for users of earlier FreeBSD releases, FreeBSD Update can be used to perform a binary upgrade."

Giant Sheets Of Dark Matter Detected 231 231

Wandering Wombat writes "The largest structures in the universe have been, if not directly found, then at least detected and pounced upon by scientists. 'The most colossal structures in the universe have been detected by astronomers who tuned into how the structures subtly bend galactic light. The newfound filaments and sheets of dark matter form gigantic features stretching across more than 270 million light-years of space — three times larger than any other known structure and 2,000 times the size of our own galaxy. Because the dark matter, by definition, is invisible to telescopes, the only way to detect it on such grand scales is by surveying huge numbers of distant galaxies and working out how their images, as seen from telescopes, are being weakly tweaked and distorted by any dark matter structures in intervening space.' By figuring how to spot the gigantic masses of dark matter, hopefully we can get a better understanding of it and find smaller and smaller structures."

Microsoft Trying To Appeal to the Unix Crowd? 468 468

DigDuality writes "With the news that Windows 2008 (recently discussed on Slashdot) will have GUI-less installs and be fully scriptable, that they've opened up their communication protocols for non-commercial usage and are providing a patent covenant (Redhat Responds), and now finally an interesting rumor floating around that Microsoft will be taking on GNU directly. Has Microsoft totally switched gears in how it is approaching the Unix and FOSS sector for direct competition? According to an anonymous email leaked from a Microsoft employee, it seems Microsoft will be developing a framework that will be completely GNU compatible. Microsoft CEO, Steve Ballmer, said on Friday (23 February) that they are aiming to restore a Unix-like environment to its former proprietary glory, at the same time proving that Microsoft is committed to interoperability. Ballmer emphasized that Microsoft's new strategy is to provide users with a complete package, and this includes users who like Unix environments. According to the supposedly leaked email, UNG, which stands for UNG's not GNU, is set to be released late 2009."

In case of injury notify your superior immediately. He'll kiss it and make it better.