What is main difference between C and COBOL 
Author Message
 What is main difference between C and COBOL

I was asked one question about the difference between C and COBOL. As I
have little knowledge on COBOL, Could you out there please help me on
this problem?

Thanks in advance.



Sun, 29 Aug 1999 03:00:00 GMT  
 What is main difference between C and COBOL

Quote:
> I was asked one question about the difference between C and COBOL. As I
> have little knowledge on COBOL, Could you out there please help me on
> this problem?

I have passing knowledge of C, but don't know if I am qualified to
answer, but I will give an answer.
What is the difference between French and Spanish?  Each can say the
same thing, get the same point across, but each has different verbs and
different ways those verbs can be used, and where they can be placed in
the sentence.  As far as I know ANSI C and COBOL can do the same things,
although sometimes it may take a little more code in one language to do
one thing, but more in the other to do another thing.  Also, I think
COBOL makes you define your variables a little more rigidly (the PIC
clause) and I think that is why C can be viewed as more flexible.


Mon, 30 Aug 1999 03:00:00 GMT  
 What is main difference between C and COBOL



Quote:
>> I was asked one question about the difference between C and COBOL. As I
>> have little knowledge on COBOL, Could you out there please help me on
>> this problem?

>I have passing knowledge of C, but don't know if I am qualified to
>answer, but I will give an answer.
>What is the difference between French and Spanish?  Each can say the
>same thing, get the same point across, but each has different verbs and
>different ways those verbs can be used, and where they can be placed in
>the sentence.  As far as I know ANSI C and COBOL can do the same things,
>although sometimes it may take a little more code in one language to do
>one thing, but more in the other to do another thing.  Also, I think
>COBOL makes you define your variables a little more rigidly (the PIC
>clause) and I think that is why C can be viewed as more flexible.

  To add my view which has been limited to Cobol in industry but only
C in school, C can easily allow less structure.  As a general
statement you can "get away" with more in C which has it's ups and
downs.  C is more "powerful" but that can be a flaw in itself.

Cheers,
Kevin



Mon, 30 Aug 1999 03:00:00 GMT  
 What is main difference between C and COBOL

Quote:

> I was asked one question about the difference between C and COBOL. As I
> have little knowledge on COBOL, Could you out there please help me on
> this problem?

> Thanks in advance.

Well the main difference is that COBOL is easy to understand..

C++ is very difficult to learn especially the graphics side of things.

COBOL as a screen designer and it is easy to do error trapping on the screen
as you can define how long ints and the chars are so they don't go overlap
data on the screen.

C++ you have to build you own screen and you can't do error trapping on
the screen as when you declare an character to have an array of 10 chars
0 - 9 and you type more than 10 chars in..  The program will except it
and it will overlap exisiting data on the screen..

There are loads more differences but I prefer COBOL for database use
and menu use..  And file handling and report making...

But I have to use C++ at Uni



Mon, 30 Aug 1999 03:00:00 GMT  
 What is main difference between C and COBOL

Quote:

>> I was asked one question about the difference between C and COBOL. As I
>> have little knowledge on COBOL, Could you out there please help me on
>> this problem?
>I have passing knowledge of C, but don't know if I am qualified to
>answer, but I will give an answer.
>What is the difference between French and Spanish?  Each can say the

More like the difference between French and Chinese.  There are some
large differences in the 'mindset' of the languages.  COBOL trades
flexibility for stability over C.  It's also a higher-level language; ever
write a C program that did indexed file operations?  You can't just write a
SELECT & FD and start work.


Tue, 31 Aug 1999 03:00:00 GMT  
 What is main difference between C and COBOL


Quote:


>>> I was asked one question about the difference between C and COBOL. As I
>>> have little knowledge on COBOL, Could you out there please help me on
>>> this problem?

>>I have passing knowledge of C, but don't know if I am qualified to
>>answer, but I will give an answer.
>>What is the difference between French and Spanish?  Each can say the
>>same thing, get the same point across, but each has different verbs and
>>different ways those verbs can be used, and where they can be placed in
>>the sentence.  As far as I know ANSI C and COBOL can do the same things,
>>although sometimes it may take a little more code in one language to do
>>one thing, but more in the other to do another thing.  Also, I think
>>COBOL makes you define your variables a little more rigidly (the PIC
>>clause) and I think that is why C can be viewed as more flexible.

>  To add my view which has been limited to Cobol in industry but only
>C in school, C can easily allow less structure.  As a general
>statement you can "get away" with more in C which has it's ups and
>downs.  C is more "powerful" but that can be a flaw in itself.

>Cheers,
>Kevin

