Lazarus

Free Pascal => General => Topic started by: jex on April 03, 2020, 10:57:47 pm

Title: Discussion - What if fpc syntax becomes C-like?
Post by: jex on April 03, 2020, 10:57:47 pm
Hello,

I've just started learning Pascal. For the most part the syntax feels redundant or idk how to explain exactly. I'm sure some will get the idea
Now say that fpc is being written from the ground up as a new project, same language features, support etc, but just the syntax is more C-like. Would this bring a positive or a negative results?

Maybe more will start learning it (mainly because it'll be much easier to quickly pick it up for experienced programmers) or at least exploring it. Can it get the attention of big enterprises to maybe adopt it in some way? can it find the popularity that it truly deserves, because imo, I've just started learning it and so far I'm so impressed especially because it was built by the community. I really appreciate the tools and support FPC/Lazarus provides completely *FREE*. Nothing asked.

What do you think? Is that even technically possible?

In other words, what do you think is the main reason for FPC/Lazarus not getting the attention it deserves?
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: Bart on April 03, 2020, 11:33:38 pm
Making it more C won't attract more users.
If they want a C-ish language, there are plenty of them.

The verbosity and clarity of Pascal is what attracts me to the language in the first place.

Bart
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: circular on April 03, 2020, 11:43:45 pm
I've just started learning Pascal. For the most part the syntax feels redundant or idk how to explain exactly. I'm sure some will get the idea
Now say that fpc is being written from the ground up as a new project, same language features, support etc, but just the syntax is more C-like. Would this bring a positive or a negative results?
I honestly have no idea what you're talking about. Can you provide an example?
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: marcov on April 03, 2020, 11:52:17 pm
I've just started learning Pascal. For the most part the syntax feels redundant or idk how to explain exactly. I'm sure some will get the idea
Now say that fpc is being written from the ground up as a new project, same language features, support etc, but just the syntax is more C-like. Would this bring a positive or a negative results?

I think you would get some weird hybrid, neither fish nor fowl.

Quote
Maybe more will start learning it (mainly because it'll be much easier to quickly pick it up for experienced programmers) or at least exploring it. Can it get the attention of big enterprises to maybe adopt it in some way?

As a completely new language it would first have to gain significant traction and a mature toolchain. Dozens of languages are launched weekly, the last one not introduced by a large corporation afaik is Python. (which is from 1991, but started to get traction only after 2000)

Moreover I don't agree with the premise in the first case. C and C syntax is terse and unwieldy to type (too many shifted letters). At first glance it looks shorter, but it is actually longer to type, typically.

Also the language would only the most superficial similarities to C, the kind of info that you get from a 20min reading session, so the benefits are so slim they are not even measurable.

And worse you still face the biggest and steepest hill, not syntax, but getting people from those popular languages to come over to your new minority language. They might grumble about syntax, but they'll just grumble on something else and stick with what they know.

So in short: IMHO hopeless :D

Quote
can it find the popularity that it truly deserves, because imo, I've just started learning it and so far I'm so impressed especially because it was built by the community. I really appreciate the tools and support FPC/Lazarus provides completely *FREE*. Nothing asked.

The big problem is that with a new language you throw away 50 years of source code and tooling and start over, and that for a vague principle that is hard to test and saves 10-20 minutes in the earliest part of the language learning.

Quote
What do you think? Is that even technically possible?

You would have to rewrite the entire parser, and redesign the whole dialect. Possible, but not trivial.

But the FPC project wouldn't be interested, so you would have to fork, create an own team, and do the work. An experienced couple devel could maybe redo the frontend to a somewhat workable state in an year. Maybe half an year if there are multiple persons that can work as a team, and assuming they are still students or in their first jobs so they can really spend a lot of time on it.

For unwashed newbies: hard to say. But long, very long.

But even then you only have the compilre, and you are years away from being on par, you have to redo IDE,xml,json classes *EVERYTHING* and  the kitchen sink:-)

Most likely some members lose steam or start to diverge in direction *HARD*.

Quote
In other words, what do you think is the main reason for FPC/Lazarus not getting the attention it deserves?

Looking at existing languages introduced or made popular in the last 10-15 years (Rust, Go, Ruby etc), that's obvious.  Not being invented or introduced by a large US corporation. Not being entrenched in a small circle of Silicon Valley venture capitalists at the right moment.

So in short: to fix the problem, give your mates the url to a ten finger typing course.
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: PascalDragon on April 04, 2020, 11:38:21 am
Now say that fpc is being written from the ground up as a new project, same language features, support etc, but just the syntax is more C-like. Would this bring a positive or a negative results?

Why should one? The idea of FPC is an open source Pascal compiler. It's even in the name: Free Pascal Compiler. Pascal languages (no matter if ISO Pascal, UCSD Pascal, Turbo Pascal, Virtual Pascal, Delphi, Oxygene) are clearly different from C-like languages. So if you don't like Pascal syntax, guess what: don't use it. There are enough C-like languages out there that you can choose from. It is the Pascal syntax that makes FPC different and thus stand out, and that's a good thing.
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: Sirius Black on April 04, 2020, 11:45:13 am
Hello,

I've just started learning Pascal. For the most part the syntax feels redundant or idk how to explain exactly. I'm sure some will get the idea
Now say that fpc is being written from the ground up as a new project, same language features, support etc, but just the syntax is more C-like. Would this bring a positive or a negative results?


AFAIK, except pascal, many programming languages more C-like, and don't forget, Pascal is old than C language, so who is more like each other?
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: Rainbow6 on April 04, 2020, 12:41:49 pm
I think it doesn’t make sense, to make one language more like another.

In the programming language world there are 2 diametrical ideas. One where you form a “readable” language after natural languages (often English) - lets say Pascal, Modula, Oberon, COBOL, AppleScript/HyperTalk, ... And there is the other extreme where you heavily rely on special characters like Perl, C, C++, Lisp, ...

Most programming languages are somewhere in between these extremes - and this is good. Every programmer has it’s personal opinion on that - so if she/he likes, she/he can develop an own language that fits - but most of us are OK with what Wirth or Kernighan or Stroustrup have built.
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: Thaddy on April 04, 2020, 01:43:25 pm
Show me the grammar < >:D > if you succeed you are briliant, otherwise you are a donkey just like me... 8-)
Fact is C is more Pascal like with intentional (and unintentional: K&R did half a job) obfuscations..... :o
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: jamie on April 04, 2020, 05:20:38 pm
There are  few things in the C language that fpc could benefit from , some are already implemented..
 
 But there are a lot of things in the C++ level when it comes to class handling is a disaster in my opinion and that is where Object pascal shines.

 But getting back to basics here...

 The Boolean auto translation would save us loads of coding …
