Link Details

Link 1020177 thumbnail
User 225256 avatar

By mswatcher
Published: Aug 26 2013 / 09:37

I am a longtime user of C++, and I have been an author and speaker in the C++ community for many years. Yet, the number-crunching backend of GreaterThanZero is written in Java and not in C++. Does that mean I have joined the ranks of those who have turned their backs on C++? No it does not, and I can prove it: search for “C++ auto and decltype”, and you’ll find that the top result is an article that I wrote only a few weeks ago. The decision to implement the math backend of GreaterThanZero in Java was driven by other considerations, primarily the appeal of Google App Engine as a hosting platform.
  • 6
  • 0
  • 927
  • 735
User 199813 avatar

agnus replied ago:

0 votes Vote down Vote up Reply

I write code mostly in Java, JavaScript, Objective-C and C++. One of the biggest struggles with C++ (as opposed to Objective-C) is the widespread use of value semantics. Most languages ​​support value semantics only for primitive values ​​and reference semantics for complex objects. Having a single way to follow contributes to language simplicity. Whenever I have to design a new class in C++ I reach a dilemma when a field is a complex object. Following the practice of any other language, then the field must be declared as a pointer, but in C++ the common practice dictates fields to be declared as values. However, this seemingly complexity turns to also be one of C++ greatest advantages. The value semantics offer a *guarantee* regarding the life cycle of a variable. Thus, we see generalized use of this guarantee as memory management tool. String and Vector manage arrays of pointers. Now in C++11 we have the generalization of this with shared_ptr as manager of arbitrary pointers. This programing idiom is called RAII and when you write in C++ is the one you really need to master.

Add your comment

Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.

Upvoters (6)

Downvoters (0)

    Apache Hadoop
    Written by: Piotr Krewski
    Featured Refcardz: Top Refcardz:
    1. Play
    2. Akka
    3. Design Patterns
    4. OO JS
    5. Cont. Delivery
    1. Play
    2. Java Performance
    3. Akka
    4. REST
    5. Java