Recent

Author Topic: Frankenstein Pascal  (Read 21275 times)

MarkMLl

  • Hero Member
  • *****
  • Posts: 6686
Re: Frankenstein Pascal
« Reply #15 on: March 16, 2021, 09:18:08 am »
I've heard there is also a perception that classic C is just a computer virus disguised as a programming language.
And C++ is C after a complete takeover of the attacked system.
And C# is a caught and disarmed C in prison.
In turn, Java harmoniously combines the beauty of C++ syntax with the performance of Python.

To his credit, Stroustrup has been rather more critical of C++ than most other language designers when discussing their life's work.

"Within C++, there is a much smaller and cleaner language struggling to get out."

Which if nothing else illustrates the difficulty of enhancing an existing language with novel concepts.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

sstvmaster

  • Sr. Member
  • ****
  • Posts: 299
Re: Frankenstein Pascal
« Reply #16 on: March 16, 2021, 09:33:53 am »
DON'T FEED THE TROLL!
greetings Maik

Windows 10,
- Lazarus 2.2.6 (stable) + fpc 3.2.2 (stable)
- Lazarus 2.2.7 (fixes) + fpc 3.3.1 (main/trunk)

440bx

  • Hero Member
  • *****
  • Posts: 4037
Re: Frankenstein Pascal
« Reply #17 on: March 16, 2021, 10:00:50 am »
<snip> the result is invariably less elegant than a fresh properly-designed language.
I think designing a _good_ computer language might very well be the greatest challenge a programmer can face.

There are countless books about algorithms to scan, parse, generate code and massage data structures used in compiler writing as well as extensive theory on grammars but, I am yet to see a book that is an in-depth scientific/mathematical study of the effects of the grammar on the expressive power of the language and its ability to minimize/eliminate terse and error prone grammatical construct (e.g, =/==, |/||, </<< and countless others in C/C++.)

N. Wirth's mind obviously gravitates towards clear and solid grammars.  Simplicity is the reflection of brilliance.

C is an infectious disease that causes human talent to embed mediocrity in programming languages. 
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

MarkMLl

  • Hero Member
  • *****
  • Posts: 6686
Re: Frankenstein Pascal
« Reply #18 on: March 16, 2021, 10:28:49 am »
There are countless books about algorithms to scan, parse, generate code and massage data structures used in compiler writing as well as extensive theory on grammars but, I am yet to see a book that is an in-depth scientific/mathematical study of the effects of the grammar on the expressive power of the language and its ability to minimize/eliminate terse and error prone grammatical construct (e.g, =/==, |/||, </<< and countless others in C/C++.)

That's an interesting point, and one that a few years ago I might have been able to use to seed some research: I was involved with an MSc course at Lowbrow University which was an interdisciplinary effort between Elect Eng, Compsci, and Human Factors and I think there were were people in all three departments who would have jumped at the idea of looking at that from both a productivity and a robustness POV.

We do, of course, have Iverson's "Notation as a Tool of Thought" https://www.jsoftware.com/papers/tot.htm but that was more self-promotion when there weren't that many languages around. However it's still a useful resource and brings me to a challenge for OP:

* Design a parser for elementary integer arithmetic expressions supporting + - / * with the correct precedence.

* Add ! as prefix inversion (0 becomes 1, any other value becomes 0) with the same precedence as prefix -

* Augment this with ! as postfix factorial.

It's doable, but you have to have a reasonable understanding of parsers first. And having that (OP, I'm talking to you) you'll be in a better position to propose language extensions.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

yodabitiota

  • Newbie
  • Posts: 5
Re: Frankenstein Pascal
« Reply #19 on: March 16, 2021, 10:42:04 am »
Well, thanks for the responses. Tbh, some of them surprised me a bit. While i was prepared to hear this would not be the right place to discuss such, i'm also surprised by people calling it ridiculous. Seems the subject is more delicate to discuss than a discussion about nuclear energy amidst environmentalists.

At least from MarkMLI i learn i'm not the first one with such request. But to me it seems it gets thrown out like a baby with the bathwater. Which is a shame.

Thing is, there's plenty stuff in other languages that are missing in Pascal. And there is a reason why 'newer' languages (Java, PHP, C#, *) mostly seem to mimic C-style and that reason is readability.