Example:

   if SomeInteger Then.....

   If SomeString Then...
etc
 what this means is simple...

 If value is 0 its false or string empty its false otherwise they are true...

 at the same time these identifiers can be used as Boolean or Value operators when it cones to performing the IF and WHILE loop control statements.

 We already have functions that work this way, why is it so hard for the compiler to see there is no assignment there and thus should assume a Boolean operation ?

 The same goes with Assigning a Booleaning..

ABoolean = SomeInteger;

 You notice how I didn't use the := ?

Anyways, I know this will never get implemented.
The usual answer is

"Bad Language Design" or "That's ugly " etc..

 Oh and while we are at it, the parser should be able to process a single or double quoted strings.

if it starts with a "....." it should be C style other wise starting with a ' is pascal style and so on..
at least this way escape chars can be used in the C-Style or make it easy to insert a single quote.

 
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: Leledumbo on April 05, 2020, 09:49:47 am
The Boolean auto translation would save us loads of coding …
Example:

   if SomeInteger Then.....

   If SomeString Then...
etc
 what this means is simple...

 If value is 0 its false or string empty its false otherwise they are true...

 at the same time these identifiers can be used as Boolean or Value operators when it cones to performing the IF and WHILE loop control statements.

 We already have functions that work this way, why is it so hard for the compiler to see there is no assignment there and thus should assume a Boolean operation ?

 The same goes with Assigning a Booleaning..

ABoolean = SomeInteger;

 You notice how I didn't use the := ?

Anyways, I know this will never get implemented.
The usual answer is

"Bad Language Design" or "That's ugly " etc..
Ooo...that's ugly :P
Really, if you want an unsafely typed language, don't pick Pascal family. The only high level language today that can't differentiate a boolean and integer are direct C descendants. The hybrids and those inspired from both (Go, Java) know the benefit and implement boolean properly as its own, distinct type from integer. It's easy to implement, yes. But developing a language is not a matter of implementing it easily, because if that's the case, just use Assembly.
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: Thaddy on April 05, 2020, 10:08:00 am
Well, { = begin and } = end.... search and replace.... Curly brackets Pascal....
Don't use curly brackets for comments, though: as everyone knows all C code is always a comment in Pascal....  8-)

(Ok,Ok,Ok, that is a very old joke...)
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: jc99 on April 05, 2020, 11:30:00 am
The Boolean auto translation would save us loads of coding …
Example:

   if SomeInteger Then.....

   If SomeString Then...
[...]

ABoolean = SomeInteger;

 
Ooo...that's ugly :P
Really, if you want an unsafely typed language, don't pick Pascal family. The only high level language today that can't differentiate a boolean and integer are direct C descendants. The hybrids and those inspired from both (Go, Java) know the benefit and implement boolean properly as its own, distinct type from integer. It's easy to implement, yes. But developing a language is not a matter of implementing it easily, because if that's the case, just use Assembly.
Uagh ..  %) The first example still sends shivers down my spine ...
By the way for correct C-Syntax you (jamie) had to write
Code: C  [Select][+][-]
  1. if (SomeInteger)
  or
Code: C  [Select][+][-]
  1. if (SomeString)
in pascal
Code: Pascal  [Select][+][-]
  1. IF SomeInteger = 0 THEN
or
Code: Pascal  [Select][+][-]
  1. IF SomeString="" THEN
which looks much more readable to me and if you are used to
Code: Pascal  [Select][+][-]
  1. ABoolean := SomeInteger = 0;
  2. ABoolean2 := SomeInteger = 2;
it is a little more to type but it keeps it's consistency.
Also
Code: C  [Select][+][-]
  1. if (SomeString)
is not so obvious to me since strings are nullable classes in c#
Code: Pascal  [Select][+][-]
  1. IF assigned(SomeString) THEN [...]
  2. IF SomeString <> "" THEN [...]
  3. IF SomeString <> "0" THEN [...]
are also possible interpretations to me, and are much more readable in pascal.
@opaque: We have pascal++ (or pascal+1 to stay in the pascal-syntax) because c++ introduced the object-orientation to c which we have since object-pascal.
With delphi the pascal-language evolved even more, to a level like C# or java speaking of class-support, interfaces & generics.   
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: Thaddy on April 05, 2020, 11:32:23 am
Well, using UPPERCASE makes it BASIC, not Pascal.... and unreadable for me. My glasses do not help in such case.
It also tends the wear out the capslock and shift keys.....
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: guest58172 on April 05, 2020, 12:14:54 pm
Hello,

I've just started learning Pascal. For the most part the syntax feels redundant or idk how to explain exactly. I'm sure some will get the idea
Now say that fpc is being written from the ground up as a new project, same language features, support etc, but just the syntax is more C-like. Would this bring a positive or a negative results?

