PascalABC.NET: Difference between revisions

Content deleted Content added
Added comparison with Delphi (new features)
Line 30:
}}
 
'''PascalABC.NET''' is a [[High-level programming language|high-level]] [[General-purpose programming language|general-purpose]] [[programming language]] supporting multiple paradigms. ItPascalABC.NET is compatiblebased with classicon [[ProceduralDelphi (programming language)|proceduralDelphi]]'s [[PascalObject (programming language)|Pascal]], but providesalso extensivehas supportinfluences offrom [[Object-orientedC Sharp (programming language)|object-orientedC#]], and[[Python (programming language)|Python]], [[FunctionalKotlin (programming language)|functionalKotlin]] paradigmsand [[Haskell]]. It is distributed both as a command-line tool for Windows (native.NET Framework), Linux and MacOS (Mono), and with an [[integrated development environment]] for Windows and Linux, including interactive debugger, [[Intelligent code completion|IntelliSense]] system, [[Graphical user interface builder|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 advantagesfeatures of [[Common Language Runtime]], such as [[Garbage collection (computer science)|garbage collection]], [[exception handling]], and [[Generic programming|generics]]. Some language constructions, e.g. tuples, sequences, and lambdas, are based on regular .NET types. PascalABC.NET is ideologically close to [[Oxygene (programming language)|Oxygene]], but, unlike it, provides high compatibility with [[Delphi (programming language)|Delphi]].
 
== KeyDifferences featuresbetween ofDelphi and PascalABC.NET ==
 
=== PascalNew syntax extensionsfeatures ===
'''•''' <code>loop</code> operator<syntaxhighlight lang="delphi">
* Operators <code>+= -= *= /=</code>
loop 10 do
* in-block variable definitions
Write('*');
* Variable declaration in <code>'''for'''</code> loop header
</syntaxhighlight>'''•''' <code>for</code> loop with a step<syntaxhighlight lang="delphi">
* Variable declaration with initialization (<code>'''var''' n: integer := 10;</code>)
for var i:=1 to 20 step 2 do
* Variable type deduction (<code>'''var''' x := 1;</code>)
Print(i);
* <code>'''[[foreach]]'''</code>
</syntaxhighlight>'''•''' <code>foreach</code> loop with an index<syntaxhighlight lang="delphi">
* Routines with a variable number of parameters
foreach var c in Arr('a'..'z') index i do
* <code>'''set'''</code> of any type (<code>'''set of''' integer</code>)
if i mod 2 = 0 then
* Methods in records
Print(c);
* Methods defined in class declaration
</syntaxhighlight>'''•''' <code>a..b</code> ranges<syntaxhighlight lang="delphi">
* Simplified syntax of units
(1..10).Printlines
* Keyword <code>'''new'''</code> (invoking a constructor)
</syntaxhighlight>'''•''' short function definition syntax<syntaxhighlight lang="delphi">
* Field initializers
function Sum(a,b: real) := a + b;
* Static constructors
</syntaxhighlight>'''•''' method implementation can be placed inside a class definition<syntaxhighlight lang="delphi">
* [[OpenMP]] directives
type Point = class
* Case for strings
x,y: real;
* Tuple type syntax (T1, T2)
procedure Output;
* Yield and yield sequence
begin
* Pattern matching
Print(x,y);
* Array slices
end;
* Interpolated strings
end;
 
</syntaxhighlight>'''•''' <code>sequence of T</code> type as an abstraction of arrays, lists and sets<syntaxhighlight lang="delphi">
=== Object-oriented features ===
var seq: sequence of integer := Arr(1..10);
 
seq.Println;
* Classes and interfaces
seq := Lst(11..100); seq.Println;
* [[Operator overloading]]
seq := HSet(1..20); seq.Println;
* [[Exception handling]]
</syntaxhighlight>'''•''' lambda functions<syntaxhighlight lang="delphi">
* [[Generic programming|Generic classes and routines]]
var a := ArrGen(10,i -> i*i);
* [[Garbage collection (computer science)|Garbage collection]]
</syntaxhighlight>'''•''' auto classes - classes with an automatically generated constructor<syntaxhighlight lang="delphi">
type Point = auto class
x,y: real;
end;
var p := new Point(2,5);
</syntaxhighlight>'''•''' one-dimentional and multi-dimentional array slices<syntaxhighlight lang="delphi">
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]]
</syntaxhighlight>
 
=== Functional style features ===
Line 200 ⟶ 210:
</syntaxhighlight>
 
== CodeSource code audit ==
In 2017<ref>{{Cite web|lang=en|url=https://pvs-studio.com/en/blog/posts/csharp/0492/|title=Analysis of PascalABC.NET using SonarQube plugins: SonarC# and PVS-Studio|website=PVS-Studio|date=2017-03-29}}</ref> and 2022<ref>{{Cite web|lang=en|url=https://medium.com/pvs-studio/re-checking-pascalabc-net-f8bfc94aba3c|title=Re-checking PascalABC.NET|website=Medium|date=2022-02-11}}</ref>, independent audit of [https://github.com/pascalabcnet/pascalabcnet 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.