Why pascal is not




















Most implementations of Pascal provide an escape hatch to allow access to files by name from the outside environment, but not conveniently and not standardly. For example, many systems permit a filename argument in calls to ' reset ' and ' rewrite ': reset fv, filename ; But ' reset ' and ' rewrite ' are procedures, not functions - there is no status return and no way to regain control if for some reason the attempted access fails.

UCSD provides a compile-time flag that disables the normal abort. This straitjacket makes it essentially impossible to write programs that recover from mis-spelled file names, etc. I never solved it adequately in the 'Tools' revision. There is no notion of access to command-line arguments, again probably reflecting Pascal's batch-processing origins.

Local routines may allow it by adding non-standard procedures to the environment. Since it is not possible to write a general-purpose storage allocator in Pascal there being no way to talk about the types that such a function would return , the language has a built-in procedure called ' new ' that allocates space from a heap.

Only defined types may be allocated, so it is not possible to allocate, for example, arrays of arbitrary size to hold character strings.

The pointers returned by ' new ' may be passed around but not manipulated: there is no pointer arithmetic. There is no way to regain control if storage runs out.

The new standard offers no change in any of these areas. Cosmetic Issues Most of these issues are irksome to an experienced programmer, and some are probably a nuisance even to beginners. All can be lived with. As a result one must have a reasonably sophisticated notion of what a statement is to put semicolons in properly. Perhaps more important, if one is serious about using them in the proper places, a fair amount of nuisance editing is needed.

Consider the first cut at a program: if a then b; c; But if something must be inserted before b, it no longer needs a semicolon, because it now precedes an ' end ': if a then begin b0; b end; c; Now if we add an ' else ', we must remove the semicolon on the ' end ': if a then begin b0; b end else d; c; And so on and so on, with semicolons rippling up and down the program as it evolves.

One generally accepted experimental result in programmer psychology is that semicolon as separator is about ten times more prone to error than semicolon as terminator. Fortunately, in Pascal one can almost always close one's eyes and get away with a semicolon as a terminator. The exceptions are in places like declarations, where the separator vs. A function name by itself is a call of that function; there is no way to distinguish such a function call from a simple variable except by knowing the names of the functions.