Maybe more will start learning it (mainly because it'll be much easier to quickly pick it up for experienced programmers) or at least exploring it. Can it get the attention of big enterprises to maybe adopt it in some way? can it find the popularity that it truly deserves, because imo, I've just started learning it and so far I'm so impressed especially because it was built by the community. I really appreciate the tools and support FPC/Lazarus provides completely *FREE*. Nothing asked.

What do you think? Is that even technically possible?

In other words, what do you think is the main reason for FPC/Lazarus not getting the attention it deserves?

From the syntax POV  no and it would be stupid. From the semantic POV I'd like to see 2 or 3 things

1. boolean evaluation of pointers and class instances
2. boolean evaluation of integers
3. implicit conversion from boolean to integer

1. boolean evaluation of pointers and class instances

Code: Pascal  [Select][+][-]
  1. if somePtr <> nil then ;

becomes

Code: Pascal  [Select][+][-]
  1. if somePtr then ;

same for class instances, interfaces.

2. boolean evaluation of integers

Code: Pascal  [Select][+][-]
  1. if someInt <> 0 then ;

becomes

Code: Pascal  [Select][+][-]
  1. if someInt then ;

3. implicit conversion from boolean to integer

Code: Pascal  [Select][+][-]
  1.  counter += Byte(someString[1] = 'a')

becomes

Code: Pascal  [Select][+][-]
  1. counter += someString[1] = 'a'

These 3 semantic changes are not breaking changes I think so they could be added without breaking code.
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: marcov on April 05, 2020, 12:30:29 pm
These 3 semantic changes are not breaking changes I think so they could be added without breaking code.

In some pointer cases autodereferencing might be a problem. Also you'll need more than the most mundane examples if you want to prove a point. Everybody knows what to do in the simple cases, it is the difficult cases that are the problem.

See e.g. https://www.freepascal.org/faq.html#extensionselect
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: howardpc on April 05, 2020, 12:40:03 pm
See e.g. https://www.freepascal.org/faq.html#extensionselect (https://www.freepascal.org/faq.html#extensionselect)
A minor point (since that page is not editable by most forum users): scepsis should be scepticism.
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: marcov on April 05, 2020, 12:43:05 pm
See e.g. https://www.freepascal.org/faq.html#extensionselect (https://www.freepascal.org/faq.html#extensionselect)
A minor point (since that page is not editable by most forum users): scepsis should be scepticism.

Done, thanks
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: guest58172 on April 05, 2020, 12:45:54 pm
These 3 semantic changes are not breaking changes I think so they could be added without breaking code.

In some pointer cases autodereferencing might be a problem. Also you'll need more than the most mundane examples if you want to prove a point. Everybody knows what to do in the simple cases, it is the difficult cases that are the problem.

See e.g. https://www.freepascal.org/faq.html#extensionselect

Maybe if you have doubts you can try in D. D has this semantics on pointers, classes and interfaces but also autodereferencing.
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: marcov on April 05, 2020, 01:06:07 pm
Maybe if you have doubts you can try in D. D has this semantics on pointers, classes and interfaces but also autodereferencing.

That would be pointless since D has yet again different semantics. Anyway, I don't think there is much interest obviously, so that would mean you'd need to fork to implement it.
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: guest58172 on April 05, 2020, 01:09:14 pm
It always ends the same way here.
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: Thaddy on April 05, 2020, 01:11:58 pm
You mean ; ? :-X
And the program ends with a dot...
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: jamie on April 05, 2020, 03:05:25 pm
I didn't mean to stir the pot but I was talking about turning fpc into C++, but extracting a little, very little ideas from some of its operations...

 Personally I love the verbosity of pascal which is why I use it, I can't stand the single or double operators used in C/C++ they aren't clear enough when reading code at first glance.

 I hate the {…} brackets I don't even use them much for comments in the pascal I use // a lot..

 I hate C++ classs styles... very poorly thought out..

 But putting that aside I like what I posted before
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: PascalDragon on April 05, 2020, 03:31:13 pm
The Boolean auto translation would save us loads of coding …
Example:

   if SomeInteger Then.....

   If SomeString Then...
etc
 what this means is simple...

 If value is 0 its false or string empty its false otherwise they are true...

 at the same time these identifiers can be used as Boolean or Value operators when it cones to performing the IF and WHILE loop control statements.

 We already have functions that work this way, why is it so hard for the compiler to see there is no assignment there and thus should assume a Boolean operation ?

Because Object Pascal has a strong type system. You can't simply have a String or an Integer be a Boolean as there is no rule for it.

Also if you so strongly desire it, then declare yourself some operator overloads:

Code: Pascal  [Select][+][-]
  1. program tboolovld;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. operator := (const aStr: String): Boolean; inline;
  6. begin
  7.   Result := aStr <> '';
  8. end;
  9.  
  10. {operator := (aArg: LongInt): Boolean; inline;
  11. begin
  12.   Result := aArg <> 0;
  13. end;}
  14.  
  15. operator := (aArg: TObject): Boolean; inline;
  16. begin
  17.   Result := aArg <> Nil;
  18. end;
  19.  
  20. type
  21.   TMyObject = class(TObject);
  22.  
  23. var
  24.   s: String;
  25.   i: LongInt;
  26.   o: TMyObject;
  27. begin
  28.   if s then
  29.     Writeln('Blubb');
  30.   {if i then
  31.     Writeln('Blubb');}
  32.   if o then
  33.     Writeln('Blubb');
  34. end.

Note: the implicit operator overload for integer types to Boolean is currently not supported. I have a fix for that however and I'll commit it soon.

The same goes with Assigning a Booleaning..

ABoolean = SomeInteger;

 You notice how I didn't use the := ?

What should that even do? That is an expression. A comparison does not equal an assignment.
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: ASerge on April 05, 2020, 04:11:53 pm
The Boolean auto translation would save us loads of coding …
Example:

   if SomeInteger Then.....

   If SomeString Then...
etc
 what this means is simple...
Even in c++, this is recognized as bad style, and in all books it is recommended to write for clarity !=null, =='\0', etc.
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: marcov on April 05, 2020, 04:20:25 pm
The Boolean auto translation would save us loads of coding …
Example:

   if SomeInteger Then.....

   If SomeString Then...
etc
 what this means is simple...
Even in c++, this is recognized as bad style, and in all books it is recommended to write for clarity !=null, =='\0', etc.

Well the boolean form would simply check for =1 of course, since that is allowed with normal Pascal booleans.
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: jamie on April 05, 2020, 05:30:44 pm
it would have to test for  not 0 because any value is considered true other than 0.

the same goes with a string..

 if not Length(AString) then...

etc


Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: marcov on April 05, 2020, 05:50:32 pm
it would have to test for  not 0 because any value is considered true other than 0.

Nope, Pascal "boolean" type is 0=false 1=true, rest undefined
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: GypsyPrince on April 05, 2020, 06:25:41 pm
@jex

The more I delve into Object Pascal the more I am finding it is not for me and will probably set it to the side, shortly. I like OP's verbosity, but there are many shortcomings in the language which make it inefficient as a commercial-level production language. Given the resistance by purists against evolving, OP will remain little more than a niche/hobby language.
 
Now... my personal finding of OP to be inefficient does not mean it is a bad language. Not at all. In fact, it is apparently a great language which many, many others find to be useful and efficient for their particular needs. My point is simply that while OP/Lazarus is perfect in fitting the needs of some, it does not meet the needs of some others. For example... my preferred languages are C and assembly.  However, because I am about to retire I will no longer be doing secured embedded systems. I will only be dabbling with small apps as a hobby. So, neither assembly nor C will any longer meet my needs, as I will be interested only in rapid development. While I think VB.NET may be the closest thing to a "perfect" language, it also will not meet my needs because I want something that compiles to native code. Thus, the reason for my tinkering with Object Pascal/Lazarus to see if it does meet my particular needs.
 
A programming language and development system are nothing more than tools. That is it. No programming language is a holy relic which deserves to be worshipped. Additionally, no language is any better or any worse than any other - merely different. Though no language is any better or any worse than another as a whole, it must be stated that any language can certainly be better (or worse) suited for a particular situation or requirement than are others. Anyone who believes or asserts otherwise is seriously misinformed in that they do not truly understand the internals of a programming language, and likely do not understand the internals of computers as well. If a given tool does not meet your needs, always feel free to choose a different tool which does meet your needs, and do not let the sarcastic comments of others pressure you in your decision making. Only you can decide what tool is good for you and what tool is not good for you. Also, you will find many people in forums such as this who act like children and make sarcastic (if not outright rude) remarks when they feel your coding style doesn't meet their own preferences. Such people are trolls who live in a bubble and cannot see the world outside of their own limited experience. Just like the tool(s) you decide fit your needs, you alone must also determine what coding style fits your own needs best, and not what some basement dweller attempts to dictate to you.

There is a new implementation of BASIC coming out around mid-summer which may be of interest to you.

https://www.elementscompiler.com/elements/mercury/default.aspx (https://www.elementscompiler.com/elements/mercury/default.aspx)

Purely as an offer of alternative information... Mercury is being produced by a well established company to pick up where Microsoft has chosen to leave of with Visual Basic.  And, whereas Visual Basic is Windows dependent (mostly) and must run via a virtual machine (.NET/Core platform), Mercury will instead allow you to specify your app to utilize the .NET and Mono platforms, or to compile to native code.  Possibly the biggest feature... its evolution will not be stalled by small-minded language purists.

Like VB.NET, Mercury will also utilize many C constructs, true namespace elements, and will be more user-intuitive. The goal of Mercury will be to make developers more efficient and less concerned about feeling like they are part of some special club like many developers in other languages.
 
Understand that I am not promoting Mercury, but merely offering alternative information.
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: mercurhyo on April 05, 2020, 06:32:16 pm
Here we go again.

- Features requests to please 1-5 users WORLDWIDE

- Look at this other language, then that one, and that one

Remember that you are on the FreePASCAL forum? You'd better...

MODERATED: Please, avoid offending others!
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: lucamar on April 05, 2020, 06:50:44 pm
The more I delve into Object Pascal the more I am finding it is not for me and will probably set it to the side here, shortly. I like OP's verbosity, but there are many shortcomings in the language which make it inefficient as a commercial-level production language.

Inefficient for commercial-level production? :o I don't know what definition of "efficiency" you're using but I can tell you that I have been programming large commercial applications in quite a lot of languages for quite some time and Pascal (specificaly Delphi and FreePascal/Lazarus) let most (if not all) others languages and dev. environments in the dust. Even BASIC and BASIC-like languages (like BAL/ABAL).

Of course, all this is extremely subjective but take also into accoutn that "efficiency" goes done the drain at the beginning, until you learn well both the language and its tools; that's valid for any language and any tool, not just Pascal.
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: GypsyPrince on April 05, 2020, 06:58:35 pm
If it were efficient, it would be used more rather than being ranked way behind.
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: lucamar on April 05, 2020, 07:17:57 pm
If it were efficient, it would be used more rather than being ranked way behind.

The ""popularity" of a language depends on lots of things beyond the perceived "efficiency" of coding in it. In fact most of the reasons why a language becomes "popular" have little to do with how easy/efficient is to program in it. Think, for example, on the number of "better C than C" which flourish for a time and then die.
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: GypsyPrince on April 05, 2020, 07:31:07 pm
If companies found the language to be efficient, more companies would be using it. They apparently disagree with your opinion.
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: lucamar on April 05, 2020, 08:06:58 pm
If companies found the language to be efficient, more companies would be using it. They apparently disagree with your opinion.

According to that logic no company would be using it, they would be using the "more effcient" one. That there are, in fact, quite a lot of them using it then serves to contradict your statement.

In most companies (whether software houses or internal software depts.) a language's perceived "efficiency" is considered (if it ever is) as a minor reason in the decision of what to use: potential programmers pool, tools price, existing code-base and quite a lot other things are considered before even efficiency comes to the table. And this is not an opinion, it's a fact I've gleaned through my long career as a programmer.

But, of course, feel free to think whatever you want. You don't like Pascal? OK, use any other thing :)
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: JanRoza on April 05, 2020, 08:27:51 pm
Can we stop these useless discussions before we bash in each others head.
We are Pascal users and discuss its use, Im getting tired of all those Pascal newcomers who need Pascal to look like another language to be able to use it.
My motto is simple: try a language, you like it than learn it, you don't like it than move on.
Don't try to turn Pascal in something it is not.
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: GypsyPrince on April 05, 2020, 08:46:14 pm
@JanRoza

Quote
try a language, you like it than learn it, you don't like it than move on.

The exact same point is easily made regarding a feature requested by someone. If you like it - use it. If you don't like it - don't use it. The only person/people who have the right to gripe about any particular request are the developers of the language/IDE. If your are not one of its developers on which the burden of implementing such a feature might rest, then you have no business saying anything about the request, other than to politely (and in an adult manner) offer an alternative suggestion as to how the person might achieve their desired goal.

Don't bash someone else for asking about a feature you will not be forced to use if you choose not to. Doing so is the absolute epitome of childish behavior.
 
Life really is that simple.
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: GypsyPrince on April 05, 2020, 09:23:02 pm
@marcov

Quote
You would have to rewrite the entire parser, and redesign the whole dialect. Possible, but not trivial.

This is a very patient and informative response to the OPs question.

I don't know if you are one of Lazarus' developers, but I'm going to take a blind guess and say you are (?).

It is nice that you are keeping in mind that most people who request a feature have absolutely no experience whatsoever in developing a parser or compiler. Even as long as I've been programming, I wouldn't pretend to know where to begin with customizing Free Pascal to my preferences, and I'm guessing (I could very easily be wrong here) the original poster wouldn't either. So, it is nice to see that you politely point out how much work it would take to implement his request rather than the often seen response given by others which equates to "Your feature request is stupid because we don't want it. Now go away!."
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: Tomas Hajny on April 05, 2020, 09:44:47 pm
Everybody involved, please, stay on topic, or don't reply. No offenses to others! As one of moderators of this forum, I've just removed about ten responses which were either completely irrelevant, or full of dirty words and direct offenses. And before replying further (even on topic), read the FAQ reference posted by Marco.

One addition - if you believe that some post is not appropriate (impolite, off-topic, etc.), don't reply to it and use the link "Report to moderator" instead.
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: marcov on April 05, 2020, 11:12:44 pm
@marcov

Quote
You would have to rewrite the entire parser, and redesign the whole dialect. Possible, but not trivial.

This is a very patient and informative response to the OPs question.

I don't know if you are one of Lazarus' developers, but I'm going to take a blind guess and say you are (?).

No. I work on Free Pascal, and mostly in libraries, not the language. But I learned a thing or two about language (and language discussion) over the years.  Note this is mostly my opinion, but some parts (like C syntax having been suggested many times and categorically rejected) are facts.

The adding of random borrowings from other languages to official FPC is extremely unlikely, see the mentioned faq item.  Pure syntax rearrangements need not apply, since they only complicate and expand the dialect. Even if you would agree that a random syntax B is better than current syntax A (and usually we don't), having them BOTH (you need to keep A out of backwards compatibility) is even worse than having only the lesser one of them.

And no, having a compiler switch or dialect mode doesn't fix that, just look at the strange objfpc-Delphi mode split that is an artefact of such discussions that still persists 20 years later. In time it will only mean that the FPC codebases will become (even more) a patchwork of styles and dialects. That is more likely to send a newbie running for the hills than clean, Pascal syntax.

I would expect interesting solutions that might get a level further on the feature selection path to be more in the direction of co-routines/m*n light threading,  maybe tuples and multiple returns from functions in general. But even those need to be embedded in a framework to make a chance. A feature in isolation is rarely worth the trouble.

So no tired old 1970's C syntax, which has been proposed already roughly three times an year since 2000 and been roundly rejected every time..  Usually also paired with the same old transparent reason of "familiarity for newbies", while the net difference only covers the first half of the first page of a tutorial book. (and you can't even skip that half page entirely since the resulting hybrid would be subtly different anyway)

Most other arguments seem to be self-evident in nature and not particularly critical of the C block syntax in the first place (and concepts like Dangling else are over their head). And even C++ follows Modula2+Pascal by introducing a modular structure, only 40 years late.

And then there is the killer problem. Who is going to implement it? This is even a problem for an accepted solution, but even more for a controversial one (since even if you can show it to somewhat work, it might not be accepted).

There is no tin of developers that are just waiting for inspiration. Most devels have todo lists that keep them busy even after retirement.

Quote
It is nice that you are keeping in mind that most people who request a feature have absolutely no experience whatsoever in developing a parser or compiler. Even as long as I've been programming, I wouldn't pretend to know where to begin with customizing Free Pascal to my preferences, and I'm guessing (I could very easily be wrong here) the original poster wouldn't either. So, it is nice to see that you politely point out how much work it would take to implement his request rather than the often seen response given by others which equates to "Your feature request is stupid because we don't want it. Now go away!."

Well, above you have a verbose "stupid etc" bit.

However, the semicolon bit was different because it hadn't come up (seriously) before, and I misjudged the initial impact on the parser. It was way larger than I initially thought (thanks to Mark and Thaddy for discussing it). Initially I thought it would be solvable locally, e.g. just fixing the ELSE statements (e.g. by forcing always a block), but the straw that broke the camel's back is behaviour with incorrect code. You would really have to redo the most basic level of the scanner/parser.

And if you want to make/suggest language suggestions, you need to start playing with parser software or write your own one, so you can predict effects better. And when doing that it is important to persist, and implement the language as designed, and don't let the parser architecture (tool or handcrafted RD) tempt you in solving it the easy way. Then you very swiftly discover that implementing undetailed features that don't align with the language philosophy is hard, very hard.
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: ASBzone on April 06, 2020, 06:19:45 am
Hello,

I've just started learning Pascal. For the most part the syntax feels redundant or idk how to explain exactly. I'm sure some will get the idea
Now say that fpc is being written from the ground up as a new project, same language features, support etc, but just the syntax is more C-like. Would this bring a positive or a negative results?

The questions I always want to ask when these discussions come up are these:

1. If the perceived benefits of FPC are so small, that you would be distracted or discouraged by its lack of a more C-like syntax, what would cause you to embrace it if it did have such a syntax?

2. What is your dissatisfaction with the existing C-like languages that caused you to look for another language, yet desire it to be C-like?

3. Why is there this implication that popularity is the best measure of the success of a language?
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: PascalDragon on April 06, 2020, 09:19:02 am
The more I delve into Object Pascal the more I am finding it is not for me and will probably set it to the side, shortly. I like OP's verbosity, but there are many shortcomings in the language which make it inefficient as a commercial-level production language. Given the resistance by purists against evolving, OP will remain little more than a niche/hobby language.

That is your view and your view only. There are enough companies out there that use Object Pascal, be it with FPC or Delphi. Because if not, at least Delphi would no longer exist with it being a commercial - and in the higher editions quite expensive - tool. And regarding the language FPC and Delphi aren't that different, so everything that counts for/against Delphi counts for/against FPC as well (aside from a few language features that we don't support yet).