These are, in general, all correct.  Certainly both languages offer
all the standard sorts of decision and control flow constructs, and both
do input and output.  I'd say the major difference (syntax aside) is that C is
essentially a systems programming language and that COBOL is a business
programming language.  COBOL offers a richer set of numeric data types
that are oriented towards business processing and decimal math.  C offers
integer and floating point, *neither* of which is appropriate for business.
COBOL also has a much richer set of file capabilities (keyed access, etc.)
You can certainly write business apps in C, by adding decimal math and
keyed file libraries - however, as a developer with extensive C experience
I'd recommend COBOL instead.  

On the other hand, C is much more like a
high-level assembler, with all the power and all the opportunities to shoot
yourself in the foot!  You *can* write some pretty aggressive systems code
in COBOL, but C is easier...

As a developer, I love C, but I think COBOL is much better for writing
business applications.  



Tue, 31 Aug 1999 03:00:00 GMT  
 What is main difference between C and COBOL

LianHai Wu asked:

Quote:
>I was asked one question about the difference between C and COBOL.

As I

Quote:
>have little knowledge on COBOL, Could you out there please help me

on

Quote:
>this problem?

>Thanks in advance.

For each of the following points there is probably a dialect
of Cobol where it isn't true (my own experience is mostly with
IBM mainframe Cobol).  But in general:

1. In C it is commonplace to allocate chunks of memory
dynamically, stitch them together with pointers, and build
data structures of arbitrary complexity.  In Cobol this
technique is either impossible or, if possible, {*filter*} and
little-used.  One can still build data structures using
array subscripts in place of pointers, but it's awkward.

2. C allows recursion; i.e. a function can invoke itself,
directly or indirectly.  Not in Cobol, though with some
extra work you can simulate recursion if you need a recursive
algorithm.

3. In C you can determine a filename at runtime and open it
as needed.  In Cobol the file name (or DD name, etc.) is
specified at compile time.

4. C views a file as a series of bytes; Cobol views it as a
series of records.  If your records consists of fixed-length
fields in fixed positions, it's a breeze to read them in
Cobol -- all you need is a single READ statement and every
field is available by name.  In C it's a real pain -- one
way or another you have to do it byte by byte.  (Yes, I know
you can read or write an entire struct, but the Standard lets
the compiler stick padding bytes between the fields in a
non-portable manner.)

5. Cobol tends to be annoyingly verbose; C tends to be
annoyingly cryptic.

6. In my experience the two languages tend to attract
different kinds of people.  Cobol people tend to be less
interested in technical elegance.  Maybe this reflects the
difference between the mainframe culture, where Cobol is
King, and the MS-DOS/UNIX culture, with its historical ties
to C.

I don't want to start a holy war -- each language has its
merits.  Some things are better done in one and other things
in the other.  With a few exceptions either language can do
anything the other can do, but perhaps more awkwardly.




Wed, 01 Sep 1999 03:00:00 GMT  
 What is main difference between C and COBOL

John,

With MVS COBOL v1.2 on MVS and VisualAge COBOL v1.2 (OS/2, AIX NT...)
which are available since at least one year, I must correct the three
first points of your answer:

1) You CAN dynamically allocate memory with COBOL (Through LE services -
CEECRHP, CEEGTST - on MVS and through arrays with the OCCURS n DEPENDING
ON phrase which now permits to declare variable length arrays in
WORKING-STORAGE You can also use pointers (var USAGE IS POINTER and SET
pointer TO ADDRESS OF var) and SOM methods (somNew, somRenew, somFree)
to allocate memory for COBOL objects and PROCEDURE-POINTER...

2) Those COBOL are recursive (PROGRAM-ID. xxx IS RECURSIVE) and
introduce a LOCAL-STORAGE SECTION that allocate a new area in the heap
for local variables each time a program is called (necessary for
recursivity). They introduce also EXTERNAL (i.e. static)  and GLOBAL
variables.

3) You can dynamically open files in VA COBOL with the SELECT ... ASSIGN
USING <var>. You specify at run time the name of the file in <var>. This
is a unique feature of VA COBOL for OS/2. You can also use
SELECT..ASSIGN TO <ext-var> where ext-var is an OS/2 environement
variable that holds the name of the file and can be set just before
running the program...

COBOL is now a much more modern language with the COBOL 1997 standards
and the OO features.

Yours Friendly,
 Biloute.

Quote:

> LianHai Wu asked:

> >I was asked one question about the difference between C and COBOL.

> As I
> >have little knowledge on COBOL, Could you out there please help me

> on
> >this problem?

> >Thanks in advance.

> For each of the following points there is probably a dialect
> of Cobol where it isn't true (my own experience is mostly with
> IBM mainframe Cobol).  But in general:

