A r t i c l e s
Navigation

Note: This Wiki is
outdated, personal views
may have changed.
L505 A.I. bot is dead
long live THX 1138

M a i n P a g e

D i r e c t o r y

Pascal is Too Verbose


Why do modern pascal programmers use things like:
  var
    s: string;
Shouldn't they instead be more verbose and use this:
  variable
    s: ansistring;
After all, "var" is not specific. Also, the ansistring is what we use in our programs, not a 'string'. Using 'string' can cause bugs in software if ansistring compiler switch is off. Using 'string' also confuses people since 'string' is overloaded to mean many many many things. It can mean shortstring, longstring, ansistring. Most people don't even know what a longstring is... they think it is an ansistring but it is not.

Why has MODE OBJFPC now allowed removal of the OVERLOAD keyword for overloaded procedures in freepascal? Programmres too lazy to type out the word overload?

Why are freepascal command line options like this:

  -Fi
  -Fu
  -FU
Too lazy to type out:
  -FINCLUDE
  -FUNITSEARCHPATH
  -FUNITBUILDPATH
Why is -FU and -Fu different, if Pascal is case insensitive?

The truth is, modern pascal programmers are liars. They say verbosity is good, but then they contradict themselves by using things like 'string' instead of 'ansistring'.

The problem with typing out the long word 'ansistring' is that the code starts to get really cluttered really fast. Consider this declaration:

  procedure DoSomething(const input: ansistring; const substring: ansistring; 
    const index: integer);

Above is a ridiculously long declaration just to do something simple. So what do Pascal programmers subconsiously do? They like to shorten and make the above declaration terser when they can:

  procedure DoSomething(input, sub: string; idx: integer);