Also we're not against the language evolving, but we're against people shouting "look at feature X of language Y and implement that in FPC!!!!11". A new feature needs to be carefully evaluated whether it's something that really benefits the language or if it's simply the syntactic sugar of the day.

The exact same point is easily made regarding a feature requested by someone. If you like it - use it. If you don't like it - don't use it.

This statement is not correct in the general case either. I mean yes, if I don't want to use a certain feature I don't need to use it, but if I use third party code I at least need to be able to understand it. Let's assume a user who doesn't like to use interfaces. And now he has to use third party code that's heavily based on interfaces (and let's say that rewriting/reimplementing it is not feasible). Thus he'll at least need to understand how interfaces work, so he can use them correctly.
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: marcov on April 06, 2020, 09:50:53 am
That is your view and your view only. There are enough companies out there that use Object Pascal, be it with FPC or Delphi. Because if not, at least Delphi would no longer exist with it being a commercial - and in the higher editions quite expensive - tool.

With 25% discount the cheapest version it is Eur 1250 or so. Do we really still have to say "higher editions" :P

Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: GypsyPrince on April 06, 2020, 10:56:44 am
@PascalDragon

Quote
That is your view and your view only.

Well, that's not exactly a revelation, or at least it shouldn't be considering I wrote this as immediately following that statement:

