Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • June 23, 2017, 07:03:43 PM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Your First Programming Language vs Now  (Read 440 times)

wraith808

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 8,734
    • View Profile
    • Donate to Member
Your First Programming Language vs Now
« on: June 12, 2017, 10:09:06 PM »
In the thread Syntax in Different Programming Languages, I quoted this:

One of my best classes in college was a class called The Organization of Programming Languages.  It was taught by someone who was giving back time as a professional in the industry, rather than a professor.  Many years later, it is one of the only ones that sticks in my mind and that I use.  I've gone from and to many different languages - Pascal to VB to C to C++ to Delphi to C# (and I currently dabble in a few others).  The syntax has never been the problem.  You can always find syntax.  It's the data structures and memory management and such that are always the sticking point.  If you can get those, you can rapidly move from one language to another with a minimum of difficulty.

I came across that thread recently, and equated it to a thread on a different board, and figured I'd pose an exercise here.

  • What was your first programming language? 
  • Can you remember a snippet from that language? 
  • What's your current language of choice? 
  • How would you rewrite that snippet in your current language?

My Answers are:

  • AppleBasic
  • Yes
  • C#
  • Yes

Code: Visual Basic [Select]
  1. 10 PRINT CHR(21): DIM CARDS(52),CHECK(52)
  2. 20 SUIT$ = "CDHS"
  3. 30 N$ = IA23456789TJQK"
  4. 40 FOR S = 0 TO 3: FOR C = 1 TO 13:CARD(C + S * 13) = MID$ (N$,C,1) + MID$ (SUIT$,S + 1,1): NEXT: NEXT
  5. 45 TEXT: HOME : NORMAL
  6. 50 FOR X = 1 TO 52
  7. 55 XX = X - 1: VTAB 1 + XX - INT (XX / 13) * 13: HTAB 1 + 10 * INT (XX / 13)
  8. 60 PRINT SPC( X < 10);X;I:";
  9. 70 N = INT ( RND (1) * 52) + 1
  10. 80 IF CHECK(N) THEN 70
  11. 90 CHECK(N) = 1
  12. 100 INVERSE: PRINT CARD$(N);
  13. 105 NORMAL: PRINT SPC( 5)
  14. 110 NEXT X

One of the interesting things about AppleBASIC is that you can have multiple commands on the same line.  Trying to put this into c# wasn't as easy as I thought.  There's still a bug somewhere in my code, and I know it looks messy, but I didn't want to put too much time into this.

Code: C# [Select]
  1. "\n".Dump();
  2. string[] cards = new string[52];
  3. int[] check = new int[52];
  4. const string SUIT = "CDHS";
  5. string N = "IA23456789TJQK";
  6. Random rnd = new Random();
  7.  
  8. for (int S = 0; S  < 3; S ++)
  9. {
  10.         for (int C = 1; C < 13; C++)
  11.         {
  12.                 cards[C + S * 13] = Microsoft.VisualBasic.Strings.Mid (N,C,1) + Microsoft.VisualBasic.Strings.Mid (SUIT,S + 1,1);
  13.         }
  14. }
  15.  
  16. for (int X = 1; X < 52; X++)
  17. {
  18.         check[X] = 0;
  19. }
  20.  
  21. for (int X = 1; X < 52; X++)
  22. {
  23.         int cardPos;
  24.         while (1==1)
  25.         {
  26.                 cardPos = rnd.Next(52);
  27.                 if (check[cardPos] == 0)
  28.                 {
  29.                         check[cardPos] = 1;
  30.                         cards[cardPos].Dump();
  31.                         break;
  32.                 }
  33.         }
  34. }

It runs, and pulls the shuffled cards- but there are nulls in there for some reason.  I also skipped over the formatting code, as I wasn't going to try to do that in the console.

Anyone else want to take a stab?

ConstanceJill

  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 100
    • View Profile
    • Donate to Member
Re: Your First Programming Language vs Now
« Reply #1 on: June 13, 2017, 12:07:31 AM »
    How would you rewrite that snippet in your current language?
[…]
    Yes
O_o?

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 37,130
    • View Profile
    • Donate to Member
