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

Bird script (programming language)

From EverybodyWiki Bios & Wiki













Bird Script
Bird Script
Bird Script
Paradigmmulti-paradigm: object-oriented, imperative, functional, procedural, reflective
Designed byKrishnavyshak R.
DeveloperySTACK
First appeared2020; 4 years ago (2020)
Stable release
  • 0.0.1.s / 13 January 2021 (2021-01-13)
Preview release
0.0.1.a / 0.0.1.b / 16 December 2020 (2020-12-16)
Typing disciplineduck, dynamic, strong, gradual (as of stable verision of Bird Script 0.0.1.s)
OSWindows, Linux/UNIX, macOS and more
LicenseApache License
Filename extensions.birds, .bsll, .bspy
Websitewww.birdscript.tk
Major implementations
CPython, Python
Dialects
BSPY, BSJ

Search Bird script (programming language) on Amazon.

Bird Script is a general-purpose, object-oriented, high-level programming language designed by Krishnavyshak and developed by ySTACK. With syntax inspired by the language BASIC, It is a compiled language with dynamic-type-checking, is currently in active development. The first stable release of Bird Script was on 13 January 2021. The concise way of writing code helps programmers to write clear, logical code for small and large-scale projects. It supports multiple programming paradigms, including structured (particularly, procedural), object-oriented and functional programming.

Description[edit]

Although resembling the BASIC language in syntax, Bird Script compiles to much more efficient native code using an LLVM backend, at the cost of precluding the dynamic aspects of BASIC. However, the advanced global type inference used by the Bird Script compiler, combined with the use of union types, gives Bird Script is a higher-level scripting language. The language has automated garbage collection and currently offers a Boehm collector. Bird Script possesses a macro system and supports generics as well as both method and operator overloading. Bird Script's concurrency model is inspired by communicating sequential processes (CSP).

Version history[edit]

Bird Script 1 guarantees compatibility for the language specification. All versions up to the current Bird Script 0.0.2.s release have maintained this promise.

Each major Bird Script release is supported until there are two newer major releases.

Major version Initial release date Language changes
1-0.0.1.a.8 2020-06-14 Initial release
1-0.0.1.a.7 2020-07-12
  • In Bird Script 1, an integer division by constant zero is not a legal program, so it is a compile-time error.
  • The definition of string has been refined to exclude and halves from the set of valid Unicode code points.
1-0.0.1.a.6 2020-09-16
  • The language now specifies that, for safety reasons, certain uses of NULL POINTER are guaranteed to trigger a run-time panic.
  • Bird Script 1 adds the ability to specify the capacity as well as the length when using a slicing operation on an existing array or slice. A slicing operation creates a new slice by describing a contiguous section of an already-created array or slice.
1-0.0.1.a.5 2020-09-28 There are no language changes in this release, the interactive shell bug removed when creating function
1-0.0.1.a.3 2020-11-06 Bird Script Package Yard (BSPY) implementation for Bundle Project can be configured form interactive shell.
1-0.0.1.a.2

1-0.0.b.0

2020-12-16
  • First Preview/Beta release of Bird Script.
  • Language support added for subprocess and direct machine commands within BSPY.
1-0.0.1.a.1 2020-12-24
  • There are no major language changes in this release. Minor bug fix in interactive shell
  • Interactive shell gain the ability to run Bird Script file (.birds) can be run outside the interactive shell, with birdscript -r <filename>
1-0.0.1.s.0 2021-01-13 First Stable release of Bird Script
1.0.0.1.s.1 2021-03-16 BSPY's First Beta release.
1.0.1.s.0 2021-08-23 Many bugs removed, Added feature to inject python code directly into a Bird Script file.

Design and Features[edit]

