Paradigm | Multi-paradigm: procedural, functional, object-oriented, generic |
---|---|
Designed by | PascalABC.NET Compiler Team |
First appeared | 2007 |
Stable release | 3.8.3.3255 / 4 April 2023 |
Typing discipline | Static, partially inferred |
Implementation language | PascalABC.NET |
OS | Cross-platform |
License | LGPLv3 |
Filename extensions | .pas |
Website | pascalabc |
Influenced by | |
Delphi, Pascal, Oxygene, C#, Python, Kotlin, Haskell |
PascalABC.NET is a high-level general-purpose programming language supporting multiple paradigms. PascalABC.NET is based on Delphi's Object Pascal, but also has influences from C#, Python, Kotlin, and Haskell. It is distributed both as a command-line tool for Windows (.NET framework), Linux and MacOS (Mono), and with an integrated development environment for Windows and Linux, including interactive debugger, IntelliSense system, form designer, code templates and code auto-formatting.
PascalABC.NET is implemented for the .NET framework platform, so that it is compatible with all .NET libraries and utilizes all the features of Common Language Runtime, such as garbage collection, exception handling, and generics. Some language constructions, e.g. tuples, sequences, and lambdas, are based on regular .NET types. PascalABC.NET is ideologically close to Oxygene, but unlike it, provides high compatibility with Delphi.
PascalABC.NET was developed by a group of enthusiasts at the Institute of Mathematics, Mechanics, and Computer Science in Rostov-on-Don, Russia. [1] In 2003, a predecessor of the modern PascalABC.NET, called Pascal ABC, was implemented by associate professor Stanislav Mikhalkovich to be used for teaching schoolchildren instead of Turbo Pascal, which became outdated and incompatible with modern operating systems but was still used for educational purposes. Pascal ABC was implemented as an interpreted programming language, that led to a significant lack of performance. Four years after that it was completely rewritten by students Ivan Bondarev, Alexander Tkachuk, and Sergey Ivanov as a compiled programming language for the .NET platform. In 2009, PascalABC.NET started to be actively used for teaching high school students. By 2015, the number of users of the language had increased significantly. It began to be actively used throughout Russia in schools and at programming contests, surpassing Free Pascal. Since then, the PascalABC.NET developers have set themselves the goal of actively incorporating modern features into the language. In the same year, PascalABC.NET became an open source project distributed under the GNU Lesser General Public License (LGPLv3). [2] [3]
In 2017 [4] and 2022, [5] independent audit of PascalABC.NET public repository was conducted. Based on the results of the static check, potentially dangerous code fragments were listed that require additional analysis by developers. It was also noted that the overall quality of the code could be improved. To do this, code duplication and redundant checks should be eliminated, and refactoring should be performed more carefully.
Designed for education, PascalABC.NET remains the most common programming language in Russian schools and one of the recommended languages for passing the Unified State Exam on informatics. [6] [7] [8] In the Southern Federal University, it is used as the first language for teaching students majoring in computer science, and for teaching children in one of the largest computer schools in Russia. [9] PascalABC.NET is widely used as a basic programming language in pedagogical universities for the training of computer science teachers. [10] [11] [12] [13] It also serves as a tool for scientific computing. [14] [15] PascalABC.NET is also built into a number of validation systems used for programming competitions. [16] [17]
In 2020, during anti-COVID lockdowns and home schooling period, PascalABC.NET website was ranked 3rd in Yandex traffic rating in the "Programming" category, and the number of downloads of the installation kit exceeded 10000 a day. [18]
Though the core of the PascalABC.NET community is located in Russia, the language is also known in other countries such as Belarus, [19] Romania, [20] Indonesia, [21] Algeria. [22]
•loop
statement
loop10doWrite('*');
•for
loop with a step
forvari:=1to20step2doPrint(i);
•foreach
loop with an index
foreachvarcinArr('a'..'z')indexidoifimod2=0thenPrint(c);
•a..b
ranges
(1..10).Printlines
• short function definition syntax
functionSum(a,b:real):=a+b;
• method implementation can be placed inside a class definition
typePoint=classx,y:real;procedureOutput;beginPrint(x,y);end;end;
•sequence of T
type as an abstraction of arrays, lists and sets
varseq:sequenceofinteger:=Arr(1..10);seq.Println;seq:=Lst(11..100);seq.Println;seq:=HSet(1..20);seq.Println;
vara:=ArrGen(10,i->i*i);
• auto classes - classes with an automatically generated constructor
typePoint=autoclassx,y:real;end;varp:=newPoint(2,5);
• one-dimensional and multi-dimensional array slices
varm:array[,]ofinteger:=MatrGen(3,4,(i,j)->i+j+1);Println(m);// [[1,2,3,4],[2,3,4,5],[3,4,5,6]] Println(m[:2,1:3]);// [[2,3],[3,4]]
Some other features such as inline variable declarations, type inference, and for
statement with a variable declaration are standard in the current version of Delphi. However, PascalABC.NET pioneered these features in 2007, [23] while in Delphi they were implemented in 2018. [24] [25]
case
statementsset of string
new T(...)
syntaxinterface
and implementation
sections)In PascalABC.NET, functions are first-class objects. They can be assigned to variables, passed as parameters, and returned from other functions. Functional type is set in the form T -> Res
. [26] An anonymous function can be assigned to the variable of this type:
##// denotes that the main program will be written without enclosing begin-endvarf:real->real:=x->x*x;
Here is an example of superposition of two functions:
##functionSuper<T,T1,T2>(f:T1->T2;g:T->T1):T->T2:=x->f(g(x));varf:real->real:=x->x*x;varfg:=Super(f,Sin);vargf:=Super(Sin,f);Print(fg(2));Print(gf(2));
Superposition operation is defined in the standard library:
##varf:real->real:=x->x*x;Print((f*Cos)(2));Print((Cos*f)(2));
In the book "How To Program Effectively In Delphi" [27] and in the corresponding video tutorials, [28] [29] Dr. Kevin Bond, a programmer and a Computer Science teaching specialist, [30] notes that PascalABC.NET has powerful functional programming capabilities which are missing in Delphi. As an example, partial function application is demonstrated:
beginvarf:integer->integer->integer:=x->y->x+y;Writeln(f(2)(6));end.
PascalABC.NET is a multi-paradigm programming language. It allows one to use different coding styles from oldschool Pascal to functional and object-oriented programming. The same task can be solved in different styles as follows: [31]
beginvar(a,b):=ReadInteger2;// read input into tuple of two variablesvarsum:=0;// type auto-inferenceforvari:=atobdosum+=i*i;Print($'Sum = {sum}')// string interpolationend.
functionSumSquares(a,b:integer):integer;beginResult:=0;forvari:=atobdoResult+=i*iend;beginvar(a,b):=ReadInteger2;Print($'Sum = {SumSquares(a,b)}')end.
This solution uses .NET extension methods for sequences and PascalABC.NET-specific range (a..b)
.
beginvar(a,b):=ReadInteger2;(a..b).Sum(x->x*x).Print// method chaining with lambda expressionsend.
This solution demonstrates PascalABC.NET-specific short function definition style.
typeAlgorithms=classstaticfunctionSumSquares(a,b:integer):=(a..b).Sum(x->x*x);staticfunctionSumCubes(a,b:integer):=(a..b).Sum(x->x*x*x);end;beginvar(a,b):=ReadInteger2;Println($'Squares sum = {Algorithms.SumSquares(a,b)}');Println($'Cubes sum = {Algorithms.SumCubes(a,b)}')end.
It is possible to write programs without usage of PascalABC.NET standard library. All standard .NET Framework classes and methods can be used directly.
usesSystem;// using .NET System namespacebeginvararr:=Console.ReadLine.Split(newchar[](' '),StringSplitOptions.RemoveEmptyEntries);var(a,b):=(integer.Parse(arr[0]),integer.Parse(arr[1]));varsum:=0;forvari:=atobdosum+=i*i;Console.WriteLine($'Sum = {sum}')end.
Though PascalABC.NET is actively used for teacher training, [7] [10] [32] [33] some members of the teaching community ignore difference between historically used Turbo Pascal and PascalABC.NET, criticizing some unspecified "Pascal" language for being far from modern programming, too wordy and not simple enough to be used as the first programming language. [34] [35] They consider Python to be the best starting point, as it is more concise and practically applicable. Their opponents, including PascalABC.NET developers themselves, argue that it is incorrect to put an equal sign between the classic Pascal and PascalABC.NET, as the latter contains lots of modern multi-paradigm features, including the ones from Python. [8] [36] [37] PascalABC.NET allows students to write as concise and expressive programs as Python, [38] and acts as a "bridge to production programming" by applying a static typing concept. [8] PascalABC.NET is also a compilable language, which makes it easier to learn programming, because all semantic errors are caught at compile time rather than occur unpredictably at runtime. [8] [39]
In programming language theory, lazy evaluation, or call-by-need, is an evaluation strategy which delays the evaluation of an expression until its value is needed and which also avoids repeated evaluations.
Pascal is an imperative and procedural programming language, designed by Niklaus Wirth as a small, efficient language intended to encourage good programming practices using structured programming and data structuring. It is named after French mathematician, philosopher and physicist Blaise Pascal.
Generic programming is a style of computer programming in which algorithms are written in terms of data types to-be-specified-later that are then instantiated when needed for specific types provided as parameters. This approach, pioneered by the ML programming language in 1973, permits writing common functions or types that differ only in the set of types on which they operate when used, thus reducing duplicate code.
In mathematics and computer science, a higher-order function (HOF) is a function that does at least one of the following:
In programming language theory and type theory, polymorphism is the use of a single symbol to represent multiple different types.
In computer science, boxing is the transformation of placing a primitive type within an object so that the value can be used as a reference. Unboxing is the reverse transformation of extracting the primitive value from its wrapper object. Autoboxing is the term for automatically applying boxing and/or unboxing transformations as needed.
In computing, type introspection is the ability of a program to examine the type or properties of an object at runtime. Some programming languages possess this capability.
In computer science, a tagged union, also called a variant, variant record, choice type, discriminated union, disjoint union, sum type or coproduct, is a data structure used to hold a value that could take on several different, but fixed, types. Only one of the types can be in use at any one time, and a tag field explicitly indicates which one is in use. It can be thought of as a type that has several "cases", each of which should be handled correctly when that type is manipulated. This is critical in defining recursive datatypes, in which some component of a value may have the same type as that value, for example in defining a type for representing trees, where it is necessary to distinguish multi-node subtrees and leaves. Like ordinary unions, tagged unions can save storage by overlapping storage areas for each type, since only one is in use at a time.
In computer science, a generator is a routine that can be used to control the iteration behaviour of a loop. All generators are also iterators. A generator is very similar to a function that returns an array, in that a generator has parameters, can be called, and generates a sequence of values. However, instead of building an array containing all the values and returning them all at once, a generator yields the values one at a time, which requires less memory and allows the caller to get started processing the first few values immediately. In short, a generator looks like a function but behaves like an iterator.
In computer programming, foreach loop is a control flow statement for traversing items in a collection. foreach is usually used in place of a standard for loop statement. Unlike other for loop constructs, however, foreach loops usually maintain no explicit counter: they essentially say "do this to everything in this set", rather than "do this x times". This avoids potential off-by-one errors and makes code simpler to read. In object-oriented languages, an iterator, even if implicit, is often used as the means of traversal.
In computer programming, a callback is a function that is stored as data and designed to be called by another function – often back to the original abstraction layer.
The computer programming languages C and Pascal have similar times of origin, influences, and purposes. Both were used to design their own compilers early in their lifetimes. The original Pascal definition appeared in 1969 and a first compiler in 1970. The first version of C appeared in 1972.
Oxygene is a programming language developed by RemObjects Software for Microsoft's Common Language Infrastructure, the Java Platform and Cocoa. Oxygene is based on Delphi's Object Pascal, but also has influences from C#, Eiffel, Java, F# and other languages.
In computer programming, an anonymous function is a function definition that is not bound to an identifier. Anonymous functions are often arguments being passed to higher-order functions or used for constructing the result of a higher-order function that needs to return a function. If the function is only used once, or a limited number of times, an anonymous function may be syntactically lighter than using a named function. Anonymous functions are ubiquitous in functional programming languages and other languages with first-class functions, where they fulfil the same role for the function type as literals do for other data types.
Devised by Niklaus Wirth in the late 1960s and early 1970s, Pascal is a programming language. Originally produced by Borland Software Corporation, Embarcadero Delphi is composed of an IDE, set of standard libraries, and a Pascal-based language commonly called either Object Pascal, Delphi Pascal, or simply 'Delphi'. Since first released, it has become the most popular commercial Pascal implementation.
In computer programming, variable shadowing occurs when a variable declared within a certain scope has the same name as a variable declared in an outer scope. At the level of identifiers, this is known as name masking. This outer variable is said to be shadowed by the inner variable, while the inner identifier is said to mask the outer identifier. This can lead to confusion, as it may be unclear which variable subsequent uses of the shadowed variable name refer to, which depends on the name resolution rules of the language.
Increment and decrement operators are unary operators that increase or decrease their operand by one.
In computer programming, ellipsis notation is used to denote ranges, an unspecified number of arguments, or a parent directory. Most programming languages require the ellipsis to be written as a series of periods; a single (Unicode) ellipsis character cannot be used.
Nim is a general-purpose, multi-paradigm, statically typed, compiled high-level systems programming language, designed and developed by a team around Andreas Rumpf. Nim is designed to be "efficient, expressive, and elegant", supporting metaprogramming, functional, message passing, procedural, and object-oriented programming styles by providing several features such as compile time code generation, algebraic data types, a foreign function interface (FFI) with C, C++, Objective-C, and JavaScript, and supporting compiling to those same languages as intermediate representations.
Dafny is an imperative and functional compiled language that compiles to other programming languages, such as C#, Java, JavaScript, Go and Python. It supports formal specification through preconditions, postconditions, loop invariants, loop variants, termination specifications and read/write framing specifications. The language combines ideas from the functional and imperative paradigms; it includes support for object-oriented programming. Features include generic classes, dynamic allocation, inductive datatypes and a variation of separation logic known as implicit dynamic frames for reasoning about side effects. Dafny was created by Rustan Leino at Microsoft Research after his previous work on developing ESC/Modula-3, ESC/Java, and Spec#.
{{cite book}}
: CS1 maint: location missing publisher (link){{cite book}}
: CS1 maint: location missing publisher (link)