Quote
Now... my personal finding of OP to be inefficient does not mean it is a bad language. Not at all. In fact, it is apparently a great language which many, many others find to be useful and efficient for their particular needs. My point is simply that while OP/Lazarus is perfect in fitting the needs of some, it does not meet the needs of some others.

So, your pointing out what I already said is an exercise in redundancy.

Quote
This statement is not correct in the general case either. I mean yes, if I don't want to use a certain feature I don't need to use it, but if I use third party code I at least need to be able to understand it. Let's assume a user who doesn't like to use interfaces. And now he has to use third party code that's heavily based on interfaces (and let's say that rewriting/reimplementing it is not feasible). Thus he'll at least need to understand how interfaces work, so he can use them correctly.

Yeah... this made absolutely no sense in the context of the point I was making. But rather, it actually re-enforces my point that if a tool doesn't work for his particular needs, he should feel free to pick another that does meet his needs.
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: marcov on April 06, 2020, 10:58:44 am
Quote
This statement is not correct in the general case either. I mean yes, if I don't want to use a certain feature I don't need to use it, but if I use third party code I at least need to be able to understand it. Let's assume a user who doesn't like to use interfaces. And now he has to use third party code that's heavily based on interfaces (and let's say that rewriting/reimplementing it is not feasible). Thus he'll at least need to understand how interfaces work, so he can use them correctly.