Bird Script is a multi-paradigm programming language. Object-oriented programming and structured programming are fully supported, and many of its features support functional programming and aspect-oriented programming (including by metaprogramming and metaobjects. Beyond the core, Bird Script have Package / Library ,System so that it is extensible, and can have many features that are not Built-in.

Syntax and semantics[edit]

Bird Script have syntax, keywords and built-in function written in Upper Case, in some situations it looks same as BASIC. But the syntax is specially constructed to write code in a cheerful way.

Indentation[edit]

Bird Script uses whitespace and keywords indentation to delimit blocks. An increase in indentation comes after certain statements; a decrease in indentation with the END block signifies the end of the current block.

Statement and control flow[edit]

Bird Script's statements include (among others):

  • The assignment statement, using a single equals sign =.
  • The VAR statement, which is used to declare a variable.
  • The AND statement, used mainly in IF and WHILE loops to state whether both arguments are correct.
  • The OR statement, also used mainly in IF and WHILE loops to check if any of the arguments are true.
  • The IF statement, which conditionally executes a block of code, along with ELSE and ELIF (a contraction of else-if).
  • The FOR statement, which iterates over an iterable object, capturing each element to a local variable for use by the attached block.
  • The WHILE statement, which executes a block of code as long as its condition is false.
  • The FUN statement, which defines a function or method.
  • The BREAK statement, exits from a loop.

Further readings of statements and control flow is on Bird Script Documentation.

Expressions[edit]

Some Bird Script expressions are similar to those found in languages such as C and Java, while some are not:

  • Addition, subtraction, multiplication and division are the same, and the symbols are the following respectively. + for addition, - for subtraction, * for multiplication and / is used to divide.
  • In Bird Script, == compares by value, versus Java, which compares numeric by value[1] and objects by reference.[2] (Value comparisons in Java on objects can be performed with the equals() method.) Bird Script's IS operator may be used to compare object identities (comparison by reference). In Bird Script, comparisons may be chained, for example a <= b <= c.
  • Bird Script uses the words AND, OR, NOT for its boolean operators rather than the symbolic &&, ||, ! used in Java and C.
  • Bird Script has a type of expression termed a list comprehension as well as a more general expression termed a generator expression.
  • Conditional expressions in Bird Script are written as IF c == b THEN a END (different in order of operands from the c ? x : y operator common to many other languages).

Typing[edit]

Bird Script uses duck typing and has typed objects but untyped variable names. Type constraints are not checked at compile time; rather, operations on an object may fail, signifying that the given object is not of a suitable type. Despite being dynamically-typed, Bird Script is strongly-typed, forbidding operations that are not well-defined (for example, adding a number to a string) rather than silently attempting to make sense of them.

Bird Script allows programmers to define their own types using Function statement, which are most often used for object-oriented programming. New instances of functions are constructed by calling the function (for example, fooFUN() or bazFUN()).

Interaction[edit]

The Bird Script official distribution also includes Bird Script Interactive Shell, an interactive command-line interpreter that can be used to test code quickly. The following code fragment represents a sample session using Bird Script Interactive Shell:

>>> PRINT("Hello, World!")
Hello, World!
0
>>> FUN foo(value) -> PRINT(value)
<function foo>
>>> foo("BAZ")
BAZ
0

Examples[edit]

The following examples can be run in a Bird Script shell such as Bird Script Interactive Shell, or saved in a file and run from the command line by typing birdscript -r <filename>or bs -r <filename>

Classic Hello world example:

PRINT("Hello, World!")

Some Basic Bird Script Code:

@ Create a new function to print greetings

FUN print_greeting(your_name, message)
    PRINT(your_name + " Has Greeted You " + message)
END

@ We will execute the function
print_greeting("Jhon Doe", "Good Morning")

Output:

"Jhon Doe Has Greeted You Good Morning"

Create a Class/Object:

CLASS animal
    FUN animal()
        VAR this.animal_list = ["cow", "sheep", "goat"]
    END
    
    FUN get_random_animal()
        RETURN GET(this.animal_list, RAND(0, LEN(this.animal_list)))
    END
END

VAR obj = animal()
PRINT("Random animal: " + obj.get_random_animal())

Output:

"Random animal: sheep"

String[edit]

There are a variety of ways to define strings in Bird Script.

The following assignments are equivalent:

@ Normal String
VAR a = "This is a normal string"

@ Convert Integer to String
VAR a = STR(10)

@ Multi line string.
VAR a = "
This is a multi line string
"

Collections[edit]

Constructing and using an array (list):

VAR a = [3, "hello", 14.5, 1, 2, [6, 15]]

POP(a, 2)           @ => 14.5
LEN(a)              @ => 5
REVERSE(a)       @ => [[6, 15], 2, 1, 14.5, 'hello', 3]
FLAT(UNQ(a))  @ => [3, 'hello', 14.5, 1, 2, 6, 15]

Control structures[edit]

If statement:

@ Generate a random number and print whether it's even or odd.
IF EVEN(RAND(1, 100)) THEN
  PRINT("The number is even")
ELSE
  puts "THe number is odd"
END

If statement with Elif (Else if) condition:

@ check the user input, if it is 1 then "yes", else if it is 2 then "no" or if any other number then "error" 

VAR user_input = INPUT_INT("Enter some number")

IF user_input == 1 THEN
    PRINT("yes")
ELIF user_input == 2 THEN
    PRINT("no")
ELSE 
    PRINT("error")
END

While loop:

@ Make a loop that continues forever

WHILE TRUE THEN
    PRINT("This loop will not end")
END

For loop:

@ Make a loop that print number upto 20

FOR i = 0 TO 20 THEN 
    PRINT(i)
END
Summary of Bird Script's built-in types
Type Mutability Description Syntax examples
bool immutable Boolean value TRUEFALSE NULL
complex immutable Complex number with real and imaginary parts 3+2.7j3 + 2.7j
float immutable Double-precision floating-point number. The precision is machine-dependent but in practice is generally implemented as a 64-bit IEEE 754 number with 53 bits of precision.[3]
str immutable A character string: sequence of Unicode codepoints "some string inside double inverted commas"
int immutable Integer of unlimited magnitude 42
list mutable List, can contain mixed types [4.0, "string", True][]

References[edit]

  1. "Chapter 15. Expressions - 15.21.1. Numerical Equality Operators == and !=". Oracle Corporation. Retrieved 28 August 2016.
  2. "Chapter 15. Expressions - 15.21.3. Reference Equality Operators == and !=". Oracle Corporation. Retrieved 28 August 2016.
  3. "15. Floating Point Arithmetic: Issues and Limitations — Python 3.8.3 documentation". docs.python.org. Retrieved 6 June 2020. Almost all machines today (November 2000) use IEEE-754 floating point arithmetic, and almost all platforms map Python floats to IEEE-754 "double precision".

Modified many sections, added code examples[edit]

Created Section "Description" , minor edit in main section[edit]

Edited lines that fell like adevertisment[edit]

Added version history, minor edits in other section[edit]


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