News for hackers. Stuff that matters.
Re:Why I use Object Pascal by V-2 on Tuesday October 17, 2017 @09:29AM (#15490702)
"You can also define your own types", "classes can also inherit other classes", "Pascal is modular"...

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.

Re:Why I use Object Pascal by mdhughes on Tuesday October 17, 2017 @09:47AM (#15490832)
C has no classes, and everything's in one global namespace.

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.

Re:Why I use Object Pascal by zeveb on Tuesday October 17, 2017 @10:44AM (#15491309)
> Scheme & LISP have no built-in classes

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.
Re:Why I use Object Pascal by CiPHPerCoder on Tuesday October 17, 2017 @10:06AM (#15490969)
> PHP in theory has namespaces, but the standard libraries are just dumped in global.

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.

Re:Why I use Object Pascal by mdhughes on Tuesday October 17, 2017 @10:34AM (#15491213)
Namespaces by 2020? That'd be nice. The \ syntax still makes my eyes bleed a bit, when most others use . or :
Re:Why I use Object Pascal by CiPHPerCoder on Tuesday October 17, 2017 @04:25PM (#15494603)
You might want to go see a doctor and get that checked out then.

Just because "most others use . or :" doesn't mean it's the only correct syntax in the realm of possibility.

Re:Why I use Object Pascal by emodendroket on Tuesday October 17, 2017 @08:18PM (#15496033)
I think there's some reason they landed on that one, but seriously, if that's your biggest complaint about the language...
Re:Why I use Object Pascal by emodendroket on Tuesday October 17, 2017 @08:19PM (#15496038)
I've posted this before but I've really been pleasantly surprised by how good working in PHP7 is. It's not my favorite but I certainly like it more than Ruby.
Re:Why I use Object Pascal by lispm on Tuesday October 17, 2017 @03:41PM (#15494193)
> Scheme & LISP have no built-in classes, and one can argue that CLOS

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'.

Re:Why I use Object Pascal by ansible on Tuesday October 17, 2017 @09:59AM (#15490920)
... and one can argue that CLOS isn't what we normally describe as OOP.

Well, yes, though I consider it far superior to most other object systems out there.

Re:Why I use Object Pascal by V-2 on Tuesday October 17, 2017 @10:04AM (#15490959)
I'm not saying these are features provided by every modern programming language - obviously eg. there are FP languages that are not object-oriented, as you pointed out.

Still, the selection of languages that do is so vast that such reasons hardly answer the question "why Pascal, of all the options".

Re:Why I use Object Pascal by mdhughes on Tuesday October 17, 2017 @10:29AM (#15491157)
There are only a few "popular" languages that have both, many that don't; those are not mandatory features for everyone.

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.

Re:Why I use Object Pascal by emodendroket on Tuesday October 17, 2017 @08:20PM (#15496042)
> I care about performance (ruling out any GC language)

[Citation needed]

Re:Why I use Object Pascal by cwyers on Tuesday October 17, 2017 @10:41AM (#15491283)
The obvious languages to compare to are Java and C#, though.
Re:Why I use Object Pascal by ape4 on Tuesday October 17, 2017 @12:03PM (#15492055)
C++ has namespaces. Yikes, I looked C namespaces. People are suggesting that you can put things in a struct. https://stackoverflow.com/questions/4396140/why-doesnt-ansi-...
Re:Why I use Object Pascal by jcelerier on Wednesday October 18, 2017 @01:15PM (#15500922)
> what we normally describe as OOP

OOP just means "functions are associated with data in a syntaxic construct of the language". Namespaces are irrelevant.

Re:Why I use Object Pascal by oneweekwonder on Tuesday October 17, 2017 @10:23AM (#15491092)
> 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.

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.

Re:Why I use Object Pascal by vram22 on Tuesday October 17, 2017 @03:55PM (#15494315)
>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.
Re:Why I use Object Pascal by cies on Tuesday October 17, 2017 @11:05AM (#15491506)
> 2.5 MB, no stdlib/.net/qt needed.

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.

Re:Why I use Object Pascal by oneweekwonder on Tuesday October 17, 2017 @12:26PM (#15492271)
Lazarus on ubuntu and windows is usable, i'm still struggling with macOS and there is legends and lore of ios/android support. It even seems to support qt, but I have not went there yet.

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...

Re:Why I use Object Pascal by cies on Tuesday October 17, 2017 @02:01PM (#15493132)
That's some interesting pros! Thanks man.
Re:Why I use Object Pascal by oblio on Tuesday October 17, 2017 @09:40AM (#15490773)
Well, C is still top-5 in all the programming language rankings I've ever seen, so... :)
Re:Why I use Object Pascal by V-2 on Tuesday October 17, 2017 @10:07AM (#15490975)
OK, but "it's not C" doesn't really make Pascal stand out ;)
Re:Why I use Object Pascal by leledumbo on Thursday October 19, 2017 @03:57AM (#15506185)
C has its root buried deep in programming world. A lot of things were written in C, big things, that people don't want to touch but they have to use. It's no longer as popular as, say 5 years ago. Along with Java, the popularity is being decentralized as communities of other languages get stronger (including Pascal).
Re:Why I use Object Pascal by TremendousJudge on Tuesday October 17, 2017 @09:40AM (#15490778)
neither javascript nor C++ are modular in 2017
Re:Why I use Object Pascal by dozzie on Tuesday October 17, 2017 @09:48AM (#15490839)
...for some value of "modular".
Re:Why I use Object Pascal by muthdra on Tuesday October 17, 2017 @10:28AM (#15491138)
...for some value of "2017".