3 ms·
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
by mdhughes 9y ago
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.
- ansible 9y ago... 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.
- V-2 9y agoI'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".
- mdhughes 9y agoThere 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.
- emodendroket 9y ago> I care about performance (ruling out any GC language) [Citation needed]
- CiPHPerCoder 9y ago> 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.
- mdhughes 9y agoNamespaces by 2020? That'd be nice. The \ syntax still makes my eyes bleed a bit, when most others use . or :
- CiPHPerCoder 9y agoYou 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.
- emodendroket 9y agoI think there's some reason they landed on that one, but seriously, if that's your biggest complaint about the language...
- emodendroket 9y agoI'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.
- cwyers 9y agoThe obvious languages to compare to are Java and C#, though.
- zeveb 9y ago> 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.
- ape4 9y agoC++ 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-c-have-namespaces https://stackoverflow.com/questions/4396140/why-doesnt-ansi-...
- lispm 9y ago> 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'.
- jcelerier 9y ago> what we normally describe as OOP OOP just means "functions are associated with data in a syntaxic construct of the language". Namespaces are irrelevant.