Yeah... this made absolutely no sense in the context of the point I was making. But rather, it actually re-enforces my point that if a tool doesn't work for his particular needs, he should feel free to pick another that does meet his needs.

Ok, try my phrasing of the same sentiment from the (long) post above:

Quote
And no, having a compiler switch or dialect mode doesn't fix that, just look at the strange objfpc-Delphi mode split that is an artefact of such discussions that still persists 20 years later. In time it will only mean that the FPC codebases will become (even more) a patchwork of styles and dialects. That is more likely to send a newbie running for the hills than clean, Pascal syntax.
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: GypsyPrince on April 06, 2020, 11:11:42 am
Quote
In time it will only mean that the FPC codebases will become (even more) a patchwork of styles and dialects. That is more likely to send a newbie running for the hills than clean, Pascal syntax.

I have to politely disagree, being that many far more mainstream languages than Pascal utilize a patchwork of styles and continue to attract newbies - i.e, JavaScript, PHP, C++ (though admittedly C++ has become an unhinged nightmare), etc.
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: marcov on April 06, 2020, 11:37:16 am
Quote
In time it will only mean that the FPC codebases will become (even more) a patchwork of styles and dialects. That is more likely to send a newbie running for the hills than clean, Pascal syntax.

I have to politely disagree, being that many far more mainstream languages than Pascal utilize a patchwork of styles and continue to attract newbies - i.e, JavaScript, PHP, C++ (though admittedly C++ has become an unhinged nightmare), etc.

It is different if you have some major backing, are the only option in the browser or are undisputed in some other way. IOW popular languages are mostly chosen because they are popular, not because their inherent properties. Even if they are "unhinged nightmares".

