Kept on Wikipedia:PascalABC.NET
| 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 | |
Search PascalABC.NET on Amazon.
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.
Differences between Delphi and PascalABC.NET
New features
• loop statement
loop 10 do
Write('*');
• for loop with a step
for var i:=1 to 20 step 2 do
Print(i);
• foreach loop with an index
foreach var c in Arr('a'..'z') index i do
if i mod 2 = 0 then
Print(c);
• a..b ranges
(1..10).Printlines
• short function definition syntax
function Sum(a,b: real) := a + b;
• method implementation can be placed inside a class definition
type Point = class
x,y: real;
procedure Output;
begin
Print(x,y);
end;
end;
• sequence of T type as an abstraction of arrays, lists and sets
var seq: sequence of integer := Arr(1..10);
seq.Println;
seq := Lst(11..100); seq.Println;
seq := HSet(1..20); seq.Println;
var a := ArrGen(10,i -> i*i);
• auto classes - classes with an automatically generated constructor
type Point = auto class
x,y: real;
end;
var p := new Point(2,5);
• one-dimentional and multi-dimentional array slices
var m: array [,] of integer := 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]]
Changed features
- strings in
casestatements - sets based on arbitrary type:
set of string - constructors can be invoked with
new T(...)syntax - type extension methods instead of class helpers
- modules can be defined in a simplified form (without
interfaceandimplementationsections)
Not implemented features
- records with variant parts
- open arrays
- nested class definitions
- inline assembly code
Functional style features
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. An anonymous function can be assigned to the variable of this type:
## // denotes that the main program will be written without enclosing begin-end
var f: real -> real := x -> x*x;
Here is an example of superposition of two functions:
##
function Super<T,T1,T2>(f: T1 -> T2; g: T -> T1): T -> T2 := x -> f(g(x));
var f: real -> real := x -> x*x;
var fg := Super(f,Sin);
var gf := Super(Sin,f);
Print(fg(2));
Print(gf(2));
Superposition operation is defined in the standard library:
##
var f: real -> real := x -> x*x;
Print((f*Cos)(2));
Print((Cos*f)(2));
In the book "How To Program Effectively In Delphi"[1] and in the corresponding video tutorials[2][3], Dr. Kevin Bond, a programmer and a Computer Science teaching specialist[4], notes that PascalABC.NET has powerful functional programming capabilities which are missing in Delphi. As an example, partial function application is demonstrated:
##
var f: real -> real -> real := x -> y -> x + y;
Print(f(2)(3));
Use in school and higher education
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[5][6][7]. 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[8]. PascalABC.NET is widely used as a basic programming language in pedagogical universities for the training of computer science teachers[9][10][11][12]. It also serves as a tool for scientific computing[13][14].