I'm not calling others to do it, and probably the discussion is not new so maybe existing effort exist. Apparently every month someone asks for it :) Anyways, i got some pointers, so guess what's left for me to do is start digging. Feel free though to give more references.

dinmil

  • New Member
  • *
  • Posts: 45
Re: Frankenstein Pascal
« Reply #20 on: March 16, 2021, 10:46:15 am »
Speaking of well designed languages, I try to use golang. It was very well at beginning, but it does not cover all of my targets (and it have very strange try except concept). It is usually used for server side programming and it have most of libraries for that. If it does not have libraries then you get chaos of third party libraries.

After a while I found new language which is development in progress. This language is https://vlang.io/
It is influenced by pascal but it have all features of golang (channels and green threads) and syntax is almost beautiful.
If those guys can complete the job then this will be probably my language of chioce.

MarkMLl

  • Hero Member
  • *****
  • Posts: 6686
Re: Frankenstein Pascal
« Reply #21 on: March 16, 2021, 11:05:16 am »
Apparently every month someone asks for it :) Anyways, i got some pointers, so guess what's left for me to do is start digging. Feel free though to give more references.

Roughly speaking, every month or so. As as I remarked in my "Modest Proposal", they're almost always newcomers.

Look, I for one am not attempting to defend Pascal as the "be all and end all" of programming languages. But the fact is that it was a minor rework (for political reasons) of ALGOL, plus a few newly-introduced ideas which have endured. Wirth knew what he was doing and the syntax was robust, unlike C whose designers were self-admitted beginners and which has a syntax with major design flaws... not to mention semantics which are an enduring millstone around the industry's neck.

You might find https://wiki.lazarus.freepascal.org/Make_your_own_compiler,_interpreter,_parser,_or_expression_analyzer useful , and in particular I've slipped a few references into the "Ancient History" section. I'd also encourage you to attempt the challenge I set earlier :-)

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

ojz0r

  • Jr. Member
  • **
  • Posts: 61
