GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 11-Jul-2013, 15:15
steamerandy steamerandy is offline
New Member
 
Join Date: Aug 2012
Posts: 27
steamerandy will become famous soon enough

Whats wrong with C++


Number 1. it's cryptic. It's not self documenting and usually needing comments to explain it's function.

The choice to have inconsistence argument passing. This is not really apparent to most. It really showed up an a program that works with several physical properties of a substance. I wrote a generalized unit selection dialog that takes a unit type, index, pressure, temperature, specific enthalpy, specific volume, etc. It indexes into arrays of pointers. That index is used to generate a dialog for selecting units. It is used to index the unit type array. An array of strings "temperature","Pressure",... And another array of pointers to the units_name array. an array of pointers to the unit descriptor string array. I.E.

Note the Density_units are really specific volume. They are reciprocal of each other. In my program externally specific volume is used while internally density is required.

typedef const char* const unit_name;

unit_name Density_units[5]= { "rD", "in^3/lb" , "ft^3/lb", "gal/lb" , "m^3/kg"};


unit_name HeatCap_Units[4] = {"././K", "BTU/lb/R", "kJ/kg/K"};

...

typedef const unit_name* unitary[];

static unitary unitptr = {Pressure_units, Temperature_units, Density_units, Energy_units, Energy_units, Entropy_units, HeatCap_Units, HeatCap_Units, Speed_Units};

It took 3 days to get this to work. I could of done it in assembly as fast as I could of typed it in. Try doing that with out the typedef to make const allowed.

With out declaring them const I had this working without a typedef. Const tells the compiler they are unchanging and can be loaded instead of generating code to initialize them at startup. They can reside in in protected memory as well.

Another thing is the ^ operator. I don't know about others but I use exponentials a lot more then xor. The ^ is the exponential operator in most languages. Poor choice as far as I am concerned. Another name used for xor is half add. Sense it is the result you get adding binary ignoring carries. HADD was the opcode for xor on the H200 computer.

That's my main rants. Any others? How about incompatibility between different c++ compilers. Like Borland passes the this pointer on the stack and Microsoft passes it in a register. Any one else ran into that problem.

Ran into that problem using Borland to write plug-ins for a product that was created with Microsoft VC++

Andy
  #2  
Old 14-Jul-2013, 00:02
Mexican Bob's Avatar
Mexican Bob Mexican Bob is offline
Regular Member
 
Join Date: Mar 2008
Location: Chicxulub, Yucatán
Posts: 686
Mexican Bob is a jewel in the roughMexican Bob is a jewel in the roughMexican Bob is a jewel in the roughMexican Bob is a jewel in the rough

Re: Whats wrong with C++


Quote:
Originally Posted by steamerandy
I could of done it in assembly as fast as I could of typed it in.

Sense it is the result you get adding binary ignoring carries.

That's my main rants.

Andy

How about rants for those who know nothing about the English language instead of dissing C++?

Could have (not could of)

Since (not sense)

That is my main rant or those are my main rants. Subject/verb plurality agreement.


MxB
  #3  
Old 14-Jul-2013, 16:55
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,435
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all

Re: Whats wrong with C++


Quote:
Originally Posted by steamerandy
Number 1. it's cryptic. It's not self documenting and usually needing comments to explain it's function.
So learn COBOL.
Russian and Swahili are also cryptic. That's why you have to learn them. Just like any programming language.

Name 1 language worthwhile that is self-documenting.

Quote:
Originally Posted by steamerandy
The choice to have inconsistence argument passing. This is not really apparent to most.
That's why most people prefer to write their code with consistent argument passing. Inconsistent gets difficult very quickly.

Quote:
Originally Posted by steamerandy
It took 3 days to get this to work. I could of done it in assembly as fast as I could of typed it in. Try doing that with out the typedef to make const allowed.
Then you need to think about and design your program before you start writing your code so you know the paths you need to follow. If you don't know C++ well enough (proven by you opening statement) you should not be designing the code as you type it in.

Quote:
Originally Posted by steamerandy
Another thing is the ^ operator. I don't know about others but I use exponentials a lot more then xor. The ^ is the exponential operator in most languages.
Wanna bet? You cannot make that statement without actually knowing most of the hundreds of languages. In fact, I only know of 1 language that uses ^ as the exponential operator. But I'm not going to be arrogant enough to claim it's the only one.

Quote:
Originally Posted by steamerandy
That's my main rants. Any others? How about incompatibility between different c++ compilers. Like Borland passes the this pointer on the stack and Microsoft passes it in a register. Any one else ran into that problem.
Really? Why does that surprise you?
Does a Ford engine seamlessly drop into a Chevrolet chassis?
Does a Waring Blender carafe fit on an Oster base?
Does an HP printer power cord fit in a Cannon?