There is a paucity of operators probably related to the paucity of precedence levels. The set types help a bit here so to speak , but not enough; people who claim that Pascal is a system programming language have generally overlooked this point. For example, [ 18 , p. There is no null string, perhaps because Pascal uses the doubled quote notation to indicate a quote embedded in a string: 'This is a '' character' There is no way to put non-graphic symbols into strings.

In fact, non-graphic characters are unpersons in a stronger sense, since they are not mentioned in any part of the standard language. Concepts like newlines, tabs, and so on are handled on each system in an 'ad hoc' manner, usually by knowing something about the character set e.

There is no macro processor. The ' const ' mechanism for defining manifest constants takes care of about 95 percent of the uses of simple define statements in C, but more involved ones are hopeless. It is certainly possible to put a macro preprocessor on a Pascal compiler. This allowed me to simulate a sensible ' error ' procedure as define error s begin writeln s ; halt end ' halt ' in turn might be defined as a branch to the end of the outermost block.

Then calls like error 'little string' ; error 'much bigger string' ; work since ' writeln ' as part of the standard Pascal environment can handle strings of any size. It is unfortunate that there is no way to make this convenience available to routines in general. Perspective The effort to rewrite the programs in 'Software Tools' started in March, , and, in fits and starts, lasted until January, The final product 19 was published in June, During that time I gradually adapted to most of the superficial problems with Pascal cosmetics, the inadequacies of control flow , and developed imperfect solutions to the significant ones array sizes, run-time environment.

The programs in the book are meant to be complete, well-engineered programs that do non-trivial tasks. But they do not have to be efficient, nor are their interactions with the operating system very complicated, so I was able to get by with some pretty kludgy solutions, ones that simply wouldn't work for real programs. There is no significant way in which I found Pascal superior to C, but there are several places where it is a clear improvement over Ratfor.

Most obvious by far is recursion: several programs are much cleaner when written recursively, notably the pattern-search, quicksort, and expression evaluation. Enumeration data types are a good idea. They simultaneously delimit the range of legal values and document them. Records help to group related variables.

I found relatively little use for pointers. Boolean variables are nicer than integers for Boolean conditions; the original Ratfor programs contained some unnatural constructions because Fortran's logical variables are badly designed. Occasionally Pascal's type checking would warn of a slip of the hand in writing a program; the run-time checking of values also indicated errors from time to time, particularly subscript range violations.

Turning to the negative side, recompiling a large program from scratch to change a single line of source is extremely tiresome; separate compilation, with or without type checking, is mandatory for large programs.

I derived little benefit from the fact that characters are part of Pascal and not part of Fortran, because the Pascal treatment of strings and non-graphics is so inadequate.

In both languages, it is appallingly clumsy to initialize literal strings for tables of keywords, error messages, and the like.

The finished programs are in general about the same number of source lines as their Ratfor equivalents. At first this surprised me, since my preconception was that Pascal is a wordier and less expressive language. The real reason seems to be that Pascal permits arbitrary expressions in places like loop limits and subscripts where Fortran that is, portable Fortran 66 does not, so some useless assignments can be eliminated; furthermore, the Ratfor programs declare functions while Pascal ones do not.

The article is often used in language comparison discussions even today, typically by critics of Pascal-family. Despite of the fact that the article is talking about the language that is there no more. The description of the language that B Kernighan is referring to in the article could be found here. The purpose of this page, is to show that the article is quite out-dated.

Without quoting of the article - the complain is about an arrays of different size though still the same type are considered a different type. Since Pascal is strict type routines cannot be shared among array of different size. The task of sorting is used as an example in the article. Typecasting in Pascal is a matter of dialect. There are probably more but I cannot remember them because I have not used Pascal in a very long while. None of those points are "closer to the metal".

Back then there wasn't even a C standard. In C, a pointer can point to any old memory address, including core elements of the machine's BIOS and operating system. In Pascal, an array is an array, not necessarily tied to anything in the machine. I think that's the great strength and great weakness of each language.

An array, protected with bounds checking accessing any memory address, provided the OS protection allows it. Don't want bounds checking? To be fair, the rant and most of the misconceptions about Pascal are about Wirth defined Pascal, not the much later extended Pascals that introduced things like "byte absolute" types.

But you're right in that no one has probably tried to suffer through strict Wirthian Pascal since the last CDC Cyber got shut down except on a bet. When I joined Apple in it was a Pascal shop that had just started moving to C. The Pascal they were using had been developed and was maintained in-house and had a number of extensions, and with the exception of a few things like different semantics for pointer arithmetic and the presence of nested procedures it felt in practice nearly the same as C, just with different keywords.

I wrote a ton of code in it, and I really didn't think about the difference much. But in college I had to use unextended Pascal, and it sucked pretty hard. Maybe that's the point of a teaching language; make it stink to the point that students are encouraged to move to better languages. Maybe the current vocational approach of teaching a "Real Language" -- ahem, Java -- to beginning programmers is flawed because they're less likely to get experience with other, better languages.

I know that I hate Java, at least how it was circa ]. Another problem with teaching introductory programming in a Real Language, I think, is the temptation to also teach more software engineering-like things as well. When you start measuring your experience with programming in decades rather than years, it's hard to remember learning how to program is actually kinda hard.

Thus, adding things like version control and IDEs to the mix gives you less time on teaching what should be the core of an introductory programming class: how to solve problems in code. Anything else is fluff that can be ignored until the foundations have been laid. An additional reason I think using something "weird" like Haskell or Scheme is that it's a very good equalizer Haskell in particular. IME, this kind of class will have two kinds of student: those who already know how to program, and those who've never programmed.

Those who already know how to program are mostly going to ignore the class, simply because it's known to them already; and this is a problem because the interactions between strong students and weaker ones is massively helpful, to both parties.

Teaching things is, somewhat ironically, perhaps the very best way of focussing your knowledge of it. When you're explaining stuff to yourself as it were , you can fudge the details you're a bit vague on which is generally thue tricky bits , but if you're explaining it any vagueness is painfully obvious I suspect this is also the reason simply explaining a problem to someone can be so helpful.