Re: Frankenstein Pascal
« Reply #22 on: March 16, 2021, 11:16:29 am »
And there is a reason why 'newer' languages (Java, PHP, C#, *) mostly seem to mimic C-style and that reason is readability.

I belive that is more connected to familiarity rather than readability per se. Sure familiarity increases readability, this is what we call legacy, but for fresh eyes that may not be the case.
I have slim to non experience in either Pascal or C-style languages and atleast for me the structured syntax with begin/end block delimiters and clearly defined variables is alot easier to read than C-like with curly braces and dynamic variable handling.
I'm trying to learn programming at a deeper level and while i get Pascal i have a really hard time with the C-like languages.

I would assume that if it wasn't for Unix with its legacy, C would be very niché.
Just trying to learn.

440bx

  • Hero Member
  • *****
  • Posts: 4037
Re: Frankenstein Pascal
« Reply #23 on: March 16, 2021, 11:30:37 am »
i'm also surprised by people calling it ridiculous. Seems the subject is more delicate to discuss than a discussion about nuclear energy amidst environmentalists.
I understand your surprise.  The C language's poor design has permeated in a great number of languages, the result is, it's become so common that it seems ok when it really is not remotely close to ok.  That may very well be the worst effect that language has had on computer science and programmers today, the normalization of a truly dismal design.

Thing is, there's plenty stuff in other languages that are missing in Pascal.
I wholeheartedly agree with that but, features are a very different thing than language design. 

And there is a reason why 'newer' languages (Java, PHP, C#, *) mostly seem to mimic C-style and that reason is readability.
No, the reason is definitely not readability.  The reason is the widespread acceptance of a repugnantly bad design that has very unfortunately become what a very significant percentage of programmers have gotten used to.  What's incredibly unfortunate is that the majority of programmers who have gotten infected by it are now unable to even tell the design is pure garbage.   It's a bit like heroin, very addictive but, definitely not good for the "consumer", particularly when that harmful stuff is dispensed in shiny "new packages" to make it look attractive (heroin++, D-eroin, etc)

probably the discussion is not new so maybe existing effort exist.
You're right, it isn't new and you won't be the last one to express a desire for it. 

Someone asked, why create mediocrity when you can copy genius ?  the answer is very simple, because it is a lot easier to copy mediocrity than genius.  That's why.   Careful not to fall in that trap.



I was involved with an MSc course at Lowbrow University which was an interdisciplinary effort between Elect Eng, Compsci, and Human Factors and I think there were were people in all three departments who would have jumped at the idea of looking at that from both a productivity and a robustness POV.
That would have been great.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

MarkMLl

  • Hero Member
  • *****
  • Posts: 6686
Re: Frankenstein Pascal
« Reply #24 on: March 16, 2021, 11:32:32 am »
I belive that is more connected to familiarity rather than readability per se. Sure familiarity increases readability, this is what we call legacy, but for fresh eyes that may not be the case.
I have slim to non experience in either Pascal or C-style languages and atleast for me the structured syntax with begin/end block delimiters and clearly defined variables is alot easier to read than C-like with curly braces and dynamic variable handling.
I'm trying to learn programming at a deeper level and while i get Pascal i have a really hard time with the C-like languages.

I would assume that if it wasn't for Unix with its legacy, C would be very niché.

I've seen people criticise the use of braces ("curly brackets") because they were having difficulty distinguishing them from parentheses and brackets ("square brackets") on their computer. I'm afraid I was less than sympathetic: they should choose a more appropriate computer for the job, or at least learn how to set it up properly.

I think that my preference would be for an underlying language to use a verbose notation similar to begin/end, but to have the option of shortening that using something akin to macros. HOWEVER, if one went with that approach the preprocessor/compiler would need a lot of intelligence to either prohibit or disambiguate use of the shortened form where there were clashes, and that would probably prevent the conventional lexer -> parser -> code generator organisation. I've had things working in the past which went some way towards that, e.g. pragmata to control the form of numbers and strings which affected all stages of the compiler.

Apropos C... I agree that it would have been niche. I've had people explain to me that the only way that you could program a UNIX computer was by using C and I've had people explain to me that the only way you could program an IBM mainframe was by using assembler... both arguments were of course fallacious but the fact that they were voiced at all indicates just how insular the communities could be.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

MarkMLl

  • Hero Member
  • *****
  • Posts: 6686
Re: Frankenstein Pascal
« Reply #25 on: March 16, 2021, 11:40:21 am »
And there is a reason why 'newer' languages (Java, PHP, C#, *) mostly seem to mimic C-style and that reason is readability.
No, the reason is definitely not readability.  The reason is the widespread acceptance of a repugnantly bad design that has very unfortunately become what a very significant percentage of programmers have gotten used to.  What's incredibly unfortunate is that the majority of programmers who have gotten infected by it are now unable to even tell the design is pure garbage.   It's a bit like heroin, very addictive but, definitely not good for the "consumer", particularly when that harmful stuff is dispensed in shiny "new packages" to make it look attractive (heroin++, D-eroin, etc)

I've remarked before that it's regrettable that there are so many people- often educated and experienced people- who think that the sole criterion is "curly-bracket languages vs begin-end languages".

It's not. K&R perpetrated some remarkably bad design choices which could have been avoided by familiarity with "the art".

In the interest of being even-handed, I can't help but observe that Wirth perpetrated some remarkably bad design choices /despite/ being familiar with the art.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

yodabitiota

  • Newbie
  • Posts: 5
Re: Frankenstein Pascal
« Reply #26 on: March 16, 2021, 11:49:57 am »
I belive that is more connected to familiarity rather than readability per se.

Well, to be fair, readability of Pascal is just fine, great even. I've no issues with that and with Pascal being my language of choice for 3 decades, it shouldn't be. But i do find myself sometimes frowning a bit, seeing alternatives. Having said that, curlies are not even on top my wish list for changes.

Such wish list includes things like real boolean instead of bitwise boolean operators, implicit casting integer types to boolean, variable scope limited to block, and a few more.

Dinmil linked to the v-language which indeed looks neat and clean, but ofc FPC has a feature set and a tonload of libraries, and i'm familiar with the language. Also, i'm the first to admit that dealing without those features is a real minor issue. So personally i prefer using a stable language that i know in and out and know what to expect from, than jumping on the next hyped train like Go or Rust which i consider too experimental for long-term projects.

But i do observe FPC going trough great lengths to maintain Delphi compatibility, while personally i don't care at all for such. I consider FPC way superior to Delphi so why even bother. And yes, Delphi improved too over the years, and of course copy good ideas, no shame in that. Meanwhile changes that are desirable by some get plain ridiculed - someone called me a Troll for that in this thread already, making me wonder how open discussions about language features are. I totally understand 'weird' features not going mainstream, but if every month someone suggest the same thing then apparently there are thousands thinking like me, just never stirring it up.

MarkMLl

  • Hero Member
  • *****
  • Posts: 6686
Re: Frankenstein Pascal
« Reply #27 on: March 16, 2021, 12:09:36 pm »
Such wish list includes things like real boolean instead of bitwise boolean operators,

Please explain what you mean here.

Quote
implicit casting integer types to boolean,

Not going to happen and AIUI C++ frowns upon that. /However/, if there were a single-character boolean inversion- let's say ! for this- I'd suggest that it would be feasible to recognise !! for boolean normalisation taking an integer type as its parameter. Please take that into account when considering the exercise I set earlier :-)

Quote
variable scope limited to block, and a few more.

Presumably you mean "block" as in "the single statement processed by a  for  statement. Ditto possibly a  with  statement as an explicit indication of the referent. TBH I agree with you, but "the Lieutenant wouldn't like it" :-)

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

440bx

  • Hero Member
  • *****
  • Posts: 4037
Re: Frankenstein Pascal
« Reply #28 on: March 16, 2021, 12:16:53 pm »
In the interest of being even-handed, I can't help but observe that Wirth perpetrated some remarkably bad design choices /despite/ being familiar with the art.
Wirth did make some "poor" choices here and there but, he deserves credit for realizing them and correcting them.  Great minds correct their mistakes, mediocre ones perpetuate them.



<snip> Meanwhile changes that are desirable by some get plain ridiculed - someone called me a Troll for that in this thread already, making me wonder how open discussions about language features are.
It's probably fair to say they are not very open.

I totally understand 'weird' features not going mainstream, but if every month someone suggest the same thing then apparently there are thousands thinking like me, just never stirring it up.
Features or syntax additions/modifications should fit nicely into the spirit of the language, that's important.  Things like "++" create all kinds of problems, particularly if they are allowed to precede or follow an identifier (as done in C/C++.)  It really does not fit well into the language, that is also true of the curly braces, they are already used to delimit comments.  FPC allows the use of "<<" and that is a quite a source of headaches.

Here is a feature I suggested https://forum.lazarus.freepascal.org/index.php/topic,49505.0.html that is a nice fit in the language, it's a rather simple one (at least it should be simple) but, it got shot down.  Features that don't fit the language are very unlikely to be adopted (with exceptions such as the previously mentioned "<<".)

(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

yodabitiota

  • Newbie
  • Posts: 5
Re: Frankenstein Pascal
« Reply #29 on: March 16, 2021, 12:51:02 pm »
Please explain what you mean here.

Ok, boolean logic is always considered bitwise in Pascal. In C, we can distinguish what we want be & vs &&, | vs || and ! vs ~. In pascal, have to jump little hoops like '(A<>B) and (B<>0)', or alternatively typecasting 'boolean(A) and boolean(B)',  if A and B are integer types, which they happen to do, a lot. It's not 'cleaner code'. 440bx suggest to use '!!' which might be an alternative albeit a bit clumsy.

Then, for incrementing (and decrementing) we're forced to use a pseudo function like 'inc', or a construct like 'x+=1'. Whereas in assembler this is one instruction. It doesn't have to be '++' btw, but 'inc' being a pseudofunction feels a bit, odd. And it's also one of them things happening a lot in code.

So, in general boolean logic is not really elegant in Pascal. I know C sometimes looks like black magic, but it (boolean logic) is the thing we have to do as programmers, and the same line in Pascal may end up 3 times as long as in C. Allowing bools for multiplication and other math functions (implicit casting of bool to integer) would be very nice to have too.

Loops are another small pain point, and there's already various discussions on that. Including the proposal to at least have a 'step'. Or to be allowed to modify the iterator. Fancier c-style would be do have multiple conditions. But this all is easily dodged with a simple while instruction so low priority in my opinion. But C's 'for' construction does have some elegance and flexibility. Luckily we have for-in loops nowadays ,if you're willing to write operators, which unfortunately don't exist for a lot of standard types and classes yet, but surely a nice feature.

Now, by no means i wish to break compatibility and with those glasses on i understand the conservatism. But as programmer, looking for an elegant language and elegant code, there's a wish list aye.
« Last Edit: March 16, 2021, 12:54:09 pm by yodabitiota »

 

TinyPortal © 2005-2018