Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

I think C++ is the future

27 views
Skip to first unread message

Sky89

unread,
Jun 5, 2018, 9:15:34 PM6/5/18
to
Hello,


I think C++ is the future, and i have learned Delphi and FreePascal that
uses modern Object Pascal, and i have coded in C++, and i think i am
understanding more C++, and i think that C++ is "easy" for me because
i am a more experienced computer programmer, and also i found it easy,
and since i am experienced with modern Object Pascal that is good on
readability, modern Object Pascal has learned me to write "clear" code
and less crypted code, so an important requirement is to write
clear code and less crypted code, this is why i am more apt to write
clear C++ code that easy maintenance and that enhance reliability,
also in the last days i have thought about those implicit type
conversions in C++ that were also inherited from C, and i have said to
myself that it is not good for reliability, but as i was learning more
C++ , i have discovered that you can control and disallow those implicit
type conversions as i have showed you in my previous post using operator
overloading etc. and i have also thought about bounds checking on
base arrays in C++, so C++ lacks bounds checking on base arrays,
and this is not good for reliability, so i have discovered that you
can solve this problem by using STL vectors that perform bounds checking
when the .at() member function is called, also
i have thought about integer overflow and underflow and conversion from
negative signed to unsigned , and i have showed
you that you can solve those problems with with C++ SafeInt here:

https://github.com/dcleblanc/SafeInt


So i have finally come to the conclusion that C++ is really powerful,
so i have said that i will continu to bring the best to C++..


And here is what i wrote on my previous posts about that, read them
carefully to understand me more:

I have thought more about C++, and I think C++ is really powerful
because STL vectors perform bounds checking when the .at() member
function is called, and for integer overflow or underflow and conversion
from negative signed to unsigned or more efficient strict-type safety,
here is how to do it with SafeInt here:

https://github.com/dcleblanc/SafeInt


I have just written the following program using SafeInt, please look at
it and try it to notice that C++ is powerful:

===

#include "SafeInt.hpp"
using namespace std;
#include <climits>
#include <iostream>
#include <sstream>
#include <stdexcept>

class my_exception : public std::runtime_error {
std::string msg;
public:
my_exception(const std::string &arg, const char *file, int line) :
std::runtime_error(arg) {
std::ostringstream o;
o << file << ":" << line << ": " << arg;
msg = o.str();
}
~my_exception() throw() {}
const char *what() const throw() {
return msg.c_str();
}
};

#define throw_line(arg) throw my_exception(arg, __FILE__, \
__LINE__);


class CMySafeIntException : public SafeIntException
{
public:
static void SafeIntOnOverflow()
{
cout << "Caught a SafeInt Overflow exception!" << endl;
throw_line("SafeInt exception");
}
static void SafeIntOnDivZero()
{
cout << "Caught a SafeInt Divide By Zero exception!" << endl;
throw_line("SafeInt exception");
}
};

void a1(SafeInt<unsigned __int8, CMySafeIntException> a)
{

cout << (int)a << endl;
}

int main()
{
try {

//throw std::invalid_argument("exception");

unsigned __int8 i1 = 250;
unsigned __int8 i2 = 150;
SafeInt<unsigned __int8, CMySafeIntException> si1(i1);
SafeInt<unsigned __int8, CMySafeIntException> si2(i2);
SafeInt<unsigned __int8, CMySafeIntException> siResult = si1 + si2;
cout << (int)siResult << endl;


a1(-1);

}
catch (const std::runtime_error &ex) {
std::cout << ex.what() << std::endl;
}
//catch (const std::invalid_argument &ex) {
// std::cout << ex.what() << std::endl;
// }


}


====



Also I have said before that C++ allows some "implicit" type conversions
and that is not good, but i have learned more C++ and now i
am understanding it more, and i think C++ is really powerful !
because you can "control" implicit conversins(that means disallowing
implicit conversions) by doing the following in C++, look carefully at
the following C++ code that you can extend:


===

include <iostream>
#include <stdexcept>

struct controlled_int {
// allow creation from int
controlled_int(int x) : value_(x) { };
controlled_int& operator=(int x) { value_ = x; return *this; };
// disallow assignment from bool; you might want to use
BOOST_STATIC_ASSERT instead
controlled_int& operator=(bool b) { std::cout << "Exception: Invalid
assignment of bool to controlled_int" << std::endl;
throw; return *this; };

// creation from bool shouldn't happen silently
explicit controlled_int(bool b) : value_(b) { };

// conversion to int is allowed
operator int() { return value_; };

// conversion to bool errors out; you might want to use
BOOST_STATIC_ASSERT instead

operator bool() { std::cout << "Invalid conversion of controlled_int
to bool" << std::endl;
// throw std::logic_error("Exception: Invalid conversion of
controlled_int //to bool");
};

private:
int value_;
};

int main()
{
controlled_int a(42);

// This errors out:
// bool b = a;
// This gives an error as well:
a = true;

std::cout << "Size of controlled_int: " << sizeof(a) << std::endl;
std::cout << "Size of int: " << sizeof(int) << std::endl;

return 0;
}


===



And as you have noticed i have invented my C++ synchronization objects
library for Windows and Linux here:

https://sites.google.com/site/scalable68/c-synchronization-objects-library

And i have invented my Scalable Parallel C++ Conjugate Gradient Linear
System Solver Library for Windows and Linux here:

https://sites.google.com/site/scalable68/scalable-parallel-c-conjugate-gradient-linear-system-solver-library

My next invention that is coming soon is the following:

I am finishing a C++ implementation of a "scalable" reference counting
with a "scalable" C++ implementation of shared_ptr and weak_ptr. Because
the implementations in Boost and C++ are "not" scalable. I will bring to
you my new scalable algorithms soon.


So stay tuned !


Thank you,
Amine Moulay Ramdane.



Rick C. Hodgin

unread,
Jun 6, 2018, 6:02:02 AM6/6/18
to
You would do yourself benefit to seek God and listen to His
advice, and change your ways:

https://www.biblegateway.com/passage/?search=Proverbs+18%3A13&version=KJV

Proverbs 17:13 -- He that answereth a matter before he
heareth it, it is folly and shame unto him.

You repeatedly post in haste, only to later correct yourself.
And:

https://www.biblegateway.com/passage/?search=James+1%3A19&version=KJV

James 1:19 -- Wherefore, my beloved brethren, let every man
be swift to hear, slow to speak, slow to wrath:

You post things before (1) knowing enough about the
subject matter, (2) with grammar errors indicating it's
an improperly considered reply that is too hasty, and (3) you do
not seek to learn from others but only espouse your current
thinking on things, which you've demonstrated repeatedly is
wrong at least as often as it's right. You also try and compare
other things to C++ which are not even in the same league.

You are harming yourself, Ramine. Repeatedly.

Slow down. Ask questions. Breathe. Pause. And above all
seek the truth. Don't respond in the moment. Give yourself
at least 10 minutes to consider your post BEFORE posting.

Don't let the enemy destroy your credibility by using you in
a manner that is against God's guidance. Seek God and let
Him move you from where you are to where you should be.
Let Him be your schoolmaster. You'll find Him amazing, Ramine.
All His ways lead to love manifesting, and people helping people.

That's only God the Father, Son, and Holy Spirit, Ramine.
None other. No great deceivers.

--
Rick C. Hodgin

Rick C. Hodgin

unread,
Jun 6, 2018, 6:24:19 AM6/6/18
to
Ramine, I have tried to reply to you privately in email, but
you post with an invalid email address.

Why?

--
Rick C. Hodgin
0 new messages