Using commas and shortening 'ansistring' to 'string' makes the code shorter and less cluttered. Yet it does the same thing as the first longer DoSomething declaration. Pascal programmers are always arguing that verbosity and the amount of time you spend typing isn't important in programming. This is total nonsense, since every Pascal programmer I know always tries to make things shorter wherever possible. Not neccessarily so short that it becomes unreadable like this:
{
  cout("what is cout? pout?");
}
But Pascal programmers do lie and they make ridiculous fanboyish comments about why verbosity is good. What they really mean (they just don't know) is that a certain amount of terseness is good.. and a certain amount of verbosity is good. But the ones who think that verbosity is king and that anything which is verbose is good.. are on crack.

Overloading is another area where pascal programmers are doing syntax shorcuts:

  procedure test(s: string);
  procedure test(i: integer);
  procedure test(s: string; i: integer);
Why not instead be a true Verbose fanboy and do it properly?
  procedure TestAsString(s: string);
  procedure TestAsInteger(i: integer);
  procedure TestAsStringInteger(s: string; i: integer);
Or alternatively:
  procedure Test_String(s: string);
  procedure Test_Integer(i: integer);
  procedure Test_StringInteger(s: string; i: integer);
Or alternatively:
  procedure Test_Ansistring(s: ansistring);
  procedure Test_Integer(i: integer);
  procedure Test_AnsistringInteger(s: ansistring; i: integer);
The answer: because pascal programmers are liars. They don't have a clue as to what they are talking about. Basically, programming is something that is done emotionally and programmers rarely go into deeper reasons why we psychologically choose the syntax we choose.

Personally, when I'm whipping up some algorithms and I'm trying to drink herbal tea or eat something with one hand.. I do kind of get sick and tired of Ada/Pascal verbosity. Not sick and tired enough that I'd change languages.. but sick and tired enough that I sometimes really just have a craving to do this:

unit someunit

iface

  pro Test(s: astring);
  fun SomeFunc(s: astring): boolean;

code

  pro Test(s: astring);
  c SOME_TEXT = 'just a test';
    OTHER_CONST = 'just a string constant';
  v moretext: astring;
    another: astring;
  b 
    ln('this is a test');
    ln(SOME_TEXT);
    ln('and whatnot');
    moretext := moretext + ' text!';
  e;

  fun SomeFunc(s: astring): bool;
  b 
    result := false;
    ln('some function');
  e;
  
e.
And don't tell me that the above code is now unreadable and that there are absolutely no advantages to it. With syntax highlighting it is just as readable as pascal.. just less cluttered, which in many cases means more readable.

In small code snippets the above code is nice and short and to the point.. but in big snippets it becomes more readable especially with long procedure declarations that start to span across the screen. It also becomes more readable when you have plenty of begin/end's everywhere but not much code (i.e. lines of useless verbose clutter). This means the above syntax benefits both small one off hacks and long term big code snippets. And you thought it was just good for one off hacks.. wrongo bongo! Clutter doesn't help large snippets of code. Neither do Java typecasts, which is essentially proof in fact that verbosity does not equal readability.

Don't believe me? Think I'm full of it? Then look at this mess:

  function SomeLongFunction(var manyparams: ansistring; 
    const param: TSomeSpecialClass): boolean;
  const 
    SOME_CONST = 5363;
  begin
    // stuff here
  end;
On large projects this always happens. Functions and parameter lists span wider. Remaining within the 80 column barrier keeps code cleaner. But for creeps sake, you don't want to be splitting all your functions up to multiple lines for every darn function which has VAR, CONST, and ansistring keywords in its declaration.

In the above declaration it is confusing as to whether the CONST parameter on the second line is a const declaration inside the function, or an actual const parameter as part of the function. So wherever possible, we want to not split up functions into multiple lines if we can avoid it by remaining within the 80 column barrier. Some programmers refuse to use the 80 column barrier because of language verbosity on large projects.. and they just widen their window on their screen. Again they are fighting pascal's verbosity a bit subconsciously and are not sure what to do about it, so they give up.

With Begin, End, Const, and Var keywords shortened to one letter, you don't have effed up source code like this:

  function somefunc(input: ansistring): boolean;
  var somestring: ansistring;
   another: ansistring;
   andanother: ansistring;
  const SOME_CONST = 603;
    ANOTHER_CONST = 752;
    ONEMORE_CONST = 752;
  begin  result = false;
     writeln('some function');
  end;
Do you see how much time programmers waste trying to line up their source code on the screen? The above code doesn't line up, so we have to put it on multiple lines.. which is OKAY in large projects.. but kind of annoying as heak when you start to realize how much arthritis you are going to have for whipping up one of the quick algorithms on your mind that you have to get off your chest right now at this moment.

So, pascal programmers, in order to make their code really neat, must increase the verbosity further by putting everything on more than one line:

  function somefunc(input: ansistring): boolean;
  var 
   somestring: ansistring;
   another: ansistring;
   andanother: ansistring;
  const 
    SOME_CONST = 603;
    ANOTHER_CONST = 752;
    ONEMORE_CONST = 752;
  begin  
     result = false;
     writeln('some function');
  end;
Or you could do something absolutely hideous and ugly like this:
(Linus Torvalds Loves Eight Space Indentation, idiot)
  function somefunc(input: ansistring): boolean;
          var        
                     somestring: ansistring;
                     another: ansistring;
                     andanother: ansistring;
          const 
                     SOME_CONST = 603;
                     ANOTHER_CONST = 752;
                     ONEMORE_CONST = 752;

          begin      
                     result = false;
                     writeln('some function');
          end; {somefunc}
And that's great.. but look at what the above function does? Nothing. Absolutely nothing. It is a useless function. You've spent all this time effing around lining things up and you haven't even written any algorithms yet. By this time, your fingers are a bit sore.. and you're thinking to yourself 'yeah, verbosity doesn't matter.. I mean, it's the algorithms that count'.

In reality, your fingers and your chemicals in your brain are saying something completely different. They're saying 'why do I have to tie my shoes three times each time I get out of bed to make breakfast, why can't I just get some slippers?'. It's bad enough having to tie your shoes ONCE. We are always looking for solutions that make our lives easier.. and unfortunately it's not just about algorithms.. it's also about stress, brain chemicals, and clutter.

Verbosity, whether you like it or not, can add ridiculous clutter to a simple piece of code.

Consider that you had no PLUS or MINUS signs:

  567 ADDITION TO 464 ADDITION TO 634;
Versus:
  567 + 464 + 634;

Let's add CAPS LOCK to the Keywords

And finally, you've got people like Niklaus Wirth who continue to use CAPS LOCK for keywords in his latest languages (and it is forced on you, since Modula/Oberon are case sensitive).

Caps lock reserved words mean that you have to put the CAPS LOCK on or use the SHIFT KEY each time you want to type a reserved word.. which is unbearable.

  PROCEDURE SomeThing;
  BEGIN
    WriteLine('Caps Lock is stupid Niklaus, we have Syntax Highlighting now');
  END.
This really hurts my arm and fingers.. and I'm not exaggerating. Try typing this stuff for a while and you will quickly either deny that its horrible or you will quickly admit what your brain really wants to try out some other language, since this one sucks.

The Human Brain

It isn't that keyboard typing takes a bit more time.. its that our human brain is wired from evolution to avoid stress. You don't tie your shoes three times after you put them on if you don't have to, even if tying the shoes theoretically doesn't take that much time. Some people even use sandals and slippers. But why? Because we can, and it is more enjoyable to have something convenient available.. instead of something that makes life stressful.

Whether or not tying laces on slippers takes that much more time than just slipping them directly on is irrelevant. What matters is how our brain is wired from evolution. Just like it doesn't take that much more time to allocate memory yourself and free and create ansistrings.. but instead people are lazy and choose the reference counter/garbage collection since we can. And using reference counted strings also means less free/create code bloat verbosity. There it is again.. pascal programmers avoiding verbosity again. Liars (did I say Lars?).

Use Your IDE and Stop Complaining

Anyone that says "but you can use code completion and set up your IDE" is missing my point. Or "you can remap your keyboard so that the 'B' key types out the word 'BEGIN' for you.

Why would you do that, if it doesn't take that much extra time to just type everything out manually with your hands? Why would you go to all that work to set up your IDE (and all your text editors, and other people's computers that you use) if typing and keywords are of such little importance?

