Re: Becoming a computer programmer

Also, another thing you need to consider is the more than 600 programming languages out there. You need to decide on a starter language--a language which will get you going.
The problem with new computer programmers is they are not used to the way programming languages function. I am a computer programmer myself (I self-taught myself) and it is better to get used to the symbols, words, abbreviations, characters, and other symbolic patterns--called tokens--programming languages use. You don't need to know how tokens are processed, unless you want to write a new computer language yourself, which is an extremely daunting and difficult task. (Other programmers will disagree with me on that one.)
Special symbols that computer languages use include, but are not limited to:

  1. Foreign-language symbols (†, ေေ‴, ɖ, ŀ, etc.)

  2. Special symbols (#, $, [ a-t ], ., ', ", :, {, }, ,, etc.)

  3. Special symbol combinations (//, /*...*/, ? :, ::, ##, [ a-t ][ a-t ], $$, &&, <<, >>, <, >, <=, >=, ||, ~, etc.)

Below is some examples in various computer languages:
Visual Basic:
The following code snippet displays a message box saying "Hello, World!" as the window loads:
Private Sub Form_Load()
    ' Execute a simple message box that says "Hello, World!"
    MsgBox "Hello, World!"
End Sub
This snippet makes a counter that moves up 1 every second (a label and a timer control need to be added to the form for this to work) until the form is closed or an integer overflow occurs:
Option Explicit
Dim Count As Integer
Private Sub Form_Load()
    Count = 0
    Timer1.Interval = 1000 ' units of milliseconds
End Sub
Private Sub Timer1_Timer()
    Count = Count + 1
    Label1.Caption = Count
End Sub
The following is a very simple VB.NET program, a version of the classic "Hello world" example created as a console application:
Module Module1

    Sub Main()
        ' The classic "Hello World" demonstration program
        Console.WriteLine("Hello World")
    End Sub

End Module
It prints "Hello, world!" on a command-line window.
This piece of code is a solution to Floyd's Triangle:
Imports System.Console

Module Program

    Sub Main()
        Dim rows As Integer

        ' Input validation.
        Do Until Integer.TryParse(ReadLine("Enter a value for how many rows to be displayed: "),
rows) AndAlso rows >= 1
            WriteLine("Allowed range is 1 and {0}", Integer.MaxValue)
        Loop

        ' Output of Floyd's Triangle
        Dim current = 1

        For row = 1 To rows
            For column = 1 To row
                Write("{0,-2} ", current)
                current += 1
            Next

            WriteLine()
        Next
    End Sub

    ''' <summary>
    ''' Shadows Console.ReadLine with a version which takes a prompt string.
    ''' </summary>
    Function ReadLine(Optional prompt As String = Nothing) As String
        If prompt IsNot Nothing Then
            Write(prompt)
        End If

        Return Console.ReadLine()
    End Function

End Module
Dylan:
A simple class with several slots:
define class <point> (<object>)
  slot point-x :: <integer>,
    required-init-keyword: x:;
  slot point-y :: <integer>,
    required-init-keyword: y:;
end class <point>;

  • By convention all classes are named with angle brackets. This is just a convention. The class could be named "Point", but that is never done. (Note that Dylan is not case sensitive.)

  • In "end class <point>" both "class" and "<point>" are optional. This is true for all "end clauses". For example, you may write "end if" or just "end" to terminate an "if" statement.

The same class, rewritten in the most minimal way possible:
define class <point> (<object>)
  slot point-x;
  slot point-y;
end;

  • The slots are now both typed as <object>.

  • The slots must be initialized manually.

define constant $pi :: <double-float> = 3.1415927d0;

  • By convention constant names begin with "$".

A factorial function:
define function factorial (n :: <integer>) => (n! :: <integer>)
  case
    n < 0     => error("Can't take factorial of negative integer: %d\n", n);
    n = 0     => 1;
    otherwise => n * factorial(n - 1);
  end
end;

  • There is no explicit "return" statement. The result of a method or function is the last _expression_ evaluated. It is a common style to leave off the semicolon after an _expression_ in return position.

  • Identifiers in Dylan may contain more "special" characters than most language. "n!" and "<integer>" are just normal identifiers. If there is any ambiguity, whitespace is used.

  • Statements such as "if" and "for" end with the keyword "end" but may optionally be written as "end if" or "end for".

Originally, Dylan used a Lisp-like prefix syntax, which is based on s-expressions:
(bind ((radius 5)
        (circumference (* 2 $pi radius)))
   (if (> circumference 42)
       (format-out "Hello big circle! c is %=" circumference)
       (format-out "Hello circle! c is %=" circumference)))
By the time the language design was completed, it was changed to an Algol-like syntax, with the expectation that it would be more familiar to a wider audience of programmers.
C:
#include <stdio.h>
int main ()
{
printf ("Hello, world! \n");
return 0;
}
This does the same thing as the VB and VB.NET ones do accept that it uses the console
C++:
#include <iostream>
using namespace std;
int main ()
{
cout << "Hello, world!" << endl;
return 0;
}
C#:
The following is a very simple C# program, a version of the classic "Hello world" example:
using System;

class Program
{
    static void Main()
    {
        Console.WriteLine("Hello, world!");
    }
}
The effect is to write the following text to the output console:
Hello, world!
Each line has a purpose:
using System;
The above line of code tells the compiler to use System as a candidate prefix for types used in the source code. In this case, when the compiler sees use of the Console type later in the source code, it tries to find a type named Console, first in the current assembly, followed by all referenced assemblies. In this case the compiler fails to find such a type, since the name of the type is actually System.Console. The compiler then attempts to find a type named System.Console by using the System prefix from the using statement, and this time it succeeds. The using statement allows the programmer to state all candidate prefixes to use during compilation instead of always using full type names.
class Program
Above is a class definition. Everything between the following pair of braces describes Program.
static void Main()
This declares the class member method where the program begins execution. The .NET runtime calls the Main method. (Note: Main may also be called from elsewhere, like any other method, e.g. from another method of Program.) The static keyword makes the method accessible without an instance of Program. Each console application's Main entry point must be declared static. Otherwise, the program would require an instance, but any instance would require a program. To avoid that irresolvable circular dependency, C# compilers processing console applications (like that above) report an error, if there is no static Main method. The void keyword declares that Main has no return value.
Console.WriteLine("Hello, world!");
This line writes the output. Console is a static class in the System namespace. It provides an interface to the standard input, output, and error streams for console applications. The program calls the Console method WriteLine, which displays on the console a line with the argument, the string "Hello world!".
A GUI example:
using System.Windows.Forms;

class Program
{
    static void Main()
    {
        MessageBox.Show("Hello, world!");
    }
}
This example is similar to the previous example, except that it generates a dialog box that contains the message "Hello, world!" instead of writing it to the console.
There are many more programming languages--see this Wikipedia article to chose one that you like. Not all of them have examples though, so you'll have to dig around. also, visit Rosetta Code to find thousands of examples in almost every programming language in existence.

_______________________________________________
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Off-topic room : Cody_91 via Audiogames-reflector
    • ... AudioGames . net Forum — Off-topic room : magurp244 via Audiogames-reflector
    • ... AudioGames . net Forum — Off-topic room : Victorious via Audiogames-reflector
    • ... AudioGames . net Forum — Off-topic room : Cody_91 via Audiogames-reflector
    • ... AudioGames . net Forum — Off-topic room : Victorious via Audiogames-reflector
    • ... AudioGames . net Forum — Off-topic room : Theo via Audiogames-reflector
    • ... AudioGames . net Forum — Off-topic room : Victorious via Audiogames-reflector
    • ... AudioGames . net Forum — Off-topic room : Ethin via Audiogames-reflector
    • ... AudioGames . net Forum — Off-topic room : magurp244 via Audiogames-reflector
    • ... AudioGames . net Forum — Off-topic room : Ethin via Audiogames-reflector
    • ... AudioGames . net Forum — Off-topic room : magurp244 via Audiogames-reflector
    • ... AudioGames . net Forum — Off-topic room : Theo via Audiogames-reflector
    • ... AudioGames . net Forum — Off-topic room : Blademan via Audiogames-reflector
    • ... AudioGames . net Forum — Off-topic room : Blademan via Audiogames-reflector
    • ... AudioGames . net Forum — Off-topic room : Theo via Audiogames-reflector

Reply via email to