> 1. In C it is commonplace to allocate chunks of memory
> dynamically, stitch them together with pointers, and build
> data structures of arbitrary complexity.  In Cobol this
> technique is either impossible or, if possible, {*filter*} and
> little-used.  One can still build data structures using
> array subscripts in place of pointers, but it's awkward.

> 2. C allows recursion; i.e. a function can invoke itself,
> directly or indirectly.  Not in Cobol, though with some
> extra work you can simulate recursion if you need a recursive
> algorithm.

> 3. In C you can determine a filename at runtime and open it
> as needed.  In Cobol the file name (or DD name, etc.) is
> specified at compile time.

> 4. C views a file as a series of bytes; Cobol views it as a
> series of records.  If your records consists of fixed-length
> fields in fixed positions, it's a breeze to read them in
> Cobol -- all you need is a single READ statement and every
> field is available by name.  In C it's a real pain -- one
> way or another you have to do it byte by byte.  (Yes, I know
> you can read or write an entire struct, but the Standard lets
> the compiler stick padding bytes between the fields in a
> non-portable manner.)

> 5. Cobol tends to be annoyingly verbose; C tends to be
> annoyingly cryptic.

> 6. In my experience the two languages tend to attract
> different kinds of people.  Cobol people tend to be less
> interested in technical elegance.  Maybe this reflects the
> difference between the mainframe culture, where Cobol is
> King, and the MS-DOS/UNIX culture, with its historical ties
> to C.

> I don't want to start a holy war -- each language has its
> merits.  Some things are better done in one and other things
> in the other.  With a few exceptions either language can do
> anything the other can do, but perhaps more awkwardly.





Wed, 01 Sep 1999 03:00:00 GMT  
 What is main difference between C and COBOL

Quote:

> LianHai Wu asked:

> >I was asked one question about the difference between C and COBOL.

> As I
> >have little knowledge on COBOL, Could you out there please help me

> on
> >this problem?

> >Thanks in advance.

> For each of the following points there is probably a dialect
> of Cobol where it isn't true (my own experience is mostly with
> IBM mainframe Cobol).  But in general:

> 1. In C it is commonplace to allocate chunks of memory
> dynamically, stitch them together with pointers, and build
> data structures of arbitrary complexity.  In Cobol this
> technique is either impossible or, if possible, {*filter*} and
> little-used.  One can still build data structures using
> array subscripts in place of pointers, but it's awkward.

> 2. C allows recursion; i.e. a function can invoke itself,
> directly or indirectly.  Not in Cobol, though with some
> extra work you can simulate recursion if you need a recursive
> algorithm.

> 3. In C you can determine a filename at runtime and open it
> as needed.  In Cobol the file name (or DD name, etc.) is
> specified at compile time.

> 4. C views a file as a series of bytes; Cobol views it as a
> series of records.  If your records consists of fixed-length
> fields in fixed positions, it's a breeze to read them in
> Cobol -- all you need is a single READ statement and every
> field is available by name.  In C it's a real pain -- one
> way or another you have to do it byte by byte.  (Yes, I know
> you can read or write an entire struct, but the Standard lets
> the compiler stick padding bytes between the fields in a
> non-portable manner.)

> 5. Cobol tends to be annoyingly verbose; C tends to be
> annoyingly cryptic.

> 6. In my experience the two languages tend to attract
> different kinds of people.  Cobol people tend to be less
> interested in technical elegance.  Maybe this reflects the
> difference between the mainframe culture, where Cobol is
> King, and the MS-DOS/UNIX culture, with its historical ties
> to C.

> I don't want to start a holy war -- each language has its
> merits.  Some things are better done in one and other things
> in the other.  With a few exceptions either language can do
> anything the other can do, but perhaps more awkwardly.



An objective opinion on this subject ! Wonderful !
Thanks Scott.

I would add that, because of the differences, COBOL tends to be good at
business oriented problems (banking, insurance, etc) , which also tend
to be record-oriented. COBOL has added features of late that move away
from this paridigm, such as pointer-like abilities (not to the extent of
C), and reference modification, but that doesn't change things much
overall. C tends to be good at technically-oriented problems (CAD/CAM,
desktop apps, embedded systems), where you must drop down to lower
levels of abstraction. IMO, the reason for the  cultural differences I
think, is that C programmers like that lower level of abstraction, and
COBOL programmers tend to like the business-level of abstraction more.