I think the move to safer languages for CS education is more to encourage people to think about the CS lessons at hand, rather than software engineering. Learning about various list types is much easier if you don't have to worry about randomly crashing things. Learning about recursion is better in a language suited for it. My CS education was founded around Scheme in part because it was a good language for showing how things worked. I thought the school went a little too far in that direction because outside of SQL, I had to teach myself every language I worked with thereafter.

It did prepare me to learn those languages. I learned programming with Pascal in high school, and it definitely didn't stink. It's way easier than C and lets you focus on the actual programming, not the idiosyncrasies of the language. It's very much like Python in this regard, but I think it's even better as a first languge. It's more explicit and to someone completely new to programming, that really pays off IMO.

I've taught beginning programming courses at the college level to adults for more than 20 years. It worked very well for me as a language and environment for learning to program. These struggles drain a lot of the energy which can be generated by making progress learning to program.

Some of the rationale for dropping Pascal, I think, was that "nobody" in the real world used it. This was untrue, of course, but the Pascal community didn't have the self-promotion and media buzz that Java did.

I find it curious that two languages deliberately designed for ease of instruction -- Pascal and Scheme -- should have such a bad reputation in some quarters.

Holy smokes this is a one sided load of hooey, where are all the folks who started out on this site who had Delphi as their favorite language?

Not to mention Lazarus and FreePascal on the open source side of things. So, if this is a historical question why C prevailed over Pascal, then OK, that's an acceptable claim to start a question. But authorship of code in Object Pascal has been growing, I don't know that the TIOBE index means a whole lot for it, but it should be clear that people are still writing code in Object Pascal and interest spikes whenever Embarcadero releases new tools, therefore actual humans interested in writing new not just maintaining old code are interested in Delphi.

Pascal, in spite of Borland's best and often misguided efforts, didn't achieve that level of market penetration. The combination of efficient execution on limited hardware, and, native access to the underlying OS and GUI libraries were probably the main reasons for C's success. Pascal never really hacked it on windows, and, Delphi arrived too late to make a difference.

Sign up to join this community. The best answers are voted up and rise to the top. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Learn more. Why has C prevailed over Pascal? Asked 10 years ago. Active 10 months ago. Viewed 44k times. Improve this question. Tom Au 7 7 silver badges 17 17 bronze badges. Konrad Morawski Konrad Morawski 9, 4 4 gold badges 34 34 silver badges 58 58 bronze badges.

If you basically only have one bankrupting company that supports the language you are working with, it definitely doesn't help I'm talking about the pre-. Net Borland. One word answer: Unix. What is C? To uppercase any string, you'd need functions. To append two random strings, you'd need thousands! Show 6 more comments. Active Oldest Votes. Pascal has lost the battle mostly because of: Verbosity if Plus Borland never opened the sources of the compiler.

Pascal's "last hope" - Delphi - was positioned by Borland as a database development platform targeted at corporate environments. This was an unfortunate marketing move made by marketing people I suppose , because creative engineers hate both databases and corporate environments.

Then the failure of Delphi for Linux, Kylix. Improve this answer. Apple's switch to Objective-C came long, long after it stopped using Pascal. The original Macintosh operating system and libraries were written using Pascal, but Apple offered good support for C soon after the Mac's introduction, and had switched over to C by the early 90's.

I don't think verbosity is a relevant argument. As code is read more than written verbosity has benefits. Isn't verbosity exactly what is advocated in languages today python vs. I don't think the verbosity was a cause, on the contrary it is one of Pascal's strengths.

This is incorrect. Turbo Pascal was widely successful. Show 20 more comments. Not only UNIX. Windows and its kernels were written mainly in C. SK-logic It came out in I wouldn't say C had taken over the world by then.

Yam: Unix and C were already widely spread in the 80's. When I studied at University beginning of the nineties , Unix and C was "the platform" every serious developer would have liked to work on. Unix was implemented in C so there would have been no Unix without C.



0コメント

  • 1000 / 1000