This is also why copying random syntax from those languages won't make you as popular.
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: jex on April 06, 2020, 01:09:33 pm
Ok, this has gotten bigger than what I anticipated.
To be clear about couple things, first I did NOT mean in any way this to be a "request" to the devs to change something. (That'd be completely silly imo). I wrote "discussion" in the title for a reason, I meant for this to be a mere discussion not a request or "ORDER" as I see some of you somehow received it to be that way.

I did NOT mean that pascal syntax sucks and needs to be buried etc (even if I do, it's only my opinion and as some has said, I can just move on)

What I wanted to discuss about is WHY pascal isn't that popular (anymore!). And I mentioned in particular the great possibilities that FPC/Lazarus provides and I was questioning if there's a known reason (or guesses as I've given my guess about syntax) as to why it isn't as "popular" as it should be (from my perspective, and possibly all of you fpc/laz users/fans).

To be even more clear when I brought syntax into topic, specifically the "C-like" syntax, I meant to mention that as a potential cause for that (?), as I said above, I was only guessing while making it a point for someone to clear it for me.

Simply this was not me just ranting about how I don't like the syntax etc, despite that I mentioned that the syntax is a bit 'wordy', but that wasn't my whole point I was trying to make.

Thanks to everyone who tried to answer my questions, Yes I was asking a question, not giving "facts" :)
Thanks to marcov's initial response I understood most of what I wanted to understand
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: munair on April 07, 2020, 07:59:20 am
Ooo...that's ugly :P
Really, if you want an unsafely typed language, don't pick Pascal family. The only high level language today that can't differentiate a boolean and integer are direct C descendants. The hybrids and those inspired from both (Go, Java) know the benefit and implement boolean properly as its own, distinct type from integer. It's easy to implement, yes. But developing a language is not a matter of implementing it easily, because if that's the case, just use Assembly.

Before C there was BASIC which also does not differentiate a boolean from an integer. In the early days BASIC did not even have a boolean type. I remember the CONST FALSE = 0 / TRUE = NOT FALSE programmer's construct which were just integers under the hood.

Pascal was designed to be an educational language, hence the choice to make it (very) strictly typed. Other than educational value there is no reason why booleans and numerical datatypes could not be interchanged. On assembly level they are all just bytes... Strictly typed languages typically produce more code because of the required explicit conversions, overloaded functions etc... While not a C programmer, I understand why the developers have chosen to leave the discipline to the programmer.
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: munair on April 07, 2020, 08:21:03 am
There is a new implementation of BASIC coming out around mid-summer which may be of interest to you.
Making it backwards compatible is building on the relics of the past which has a limiting, restricting effect. Free Pascal / Lazarus is a perfect example maintaining its Delphi compatibility.
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: 440bx on April 07, 2020, 08:40:23 am
.. there is no reason why booleans and numerical datatypes could not be interchanged.
No. Definitely not.  The truth value of a statement has nothing to do with numbers.   The same way that a number is a totally different thing than a character. 

On assembly level they are all just bytes...
Yes but, that is only because bits are not individually addressable.  That statement you made is also true for characters and it doesn't imply that because they are also represented as numbers that they should be treated as such.

Strictly typed languages typically produce more code because of the required explicit conversions, overloaded functions etc...
On the contrary.  A compiler for a strongly typed language can produce better code than it could for a "loosely" typed language and the reason is because, strong typing provides more information and more _accurate_ information which enables the optimizer to use algorithms that it could not safely use if it didn't have all that information.


Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: munair on April 07, 2020, 08:44:38 am
However, the semicolon bit was different because it hadn't come up (seriously) before, and I misjudged the initial impact on the parser. It was way larger than I initially thought (thanks to Mark and Thaddy for discussing it). Initially I thought it would be solvable locally, e.g. just fixing the ELSE statements (e.g. by forcing always a block), but the straw that broke the camel's back is behaviour with incorrect code. You would really have to redo the most basic level of the scanner/parser.
Has there ever been an established language that underwent such a dramatic change?
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: munair on April 07, 2020, 08:53:04 am
On the contrary.  A compiler for a strongly typed language can produce better code than it could for a "loosely" typed language and the reason is because, strong typing provides more information and more _accurate_ information which enables the optimizer to use algorithms that it could not safely use if it didn't have all that information.
Better code is not necessarily less/more efficient code. If safety is a requirement, then strictly typed languages are the way to go. Like I said, there is a reason why some language developers leave the discipline to the programmer. Assembly programmers can do things no one can in a higher level language and there is something to say for some of that freedom to shine through a higher level lang. In the end, it is all a matter of preference.
Yes but, that is only because bits are not individually addressable.  That statement you made is also true for characters and it doesn't imply that because they are also represented as numbers that they should be treated as such.
There is a clear difference between numerical and alphanumerical data, also on assembly level. Apart from the different numerical values between 0 and '0' there is the difference in addressing and data handling. Assembly has a whole range of instructions that specifically deal with character/string handling that assume specific registers to be set/initialized.
No. Definitely not.  The truth value of a statement has nothing to do with numbers.   The same way that a number is a totally different thing than a character. 
I disagree. It is convenient to treat an identifier as a boolean expression to see if it holds a non-zero value. In BASIC this is basic programming practice. If booleans have the highest priority in expressions, you don't end up with the restrictions found in languages such as Pascal. Think about it, every expression is potentially boolean until it turns out otherwise (math expression). This is a very natural approach and it doesn't require additional type checking.
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: PascalDragon on April 07, 2020, 09:37:25 am
@PascalDragon

Quote
That is your view and your view only.

Well, that's not exactly a revelation, or at least it shouldn't be considering I wrote this as immediately following that statement:

Quote
Now... my personal finding of OP to be inefficient does not mean it is a bad language. Not at all. In fact, it is apparently a great language which many, many others find to be useful and efficient for their particular needs. My point is simply that while OP/Lazarus is perfect in fitting the needs of some, it does not meet the needs of some others.

So, your pointing out what I already said is an exercise in redundancy.

Look again at what I quoted:

The more I delve into Object Pascal the more I am finding it is not for me and will probably set it to the side, shortly. I like OP's verbosity, but there are many shortcomings in the language which make it inefficient as a commercial-level production language. Given the resistance by purists against evolving, OP will remain little more than a niche/hobby language.

You made a general statement here. You did not say "in my opinion there are many shortcomings" or something like that. You stated generally that these "make it inefficient as a commercial-level production language". And that is simply not true.

Quote
This statement is not correct in the general case either. I mean yes, if I don't want to use a certain feature I don't need to use it, but if I use third party code I at least need to be able to understand it. Let's assume a user who doesn't like to use interfaces. And now he has to use third party code that's heavily based on interfaces (and let's say that rewriting/reimplementing it is not feasible). Thus he'll at least need to understand how interfaces work, so he can use them correctly.

Yeah... this made absolutely no sense in the context of the point I was making. But rather, it actually re-enforces my point that if a tool doesn't work for his particular needs, he should feel free to pick another that does meet his needs.

You stated that one does not need to use a feature if one does not want it. I (and marcov) explained why this isn't realistic.
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: marcov on April 07, 2020, 12:17:09 pm
Pascal was designed to be an educational language, hence the choice to make it (very) strictly typed.

Pascal was designed for development of algorithms in HLL and teach them to students. The audience to teach was mostly Math students close to their Masters, and compiler construction was also a real concern. Or after. In that they and age they were pretty much the only programmers.

It is not like Logo that was meant to teach children.

Quote
Other than educational value there is no reason why booleans and numerical datatypes could not be interchanged.

This is incorrect. Boolean and integer math are also separate, so heaping them together is not intuitive either.  So the question should be why they should be heaped together, something that probably has roots in minimizing code  of the first B and C compilers so it would fit in the memory of the mini computers they were using.

Note that new C99 boolean types follow the pascal definition more https://stackoverflow.com/questions/4767923/c99-boolean-data-type

Quote
On assembly level they are all just bytes...

So then why does C use int and not byte?

Quote
Strictly typed languages typically produce more code because of the required explicit conversions, overloaded functions etc... While not a C programmer, I understand why the developers have chosen to leave the discipline to the programmer.

Typecasts don't generate code, overloaded functions neither.  Don't let dumb C advocacy by newbies fool you. The reason that C compilers are fast is mostly the work put into C compilers, not the language itself.

So there are three aspects:


About size we can be simple. Making boolean the same size as integer is the most portable way. Nowadays that is best, but in the past it was often wasteful, which is why Turbo Pascal had it as 1-byte. Embedded systems often have booleans as "true" size, 1-bit, as they often have bitaddressable memory.

Convention is a matter of taste. Both conventions make sense. The C definition defines all values in a range, the Pascal definition (which forces 1=true) keeps that if A and B are both true, they are also binary the same, iow = is a binary operator.   As said C99 tries to acquire this property too for the "boolean" type, the old integer boolean is more or less legacy now.

Then the compatibility to int. I don't see any use advantage or reason, so it is IMHO just legacy from the early days of B/BCPL when C was mostly untyped

Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: marcov on April 07, 2020, 12:19:49 pm
Has there ever been an established language that underwent such a dramatic change?

BASIC had nearly everything done to it at some point. It is the most fragmented language I think.

The transition from interpreters with linenumbers to more compiled versions without (early to later Quck Basics and later VB) comes to mind, but I don't know the details well enough.

Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: munair on April 07, 2020, 12:58:44 pm
Boolean and integer math are also separate, so heaping them together is not intuitive either.  So the question should be why they should be heaped together, something that probably has roots in minimizing code  of the first B and C compilers so it would fit in the memory of the mini computers they were using.
It is not that they should be heaped together as a specific purpose. The question is, should booleans be strongly typed? What is the harm in for example:]http://sharpbasic.com/images/bool-01.png] (http://sharpbasic.com/images/bool-01.png)

Quote
So then why does C use int and not byte?
I was speaking of bytes in general regardless of word size. C is a bit peculiar in that it does not have a datatype called 'byte' but 'char' instead, and to make things more confusing arrays of chars instead of strings. It wouldn't be my first choice of language design.
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: munair on April 07, 2020, 01:23:36 pm
BASIC had nearly everything done to it at some point. It is the most fragmented language I think.

