std::args().skip(1).next().unwrap();
...to be OOP? Because that looks remarkably like some Java code I've written. std::args().skip(1).next().unwrap();
...to be OOP? Because that looks remarkably like some Java code I've written.What I mean by OOP is the smallest unit of programming being an Object with mutating data. These objects are basically combinations of mutable data and methods tied together into entities. Imagine a graph of a bunch of mini-programs with mutating state, moving around, getting injected into one another and talking to one another. This is OOP.
This is opposed to another style of programming where data flows through pipelines from input to output rather then a bunch of entities messaging each other and changing each others state. Both Rust and Go are moving away from this OOP paradigm of programming by putting less emphasis on OOP based syntax.
Two of the most popular are what I've nicknamed the "Smalltalk definition" and the "Java definition".
Alan Kay, on OOP:
> OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. It can be done in Smalltalk and in LISP.
Java, which I attribute to Java simply because it's very popular and clear about how they think about this:
> https://docs.oracle.com/javase/tutorial/java/concepts/ defines five core concepts:
> * An object is a software bundle of related state and behavior.
> * A class is a blueprint or prototype from which objects are created.
> * Inheritance provides a powerful and natural mechanism for organizing and structuring your software.
> * An interface is a contract between a class and the outside world.
> * A package is a namespace for organizing classes and interfaces in a logical manner.
This Rust code is missing key aspects of both definitions. The surface syntax may look the same, but the details are different:
vs Smalltalk, this is the opposite of late bound, or "messaging": it's all early bound, aka statically dispatched.
vs Java, there's no objects here: while there is a method syntax, Rust separates state and behavior, into structs and functions. Methods are functions that support the method call syntax in addition to the regular function syntax. There's no classes here, nor inheritance. There is the use of an interface-like thing, and namespace/package like things.
TL;DR: there's more to OOP than method syntax.