Computer Science Teacher
Computer Science Teacher - Thoughts and Information from Alfred Thompson

September, 2011

  • Computer Science Teacher - Thoughts and Information from Alfred Thompson

    Readability in Programming Languages

    • 37 Comments

    I saw a side by side comparison of a bunch of scripting languages online recently. Scripting Languages: PHP, Perl, Python, Ruby My first, and second reaction was yuck! Now I have my biases – biases which may  not be shared by others of course. But I like readable code and for me anytime I see a special character (anything not an alphanumeric) it slows me down. This got me thinking about where we are going in design of programming languages? Are we moving forward (what ever that means) or backwards or just sideways?

    Back when I started programming close to 40 years ago the big three programming languages were FORTRAN and COBOL with an up an coming language called BASIC. FORTRAN (short for FORmula TRANSlation) was used by mathematicians (my math major brother had to learn it) and scientists. COBOL (the B stands for Business) was used for business applications. BASIC was a teaching/Learning language that was spreading into business. COBOL was both loved and hated by different people for its wordiness. But it was at least understandable. Take the loop below:

    PERFORM VARYING WS-BOTTLE-NUM FROM 98 BY -1
                   UNTIL WS-BOTTLE-NUM < 2
    END-PERFORM

    Pretty close to an English sentence. Compare that to this sample for a C-style language (C#)

    for (WSBOTTLENUM = 98; WSBOTTLENUM >= 2; WSBOTTLENUM--)
    {
    }

    Which one is more obvious? Pretend you are not an experienced programmer.

    BASIC (Visual Basic in this case) is somewhere in the middle.

    For WSBOTTLENUM = 98 To 1 Step -1
     
    Next

    The step – the counting down – is more easily understandable for me at least. Now let’s take a look at something very simple. k = i / 10;

    This drives beginners crazy. What’s going on here? Sure we programmers know but a lot of beginners struggle with which direction the operation is going. Compare that to the same code in COBOL

    divide i by 10 giving k

    Wordy? Sure, but at least even a beginner can read it. Now I am not arguing that we should all go back to COBOL though honestly with modern IDEs and features like Intellisence it would be a lot easier than it was back when I was typing out punch cards. Rather I am suggesting that beginner languages can and probably should be more wordy rather than more obscure – that English is easier to pick up than “what does # in this programming language mean?”

    Just for fun, if you want to see what different programming languages really look like visit the 99 Bottles of Beer site.

    This Website holds a collection of the Song 99 Bottles of Beer programmed in different programming languages. Actually the song is represented in 1434 different programming languages and variations.

    Somewhat related posts:


  • Computer Science Teacher - Thoughts and Information from Alfred Thompson

    Private Character Editor

    • 1 Comments

    I get questions. Oh boy do I get questions. I don’t know if people think I know a lot (I don’t) or if they think I can find out everything (I try and do have a reasonable success rate) or just don’t know who to ask but teachers (and some others) send me questions all the time. Especially for teachers I really try to get answers. And I welcome the questions. Coding questions are particularly fun. Questions about Microsoft products are often interesting because sometimes I hear about products I didn’t even know existed before. A day when you learn something new is a good day. So the other day when I received a question about the Private Character Editor was a good day.

    What is Private Character Editor? I had to look it up. From the documentation:

    You can use Private Character Editor to create your own characters, which you can then insert into documents by using Character Map. For more information about Character Map, see Using special characters (Character Map): frequently asked questions.

    BTW I also found this helpful little Use the Private Character Editor  tutorial that you may want to look at. It’s not an official Microsoft site so the usual caveats apply. But the question at hand was not about how to use the Private Character Editor but how to take the special private characters that had been created to other computers without reproducing them one by one on all the computers in a lab. So I started to play.

    image

    It turns out that creating your first character creates a file at C:\WINDOWS\FONTS\EUDC.TTE (there is also a .EUF file but I haven’t figured that out yet) Anyway. What I did was to copy the EUDC.TTE file from C:\WINDOWS\FONTS on my computer to other computer’s C:\WINDOWS\FONTS directories. You should see a message about installing the font when you do this. Once that happened I saw the option in the character map program like all the documentation shows.

    image

    I also see EUDC as a font in font lists but I’m not sure there is a reasonable way to get at the characters that way. I may try some thing's later but for now I am happy that I can get my special characters from the Character Map and move them to other computers for basically the work of a file copy.

    Note that you probably need administrator rights on the computers you are copying the file to. And I am not at all suggesting that this is completely supported but at least it worked on a couple of Windows 7 computers that I tried it on.



Page 6 of 6 (17 items) «23456