The transition from interpreters with linenumbers to more compiled versions without (early to later Quck Basics and later VB) comes to mind, but I don't know the details well enough.
With each 'upgrade' they became different languages altogether. GW-BASIC is not compatible with QuickBASIC. QuickBASIC 7.0 (PDS) was mostly compatible with QB 4.5 a notable difference being string addressing in the far heap. Visual Basic 1.0 (for DOS) was mostly compatible with PDS without graphical (text) UI. Visual Basic for Windows (up until 6.0) no longer supported DOS. Visual Basic .NET was a completely new language (not the best IMO).

Most of these upgrades are no different than the Pascal upgrades since the early 70s.
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: marcov on April 07, 2020, 02:53:46 pm
Boolean and integer math are also separate, so heaping them together is not intuitive either.  So the question should be why they should be heaped together, something that probably has roots in minimizing code  of the first B and C compilers so it would fit in the memory of the mini computers they were using.
It is not that they should be heaped together as a specific purpose. The question is, should booleans be strongly typed? What is the harm in for example:]http://sharpbasic.com/images/bool-01.png] (http://sharpbasic.com/images/bool-01.png)

Why should anything be strong typed? Why have typing at all. But you choose a certain model for a language, and then you stick to it. Pascal is already very forgiving in that it allows assignments of integers to real and random integer types to other integer types.

And it only leeds to unnecessary avenues for bugs. One could also invert the question and ask yourself if an extra typecast is so bad that one time you want to assign 42 to a boolean.
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: munair on April 07, 2020, 03:12:45 pm
Pascal is already very forgiving in that it allows assignments of integers to real and random integer types to other integer types.
Yet, it isn't forgiving in passing parameter types, like an integer argument to a word parameter. That is the kind of inconsistency that often prevents programmers from using such language.

Of course, there isn't any harm in requiring explicit cast, but what purpose does it serve other than wanting to notify the programmer that he may not know what he is doing? Why would a programmer have to always explicitly indicate what a compiler can do implicitly? That is the difference between strongly and weakly typed languages. I guess it will always be a matter of taste. Some prefer a compiler to force a programmer to discipline. Others prefer a compiler to allow more freedom (and creativity).
Quote
Why should anything be strong typed?
Actually, that is a very good question. Assembler doesn't know about types, not even about signed or unsigned. Higher level languages were invented to make things easier for the programmer. With those languages came philosophies, which, IMO were often taken too far.
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: Martin_fr on April 07, 2020, 03:18:18 pm
What is the harm in for example:]http://sharpbasic.com/images/bool-01.png] (http://sharpbasic.com/images/bool-01.png)

The harm would be that simple typos would no longer be rejected as error.
Code: Pascal  [Select][+][-]
  1. var
  2.   CurrentValue: Integer;
  3.   CurrentValid: Boolean;
  4. ....
  5. TempBool := CurrentValue; // typo: should be CurrentValid

Personally I am glad for every hour of debugging from which the compiler saves me.

And typing/reading/... a typecast where it is needed and wanted is much less effort that all the debugging that otherwise would be due.
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: munair on April 07, 2020, 03:31:43 pm
What is the harm in for example:]http://sharpbasic.com/images/bool-01.png] (http://sharpbasic.com/images/bool-01.png)

The harm would be that simple typos would no longer be rejected as error.
Code: Pascal  [Select][+][-]
  1. var
  2.   CurrentValue: Integer;
  3.   CurrentValid: Boolean;
  4. ....
  5. TempBool := CurrentValue; // typo: should be CurrentValid

Personally I am glad for every hour of debugging from which the compiler saves me.
I perfectly understand. Personally I love compilers that allow that kind of assignment. Instead of an error it could optionally throw a hint or warning at compile time as a debugging switch, just as is being done with uninitialized data (which also often lead to bugs which can be even less obvious than typos).
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: ASBzone on April 07, 2020, 04:36:48 pm
Yet, it isn't forgiving in passing parameter types, like an integer argument to a word parameter. That is the kind of inconsistency that often prevents programmers from using such language.

Programmers who want that kind of "flexibility" would be well advised to stay away from a strongly typed language -- just as I try to stay away from many apps written by programmers who love to exploit said "flexibility".

That smacks of poor planning, and a correspondingly higher number of bugs.
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: PascalDragon on April 08, 2020, 10:11:31 am
Pascal is already very forgiving in that it allows assignments of integers to real and random integer types to other integer types.
Yet, it isn't forgiving in passing parameter types, like an integer argument to a word parameter. That is the kind of inconsistency that often prevents programmers from using such language.

Huh? As long as you don't have a var, out or constref parameter (and these do have reasons) the language is very forgiving there:

Code: Pascal  [Select][+][-]
  1. procedure Test1(arg: LongInt);
  2. begin
  3. end;
  4.  
  5. procedure Test2(arg: Word);
  6. begin
  7. end;
  8.  
  9. var
  10.   l: LongInt;
  11.   w: Word;
  12. begin
  13.   Test1(l);
  14.   Test1(w);
  15.   Test2(l);
  16.   Test2(w);
  17. end.

Compiles without error...
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: munair on April 08, 2020, 10:34:41 am
Well, I stand corrected there. It's been a while since I programmed with FPC but I remember an issue where parameter passing with date variables raised a type mismatch. It was something with EncodeDate or something and types not compatible with words, if I remember correctly. It's been a while like I said, but I'll be sure to point it out when I come across this issue again.
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: PascalDragon on April 08, 2020, 10:51:22 am
Probably DecodeDateTime (https://www.freepascal.org/docs-html/current/rtl/dateutils/decodedatetime.html) and friends? In that case please take note that it's using out parameters which must be the same type, because it's essentially passing a pointer under the hood (which is why I excluded them in my list above).
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: munair on April 08, 2020, 10:59:18 am
Probably DecodeDateTime (https://www.freepascal.org/docs-html/current/rtl/dateutils/decodedatetime.html) and friends? In that case please take note that it's using out parameters which must be the same type, because it's essentially passing a pointer under the hood (which is why I excluded them in my list above).
That was probably the issue I ran into.
Title: Re: Discussion - What if fpc syntax becomes C-like?
Post by: munair on April 11, 2020, 04:16:34 pm
While the subject of loosely vs strictly typed is sensitive, it is something that can be easily overcome by a special directive. For example, the language I'm working on (which is loosely typed by default) supports the "option strict" directive to enforce strict typing when put at the top:http://sharpbasic.com/images/option_strict.png (http://sharpbasic.com/images/option_strict.png). It is probably not conform Pascal standards though.
TinyPortal © 2005-2018