You can edit almost every page by Creating an account. Otherwise, see the FAQ.

G Sharp (programming language)

From EverybodyWiki Bios & Wiki


G#
ParadigmRule-based
Designed byDanny Betancourt
DeveloperDanny Betancourt
First appeared2019; 5 years ago (2019)
Stable release
0.1 / May 1, 2019; 5 years ago (2019-05-01)
Typing disciplinestatic, dynamic, strong
PlatformCommon Language Infrastructure
Filename extensions.gs
Websitewww.gsharp.dev
Influenced by
C#, F#, Occam-π, Go, Forth

Search G Sharp (programming language) on Amazon.

G#[lower-alpha 1] (pronounced G sharp) is a programming language and the principle language of the A Major robotics integrated development environment. Though specifically designed to interact with hardware, it has all the basic functionality to make it a general purpose language.

Design goals[edit]

The primary goal of this language is to provide people with a friendly introduction to robotics routine programming. It makes use of .NET Core's Common Language Infrastructure to allow interoperability between G#, C#, and F#. The purpose being that G# can focus entirely on communication with hardware components (by way of an Arduino board) while leveraging the strengths of C# and F# to handle more general purpose and advanced features on the user/system side.

The syntax of G#, therefore, is simplified so it's easier for beginners to make sense of. For example, the standard string type has been renamed text. Similarly, many of the library imports are handled automatically by the Compiler. An output to the screen is accomplished by invoking the output method without specifically calling out to the System namespace. The main advanced feature G# is designed to take advantage is that of concurrency so multiple components can move fluidly.

Name[edit]

The name G# and the IDE it's a part of are both inspired by music theory. In the A major scale there are exactly three sharps: C#, F#, and G#. It was a straightforward conclusion to create the missing G# in .NET Core's ecosystem and name the new IDE A Major.

The music scale also refers to G# as the leading tone. Mirroring that, G# stands out from C# and F# by prioritizing something the other two don't; that being the focus on the rule-based paradigm and distributed execution.

Syntax[edit]

The syntax naturally draws heavy inspiration from both C# and F#, but an emphasis has been placed on promoting instant understanding by new programmers. Where helpful, shared concepts were given a new name for this purpose.

The minimum required structure is:

container Main

Main() =

{

}

The compiler seeks this Main container and then the subsequent Main function to serve as its entry point. There is little boilerplate while still introducing a clear organization of the code.

A number of elements were brought over from C# and F# to promote familiarity. Those include C#'s if, while, do while, and case constructs. F# has contributed its version of the for loop and its |> operator for the purposes of type casting. There's also standard use of the +, -, *, /, and % operators without / performing floating point division.

The compiler attempts to infer as much as possible so developers won't have to worry too much about types. Even when types must be explicit, the type system has been simplified to promote unity. G#'s supported types include number, text, boolean, object, and dynamic. The compiler handles storing and using numeric values and offers a dynamic type to mimic an interpreted language. When possible, casting is automatic based on context.

At any point in the program, blocks may be written with built-in keywords to execute C# and F# code in the context of the current program.

number score = 15;
F#<code>{
     score <- Registration.process score

}

Distinguishing features[edit]

The output of a G# program is twofold. The parts able to be consumed by the system (for example, console input and output) are kept local and are intended to mostly serve the purpose of monitoring the status of the machine.

The output is transmitted to the connected Arduino board for execution of the robotics routines, if any were generated.

Libraries[edit]

Any of the built-in .NET libraries may be incorporated into the program as well as any custom written C# classes and F# modules.

Examples[edit]

The following is G#'s rendition of the "Hello world" program:

container Main

Main() ={
     output("Hello, world!");

}

This code will display this text in the console window:

Hello, world!

The following is an example of a routine that can play the first four notes of the Fairy Tail theme:

container Main
Main() ={
     // Assuming a simple hand structure with appropriately-placed servos, which A Major will map automatically
     Joint wrist = Joints.Origin;
     Joint indexFinger = wrist.B0, middleFinger = wrist.C0, ringFinger = wrist.D0;
     Routine playFairyTailAnimeTheme =
     { // Routines maintain state with a local implicit stack
          middleFinger.down(5); // D5
          middleFinger.pause(100);
          go // A union of Occam-π's and Golang's influence to run these two commands asynchronously
          {
               middleFinger.up(5);
               ringFinger.down(5); // E5
          }
          go
          {
               ringFinger.up(5);
               middleFinger.down(5); // D5
          }
          go
          {
               middleFinger.up(5);
               indexFinger.down(5); // C5
          }
          indexFinger.up(5);
     }
     playFairyTailAnimeTheme; // invoke

}

See also[edit]

Notes[edit]

  1. By convention, a number sign is used for the second character in normal text; in artistic representations, sometimes a true sharp sign is used: G♯.

References[edit]

External links[edit]


This article "G Sharp (programming language)" is from Wikipedia. The list of its authors can be seen in its historical and/or the page Edithistory:G Sharp (programming language). Articles copied from Draft Namespace on Wikipedia could be seen on the Draft Namespace of Wikipedia and not main one.