Not to say these are not valid reasons, or expectations one may have from a language, but - what exactly is Pascal being compared to? I mean, it's 2017.
Not to say these are not valid reasons, or expectations one may have from a language, but - what exactly is Pascal being compared to? I mean, it's 2017.
Scheme & LISP have no built-in classes, and one can argue that CLOS isn't what we normally describe as OOP. Both normally have a global namespace.
Inheritance in JavaScript is possible but very hard to implement correctly before ES6. Node has namespaces (sort of) but client-side JavaScript generally doesn't.
PHP in theory has namespaces, but the standard libraries are just dumped in global.
Nonsense. Lisp has a plethora of standard classes: T, NUMBER, PATHNAME, SYMBOL, SIMPLE-ARRAY, BASE-STRING &c. &c. &c. In fact, I just ran this on a pristine SBCL (no user or :
(let ((ch (make-hash-table :test 'eq)))
(labels ((pc (class)
(loop for subclass in (sb-mop:class-direct-subclasses class)
unless (gethash subclass ch)
do (progn
(setf (gethash subclass ch) t)
(pc subclass)))))
(pc (find-class t)))
(length (loop for class being each hash-key of ch collect class)))
→ 659
Yes, a basic running SBCL has six hundred and fifty-nine classes built into it. It all works remarkably well.> one can argue that CLOS isn't what we normally describe as OOP
Probably not, but it's better.
> Both normally have a global namespace.
CLOS classes are themselves instances, identified by a symbol which lives in a package — i.e., within a namespace. E.g:
(defclass foo () ())
→ #<STANDARD-CLASS COMMON-LISP-USER::FOO>
(defclass swank::foo () ())
→ #<STANDARD-CLASS SWANK::FOO>
(make-instance 'foo)
→ #<FOO {1003ED8AA3}>
(make-instance 'swank::foo)
→ #<SWANK::FOO {1003EDEC03}>
Those are two different classes, both name FOO, but their names live in different packages.Modern PHP development almost exclusively uses Composer libraries rather than the standard libraries, which overwhelmingly use namespaces in Vendor\Project format.
There's going to be a push to clean up the standard library in the coming years. The plan is to introduce a namespaced alternative to the standard library in the global namespace which also cleans up a lot of nits (e.g. phpsadness.com posts). Maybe in PHP 8? Then when the ecosystem catches up, we can discuss deprecating/removing the "just dumped in global" way of doing things in PHP 9.
Source: I'm very likely going to be the main person driving this push.
Just because "most others use . or :" doesn't mean it's the only correct syntax in the realm of possibility.
CLOS is built-in.
> CLOS isn't what we normally describe as OOP
There is no 'normal' description of OOP. Smalltalk, C++, Java, Self, Javascript, ... are all object-oriented programming languages and are widely different. If you look at the OOP literature you will find dozens of definitions of OOP.
CLOS has classes, instances, inheritance, dispatch, and other features of OOP.
> Both normally have a global namespace.
Namespaces for symbols in Common Lisp are called 'packages'.
Well, yes, though I consider it far superior to most other object systems out there.
Still, the selection of languages that do is so vast that such reasons hardly answer the question "why Pascal, of all the options".
I care about performance (ruling out any GC language), multi-platform native binaries, language readability, dev community, and a bundle of other factors. Pascal turns out to hit most of my needs and not annoy me too much.
Of the thousands of more obscure languages, I'm sure there's one that'd be perfect, except I'd have a worse time with libraries.
[Citation needed]
OOP just means "functions are associated with data in a syntaxic construct of the language". Namespaces are irrelevant.
I have been searching for it for 15 min now, but last month or so on hn there was a article comparing programming languages and compilers. fpc performance was comparable to c.
Also a mvp production exe will be 2.5 MB, no stdlib/.net/qt needed.
And a hello world Free Pascal EXE can be as small as 57KB:
$ dir fpc_hello.exe
07/26/2016 09:43 PM 57,402 fpc_hello.exe
Source and output:
$ type fpc_hello.pas
program hello_1;
{ uses ; }
var i: integer;
BEGIN for i := 1 to 10 do
begin
writeln(i:4, ' Hello from Free Pascal');
end;
END.$ fpc_hello
1 Hello from Free Pascal
2 Hello from Free Pascal
3 Hello from Free Pascal
4 Hello from Free Pascal
5 Hello from Free Pascal
6 Hello from Free Pascal
7 Hello from Free Pascal
8 Hello from Free Pascal
9 Hello from Free Pascal
10 Hello from Free Pascal
I also checked the size of similar programs in C and D. C was about 22KB, IIRC. D was something more, don't exactly remember, but not a lot more, probably.This is a pro of Pascal then :)
I was also looking for the pros of Pascal in contrast to what we've come to expect of languages while skimming the article.
Something else to mention about lazarus is you can hot compile the ide too add in components, fix issues; While using lazarus. It takes a couple of minutes to recompile and there a fail safe cli method to restore. But rather amazing if you wonder how long it takes to compile visual studio professional or qt.
http://wiki.freepascal.org/IDE_Window:_Configure_Build_Lazar...