Slashdot Mirror


Java Gets Templates

lastberserker writes "Call them all you want - generics, parametrized types, thingamagic mumbojumbo - but (tada!) Java gets templates in 1.5 release. Nice landing after 5+ years of dancing around a bush. Competition is good, pardon my pun."

121 comments

  1. must be a by-product of severe sleep-deprivation by infernow · · Score: 0

    or something.

    --

    that that is is that that is not is not

  2. OMG templates totally rule! by lightspawn · · Score: 2

    You know, I've never felt a need for templates. You're the one controlling what data goes into which data structure, so as long as you're not confused (and not forced to work with people who are) templates aren't necessary.

    Oh, and I was thinking of another kind of templates (web pages/content/presentation) when I read the title, but of course we have waay too many of those in Java already.

    So, what else is still missing from the language? It seems almost ready to go mainstream.

    1. Re:OMG templates totally rule! by Anonymous Coward · · Score: 0

      Templates are better for "generic programming". While it can be done with inheritance and not sure what java has but opaque or "void*" pointers in c++. However with opaque pointer route doesn't really give you type safety.

    2. Re:OMG templates totally rule! by jilles · · Score: 5, Informative

      Sounds like you don't get the point. The reason templates are useful is because it reduces the amount of code you need to write for common situations in a typesafe way. This makes your code more compact (duplicate code) and less error-prone (it's all type safe and you only write it once).

      BTW. generics are old news. The prototype compiler and the proposal have been available for at least a year. On the javalobby there's a link to some additional language extensions: http://www.javalobby.org/thread.jsp?forum=61&threa d=6009 (lets hope /. gets this right). Lets hope all these goodies end up in 1.5.

      --

      Jilles
    3. Re:OMG templates totally rule! by Cuthalion · · Score: 1

      Yeah, if you're not going to screw up, then you don't need any type checking at all! However, if you want to compiler to tell you in the unlikely event that you or someone else using your code DOES screw up, static type checking is a great thing, and this allows you to do more without giving up that benefit.

      --
      Trees can't go dancing
      So do them a big favor
      Pretend dancing stinks!
    4. Re:OMG templates totally rule! by Wrexen · · Score: 3, Informative
      Templates are useful for tons of things other than generic containers. Consider something like this in C++
      template <class T> T Max(T x,T y) {
      if(x>y)
      return x;
      else
      return y;
      }
      The compiler can determine at compile-time if you're comparing similar types, and error if you're not. Also, it doesn't need to do any run-time type checking to figure out which > to use.

      The Java equivalent would return an Object and take two Objects as parameters. All the type safety you work so hard to preserve is lost, and at run-time you're taking a performance hit every time this is called for a myriad of reasons.
    5. Re:OMG templates totally rule! by lightspawn · · Score: 3, Informative

      The compiler can determine at compile-time if you're comparing similar types, and error if you're not. Also, it doesn't need to do any run-time type checking to figure out which > to use.

      The Java equivalent would return an Object and take two Objects as parameters.


      No, the java equivalent would use an interface, probably called "comparable" or somesuch.

    6. Re:OMG templates totally rule! by Anonymous Coward · · Score: 0

      Please give an example, with type-checks.

    7. Re:OMG templates totally rule! by __past__ · · Score: 3, Flamebait
      So, what else is still missing from the language?
      • Metaclasses
      • Higher Order Functions
      • Multiple Inheritance
      • Multimethods
      • Integration of primitive types and classes
      • Makros
      • A GUI library that is not dog slow (Swing) or bothers you with memory management (SWT)
      • A Free implementation. Maybe a standard would help, too.
      Feel free to complete...
    8. Re:OMG templates totally rule! by JohnFluxx · · Score: 1, Redundant

      I'm confused - I thought that's why everything inherited from the Object class?

      Object Max(Object x, Objecty) {
      if(x > y) return x else y;
      }

      or some such - my java is rusty. perhaps you need to standardise on a function, say, x.biggerthan(y) and ensure it is transitive, reflexive, commutive etc...

    9. Re:OMG templates totally rule! by Anonymous Coward · · Score: 0

      Yeah there is lots missing. But even within in Generics, does Java support Partial Template Specialisation ? Or Default Template Parameters? This still doesnt seem to be a fully functional parameterised type system

    10. Re:OMG templates totally rule! by Anonymous Coward · · Score: 0

      Object Max(Object x, Objecty) {
      if(x > y) return x else y;
      }

      Well this wouldn't work for primitives.
      There is a small performance hit casting to Object.
      But most importantly this loses all type safety.

      This Max function allows you to write code like this

      Salary s;
      Temperature t;

      Max(s,t);

      This would not trouble the compiler. But would give meaningless results, possibly even a runtime error for certain combinations of tyes;

      A generic Max algorithm would allow the following

      Salary s1, s2;
      Temperature t1, t2;

      Max<Salary>(s1,s2);

      or

      Max<Temperature>(t1,t2);

      but

      Max<?>(s1,t2);

      Would cause a compiler error.

      In fact in C++ you can just type Max(s1, s2) and the compiler will work out which parameterised type to use. It looks as if Java Generics will make you type the full verbose name of the method each time.

    11. Re:OMG templates totally rule! by Max232 · · Score: 1

      Hmm, I think you get it more than lightspawn does, but when you said "generics are old news" I was expecting that you were about to point out that templates (as they exist in C++, Modula-3 ('generics'), and numerous other languages) are basically a kludge to work around limitations in the object model.

      The Beta programming language has a much better object model than Java/C++, which completely obviates the need for templates while still providing type-safety; basically, it lets you override 'data members' as well as 'function members' of your classes when subclassing.

      Of course, Beta is a bit hard to come to grips with if you first encountered the idea of an object-oriented language in the context of C++ or Java. Still, a little mind-bending can be good for one's perspective...

    12. Re:OMG templates totally rule! by Nefarious+Wheel · · Score: 2, Insightful
      (sigh). Strong data types are for weak minds.

      -- Eldergeek

      It's a treat to beat your feet in the missedthepointand mod

      --
      Do not mock my vision of impractical footwear
    13. Re:OMG templates totally rule! by jilles · · Score: 2

      I was referring to the fact that generics in Java is nothing new. The proposal for inclusion of generics in Java has been around for quite some time. At the time the 1.4 spec was being finalized it was nearly ready. I've been aware for more than a year now that the intention was to include generics in Java 1.5.

      I agree that probably Java's generics are a bit of a compromise between the Java object model, generics security and type safety. Arguably, C++ is more powerfull but less safe in that respect. Probably Beta does a better job at implementing generics. However, generics are not the solution to all problems. Essentially separation of concerns is not possible for all problem dimensions (which is what both OO and generics try to achieve).

      --

      Jilles
    14. Re:OMG templates totally rule! by Kynde · · Score: 1

      Sounds like you don't get the point. The reason templates are useful is because it reduces the amount of code you need to write for common situations in a typesafe way. This makes your code more compact (duplicate code) and less error-prone (it's all type safe and you only write it once).

      Given how templates exist in C++, all it takes away is just few casts. Which as in comparison to templates are naturally type safe, because with templates you can only handle a certain type in the templated object, thus if in such case you use type casting, where's the problem?

      I am a C++ programmer, so don't flame me for that.
      But seriously all it reduces is few type casts.

      --
      1 Earth is warming, 2 It's us, 3 it's royally bad, 4 we need to take action NOW
    15. Re:OMG templates totally rule! by Anonymous Coward · · Score: 0

      In Java, all objects are pointers, so you'd save a few casts (and have an extra check to prevent the wrong class type from being inserted into your list or whatever).

      For C++, objects might be newed or they might be automatic, so templates can do a lot of extra stuff (especially with overloaded copy and comparison operators... list<int> , list<class myClass> not just list<class Int *> , list<class myClass *> )

    16. Re:OMG templates totally rule! by Hard_Code · · Score: 4, Funny
      Hey, you forgot:

      • My pet "feature" of dubious merit


      Until it has that it is obviously not complete!
      --

      It's 10 PM. Do you know if you're un-American?
    17. Re:OMG templates totally rule! by Tom7 · · Score: 2

      It doesn't just reduce the keystrokes needed to do the type casts, it reduces their possible mis-use and therefore means that if your program compiles, it is more likely to be correct. This is good. It also means that good generic programming techniques will be used more often because they are more convenient.

    18. Re:OMG templates totally rule! by lastberserker · · Score: 1
      • Metaclasses (meaning classes whos instances are in turn classes) are, naturally, templates.
      • Higher order functions can be implemented using templates (see boost::function.
      • Macroses are external to the language, use cpp at will.

      As for the rest, it would be nice, but we can continue surviving without these until 1.6 or so ;-)

      --
      My other Beowulf cluster is... er...
    19. Re:OMG templates totally rule! by __past__ · · Score: 2
      Metaclasses (meaning classes whos instances are in turn classes) are, naturally, templates.
      How so? I'd say the only natural thing would be if they were, well, classes.
      Higher order functions can be implemented using templates (see boost::function [boost.org].
      Sure, boost is cool. However, it still feels nicer to have a language that is well prepared to pass closures around freely.

      BTW, even in Java people use poor man's HOFs, namely in form of anonymous inner classes. Hardly elegant, IMHO.

      Macroses are external to the language, use cpp at will.
      The C preprocessor is indeed external to the language, but it doesn't have to be that way. Think Lisp macros, or CamlP4 for Objective Caml, where you deal with language elements structurally, not just modify text.
    20. Re:OMG templates totally rule! by cookd · · Score: 1

      Oh, and I was thinking of another kind of templates (web pages/content/presentation) when I read the title, but of course we have waay too many of those in Java already.

      If that is what you think of when you hear "templates" in reference to programming languages, perhaps you need to become more familiar with the world of Computer Science (not computer programming -- there is a difference). Anyway, that sentence gives the impression that you don't spend enough time deep in code to make any experienced comments about language features.

      You know, I've never felt a need for templates.

      This is either flamebait, you don't know what the real principles of system design are (see the Computer Science comment above), or you don't have enough experience to be speaking. Perhaps a combination of the three.

      You're the one controlling what data goes into which data structure, so as long as you're not confused (and not forced to work with people who are) templates aren't necessary.

      Parameterized containers are just one use of templates, and obviously you haven't found the others. Programmers with a lot of experience are usually very excited when they learn about templates, because they can immediately see where they would be really useful. If you can't, then you need to do more reading than speaking (insert sagely counsel here ending with "young padawan"). A function needs to be written twice, once for 8-bit characters and once for 16-bit characters. Templates make it possible to write (and, more importantly, maintain) just one version of the function that handles both situations. And it will also nicely handle the situation of 32-bit characters just fine if that situation ever arises.

      Even in the case of simple parameterized containers, templates do a lot more than you give credit for. First, it isn't always YOU that puts stuff in the container. Did you know that some programs aren't written by just one person? Yes, really! So sometimes somebody else misunderstands what goes into your nice generic vector named "nuts". It compiles ok, and works most of the time, but once in a while an exception now pops up. Hey, how did this walnut get into my peanut vector?

      Second, when extracting items from the vector, there is no need to cast the type. And remember that casting actually has a runtime cost -- the system has to verify the type.

      It [the Java language] seems almost ready to go mainstream.

      Alright, if that isn't flamebait, I don't know what is.

      --
      Time flies like an arrow. Fruit flies like a banana.
    21. Re:OMG templates totally rule! by Anonymous Coward · · Score: 0

      The reason templates are useful is because it reduces the amount of code you need to write for common situations in a typesafe way. This makes your code more compact (duplicate code) and less error-prone (it's all type safe and you only write it once).

      You know, this is just not true.

      As code becomes more flexible it becomes bigger, not smaller, and more complex. As code grows more complex, it suffers more bugs, not less, and it exhibits more mysterious Heisenbugs owing to the unforeseen interactions with other (complex) code.

      IF you can write a piece of flexible code with very few to no bugs, AND your application is structured so that there are many opportunities to use it over and over again, THEN it may be justified to put in the extra effort to write flexible code. But generally, the number of bugs is underestimated whereas the opportunity for reuse is overestimated.

    22. Re:OMG templates totally rule! by aled · · Score: 1

      I agree. I think that with interfaces you reuse design while templates helps reuse of code. I'm for design reuse every day of the week, even if it means more code.
      But that just my own opinion.

      --

      "I think this line is mostly filler"
    23. Re:OMG templates totally rule! by aled · · Score: 1

      Macros are evil. Really.

      --

      "I think this line is mostly filler"
    24. Re:OMG templates totally rule! by Anonymous Coward · · Score: 0

      Java is free. goto www.javasoft.com. The Runtime/development environment are all available for free. Pretty sad you dont even know simple facts, my guess is most of your other points are falicies as well.

    25. Re:OMG templates totally rule! by Quadking · · Score: 1

      First, templates increase the amount of code you need to write and second, I don't see how it makes the code more compact or reduces duplicate code. That is a factor of design. The compile time type checking is generics saving grace.

  3. Operator Overloading? by Wrexen · · Score: 3, Interesting

    Does this mean Java will get operators soon? Back when Java was introduced, lack of templates was called a "feature", just like the lack of operator overloading. Have the designers seen the light?

    1. Re:Operator Overloading? by metalpet · · Score: 2, Interesting

      c++ folks are used to use operator overloading with templates together. The sample code 3 posts above does just that.. the "ab" assumes the "" is overloaded for the chosen type.

      Java ain't complete 'till C# compiles on it?

      (if Java is gonna have weird cool features added, I'd like to vote for what I read in the Eiffel doc the other day: design by contract, with pre and post conditions and class invariants. )

  4. How sad by Tal+Cohen · · Score: 3, Insightful

    Sad to see that the suggested implementation of templates does not include type-specific elements, a-la Eiffel (so, for example, I could declare a SortedList type, where only types that implement Comparable can be used). Java's single-root nature would mean that if you want to accept any type as a parameter, just use Object.

    --
    - Tal Cohen
    1. Re:How sad by Hellkitten · · Score: 2

      (so, for example, I could declare a SortedList type, where only types that implement Comparable can be used)

      List<Comparable>
      would probably do that for you

      Disclaimer: I didn't actually check the spec, but int the page of the article there is nothing that indicates that is has to be a class and not an interface or abstract class

      --
      - We are the slashdot. Resistance is futile. Prepare to be moderated -
    2. Re:How sad by Hellkitten · · Score: 3, Informative

      Damn I hate replying to myself

      It seems I may have misunderstood the parent post. Reading through it again I believe he meant something like

      class MySortedList<Comparable Element>{
      void insert(Element e) {
      /* now we can do this: */
      int i = e.compareTo(another_element);
      /* because we can be sure that e implements
      comparable */
      }
      }

      which it seems the specification doesn't support, and it should have. (to be really useful)

      --
      - We are the slashdot. Resistance is futile. Prepare to be moderated -
    3. Re:How sad by Kynde · · Score: 1

      And where is it that you need templates in there?

      Don't get me wrong here, I'm a C++ (and Java) programmer myself, and I do use templates every so often, but seriously that's not the thing you need templates for. If you already have a common interface for the storable items that provides you the stuff you need you really don't need the template at all.

      I've seen all sorts of people write all sorts of heavily templated code over the years and I must say that the need for them (besides some heavy trickery and ioccc uses) there's been little accomplished that couldn't have been done equally well using other means.

      I never understood why was it so much easier to use templates and rely on the fact that the class has said compareTo method than it is to then declare that your class implements interface Comparable for example.

      Besides implementing templates for java all in all escapes me. Although it may strip away few casts, but I wonder wether that really makes things better.

      --
      1 Earth is warming, 2 It's us, 3 it's royally bad, 4 we need to take action NOW
    4. Re:How sad by Anonymous+Brave+Guy · · Score: 2

      One of the major plus points of templates is precisely that they don't require you to implement a particular interface by name. Thus they can adapt to any types provided by other parties that provide the necessary interface functions without explicitly saying that they derive from some known base class.

      And yes, stripping away the casts is better. It reduces a major class of bugs from run-time to compile-time, and that is a Good Thing.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    5. Re:How sad by Hellkitten · · Score: 2

      You are right, there is no absolute need for templates. But if they are going to implement them they should do it right, and that mean beeing able to force one or more interface(s) and/or a base class as the template type. After all the reason was stronger type safety

      e.g. for a collection class you could just as easily just use that interface or base class as the parameter, and document that all object in the collection should be the same class

      It's basically an extra bit of syntax to generate compile-time errors instead of run-time errors, letting stupid programmers know earlier:)

      --
      - We are the slashdot. Resistance is futile. Prepare to be moderated -
    6. Re:How sad by Anonymous Coward · · Score: 0

      I've said it before, and i'll say it again... Objective-C has all the features that Java lacks, with none of the problems (unless you count C as a problem).

      Anyhow, in Objective C, there are Protocols, so you can require an Object to support methods x, y, and z, without affecting the inheritance chain.

    7. Re:How sad by renehollan · · Score: 2
      I never understood why was it so much easier to use templates and rely on the fact that the class has said compareTo method than it is to then declare that your class implements interface Comparable for example.

      To answer your question, if you don't mind a C++ focus, may I suggest that you read Andrei Alexandrescu's "Modern C++ Design", Addison-Wesley, Boston, Mass., 2001, ISBN 0-201-70431-5. Among other things, it offers a way of facilitationg the explicit coding of design pattern implementations.

      --
      You could've hired me.
    8. Re:How sad by bunratty · · Score: 4, Informative

      You should be able to write this as:
      class MySortedList<Element implements Comparable> {
      void insert(Element e) {
      /* now we can do this: */
      int i = e.compareTo(another_element);
      /* because we can be sure that e implements comparable */
      }
      }

      --
      What a fool believes, he sees, no wise man has the power to reason away.
    9. Re:How sad by bunratty · · Score: 2
      That's how templates in C++ work. It's not how generics in Java work.

      In Java, if you specify that any class T can be used, you can call only methods declared in Object on variables of type T. If you want to call other methods, you must constrain the type to a subtype of Object.

      --
      What a fool believes, he sees, no wise man has the power to reason away.
    10. Re:How sad by Anonymous+Brave+Guy · · Score: 2
      That's how templates in C++ work. It's not how generics in Java work.

      I did mention that myself, if you check. :-)

      In Java, if you specify that any class T can be used, you can call only methods declared in Object on variables of type T. If you want to call other methods, you must constrain the type to a subtype of Object.

      And this is where the approach now taken in Java is seriously inferior: there goes your type safety. How, pray tell, are you going to mandate that some third party library developer must implement a suitable interface in any class they provide, such that you can write generic methods to work with a whole family of types that support the interfaces you need, without knowing in advance what they are? Must they implement a single-method interface for every method in their class, and must you specify explicitly which methods' interfaces are required for your generic function? I don't think you've thought this through far enough.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    11. Re:How sad by bunratty · · Score: 2
      I have to admit, I don't get your points at all.

      Why do you say "there goes your type safety"? Can you explain in detail why Java generics are not type safe?

      I also don't follow the vague example you give about the third party developer. I can't recall any situation I encountered like that when using C++ templates. Can you give a more specific example?

      --
      What a fool believes, he sees, no wise man has the power to reason away.
  5. Not really the point. by WasterDave · · Score: 0, Flamebait

    Y'know, just as I'm starting to understand why developers, corporations, every man under the sun thinks Java is a good thing ... they go and do this.

    How're you supposed to get people to maintain 1.5 code then? D'you know how many C++ coders don't understand templates? Even to use them it's a scarily small number.

    There's very little you can do with a template that you can't do with a well designed virtual base class (whatever they're called in Java). And what you can do boils down to performance, which sucks under Java anyway.

    Don't get it. Should've let it be.

    Dave

    --
    I write a blog now, you should be afraid.
    1. Re:Not really the point. by Anonymous Coward · · Score: 0

      Its pretty sad that someone who doesnt even know simple Java terminology( Abstract ) thinks they are qualified to make a childish statement like Java Sux.
      Its sad how many ./ers dont truely understand o/o concepts or the many other cool features of Java. Hell many still think the only place Java exists is within Applets.
      I would suggest that before you repeat the boring untrue Java is slow do a little research and stop talking out of your ass.

    2. Re:Not really the point. by Kynde · · Score: 4, Informative

      Its sad how many ./ers dont truely understand o/o concepts or the many other cool features of Java. Hell many still think the only place Java exists is within Applets.

      Although I agree with you, I must say that "understanding object orientation" amongst programmers is little like "understanding humour" amongst ordinary people. Everybody think they do.

      Any language (that I know of, and that is quite a bunch) can be used to write "proper OO code" aswell as plain-old imperative programming.

      I think Alan Cox put it well when he said "object orientation is a state of mind". Linux kernel is really object oriented on many many levels.

      --
      1 Earth is warming, 2 It's us, 3 it's royally bad, 4 we need to take action NOW
    3. Re:Not really the point. by Anonymous Coward · · Score: 0
      Linux kernel is really object oriented on many many levels.


      you mean



      class Linux : minix

      {
      ...

      }

    4. Re:Not really the point. by pauljlucas · · Score: 2
      There's very little you can do with a template that you can't do with a well designed virtual base class
      Clearly, you've never really used templates to their potential. Go read Modern C++ Design by Alexandrescu.
      --
      If you reply, do so only to what I explicitly wrote. If I didn't write it, don't assume or infer it.
    5. Re:Not really the point. by Hezaurus · · Score: 1

      In exactly what way does java performance suck? (if we keep the swing out of the equation)

      --
      No matter how fast light travels it finds the darkness has always got there first, and is waiting for it. (T. Pratchett)
    6. Re:Not really the point. by Tablizer · · Score: 0, Troll

      Although I agree with you, I must say that "understanding object orientation" amongst programmers is little like "understanding humour" amongst ordinary people. Everybody think they do.

      That is because nobody can agree on what "proper OO" really is, including the OO celebrities. They bicker for their viewpoint as much as newbies.

      Any language (that I know of, and that is quite a bunch) can be used to write "proper OO code" as well as plain-old imperative programming.

      Java does not make procedural programming very simple. I still can't get:

      print("hello world");

      in Java without dotted thingies hanging from its ass or funky interface declarations for every fricken class that uses it.

      I think Sun errored in its OOP-only push. Even many OO fans agree that procedural is sometimes the best approach for *some* things.

    7. Re:Not really the point. by Tonetheman · · Score: 1

      It really isn't a question of using templates to their potential. I have read through the Modern C++ Design book a bit and I am amazed at what you can do with templates.

      I am very hesitant to trust templates in large production code. Really that comes more from bad implementations (MS) but it also comes from the notion that I can write faster code myself. Even with the casts. I know that this statement flys in the face of reuse but there are quite a few people like me who do not think that OO has really helped with reuse that much. I still copy and paste and so do a lot of the coders that I know. Too deep of an inheritance tree will bring a lot of baggage and even worse sometimes undocumented baggage.

      Java does not really "need" templates so much I think. Maybe better casting syntax like C++. I really like the static_cast syntax better than the parens... really just easier on the eyes to be honest.

      The interesting thing about templates is to see how is it implemented. Did they break compatibility with existing JVM instructions? That is the interesting part. I think that you could implment templates without any changes to the underlying JVM and make the compiler do the work.

      Anyway it will be interesting but I would rather see Java go open source more than see templates brought into an already powerful language.

      My two cents

    8. Re:Not really the point. by WasterDave · · Score: 2

      'kay, so it was a bit late and I was trolling. Java performance has traditionally sucked. Java performance is currently one hell of a lot better than when I first tried it. None the less, this has raised Java's performance to the point where it's acceptable for 99% of tasks, but for the last 1% you're going to have to use C/C++.

      Or JNI over to C/C++ at least.

      Dave

      --
      I write a blog now, you should be afraid.
    9. Re:Not really the point. by WasterDave · · Score: 2

      Flamebait? Is Slashdot truly disappearing up it's own arse or what? Are there no coders left in the whole world?

      FFS

      --
      I write a blog now, you should be afraid.
    10. Re:Not really the point. by Kynde · · Score: 1

      That is because nobody can agree on what "proper OO" really is, including the OO celebrities. They bicker for their viewpoint as much as newbies.

      Yep, that is so true. There is also the question of "proper editor"... :-)

      Besides such a huge amount of programming indifferences are really about coding style and other irrational issues. Even some of the OO concepts depend on one's liking.

      Java does not make procedural programming very simple. I still can't get:

      print("hello world");

      in Java without dotted thingies hanging from its ass or funky interface declarations for every fricken class that uses it.


      Nah, it's just as easy. But nonetheless my point was more along the lines "no matter how we rant about certain language features, the bottom line will always be 'good programmers write good code and crappy ones will crap on their terminals'". I know it sounds awfully trivial, but somehow people do tend to forget. Especially during IT boom few years back every god damn company hired anybody how knew how to spell computer. I've heard of people claiming to know java, but then when allowed ask questions have said "just one, what are all those dots and parentheses for?". (and that's a true story)

      I think Sun errored in its OOP-only push. Even many OO fans agree that procedural is sometimes the best approach for *some* things.

      I couldn't agree more. We've been writing an OS from scratch in C++ that will run Java bytecode and it's not just the little things that break out of the OO style. There are numerous things in a kernel that doesn't make sense in OO, but also numerous things that naturally go beautyfully that way. I can't help constantly thinking why we're bothering with C++ at all, although that's really my language of choice for most tasks, in this case I'd drop it down to C. That'd give us the most leash and would still let us easily write solid OO implementations where deemed suitable. (a lot like linux kernel has been done)

      One might ask that what's there to drop down from C++ to C, well I'll tell you, style. Object orientation using C is far more adaptive for strict memory usage than with ordinary classes in C++. Moreover lot of the benefits in C++ don't really come in handy when writing a kernel.

      --
      1 Earth is warming, 2 It's us, 3 it's royally bad, 4 we need to take action NOW
  6. Good, and when do we gets enumerated types? by Pascal+Sartoretti · · Score: 2, Interesting

    After years of discussions, Sun aknowledges that, although life is possible without generics, it is often better with them.

    Now, how many years do we have to wait until they do the same with the good old enum type?

    Pascal

    1. Re:Good, and when do we gets enumerated types? by Anonymous Coward · · Score: 0

      I would suggest that you investigate the Type-Safe Enum pattern. Its many benefits etc are not know by many.

    2. Re:Good, and when do we gets enumerated types? by Pascal+Sartoretti · · Score: 1

      If have seen many of these solutions. You end up with a 30 lines long class that does a little better than what a good enum would do in one single line.

      By "good" enum, I mean something akin to what exists in Ada / Pascal / Modula / Eiffel, not the lousy C/C++ construct.

      Pascal

    3. Re:Good, and when do we gets enumerated types? by Anonymous Coward · · Score: 2, Informative
    4. Re:Good, and when do we gets enumerated types? by Anonymous Coward · · Score: 0

      Yeah with type safe enum there is a lot code for very basic functionality.

      Also there is a bug with this pattern where multiple instances of a single value can exists in a multi class loader environment.

      e.g. Color.GREEN != Color.GREEN if these two objects have been loaded by two different class loaders then passed to each other.

  7. Nooooooo by Khazunga · · Score: 3, Insightful
    Please don't. Operator overloading is one of those cool features that tend to create write-only software. I don't want the meaning of '+' to be different every time I look at it in someone else's code. And please, don't come up with the string concatenation example.

    <irony> 1+1=3 for large enough values of 1 is the most I can concede in operator deviant behaviour. </irony>

    --
    If at first you don't succeed, skydiving is not for you
    1. Re:Nooooooo by lightspawn · · Score: 2

      Please don't. Operator overloading is one of those cool features that tend to create write-only software. I don't want the meaning of '+' to be different every time I look at it in someone else's code. And please, don't come up with the string concatenation example.

      The meaning can be the same, or different - it depends on the body of the function, not its name. Just like, say, toString() can do what you expect it to - or something else entirely. The language should not be expected to prevent you from defining functions named toString() just because they don't perform the function you think they should. Why should it be any different with operators?

    2. Re:Nooooooo by Khazunga · · Score: 5, Insightful
      The language should not be expected to prevent you from defining functions named toString() just because they don't perform the function you think they should. Why should it be any different with operators?
      Operators, to be usable, should be very terse. Three characters maximum is a good recommendation. Most operators are one or two characters.

      With that short a definition, the operator's meaning must be inferred by the reader's culture. + is the arithmetic sum operator. We know what it does after working with it for years.

      Methods, on the other hand, can have extremely verbose names. That is one of the good things on the Java coding guidelines. Names are verbose. There's no strcmp. There's String.compareTo. If the compare is case insensitive, there's String.compareToIgnoreCase.

      Objectively, you are right. There's no guarantee a function performs what its name implies. However, if a function's name is incorrect, I can smack the developer on the head. If an operator's name is incorrect, the developer may have done it right, since having an operator named multiplyTransposeAndNormalize is awkward. It's the whole concept of operator overloading that is wrong.

      --
      If at first you don't succeed, skydiving is not for you
    3. Re:Nooooooo by scrytch · · Score: 2

      > Please don't. Operator overloading is one of those cool features that tend to create write-only software.

      No, this is write-only software.

      a = BigInt(xyz);
      b = BigInt(pdq);

      a.add(b.div(3))

      --
      I've finally had it: until slashdot gets article moderation, I am not coming back.
  8. Good, but need to avoid a few problems by magnum3065 · · Score: 5, Informative

    Doing mainly C++ development I've learned to love the STL and most recently the Boost libraries and I've long regretted that Java didn't support templates. It always confused me that with as much emphasis was placed on strong typing in Java that there was so much need for casting.

    Although I'm glad to see the introduction of templates, I'm also concerned about how some of the problems I've encountered with C++ templates will be avoided. The biggest problem I've encountered has been the lack of interface checking.

    For example the templated function for_each(begin, end, function) iterates from 'begin' to 'end' calling 'function' on each item inbetween. However there is no mechanism to specify that the type of passed to 'begin' and 'end' must have an equality operator and an operator* and 'function' must take one parameter of the type returned by *begin. This can cause very strange compiler errors when a user tries to pass a variable that doesn't support the proper operations to be compatible with the function. These errors actually appear to occur within the templated code, not the user-written code and can make determining the cause of these errors very difficult.

    The Boost Concept Check library provides a way for programmers writing templated C++ code to enforce the interface requirements on the templated parameters in a way that gives more informative error messages. However this is rarely used, even in the Boost libraries. The documentation on the Boost Concept Check gives a good example of the kind of errors that C++ programmers dread.

    In order for Java templates to be successful they will need to provide some manner of enforcing requirements on the interface necessary for the templated code to work and provide useful errors at compile time if it doesn't.

    1. Re:Good, but need to avoid a few problems by hotpotato · · Score: 1
      I've experienced the exact same problem you're describing when using C++. However, I believe there are two important differences between Java and C++ that will reduce its effect with Java:
      • STL usually requires relatively simple things from template types: equality/comparability operators, copy construction, etc. These issues are already addressed in Java: All Objects support equality (using equals()), there's an interface for comparing objects (Comparable), and copy construction is simply not needed because of simpler memory allocation.
      • In my experience, C++ tend to use templates where an interface would suffice. Sometimes this is a symptom of premature optimization (everybody knows templates are so much more efficient than inheritence with its virtual calls..). Other times, its caused by lack of understanding. Usually, however, it's because of the dreadful tendency of C++ programmers to use the minimal number of classes necessary, and using an interface would entail writing a whole new class to accomodate it..

        Anyway, Java already has a long tradition of using interfaces properly (it even has its own keyword :), and I believe Java programmers better understand its proper use. Hence, overusing templates is less likely to occur in Java.

  9. AAAAAAAAArgh -- missing the point sooo badly by Anonymous+Brave+Guy · · Score: 5, Interesting

    Sorry, but I'm going to rant now, because every time I see this ill-informed argument it really annoys me.

    Operator overloading is a fact of life when you are working with generics. Suppose I want to write a generalised summation method, which adds up all the elements in a list, whether those are int, float, SomeComplexNumberType or whatever. Question: what well-known and easily understood notation would make sense to use when writing this method? Should I write another method called add that has several versions, for each type I'd like to add up? Or maybe it should be addTo? After all, by your own argument, verbose and descriptive names are the way forward. But what if someone else provides a fixed-point type with a method called sum instead? Or maybe a static method taking two fixed-point values called sumOf? Do you see my point here? If everyone uses + to mean +, then writing such code is easy. If everyone uses different notation, which is forced if you don't allow operator overloading, then what you get is unmaintainable crap that cannot take advantage of generics in many of the most useful ways.

    Java already has operator overloading anyway. You have + to concatenate strings. You have a conversion operator called toString. You have / that divides real numbers, but takes the integer part of the result for integral types. The only difference between these and what you have in a language like C++ is that in Java, you can only take advantage of this concept where the Java designers want you to, whereas in C++, you can write your own types at full strength as well.

    Yes, operator overloading can be abused. So can method naming (and no, you can't smack the developer on the head, if he happens to work on the other side of the world and you're stuck using his library). But op overloading is more than mere syntactic sugar, where generic programming is involved. There are accepted standards for how we write certain concepts such as addition or strict ordering, and operator overloading is necessary to allow user-defined types to meet those standards, and thus to allow well-written generic code to take advantage of parameterised types and such to best effect. Without it, you've got a fabulous canvas, yet nothing but coarse paintbrushes to draw with.

    Alas, as is so often the case, I fear the Java community has been too quick to think it understands, and to go for the buzzword feature without investigating the supports deeply enough. Parameterised types are a good start, and I'm glad to see them included, but I suspect that with experience, there'll be some serious enhancements in a couple of revisions' time...

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    1. Re:AAAAAAAAArgh -- missing the point sooo badly by nojomofo · · Score: 5, Insightful

      I don't necessarily disagree with everything you're saying here, but a few things drew my attention....

      You have a conversion operator called toString

      Um, no. You have Object.toString() which is a method, not an operator.

      There are accepted standards for how we write certain concepts such as addition or strict ordering, and operator overloading is necessary to allow user-defined types to meet those standards...

      It sounds like you're talking about why operator overloading is necessary for C. For one, "user-defined types" don't exist in Java. Second, I don't agree with what you're saying. What about Lisp? Do you think that Lisp is a poor language because you don't add two numbers by saying 1 + 2? Lisp breaks your "accepted standards for how we write... addition".

    2. Re:AAAAAAAAArgh -- missing the point sooo badly by Hard_Code · · Score: 3, Insightful
      Suppose I want to write a generalised summation method, which adds up all the elements in a list, whether those are int, float, SomeComplexNumberType or whatever. Question: what well-known and easily understood notation would make sense to use when writing this method?


      In Java, operators already only apply to primitives anyway, with the exception of the + operator, and then only when in a string context (ok ok, there is 'instanceof' and 'new'...i'm not sure if these can be meaningully considered "operators" as they are reserved for very specific uses). Collections also only apply to objects. It already doesn't make sense to be able to perform certain operations on arbitrary objects. E.g., what does the addition operation do with operands of Bicycle type and the Color orange? If you are going to use generics for collections, you are already going to declare them to use some homogenous base class. In your case it would be something like Addable, which would have an add() method or whatever. Or perhaps just Number, from which you get primitive values, and add them with the primitive + operator. At some point you have to draw the line in defining things. Performing arbitrary operations on arbitrary objects at best makes no sense, and at worse can be very very dangerous.
      --

      It's 10 PM. Do you know if you're un-American?
    3. Re:AAAAAAAAArgh -- missing the point sooo badly by elflord · · Score: 2
      For one, "user-defined types" don't exist in Java.

      I think he means "classes". Why should '+' work for the java string class, but not for a user defined string ?

      Second, I don't agree with what you're saying. What about Lisp? Do you think that Lisp is a poor language because you don't add two numbers by saying 1 + 2?

      There are accepted standards for what '+' means. Even in LISP. The fact that the lisp programmer writes (+ x y) instead of x + y is not relevant -- the point is that it makes sense to have x+y or (X x y) mean the same thing ("add these things together) for user-defined types (like big numbers, high precision floating point numbers, quaternions, finite abelian groups, matrices) as it does for built-in types.

    4. Re:AAAAAAAAArgh -- missing the point sooo badly by Anonymous Coward · · Score: 0

      Um, no. You have Object.toString() which is a method, not an operator.

      I think the point he's trying to make, is that toString() is implicitly called when the + operator is used with Strings. So it is actually similar to C++'s conversion operator.

      operator std::string() { /* blah */ }

    5. Re:AAAAAAAAArgh -- missing the point sooo badly by Anonymous+Brave+Guy · · Score: 2

      With respect, I think you miss the point as well. The fact that Java treats primitive types differently from those derived from Object is already a serious thorn in the side of many a programmer. This sort of generic feature could provide a systematic, uniform way of dealing with such types, banishing the need to use bastardisations like Integer to a much smaller range of applications. This, IMHO, is a Good Thing.

      You're quite right, of course, that it doesn't make sense to try to add an apple and the colour purple. What you're ignoring is that you simply wouldn't provide an addition operator taking a Bicycle and an Orange, and thus trying to do add them with a generic function could and should result in a compile-time error, or at least a run-time error if you're relying on late binding. There is no problem here; at worst it's the same as what you've got if you do the same thing in non-generic code now.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    6. Re:AAAAAAAAArgh -- missing the point sooo badly by scovetta · · Score: 1

      Operator overloading seemed good at first until: Dog d1 = new Dog(); Dog d2 = new Dog(); Dog d3 = d1 + d2; Just because you can do something, doesn't make it right. The 2% of coders that can use it correctly will have to suffer because the rest can't. M

      --
      Wer mit Ungeheuern kämpft, mag zusehn, dass er nicht dabei zum Ungeheuer wird. --Nietzsche
    7. Re:AAAAAAAAArgh -- missing the point sooo badly by hotpotato · · Score: 1
      Suppose I want to write a generalised summation method, which adds up all the elements in a list, whether those are int, float, SomeComplexNumberType or whatever ...

      I believe Java generics don't support primitive types, only classes and interfaces.

      Should I write another method called add that has several versions, for each type I'd like to add up? Or maybe it should be addTo?

      The problem you pose is real: We should have a standard way of adding to instances of a certain type. However, IMHO the best solution isn't to add operator overloading, but rather to standardize an addition interface:

      interface Addable {
      public void add(Object other);
      }
      And of course you can also make it generic to avoid downcasts.. :) This is similar in concept to Comparable, and doesn't resort to operator overloading, which is, to Java, nothing but syntactic sugar.
    8. Re:AAAAAAAAArgh -- missing the point sooo badly by Anonymous+Brave+Guy · · Score: 2
      I believe Java generics don't support primitive types, only classes and interfaces.

      Oh, dear. I read about that when the proposals first flew around a while back, but I confess I thought they'd changed it, and didn't really check in detail this time.

      That's a shame, because now one of the few really good things that was going to come of this hasn't.

      However, IMHO the best solution isn't to add operator overloading, but rather to standardize an addition interface:

      We already have one of those: it's called the + operator. :-)

      But seriously, your approach is fundamentally flawed in at least one totally unnecessary way: it requires a different interface to be implemented for each relevant method, so a numeric class might well have to implement more than a dozen interfaces just to do the basics (and still wouldn't be compatible with primitive types, unless you're going to provide that interface for them as well). Presumably your parameterised functions or types are also going to list all the interfaces they require of each parameter type explicitly as well?

      This is similar in concept to Comparable, and doesn't resort to operator overloading, which is, to Java, nothing but syntactic sugar.

      But Comparable has always been a bit of a dark hat in a room full of white suits. It's there exactly because the need I'm talking about exists, but for some reason people I've never fathomed Java people don't seem to like operator overloading.

      The question is, at what point does this break down? Do you provide interfaces for LessThanComparable, StrictlyLessThanComparable, EqualityComparable, InequalityComparable, GreaterThanComparable and StrictlyGreaterThanComparable, to correspond to the various equality and inequality operators? (Do you make the primitives provide them as well?) Do you try for more abstract concepts, such as Ordered or StrictlyOrdered? The latter is probably better style, but then you lose an element of precision that might be important when working with arbitrary types. Perhaps you start with an interface for each method, and then create more abstract, compound interfaces derived from them? But now, my poor little class that just wants to compare two int members for an ordering, is supporting multiple layers of interfaces, several at a time, and providing an artificial method, just so I can sort it?

      Thanks, but I'll take operator overloading and proper generics any day.

      And by the way: I'll think about admitting that operator overloading is mere syntactic sugar just as soon as you show me a class that works like a function, so I can pass it in to a generic algorithm. :-)

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  10. Obligatory "parametrics != generics" comment by Anonymous+Brave+Guy · · Score: 3, Informative

    Since no-one has yet pointed it out that I can see, it should be noted that what we're talking about here is parameterised types, and to a limited extent, parameterised methods. This is still quite some way from what you can do with serious generics in other languages.

    There is an obvious comparison with C++ templates here, and although those are not the best generics around themselves, they do have a few very useful tricks up their sleeves. In Java, you can now do parameterised containers, and to a limited extent you can do generic algorithms, although the lack of things like operator overloading cripples these from birth. You can't, AFAICS, do some of the funky stuff with traits classes, and things like template metaprogramming, expression templates and Andrei's tricks combining templates and inheritance -- the stuff that's used in several of the best C++ libraries today to give them an edge -- are out of the question for now.

    That's a shame, because one of the great things about C++ templates is that using them is pretty easy, but there's quite a bit of power under the hood for people actually implementing class and function templates, such as the designers of those libraries. That means improved performance and/or flexibility for Joe Developers everywhere, even if only a few people know and use the features under the hood.

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  11. Yeeeeeeeees by Anonymous Coward · · Score: 1, Insightful


    But sometimes the terse name is the right one to use. The standard examples come from maths programming. If you have a Complex number class, then it is far more natural to write

    Complex c1;
    Int i;
    Complex c2 = c1 + i;

    Rather than
    Complex c2 = c1;
    c2.addInt(i);

    Of course a method is usually the best place to put functionality. But not always Blitz is a great maths library using templates and operator overloading when necessary to produce a very powerful and usable system.

    Other examples are the iostream library and STL in C++.

    The ability to overload the <operator allows the STL to use primitive types and user defined types in the same algorithms.

  12. Too little, too late by MobyDisk · · Score: 4, Insightful

    Too late:
    Sun ignored requests from the developer community to extend the Java core language. Now they finally listen, after Microsoft copied Java with C# and added generics. This is why Java has gone from the hottest thing since Starbucks, to yet another language. They didn't listen to their user base until 2 years after it was too late.
    Lessons learned:
    This is also why Microsoft is so successful - they constantly innovate, rather than sitting on their market dominance. I foresee Sun suddenly trying to play catch-up with new core Java features. I will enjoy reading the spin Sun puts on this, after saying for years that none of these features were necessary.

    1. Re:Too little, too late by addaon · · Score: 4, Informative

      Sun (or at least the people I've spoken to at Sun, who do represent their company) never said that generics weren't necessary. They said, with surprising honesty, that no one had yet come up with an implementation of generics that made sense for the virtual machine. The current implementation of java with generics has been available for around 18 months (externally for what, 12 months?), and has been a compromise implementation, giving a highly requested feature at some cost, perhaps, in the potential beauty of the implementation. The reason that generics weren't included with Java 1.0 is that no one could agree on how to do them; Sun has since realized that they won't be perfect, regardless, but that it's time to push them out the door. Probably, their publication of this stuff is prompted by C# (which uses, more or less, the same flawed-but-usable implementation). But I really do respect Sun's restraint in trying to make it as good as possible.

      --

      --

      I've had this sig for three days.
    2. Re:Too little, too late by pmz · · Score: 3, Interesting

      This is also why Microsoft is so successful - they constantly innovate, rather than sitting on their market dominance.

      Sure they do. Microsoft is extremely good at seeing what other people are doing and, then, copying, buying, or squashing it to meet their agenda. In the case of C#, they first inhibited Java with their VM "embrace and extend" scheme, and then took Java, copied it, renamed it, and added a few things.

      I guess you could call standing on other peoples shoulders innovation, but that is a relatively weak use of the word. Microsoft is more like the business partner that is your friend right up to the point of stabbing you in the back and taking credit for your work.

      As for real innovation, I often wonder what "killer apps" were stifled over the years by Microsoft. Like weeds in a garden, Microsoft is always there...

    3. Re:Too little, too late by MobyDisk · · Score: 2

      Don't turn this into a pro-MS or anti-Java thread. The point is that everyone lauded Sun for creating Java, then they got lazy.

      I explicitly said that Microsoft embraced and extended Java. But all innovation is improving on existing ideas and adding your own. From the Franklin stove to alternative-fuel cars, to programming languages. The point is laziness. It took Sun 5 years to add templates to Java. In that same time span, Microsoft duplicated everything Java had, and more. Like it or not, that's a road to success.

    4. Re:Too little, too late by DmitriA · · Score: 4, Informative

      Wrong! C# uses a RADICALLY different implementation of generics - Java opted for 'erasure' approach because they needed to preserve backward-compatibility. So that means that all generic type information is removed by the compiler/translator and that code is replaced with polymorphic subtyping with casts (essentially, using the same collections of Objects but everytime you insert or retrieve an element, it will do a cast) - thus, horribly slow runtime performance.

      Next version of C# will support generics in the VM and that will remove the need for casts and allow you to do other nifty stuff like polymorphic recursion, getting specific runtime information that Vector is really that and not a Vector - in Java, you would have to look at the actual elements to determine that.
      In fact, Microsoft Research people that presented a paper on generics in .Net at PLDI '01 claim that this is the first ever implementation of generics with support in the VM itself. But I think if Sun had the time to do it in Java in the beginning, they would've opted for a similar design, but since they hadn't and now they can't go around changing all the VMs and losing compatibility with all the code that is out there, that wasn't an option for them

    5. Re:Too little, too late by Anonymous Coward · · Score: 1, Informative

      Here's more information about C# vs. Java generics: http://www.gotdotnet.com/team/csharp/learn/Future/ VCS Language Changes.aspx.

    6. Re:Too little, too late by jafuser · · Score: 2
      This is also why Microsoft is so successful - they constantly innovate, rather than sitting on their market dominance
      <sarcasam> Oh, so that would explain why Outlook Express has improved *so much* since version 4.</sarcasam>

      I like OE. It has a clean UI, but it really hasn't changed since I started using it.

      • the rules system is too simplistic
      • it doesn't include the original author's name in an automatically forwarded email
      • going from next to previous message is awkward
      • memory management on newsgroups is inefficient
      • there should be plugins for binary decoders
      • I can't edit a list of file extensions which are "dangerous", so I have to open the settings window, flip to another tab, uncheck the "protect me from dangerous attachments", then save the attachment and go back in and re-enable the setting.

      The only really neat feature they did add was the junk filter, and that got removed thanks to some moron e-card quasi-spammer.

      --
      Please consider making an automatic monthly recurring donation to the EFF
    7. Re:Too little, too late by Anonymous Coward · · Score: 0

      (a)
      Anyway, I hardly consider it "too late". No one I know is seriously considering .net over the mature, proven, reliable, multivendor J2EE.

      The can only make Java's stranglehold stronger. Java has a near-monopoly in the enterprise web application server space.

      (I am a Common Lisper, and know that Java and .net both suck royally - but so did cobol, and look how much that was used.)

      (b)
      Innovate? Never.

      Innovation would be inventing a whole new language feature, say "confrabulation", that made programming 100x easier.

      Generics are (pretty obviously) already in C++, among other languages.

      MS have NEVER innovated! They copy, and they tie-in (embrace and extend). The only people who think MS innovate are those who have never looked beyond MS's offerings in the first place. E.g. "Windows 95: Now Multitasking!" - other oses, including really cheap-ass ones like AmigaOS, had been multitasking for years.

  13. Constantly innovate? Too late!!! by Anonymous Coward · · Score: 0

    You believe M$ propaganda, all that innovation hoo-haa? Sorry pal, wake up, no company that "constantly innovates" comes out with a Java clone about 5 years too late!

    1. Re:Constantly innovate? Too late!!! by zuzzabuzz · · Score: 0

      Amen to that. I was just thinking about that last night. Java was pretty rough when it first came out, but they were trying to avoid a lot of pitfalls from languages before.
      It's come a long way, with a lot of clean up. And then, after all of that birthing pain, an almost exact clone of the language comes out...in record time, no less! Innovative!

      --
      -buzz
    2. Re:Constantly innovate? Too late!!! by kzeddy · · Score: 2, Insightful

      So what?!?! This whole thread is missing the point. Its not about being innovative but winning the game. Do you really think that Microsoft cares if java was first to come out and that C# is just a clone with a few added features. The first people out the gate are not the ones who always unless they keep up that lead throughout the race. For all we know, it may have been Microsoft's intention all along to wait on competing with Java until it was necessary. Come out with a better (my opinion) product not while its competition has just started but until it has matured a little and innovation has slowed. That way you know the boundaries of your competition's product and you simply go through a checklist of things to improve and a couple of new things that your competition doesn't have. ./'ers would do themself some real good if they started thinking a little more like businesspeople and a little less like naive programmers.

    3. Re:Constantly innovate? Too late!!! by TheShadow · · Score: 1

      I don't know what C# you're looking at but it certainly isn't a Java clone. It borrows more from VB and C++ then from Java. Maybe that's why it's not called J#.

      --

      --
      "What do you want me to do? Whack a guy? Off a guy? Whack off a guy? Cause I'm married."
    4. Re:Constantly innovate? Too late!!! by Anonymous Coward · · Score: 0

      bollocks. it's java all over.

  14. Bjarne was right! :) by Bish.dk · · Score: 2, Interesting
    So it turns out that Bjarne was right in his interview with Visual C++ Developers Journal in June 2000:
    Very little in Java is new to a student of programming languages, so there has been little effect on the C++ definition. In that area, Java is still playing catch-up (for example, I think it is just a matter of time before Sun will add a template-like mechanism to Java).
    -- Henrik
  15. Some Java Generics problems by Anonymous Coward · · Score: 0
    Some Java Generics problems:

    Templates only work on Objects - you cannot use templates on built-in types (int, double, etc) unless you manually box/unbox them.

    Casts from Object, although hidden from the programmer, are still performed at runtime behind the scenes. This incurs runtime overhead as Java casts invoke code to check the type. This makes Java generics unsuitable for high-performance scientific programming.

    1. Re:Some Java Generics problems by fruity_pebbles · · Score: 2, Insightful
      This makes Java generics unsuitable for high-performance scientific programming.

      Which doesn't change anything, because Java in general is unsuitable for high-performance scientific programming.

  16. Missing from the language... by Tom7 · · Score: 3, Insightful

    > So, what else is still missing from the language? It seems almost ready to go mainstream.

    Well, I don't know about most Java programmers, but the missing features that constantly bug me are:

    - Higher-order functions (Seriously, you can't live in a language that doesn't have this once you get used to programming with them!)
    - Algebraic Types and Pattern Matching (Vital for manipulating syntax trees, like in a compiler)
    - Tuples
    - Getting rid of 'null' (This is possible, in fact, easy, and would make the language much cleaner, less error prone, and even more efficient)
    - Uniform typing discipline (ie, int vs. Integer ... I think this is relieved a little bit by generics)
    - Parameterized Modules (a la SML's functors)

    There are also some bugs in the language itself, though those wouldn't really bother me day-to-day.

    - Arrays are covariant, leading to class tag checks on every array write (in the general case)
    - The description of binary compatibility is broken (It can lead to situations where recompliation of the class files either leads to a different program, or to a failure to compile!)
    - ...

    A language that makes some of these strides is called Nice , though I've never used it.

    1. Re:Missing from the language... by cookd · · Score: 1

      I understand the rest, but I'm not sure about what you find wrong with null. Please expand on that, if you would.

      Thanks.

      --
      Time flies like an arrow. Fruit flies like a banana.
  17. Boost CC library is in GCC by devphil · · Score: 2


    Recent versions of GCC ship with a version of the Boost Concept Checks embedded in (and adapted to) libstdc++. You can turn it on with a #define, or turn it on all the time with a switch to the 'configure' script. The docs explain how.

    My own copy of GCC has the checks turned on permanently. Very useful.

    --
    You cannot apply a technological solution to a sociological problem. (Edwards' Law)
  18. Adding Generics Forum by bunratty · · Score: 2

    Don't forget to visit the Adding Generics Forum for more detailed posts about generics and other new features being added to Java.

    --
    What a fool believes, he sees, no wise man has the power to reason away.
  19. Um, yes. :-) by Anonymous+Brave+Guy · · Score: 2
    Um, no. You have Object.toString() which is a method, not an operator.

    Perhaps my terminology isn't the norm in the Java world, but nonetheless, what you have is exactly the same as a conversion operator in other languages. It is a means of implicitly converting between types. Except that in Java, you can only set that up for conversion to a String implicitly. (Don't even get me started on why all classes should have to provide this method in the first place, or on the common root class flamefest.)

    It sounds like you're talking about why operator overloading is necessary for C. For one, "user-defined types" don't exist in Java.

    Really? What's a class, then?

    Second, I don't agree with what you're saying. What about Lisp? Do you think that Lisp is a poor language because you don't add two numbers by saying 1 + 2? Lisp breaks your "accepted standards for how we write... addition".

    Lisp has an accepted standard of its own: (+ 1 2) is the sum of the numbers 1 and 2. The point is not a universal notation, but a consistent notation within the language, which allows you to write a generic method once that can work with any suitable type without further modification.

    Your example is particularly ironic because Lisp's S-expressions are a prime example of exactly the sort of uniform syntax I'm advocating here.

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    1. Re:Um, yes. :-) by nojomofo · · Score: 1

      Seems to me that the whole crux of what you don't like about Java (at least as relates to this subject...) is that there is a fairly marked distinction between primitive types and classes. They behave differently. They are used differently. Yes, Strings do use the + operator and there is implicit toString() calling, which ar an exceptions (side note: I have no idea what you mean when you say "Except that in Java, you can only set that up for conversion to a String implicitly"). If you're that much of a "purist" that this is a problem for you, then maybe only Lisp is uniform enough for you.

      But really, as others have pointed out, what does it mean to add a primitive to an object (of a perhaps arbitrary class) or two different objects? Why is it really so wrong that you have to define in a method what happens when you add them?

  20. They did by ken_mcneil · · Score: 1
    If you read the spec you will find that they have implemented a method for interface checking. You can require that a template parameter have a certain base class and/or implement a set of interfaces. Here is an example:
    interface Iterable<T> {
    Iterator<T> iterator();
    }
    interface List<T> implements Iterable<T> {...}
    interface Set<T> implements Iterable<T> {...}
    class Test {
    void <T,S implements Iterable<T>> printList(S s) {
    Iterator<T> it = s.iterator();
    while (it.hasNext())
    System.out.println(it.next());
    }
    }
    The careful reader will also note that they fixed the requirement that >'s have to be seperated by whitespace.
  21. Info + IDE supporting Java Generics by kryps · · Score: 2

    For the impatient:

    The preliminary spec for generic types in Java is here.
    The Sun prototype compiler can be downloaded here.
    And a forum for discussion of Java generics is also available.

    You might also want to check out CodeGuide. This is AFAIK the only IDE which already supports Java generics as described in the spec (and is an awesome IDE for traditional Java as well).

    Enjoy!

    -- kryps

  22. Generics aren't the only addition by GimpyMcJackass · · Score: 1
    • Templates only work on Objects - you cannot use templates on built-in types (int, double, etc) unless you manually box/unbox them.
    Remember, generics are just one addition. One of the other additions is autoboxing, so you don't have to worry about manually boxing primitives anymore.

    There's a bit at the end of this article.

    It doesn't mention this specifically, but it alludes to also including static imports, foreach-like construct, and possibly enums.

  23. Let's just compare them, and see... by Anonymous+Brave+Guy · · Score: 2

    My objection isn't just that primitive types and UDTs work differently, although that is a fundamental cock-up that should long since have been fixed. My main objection is that we already have a sensible way to represent these concepts, and it's absurd to go around reinventing the wheel, and in a somewhat arbitrary way at that, rather than going with the obvious.

    Is it really wrong that a multiply-and-add operation on two matrices be written as M = A * B + C? Or that a new date should be calculated with seasonEnd = seasonBegin + seasonLength? Why is it in any way better to write something like:

    • M = A.Multiply(B).Add(C)
    • M = Matrix.Sum(Matrix.Product(A, B), C)
    • M = MultiplyAndAdd(A, B, C)

    or any of the zillions of other possible permutations? Do you honestly feel that this is less subject to abuse, or less error-prone?

    And why shouldn't my parameterised tree container, and the algorithms that operate over it, be able to work with int and float data, as well as BigNumber and FixedPoint values? Why should I have to write it all twice (at least)?

    Operator overloading is much cleaner, reduces the programming effort required to develop parameterised data structures by a factor of at least two, and consequently reduces error rates. The only point I've seen against it that is true is that there is scope for misleading operator overloads to be provided. It isn't hard to see the conclusion, if only you sit down and look at it objectively.

    Oh, and the implicit conversion thing relates to the fact that I can convert an object into a string just by context ("some " + myObject + " thing") but I can't implicitly convert to an int for analogous summation purposes, say.

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  24. Java desperately needs const types by Anonymous Coward · · Score: 0

    Const types and methods in Java would give the programmer a strong guarantee about the behavior of a function rather than just a convention that a naive fellow programmer could easily break.

  25. Java Evolving...to C++ by RAMMS+EIN · · Score: 2

    Great. Finally Java gets one of the features people so desparately need. Admittedly, Java is very cleanly designed, but I really find Java programming painful. Templates were one thing that was missing. Macros are another. Does Java have regular expressions these days?

    And really...the more of those missing features get added to Java, the more it gets to look like that other object oriented language with a syntax like C's...I believe it is called C++. Yes, I know objects are optional in C++, but they are in Java, too. int, float, etc. are simple types. Java is big, bloated, slow (yes it is) and a pain to program due to missing features. Once the missing features are added, and the speed is brought on par with other languages through compiling to native code, it will be just like C++. It won't be more portable, either. As far as I am concerned, Java is an expiriment, a failed experiment, to be exact. Go Python!!

    --
    Please correct me if I got my facts wrong.
    1. Re:Java Evolving...to C++ by Anonymous Coward · · Score: 0

      Another /.er making comments based on ignorance. If he/she bothered to check he/she would know java has regular expressions. He/She would also know that Java does indeed compile to native code at runtime by the JIT for frequently used methods etc.

      Pretty funny how one of the best python implementations JPython uses the same flawed Java JVM. Perhaps you used it and never really realised what was going on...

      Java is nothing like C/C++. THe fact you dont have pointers really changes things and makes Java truely o/o other than a set of macros for assembly language( which is truely what C is ).
      Buffer overruns/exploits etc ever happen in Java ??? Wonder why...

    2. Re:Java Evolving...to C++ by Anonymous Coward · · Score: 0

      >Does Java have regular expressions these days?

      Yes, in java.util.regex

  26. Clearer answers, I hope :o) by Anonymous+Brave+Guy · · Score: 2
    Why do you say "there goes your type safety"? Can you explain in detail why Java generics are not type safe?

    It's not that they are necessarily not type-safe, not in the way that the current containers are because you have to perform a potentially wrong downcast to use them.

    However, suppose I develop the world's greatest sorting algorithm, and I want to write a generic implementation for it to sort arbitrary sequence containers of arbitrary types. There are inevitably certain minimal requirements: I must be able to traverse my container in a suitable way for my algorithm to work, the types must support a suitable ordering relation, and so on.

    As I understand it, several people in this thread are advocating the use of interfaces to ensure that only suitable types get passed to my sorting algorithm, thus ensuring type safety. The problem with that is what happens when someone comes along with a new container or sortable type that provides the necessary methods, but doesn't explicitly use that interface. Now my "generic" sorting algorithm can't be used, purely because of a naming issue. (I realise there are certain standard interfaces defined for things like comparison in Java, but obviously for types and algorithms in general that won't be the case.)

    The requirement to implement interfaces explicitly is simply an unnecessary bar to the use of generics. In other languages, from C++ to SML, you can achieve similar effects without ever explicitly naming your interface. Instead, the algorithm simply fails to compile if it's used with types that don't match the way the algorithm uses them. Added to the presence of operator overloading, which standardises many fundamental arithmetic and logical operations from the start, writing generic algorithms that really are quite general is significantly easier.

    Further, the concept of an interface as defined in languages like Java is inadequate to enforce useful constraints in practice anyway. The suggestion has been made, and refuted, many times in the C++ world, and alternative approaches to document and enforce constraints within template code have been developed instead.

    The only alternative that I see as Java's generics stand today is to define all your generic algorithms to work with any Object, and go back to downcasting, but then you might as well never have bothered with generics in the first place.

    Thus your two alternatives are either an interface-based system, which is type-safe but unnecessarily restrictive and less efficient, or to use generics only for type-safe containers and to write your generic algorithms in terms of Objects, which leaves open type safety loopholes.

    Ultimately, implementing generic algorithms will always suffer because one man's search method is another man's find. It is helpful to offer methods of standard names to make generalising code easier, but clearly you can't have a standard interface for everything in a general purpose library that may be put to any use. I advocate the use of operator overloading, because the sorts of calculations performed by built-in operators tend to be useful in a wide variety of contexts. Beyond that, if your generics only deal with the methods that are actually presented, whether or not they're explicitly identified by a formal interface, at least you keep the range of application as wide as possible. If you need to go farther still, you're into the land of intermediate classes (such as the iterators in C++'s standard library) to standardise an interface by force. In that case, you can always implement a named interface there, but of course there's an inherent performance hit in doing so, and you really want such intermediate classes to be so lightweight that you don't even realise they're there under normal use.

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  27. Yesssss, for mathematical types by upper · · Score: 2

    I'm a mathematician. I do arithemetic operations with types that aren't built in to the language. And they aren't all exotic -- things like vector addition. (no, not the misnamed java.util.Vector.) If x,y,z are n-dimensional vectors, how to you code w=x+y+z? I want the code to look the way it does for builtins:

    Vector w=x+y+z;

    Otherwise, the math gets _badly_ obfuscated and buried in minutia. I have yet to use a language that allowed it. (Yes, this is a pet peeve.)

    And I don't buy that it won't be clear what "+" means in each case. It means the addition operation that makes mathematical sense given the operands. If that isn't clear to you, you aren't going to get the code no matter how it's written.

    Example time. The addition code is written for binary (2 argument) addition, because you shouldn't have to write more than. Assume addition code also allocates the memory or invokes the constructor for the result, because it gets *really* ugly if it doesn't.

    C: You have to use a name instead of "+", and you have to manage the memory. I wrote a few thousand of lines of this stuff as a grad student.

    double *temp = vectoradd(x,y);
    double *w = vectoradd(temp,z);
    free(temp);

    C++: You can use "+", but you still have to manage the memory. [It's possible to do better if you overload "=" to do reference counting. But if you don't like overloading "+", you really won't like that.]

    Vector temp = x+y;
    Vector w = temp+z;
    ~temp();

    Java: You don't have to manage the memory, but you are back to using names:

    Vector w = x.add(y).add(z);

    If these examples don't seem very messy, see what (a*x*x+b*x+c)/(d*x*x+e*x+f) turns into if you change the variables from doubles to some object type -- say representing complex numbers. And remember that that's pretty simple as math expressions go.

    Here's what I propose: don't let the programmer overload "+" arbitrarily. But for classes which implement certain kinds of mathematical entities, have a set of methods they must implement with the types that make mathematical sense. E.g. if class foo claims to be a vector, it must implement

    public foo add(foo, foo)
    public foo scalarMultiply(double, foo)
    public foo scalarMultiply(foo, double)

    Then overload the standard arithmetic operators with these methods. It should be possible to make it work well for mathematical objects, but unpleasant for anyone who wants to tries to cheat the system.

    1. Re:Yesssss, for mathematical types by e-Motion · · Score: 1

      C++: You can use "+", but you still have to manage the memory. [It's possible to do better if you overload "=" to do reference counting. But if you don't like overloading "+", you really won't like that.]

      Vector temp = x+y;
      Vector w = temp+z;
      ~temp();


      Not only is that invalid C++ code, but you seem to be complaining about a non-existant problem. Your class should look something like this:

      #include <stddef.h>
      #include <assert.h>
      #include <algorithm>
      #include <iostream>
      class Vector {
      double * d_; size_t nElems_;
      public:
      typedef size_t size_type;
      Vector( size_type n ) : d_(new double[n]), nElems_(n)
      { std::fill_n( d_, n, 0.0 ); }
      Vector( const Vector& v ) : d_(new double[v.nElems_]), nElems_(v.nElems_)
      { std::copy( v.d_+0, v.d_+nElems_, d_ ); }
      double& operator[]( size_type i )
      { assert( i < nElems_ ); return d_[i]; }
      Vector& operator=( const Vector& v ) {
      if( v.nElems_ > nElems_ ) {
      double * tmp = new double[v.nElems_]; delete[] d_; d_ = tmp;
      }
      nElems_ = v.nElems_;
      std::copy( v.d_+0, v.d_+nElems_, d_ );
      return *this;
      }
      Vector& operator+=( const Vector& v ) {
      assert( v.nElems_ == nElems_ );
      for( size_type i = 0; i < nElems_; ++i ) d_[i] += v.d_[i];
      return *this;
      }
      size_type size() const { return nElems_; }
      ~Vector() { delete[] d_; }
      };
      Vector operator+( const Vector& lhs, const Vector& rhs )
      { Vector tmp(lhs); tmp += rhs; return tmp; }

      int main() {
      Vector a(10); Vector::size_type i;
      for ( i = 0; i < a.size(); ++i ) a[i] = i;
      Vector a2 = a + a;
      for ( i = 0; i < a2.size(); ++i ) {
      if ( a2[i] != a[i] + a[i] )
      std::cerr "a2 is not a + a" std::endl;
      } // Note: no cleanup necessary here
      }

  28. Java ignorants by Anonymous Coward · · Score: 0

    I wish all the /.ers would think and do a little research for saying the proverbial Java is slow and then shoot themselves in the foot by making a stupid statement.
    AKA -> Does java do regular expressions ? Java applets suck.

    Learn a bit about mvc before you comment and say php does everything. If you truely understood all the benefits of o/o programming you would appreciate the abilities to create a set of reusable individual components which could have many clients. Try that in PHP. Id like to see any C programming using a handful of lines be able to consume bytes from a socket and then by changing one line read from a file(java.io.*/java.net.*).
    One cant dispute the fact that java is elegant, useful and obviously a success hence its basically the model that sun copied with its .NET architecture. So many terms are interchangable with JAVA / J2EE concepts.

  29. The problem with null by Tom7 · · Score: 2

    The problem with null is that it's yet another unnecessary run-time check. Suppose having a value of class Integer meant that you really had an integer object (instead of including the possibility that it is null). Sometimes we want to return a value plus the possibility of an error condition, in which case null is useful, so we'd have some other type for "possibly null" objects.

    You might have something built in to the language like this, like writing "Integer?" as the class name (the language Popcorn does this), you might also just have a powerful enough language that it can be coded up easily (SML has this with its polymorphic 'option' type).

    With the old null, you might write this:

    Integer x = something();

    if (x != null) { ... code involving x ...

    } else { ...
    }

    Note that if you pass x to another function, that function probably needs to check to see if x is null, too. Similarly, the bytecode interpreter needs to check for null whenever you do a method invocation on x. Without null, you might write (I am just making up the syntax; you might want to see how Nice does it):

    Integer? x = something();

    switch (x) {
    null: ... break;
    Integer(y): ... same code involving y ...
    }

    The important thing here is that we've statically captured the fact that we've done a null check (y would have type 'Integer', not type 'Integer?'). Now, the byte code interpreter never needs to check y to see if it's null (efficiency gain), the programmer is never allowed to use a value unless he's checked that it's null (program robustness), the potential for a function to return null is reflected in its type (modularity), and the programmer has to insert fewer checks, because once it's an Integer, it is not necessary (and doesn't make sense!) to check for nullness (saves typing).

    In my own Java programming, and experience with using other folks' Java programs, the Null Pointer Exception is much more common than the Class Cast Exception. However, in my experience with Object Oriented Programmers, the love of "null" runs deep, so it might be a harder sell than generics!

  30. But you can't guess what other types it would help by Anonymous+Brave+Guy · · Score: 2
    Here's what I propose: don't let the programmer overload "+" arbitrarily. But for classes which implement certain kinds of mathematical entities, have a set of methods they must implement with the types that make mathematical sense. [...] It should be possible to make it work well for mathematical objects, but unpleasant for anyone who wants to tries to cheat the system.

    And how, exactly, do you propose to work out who is "cheating the system" and whose use is quite legitimate? Is the use of + to concatenate strings acceptable to you? What about other string-like classes? How about for adding date/time and time period classes?

    At the end of the day, you can never anticipate every use to which such a feature could usefully be put. You have two choices: try, and provide something that is sometimes useful but usually frustrating, or leave the choice to the informed developer, and let them do what they will with it. The fact that C++ is still here is testament to the fact that the second approach works. I can't think of a single language that tries to restrict the programmer this way that has lasted more than a short period.

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  31. Re:But you can't guess what other types it would h by upper · · Score: 2

    I've already included string concatenation with + -- the set of all finite strings from a given alphabet forms a semigroup under concatenation.

    But you're basically right. I don't know how many mathematical types -- or properties -- I would want to add. It would probably be a few dozen, and undoubtedly more in the second release.

    I don't want my languages telling me what to do any more than you do. But that's not where I'm going. I need both overloading and automated memory management, and I need them in a compiled general purpose OO language. But I only need overloading in a specific context where it really makes sense. I'd be quite happy with a design-by-contract setup which requires that the class fulfill (within roundoff error) the appropriate mathematical definition. E.g. to be a semigroup, you have to have the operator be associative. That is, (a+b)+c == a+(b+c).

    And that shouldn't trigger the (legitimate, IMO) complaints that overloading-heavy code is write-only.

  32. Re:But you can't guess what other types it would h by Anonymous+Brave+Guy · · Score: 2

    I think we're on the same wavelength, but just a couple of points are worth mentioning...

    Firstly, it's almost invariably not true that (a+b)+c == a+(b+c) from a numerical analysis point of view. The problems of limited precision render such mathematical niceties, well, niceties. While I appreciate that it would be nice to program in a higher level language where such mathematical contracts were used, none of those under discussion around here will ever qualify.

    As for overloading-heavy code being write-only, I couldn't disagree more. Code where operators are overloaded usefully (viz. typical mathematical types, string concatenation, etc.) is far more readable than the equivalent with longhand methods being used all over the place, particularly in a language such as Java that has no free functions. The only time such code becomes write-only is when the operators are overloaded in a misleading way (for example, having unexpected side-effects) and that's no different to the effect of choosing a bad name for any other function, or variable, or type.

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  33. OK, we're almost in agreement by upper · · Score: 2

    I am aware of roundoff error. That's why there's a parenthetical "within roundoff error" in my previous message. :)

    I don't have a much experience reading other people's code with overloaded operators. But I think overloading would help clarity if, and only if, the overloaded function is enough like the builtin version of the operator. At a minimum, the semantics need to be analogous and the presence or absense of side-effects needs to be the same. Overloading "=" to implement reference counting doesn't qualify in my book. (This is closer to what you just said than to what I initially proposed.)

    After all, in many languages the builtins are essentially overloaded -- int+int isn't the same thing as double+double.

  34. Ain't Java great? by Anonymous Coward · · Score: 0

    That is one of the good things on the Java coding guidelines. Names are verbose. There's no strcmp. There's String.compareTo.

    Exactly. To create a file, I say createNewFile(). To create a folder, I say mkdir(). Er, oops. I guess Sun let one of their old Unix hackers out of his cage while they were designing Java.

  35. Please explicate by Julian+Morrison · · Score: 2

    How precisely is java's new generics design flawed?

  36. Why is "plus " more readable than "+"? by Per+Abrahamsen · · Score: 2
    I really don't get that argument. Take this example:
    Foo a = get_a ();
    Foo b = get_b ();

    Foo c = a.plus (b); // readable, no lookup needed.
    Foo d = a + b; // unreadable, need to look up "+".
    Why is the assignmed to c inherently more readable than the assignment to d?

    1. Re:Why is "plus " more readable than "+"? by Khazunga · · Score: 2
      Why is the assignmed to c inherently more readable than the assignment to d?
      Example: Foo is a type where for c=0, the plus operation results in infinity (convoluted example, I know). How does plus() handle that case? Does it throw an Exception? Does it return a NaN? Does it return Infinity? Can you have all three choices available? How do you distinguish them?

      With +, you can't verbosely specify the behaviour and implement all three cases -- see my other post in the thread. With the method notation, you can have:

      • Foo.naturalPlus()
      • Foo.integerPlus()
      • Foo.bigNumberPlus()
      Note that I don't assume that method notation is the best for all cases. I'm stating that 95% of the uses of operator overloading, to use operator notation for user-defined types, fall into this kind of traps, and make code terribly difficult to read.
      --
      If at first you don't succeed, skydiving is not for you
  37. Re:Too little, too late - it's natural to leapfrog by jptxs · · Score: 1

    Look at processors. Sun leapfrogged HP, DEC and IBM with Sparc way back when. HP came back and did it to all of them; now IBM. In technology, there is always a feature/power/flexability leapfrog cycle where one vendor (including MS) pulls out ahead, and then later on another does the same. No news there...

    --
    we speak the way we breathe --Fugazi
  38. I stand corrected by upper · · Score: 2

    It looks like you're right and I was wrong.

    It's been a while, but I believe I was manipulating pointers to objects to avoid all copying. The application was computationally intensive, but it was probably silly of me anyway.
    My C++ experience isn't extensive, and the implementation wasn't exactly modern.