CompuServe Thread

#Pascal or C++ ?

8 messages in this thread
#43703From: Bert PutJan 9, 1993 2:23 AM
Hi David, I dunno if this is any help, but here goes: I'm proficient in both Pascal and C (not C++). I've written large programs in both lanuages and if I were to make a choice between the two, I'd choose C. I learnt Pascal first and have about 4 years of experience under my belt, including file handling, screen handling and small indexes (mainly in memory). Pascal is great for learning structured programming and really helps you to write good, clean, modular code. However, there are some deficiencies in it's file handling routines which can be overcome, but are fiddly. In particular, I needed a way to keep track of deleted records so I could reuse them. This required either a header at the beginning of the file or a seperate file containing the details that would otherwise go into that header (i.e. first/last deleted record nbr, active record count, etc) Again, it can be done, but is fiddly. Enter C. C opens up a whole new world in programming. It's harder to learn than Pascal, only because it works at what I call a "lower" level (i.e. closer to assembly). This is deliberate, in order to give the programmer more power and responsibility. The assumption when writing code in C is that the programmer knows what he is doing. To that end, you have access to such things as pointers and low-level functions, with all the dangers associated with them. [More]
#43704From: Bert PutJan 9, 1993 2:23 AM
[Continued] C will also perform conversions from one variable type to another when it can, at times when pascal would throw up its arms in horror. This has its pros and cons. Sometimes the conversion is OK and your results are as expected. Other times a conversion results in the program behaving completely differntly to your expectations, sometimes requiring lengthy sessions with a debugger to find out why. As long as you are aware of this latent power and are careful in how you harness it, you can literally do _anything_ with it. It's no accident that most of the leading software packages (and even operating systems) are written in C. In summary, C is _much_ more flexible and offers the programmer a lot of power. In return, the programmer must be more disciplined in his coding methods; no sloppy coding here! Pascal insists that you write strongly structured code and will be suitable for all your needs, as long as you don't want to do anything too fiddly (i.e. files containing records of different lengths, etc) I'm sure there are many people who'll poke holes in my comments; especially as there are many more issues here than those outlined in this message. I look forward to a lively discussion! Good Luck; I hope this helps. Cheers, Bert.
#43844From: Tom MoranJan 12, 1993 9:22 PM
I'd venture that in 20 years C will be used as much as assembly is today. Large programs (unfortunately the wave of the future) will be written in a more structured language that will probably be a Pascal descendant.
#43860From: Larry WidingJan 13, 1993 7:53 AM
Tom, I can safely say that the language of use in 20 years will look like nothing any of use can predict. Hopefully it will be a language that takes the best of the current languages, and drops the worst of those languages. Though I would say that C will probably be used significantly in 20 years, just look at Cobol and Fortran, which are still going strong. Larry
#43899From: Bert PutJan 14, 1993 3:57 AM
Tom, The news is that C is _already_ much more proliferant than assembly because it's much easier to understand, and you get to do less work for the same result. The compiler does all the dirty work for you and looks after such things as registers and segments. Some compilers do this much better than others… Things that take lots of time in assembly are a snap in C. As for large programs, the same applies. Pascal is great for structured programming but when you need to do "fiddly" things, C is definitely the language of choice. C allows easy integration of modules (whether written in C or another language) to produce a large application. You write each module which handles only specific tasks, then write more modules to connect them all together. Here's an example: GADGETS is my screen handler library. It uses several modules: GWINDOWS, GBOXES, GHELP… etc. Each of these modules performs specific tasks, all to do with drawing boxes on the screen, saving the data underneath and putting meaningful text inside the boxes. GADGETS connects them all together and, in doing so, provides a consistent user interface to the program underneath, including menus and data input boxes. Each of these modules are made up of seperate source files, which result in seperate .OBJ files, which are simply linked into your program. Access to the functions in each .OBJ file is via header files. What could be simpler than that? Cheers, Bert.
#43908From: Tom MoranJan 14, 1993 12:22 PM
I would slightly amend your statements: The news is that *any high level language* is _already_ … … is great for structured programming but when you need to do "fiddly" things, *assembly* is definitely the language of choice. C allows *the same kind as assembly of* integration of modules … Aesthetically, and functionally, I compare languages to architectural styles. C is early Gothic, fairly straightforward and works well for a limited type of structure. C++ is late Gothic with many flying buttresses trying to hold up more difficult structures. Pascal is Louis Sullivan, less ornamental, but uses steel for a dramatic increase in the complexity of what it can do. Ada is Bauhaus, similar to its predecessor, but more comfortable in using the newer techniques. (I've done C for 10 years and Ada for 5 and haven't found anything in C that isn't easier in Ada or Ada plus assembly. And many things that are simple in Ada that are a real pain in C.)
#44020From: Bert PutJan 16, 1993 8:24 PM
Hi Tom, Hmm, OK. I stand (sit!) corrected. I certainly agree that the more "fiddly" the project is, the more "low-level" your language has to be to cope with it. I'm sure you already know that the more "low-level" your language is, the more responsibility is bestowed on the programmer to clean up his act. In assembly, you have to deal with the management of the hardware itself; registers, memory, etc. The slightest slip-up and the best you can expect is an infinite loop, the worst is a system crash. With C, the compiler does more work for you and you get to be a little more abstract with your coding – but not so abstract that you lose sight of what the computer is doing "behind the scenes". With Pascal, the compiler does lots more work for you, and any low-level stuff is almost impossible without resorting to assembly in-line code, or linking other modules written in other languages. However, David's original message asked about the difference between Pascal and C++ – and being a Paradox programmer who does not expect to use the new ^O go amigaclmforum
#44041From: Tom MoranJan 17, 1993 12:10 AM
'simple in Ada … a pain in C … what kinds of things' Multitasking, object assignment (eg a:=b; where a and b are structures or arrays, not just ints or chars, with the compiler generating REP MOVs as appropriate), dynamic array sizes, multi (vs static/not static) level name space, the ability to specify the range of an integer to the compiler (vs modifying your code to keep up with the current compil^O ^C