News for hackers. Stuff that matters.
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.