Life is not that easy...
And, MxB Missed the above quote. It should be "Has any one else run into that problem?"
__________________

Definition: Politics
Latin, from
poly meaning many and
tics meaning blood sucking parasites
-- Tom Smothers
  #4  
Old 16-Jul-2013, 04:42
steamerandy steamerandy is offline
New Member
 
Join Date: Aug 2012
Posts: 27
steamerandy will become famous soon enough

Re: Whats wrong with C++


Originally Posted by WaltP

"So learn COBOL."

I already know COBOL. Wrote a COBOL compiler in 1972. The Ramada Inns front office reservation software was written in COBOL using that compiler.

That COBOL was written with a Mata Compiler Compiler I write. The Compilers ran on a DEC-System-10 producing binary code for a TI-990 mini computer. The unique feature of my meta compiler was a target computers instructions set could be defined by it. The machine description language provided for describing assembly like opcodes and generating the fields of the operation into a bit stream output. The linker for the compiler compiler handled the relocatable output bit stream formats creating a load module compatible with the target machine. The linker acted as the second pass of the compiler handling forward references in the generated code. Actually a LISP like fixup expression was generated by the compiler compiler. Complex address expressions were handled with ease. Another level of abstraction to separate the compiler tree crawling and parsing logic from the sequential coding process was the pseudo language, allowing the defining of higher operations function that called the machine operations to generate the binary. The language being compiled was sequentiallized intio pseudo code designed as a match for the language being compiled. To generate code for a different processor simple define the instruction set and data pseudo ops in the machine description language using the processors hand book. Rewithe the pseudo operations to use the new instruction set and you are generating code for a new processor. Try writing a COBOL compiler with LEX & YACC. COBOL has context sensitive syntax.

I have written programs in EasyCoder assembly for Honeywell H200 computers. Autocoder for IBM 1400 series computers. IBM 360 assembly. MACRO the DEC-10 assembler, PDP-11 assembly PDP-8 assembly, 6502 assembly. Intel 80x86 assembly, 68000 assembly, 8080 assembly, Z80 assembly. Z8000 assembly, LGP-30 assembly, Recomp II assembly, PASCAL, ALGOL, SNOBAL, COBOL, BLISS-10, AID or JOSS, ADA. Wrote PASCAL and ADA compilers at KONTRON FutureData.

Originally Posted by WaltP

"Russian and Swahili are also cryptic. That's why you have to learn them. Just like any programming language."

Stoha eta COBOL? Stoha eta WaltP? Stoha eta sneg" Stoha eta garagekie?

I know a bit more Russian but cant post it here. "Stoha eta" means what is

"sneg" is snow. "garagekie" You know! What you open your garage with!! Yuk Yuk a joke!!


Originally Posted by WaltP
" Name 1 language worthwhile that is self-documenting."

COBOL was usually quite readable with out comments. But that depended on the use of descriptive variable names. Actually I find it easier to follow hand written assembly code than a lot of C and C++ code I have ran into.


Originally Posted by steamerandy

"The choice to have inconsistence argument passing. This is not really apparent to most."

Originally Posted by WaltP
"That's why most people prefer to write their code with consistent argument passing. Inconsistent gets difficult very quickly."

Do you know what const does?

I am talking about C and C++ passing by default, for example, strings by address and integers by value. That is what created the problem I illustrated having to use typedefs to get a constant data structure of an array of pointers to arrays of pointers to strings. Other corresponding arrays hold the unit conversion factors. It wasn't something that I had to do. It worked fine with out making them const. But I tried many ways to just use the const declaration directly and every way I tried got errors or non working code. Putting the const declarations in the typedef made it work and it generated the correct code. I checked the generated machine code. The const declarations were loaded with the code. Not generated by startup code when the program loaded.

Sorry. I thought what I explained was obvious. Having been programming for over 39 years now. And a big part of that 39 years, writing commercial compilers and operating systems. I sometime forget I need to dummy it down to for my audience.


Originally Posted by WaltP
"Then you need to think about and design your program before you start writing your code so you know the paths you need to follow. If you don't know C++ well enough (proven by you opening statement) you should not be designing the code as you type it in."

As you did not obviously understand. Again! Do you know what const does?

That peace of code is just a vary vary small part of a 6384 line program. Not including my 6 include files line count. It is part of a steam properties plug-in for VisSim. There are 7 source files in the project. It implements the IAPWS-95 scientific formulation for general and scientific use. I also use the SAT-92 saturation line formulations and the IAPWS IFC-97 formulation for industrial use. The IAPWS-95 formulations take temperature and density as arguments. So when given temperature and pressure I have to solve for the density that results in the given pressure. A programed search algorithm. It a lot more difficult given pressure and enthalpy. The temperature and density must be solver for that yield the given pressure and enthalpy. And to make maters more difficult there is the saturated mixture region where boiling occurs and you have a mixture and liquid and vapor at the same pressure and temperature and the other properties vary with mixture quintiles. I.E. 90% vapor and 10% liquid. And temperature and density values in the mixture region can cause computation exceptions. So if the point searched for is in the saturated mixture region the region boundary points at the vapor and liquid states must be used with the quality to determine the point.