IMO, C/C++ does have alot of weaknesses (see
http://www.*-*-*.com/ ~geldridg/cpp/cppcv3/ ) but it's still out
there and we have to deal with it. I like to encourage people to look at
and consider other options, but unfortunately one of the important
aspects of language selection is the ability to find expertise, so
languages tend to be self-perpetuating.

Dave Sailer
Camp Hill, pa



Thu, 02 Sep 1999 03:00:00 GMT  
 What is main difference between C and COBOL


Quote:

> 1. In C it is commonplace to allocate chunks of memory
> dynamically, stitch them together with pointers, and build
> data structures of arbitrary complexity.  In Cobol this

This is the area where many problems occur in C programs. It
is amazingly frquent that memory leaks occur when it is not
deallocated correctly, or 'wild' pointers occur because the
pointer continues to be reused after the memory is deallocated.

Pointers are an area best avoided by inexperienced programmers,
and by those who want to have reliable programs.  If they are
to be used then an add-on memory tracker is vital during testing
so the problem areas can be found - they can be very subtle.

Quote:
> technique is either impossible or, if possible, {*filter*} and
> little-used.  One can still build data structures using
> array subscripts in place of pointers, but it's awkward.

In many cases the data structures being built are best held in
a structured file anyway as the data may be shared.  Programming
courses tend to focus on single programs but in real usage
several program may be using the data at the same time which is
impossible in dynamic tables within one program.

Quote:

> 2. C allows recursion; i.e. a function can invoke itself,
> directly or indirectly.  Not in Cobol, though with some
> extra work you can simulate recursion if you need a recursive
> algorithm.

There are no recursive algorithms which don't have an iterative
equivalent.  usually the iteritive one is safer and faster,
though they take slightly more work storing and retrieving
the 'stack'.

Quote:

> 3. In C you can determine a filename at runtime and open it
> as needed.  In Cobol the file name (or DD name, etc.) is
> specified at compile time.

I have been specifying filenames dynamically at run time in Cobol
for nearly 20 years with MF Cobol.  Most other Cobols on DOS and
Unix can also do this too.

Quote:

> 4. C views a file as a series of bytes; Cobol views it as a
> series of records.  If your records consists of fixed-length
> fields in fixed positions, it's a breeze to read them in
> Cobol -- all you need is a single READ statement and every
> field is available by name.  In C it's a real pain -- one
> way or another you have to do it byte by byte.  (Yes, I know
> you can read or write an entire struct, but the Standard lets
> the compiler stick padding bytes between the fields in a
> non-portable manner.)

> 5. Cobol tends to be annoyingly verbose; C tends to be
> annoyingly cryptic.

The crypticness of C is generally countered quite easily by
adding appropriate comments - which then make the program as
bulky as Cobol.  I find that comments generally detract from
understanding a program because there is no assurance that
they are true.  In general one would tend to believe the
comment rather than understand the code.  I tend to write
verbose C with long variable names (no longer limited to 6
characters) and avoiding all the short cuts.

Quote:

> 6. In my experience the two languages tend to attract
> different kinds of people.  Cobol people tend to be less
> interested in technical elegance.  Maybe this reflects the
> difference between the mainframe culture, where Cobol is
> King, and the MS-DOS/UNIX culture, with its historical ties
> to C.

I have been working exclusively on DOS/Windows/Unix for nearly
20 years primarily in Cobol.  There is no 'mainframe culture'
here.


Thu, 02 Sep 1999 03:00:00 GMT  
 What is main difference between C and COBOL


Quote:

> 3) You can dynamically open files in VA COBOL with the SELECT ... ASSIGN
> USING <var>. You specify at run time the name of the file in <var>. This
> is a unique feature of VA COBOL for OS/2. You can also use

In what way is this a 'unique feature' of VA COBOL ?  I have been
using this in MF Cobol for nearly 20 years and MS Cobol has had
a similar feature: VALUE OF FILE-ID IS <var> since version 1.

I am sure that RM and Accu do much the same.

Quote:
> SELECT..ASSIGN TO <ext-var> where ext-var is an OS/2 environement
> variable that holds the name of the file and can be set just before
> running the program...

This also has been in MF for many years.


Thu, 02 Sep 1999 03:00:00 GMT  
 
 [ 37 post ]  Go to page: [1] [2] [3]

 Relevant Pages 

1. I am looking for a VI that login and logout users to a main VI.

2. LE 1.8 wierd COBOL abend dump-longish ( x-posted to IBM-MAIN and COBOL )

3. Differences between VS COBOL II and COBOL for MVS and VM

4. Differences between Cobol and Cobol II (Mainframe)

5. Difference between Cobol and AS/400 Cobol

6. VS COBOL and COBOL/370 differences?

7. Differences in Cobol 1 and Cobol 2

8. Difference between COBOL II and COBOL/370

9. What difference(s) am I missing? (Tcl_Eval) (Tcl_EvalFile)

10. to CS: or not to CS: in F-PC assembler

11. COBOL/VSAM/Contract/CS/Tx

12. Help a Non Cobol CS Instructor with CASE...

 

 
Powered by phpBB® Forum Software