Ironically, the people who set up their IDE's with training wheels and keyboards shortcuts are proving my point that verbosity and hand typing does matter in programming languages. If setting up your IDE is so easy to do and it solves all your problems then good for you. I hate doing that and I never rely on my IDE to type out begin/end for me or for loops or while loops. That is simply false productivity. It's waste of time and a hyped scam sold by people like Borland who say ridiculous things like 'Buy Delphi 2006 because it contains a new feature that types Begin and End for you automatically!'. Can I say, effing Idiotic?

That doesn't reduce the clutter in your source files! And it causes your brain to memorize all sorts of hard to remember shortcut keys just to have begin/end and appear on the screen for you. That's no better than just typing it out yourself. It's all marketing nonsense.

Look at my 'ansistring' vs 'string' argument at the top of the article to see what I mean about clutter issues with verbosity. Plus, real programmers don't want to spend time effing around with their $4052.00 IDE all day long trying to make it do work for us. In reality we the experienced programmers know that its quicker for us just to put the code down ourselves because sometimes the IDE training wheels get in our way and do things we don't want them to do. Other unexperienced programmers and managers buy into tools like Delphi for thousands of dollars each time a new version comes out, because it supposedly does all the coding for you with one keyboard shortcut (and UML diagrams).

Turn off Much Of the IDE Crap

In EditPlus and my IDE's, I turn OFF automatic indenting because many times it gets in my way. I turn off automatic brace closing or begin/end closing because that often gets in my way too. I turn off curled bracket closing too as that very often gets in my way. The training wheels and dialog windows in IDE's don't work when we have to SSH/Telnet into some server without an IDE too.

(Yes, I know you can use text mode FP-IDE over SSH/Telnet, but I can also use midnight commander as my window manager instead of using Windows or KDE or Gnome.. yeah yeah I've heard it all before.)

(And yes, I do use some IDE tools like for example the code insight to peak into classes, units, or records.. but that isn't the point. I also use CTRL-F1 to find help and I set up tools menu items for Lufdoc help. I also use syntax highlighting which is a nice IDE feature. But again, that's not the point I'm making.)

So don't come in and start shouting 'all you have to do is set up your IDE to have CTRL-B type out 'begin' for you and CTRL-E type out 'end;' for you. Because the CTRL key hurts my pinky finger and is just about as annoying to type as the full begin word, and I hate IDE training wheels. So that isn't a solution. And again, it does not solve the clutter problem I mentioned.

Plus, setting up keyboard shortcuts quickly leads to problems when keyboard shortcuts start conflicting which each other.. i.e. I want the CTRL-F or ALT-F maybe for some FIND tool.. so if I set it up to punch out a FOR loop for me I'm in deep trouble. Or maybe CTRL-F launches the freepascal compiler at the command line. I definitely don't want to hit CTRL-ALT-SHIFT-F to have my IDE type out a FOR loop, because that defeats the whole purpose of a keyboard shortcut.

IDE keyboard shortcuts, automatic code completion, automatic begin/end completion, bracket completion.. and all that other IDE training wheels shit that Borland tried to sell you becomes harder to type and memorize than actual code itself! Have you ever tried taking a shortcut in a car only to find out that the shortcut has more stop signs and lower speed limits than the four lane highway?

About
Note: This Wiki is outdated, personal views may have changed.

This wiki contains info on life, health, humans, nature, programming, database, fads, paradigms, poems, principles, theories.

Articles may contain statements which some may find helpful and encouraging, or even discouraging.

Beware, I believe in the Grand Justice system.
_ _ _