Re: Your First Programming Language vs Now
« Reply #2 on: June 13, 2017, 01:40:51 AM »
My first language was BASIC, learned from some wonderful books and coded on a Cromemco Z-2D in the late 1970s.
The biggest shift for me was moving from non object-oriented programming language to an object-oriented programming (OOP) language... I feel like OOP was such a revolution in terms of changing the way I think of code and organization of ideas, that it has had broad ramification in my entire thinking pattern outside of programming..

anandcoral

  • Honorary Member
  • Joined in 2009
  • **
  • Posts: 454
    • View Profile
    • Donate to Member
Re: Your First Programming Language vs Now
« Reply #3 on: June 13, 2017, 02:11:20 AM »
I too started in Basic, i.e. Basic in MS Dos 2.0. Got BASICA in Dos 3.0 then GWBasic and so on. For job I had to learn dBase III but I used the logic of Basic to create my first program in dBase III.

Now working in Xbase++, upgraded from FoxPro, my mind still works in Basic and converts the codes in required language :)

Regards,

Anand

x16wda

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 697
    • View Profile
    • Donate to Member
Re: Your First Programming Language vs Now
« Reply #4 on: June 13, 2017, 05:42:25 AM »
Basic was pretty universal as a learning language back in the day. My first PC was a Timex Sinclair ZX81 which was cool but limiting - and I think the whole language was snippets. :P Upgraded to an Atari 400 and started playing with 6502 coding, then an Atari ST and 68000. By then I was a systems programmer on a mainframe so I started doing some assembly on that beast (IEFBR14, anyone?) but mostly building user interface stuff for ISPF in Clist and Rexx  :Thmbsup:. These days 95% of what I write is utilities in Rexx, since it runs everywhere. And trying to pick up a little Powershell because it does some really cool stuff too.

wraith808

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 8,734
    • View Profile
    • Donate to Member
Re: Your First Programming Language vs Now
« Reply #5 on: June 13, 2017, 07:53:39 AM »
    How would you rewrite that snippet in your current language?
[…]
    Yes
O_o?

I would think that since the rest of the post is the actual doing of that, one could overlook that word's inclusion.  :P

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,491
    • View Profile
    • Donate to Member
Re: Your First Programming Language vs Now
« Reply #6 on: June 13, 2017, 11:28:10 AM »
My first programs were written in GWBasic.  The first one that was actually useful was just a console program with a menu to calculate how much of each ingredient to put in the mix to conjure up this hot glue we had to mix for test batches at the research lab where I worked.  You could put in the weight of any ingredient or the total weight you wanted to produce of the glue.  We were doing it using a calculator.  Fortunately the PC in work also had a 5 1/4" floppy so I could run my program.  It was just faster and more convenient to hit a menu number then type in an amount.  Since the ratios never changed I never had to update the code.

Then I did the QuickBasic 3.0 compiler before moving on to Turbo Pascal, C and assembler.  Eventually C became C++.  Most small hotkey type utilities now I do in AHK and/or AutoIt3.  Now and then I try to keep my hand in with something C++ to keep up on the language changes.

Ironically I tried the freeBasic compiler for a time.  It has so many compatibility modes to let you compile code be it comma function call style or with parens.  I had a hell of a time just making basic(no pun intended) WinAPI calls as I could not seem to get my head around the external declarations.  Just too frustrating.

My older brother worked for DEC and showed me a few things in Pascal.  At the time the conventional wisdom was "structured programming."  When OOP came out at first I thought it was no biggie.  Just another wrinkle added onto structured programming.  My brother thought it was a "scam" and dismissed it.  When I got the idea of OOP I convinced him it was not just some new jargon to sell new textbooks but had a lot of power.  When I gave a few hypotheticals how polymorphism could be applied he saw the potential and got into C++.

But I was never an application programmer.  I identify more with Leo LaPorte because he went through a similar journey.  He learned several programming languages including assembler just to learn how computers worked and write his own utilities.  But he never cranked out code for a living.


Deozaan

  • Charter Member
  • Joined in 2006
  • ***
  • Points: 1
  • Posts: 7,934
    • View Profile
    • Donate to Member
Re: Your First Programming Language vs Now
« Reply #7 on: June 19, 2017, 01:03:15 AM »
    How would you rewrite that snippet in your current language?
[…]
    Yes
O_o?
I would think that since the rest of the post is the actual doing of that, one could overlook that word's inclusion.  :P

Programmers aren't often in the habit of overlooking semantic details. In fact, they are highly trained to seek them out. This is how you bug-hunt.  :P