My includes are the interface to the various steam formulations contained in separate files. Then there is the VisSim block implementation file vissimplugin.cpp that implements some 36 vissim blocks. It contains some 1523 lines of code. Of that const illustration I posted there is is some 50 lines of code.

When I left the Ramada reservation group I went to work for CompuGraphic. My first task there was to convert their hyphenation algorithm that was coded in some preparatory 8-bit micro assembly code into PDP-11 code. We were developing a new product "Work Station for News Paper add layout". They estimated it would take 3 months to do the conversion. It was done in 3 days. You see, what they didn't realize is that, one does not have to understand a program to convert it from one language to another. I already knew PDP-11 code, After an hour or so of looking up opcodes for the 8 bit micro the conversion sailed along. It really took less then a day of time. I was out a lot getting settled in. Utilities turned on and the like.


Originally Posted by steamerandy

"Another thing is the ^ operator. I don't know about others but I use exponentials a lot more then xor. The ^ is the exponential operator in most languages."

Originally Posted by WaltP
"Wanna bet? You cannot make that statement without actually knowing most of the hundreds of languages. In fact, I only know of 1 language that uses ^ as the exponential operator. But I'm not going to be arrogant enough to claim it's the only one."


As far as the ^ rant. I have been working with math system for a while. Mathcad uses the ^. JOSS and AID do use the "^" ALGOL uses the "^" BASIC uses the ^ operator. "^" is the power operator in JAVA. Also MATLAB uses "^" as the power operator. I have been working with 56 term equations for steam properties. And the program readability suffers when it takes 6 characters for a power operation instead of one. I am 66 years old and it's a bit taxing to see the computer screen and remember whats off the screen. So having a huge equation that wont fit in the viewable area of my screen is a bummer.


Quote:


Originally Posted by steamerandy

"That's my main rants. Any others? How about incompatibility between different c++ compilers. Like Borland passes the this pointer on the stack and Microsoft passes it in a register. Any one else ran into that problem."

Originally Posted by WaltP
"Really? Why does that surprise you?
Does a Ford engine seamlessly drop into a Chevrolet chassis?
Does a Waring Blender carafe fit on an Oster base?
Does an HP printer power cord fit in a Cannon?"

"Really? Why does that surprise you?"
Because it is a C++ standard that the "this" pointer is the last "argument" passed. And is to be passed in the same way other arguments are passed by default. It is part of the C++ standard. Passing it in a register is a Microsoft "enhancement" It is more efficient but is nonstandard.

This was a problem with Adobe PageMaker. A coworker preferred using Borland builder. But was having a problem calling some interface functions with his plugin. I traced through the code and found the problem. Not really a hard problem to fix. Wrote an assembly finger that poped the stack to the this pointer register exchanged the this register and the top of the stack and jumped to the original entry point. I was worried about the class layouts not matching up. But all seamed to work OK.

"Does a Ford engine seamlessly drop into a Chevrolet chassis?"
They do not necessarily fit a different ford chassis. But it can be done. But does a Ford engine seamlessly drop back into the chassis it came out of? No not always.

"Does a Waring Blender carafe fit on an Oster base?"

I really do not know. I am not a blenders salesperson or reprehensive. There are many different Waring and Oster blenders. I do know that in a lot of cases when you purchase and Oster carafe they do not include the blade assembly. The Oster carafe can be used with different blade assemblies. There are at least two Oster drive types. A rubber - rubber and a metal - metal square shaft. The high end Oster blenders use the square shaft. The Oster will work with both. So maybe a Waring carafe will work with an Oster base.

"Does an HP printer power cord fit in a Cannon?"
The old ones did. They used a standard pluggable power cord. A PS3 power cord would work on the old printers.

Andy
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
NOT sure what is wrong with script fscanf jenmaz C Programming Language 14 29-Oct-2004 14:53
Can someone tell what i'm doing wrong? sosy2001 C Programming Language 1 14-Oct-2004 22:27
Dropped By Google...What am I doing wrong? ademaskoo Search Engine Optimization Forum 6 30-Jul-2004 23:08
When server migrations go wrong... Div Web Hosting Forum 7 12-Jul-2004 17:34
something wrong with this code loon MySQL / PHP Forum 5 07-Jul-2003 05:55

Network Sites: GIDNetwork · GIDApp · GIDBlog · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 18:36.


vBulletin, Copyright © 2000 - 2017, Jelsoft Enterprises Ltd.