PascalABC.NET has built-in units aimed at teaching children of primary and secondary school age: GraphWPF (raster graphics), WPFObjects (vector graphics), Graph3D (3D graphics and animation), Robot, Drawman and TurtleWPF (for beginners).These units represent a higher abstraction level allowing beginners not to focus on technical aspects of drawing.
The figure shown is drawn with the following code:
uses TurtleWPF;
begin
Down; // prepare turtle's pen
SetSpeed(11); // set turtle's movement speed
SetColor(Colors.Red); // set pen color
for var i:=1 to 450 do
begin
SetColor(RGB(128+i,0,i)); // change pen color
Forw(i); // move turtle forward
Turn(96); // rotate turtle clockwise
end;
end.
PascalABC.NET is also built into a number of validation systems used for programming competitions[15][16].
Programming styles and code examples
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:
Oldschool style
var a,b,i,sum: integer; // variables definition preceeds the main program body
begin
Read(a,b);
sum := 0;
for i:=a to b do
sum := sum + i*i;
Write('Sum = ',sum)
end.
Equivalent PascalABC.NET style
begin
var (a,b) := ReadInteger2; // read input into tuple of two variables
var sum := 0; // type auto-inference
for var i:=a to b do
sum += i*i;
Print($'Sum = {sum}') // string interpolation
end.
Procedural style
function SumSquares(a,b: integer): integer;
begin
Result := 0;
for var i := a to b do
Result += i * i
end;
begin
var (a,b) := ReadInteger2;
Print($'Sum = {SumSquares(a,b)}')
end.
Functional style
This solution uses .NET extension methods for sequences and PascalABC.NET-specific range (a..b).
begin
var (a,b) := ReadInteger2;
(a..b).Sum(x -> x*x).Print // method chaining with lambda expressions
end.
Object-oriented style
This solution demonstrates PascalABC.NET-specific short function definition style.
type Algorithms = class
static function SumSquares(a,b: integer) := (a..b).Sum(x -> x*x);
static function SumCubes(a,b: integer) := (a..b).Sum(x -> x*x*x);
end;
begin
var (a,b) := ReadInteger2;
Println($'Squares sum = {Algorithms.SumSquares(a,b)}');
Println($'Cubes sum = {Algorithms.SumCubes(a,b)}')
end.
Close to regular C# style
It is possible to write programs without usage of PascalABC.NET standard library. All standard .NET Framework classes and methods can be used directly.
uses System; // using .NET System namespace
begin
var arr := Console.ReadLine.Split(
new char[](' '),
StringSplitOptions.RemoveEmptyEntries
);
var (a,b) := (integer.Parse(arr[0]),integer.Parse(arr[1]));
var sum := 0;
for var i:=a to b do
sum += i*i;
Console.WriteLine($'Sum = {sum}')
end.
Source code audit
In 2017[17] and 2022[18], 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.
See also
References
- ↑ Kevin R. Bond (2021). "Chapter 44. Anonymous methods". How to Program Effectively in Delphi for AS/A Level Computer Science. Educational Computing Services Ltd. ISBN 9780992753603. Search this book on
- ↑ Kevin Bond. "How to Program Effectively in Delphi. Lesson 44. Part 1". YouTube. Retrieved 2023-04-04.
- ↑ "Delphi Boot Camp 2022 - Delphi and functional programming using anonymous methods". YouTube. Retrieved 2023-04-04.
- ↑ "Brief biography Dr Kevin R Bond" (PDF). Educational Computing Services Ltd.
- ↑ "Metodicheskie rekomendacii po podgotovke i provedeniyu edinogo gosudarstvennogo ekzamena po informatike i IKT v komp'yuternoj forme v gorode Moskve v 2021 godu [Guidelines for the preparation and conduct of the unified state exam in computer science and ICT in the city of Moscow in 2021]" (PDF) (in русский). Departament obrazovaniya i nauki goroda Moskvy [Department of Education and Science of Moscow]. p. 110.
- ↑ Polyakov, Konstantin. "Doklady na konferenciyah i seminarah [Reports at conferences and seminars]" (in русский).
- ↑ Bogdanov, Alexey (2022-10-04). "PascalABC.Net or Python/ C#/C++". YouTube (in русский). Retrieved 2023-04-05.
- ↑ Popova, Ekaterina (2022-09-06). "Kak v Rostove gumanitarii uspeshno obuchayutsya IT-special'nostyam [How humanitarians successfully study IT specialties in Rostov]". Komsomolskaya Pravda (in русский).
- ↑ Dzhenzher, V.O.; Denisova, L.V. (2019). "Mathematical animation in computer simulation at school". Informatics in School (in русский) (6): 51–54. doi:10.32517/2221-1993-2019-18-6-51-54. Unknown parameter
|s2cid=ignored (help) - ↑ Dzhenzher, V.O.; Denisova, L.V. (2021). "Implementation of the Hamming code on PascalABC.NET while studying the theoretical foundations of informatics". Informatics in School (in русский). 1 (9): 29–38. doi:10.32517/2221-1993-2021-20-9-27-36. Unknown parameter
|s2cid=ignored (help) - ↑ Dzhenzher, V.O.; Denisova, L.V. (2020). "Scientific graphics in PascalABC.NET: plotting function graphs in a rectangular cartesian coordinate system". Informatics in School (in русский) (1): 31–39. doi:10.32517/2221-1993-2020-19-1-31-39. Unknown parameter
|s2cid=ignored (help) - ↑ Kulabukhov, S.Yu. (2021). "Mathematical modeling in informatiсs lessons using numerical solution of differential equations". Informatics in School (in русский) (2): 14–21. doi:10.32517/2221-1993-2021-20-2-14-21. Unknown parameter
|s2cid=ignored (help) - ↑ Khazieva, R.T.; Ivanov, M.D. (2020). "Selection of optimum device parameters for permanent magnetic field generation". Power Engineering: Research, Equipment, Technology (in русский). 22 (6): 176–187. doi:10.30724/1998-9903-2020-22-6-176-187. Unknown parameter
|s2cid=ignored (help) - ↑ Lukyanov, O.E.; Zolotov, D.V. (2021). "Methodological support for the training of UAV designers and operators". VESTNIK of Samara University. Aerospace and Mechanical Engineering (in русский). 20 (1): 14–28. doi:10.18287/2541-7533-2021-20-1-14-28. Unknown parameter
|s2cid=ignored (help) - ↑ "ACMP Olympiad System". Archived from the original on 2023-03-27. Retrieved 2023-04-05. Unknown parameter
|url-status=ignored (help) - ↑ "Yandex Contest Compilers List". Yandex Contest. Archived from the original on 2023-03-14. Retrieved 2023-04-05. Unknown parameter
|url-status=ignored (help) - ↑ "Analysis of PascalABC.NET using SonarQube plugins: SonarC# and PVS-Studio". PVS-Studio. 2017-03-29.
- ↑ "Re-checking PascalABC.NET". Medium. 2022-02-11.
External links
This article "PascalABC.NET" is from Wikipedia. The list of its authors can be seen in its historical and/or the page Edithistory:PascalABC.NET. Articles copied from Draft Namespace on Wikipedia could be seen on the Draft Namespace of Wikipedia and not main one.
| This page exists already on Wikipedia. |
