by michaelochurch · 14y ago · 0 comments
For example, when you write a SQL query, do you have to micromanage the database in how it's performed? No. That's an example of encapsulation. The implementations are different, but the interface is fairly stable. That's something OOP-like that works very well-- an interface that hides (encapsulates) complexity.
Objects are general and powerful, and that's part of the problem. "Power" isn't always good; GOTO is also extremely powerful, but should be used sparingly. Objects are not specific. Is it a function, or a tangle of methods, or a data object, or a "singleton" module? This isn't clear, and it becomes even less clear in the industrial world where tens of hands pass over code and it turns into mashed potatoes.
There are some good ideas in "object-oriented programming", but it's also an extremely complicated programming model and it's hard to develop OOP code correctly. If you don't know what "open recursion" is and why it's dangerous, you shouldn't be doing OOP.
What happened in the 1990s is that there was an effort (now becoming acknowledged as a failure) to commoditize programming talent-- to make 5 mediocre programmers able to replace a great one, and thereby prevent what we see now (the long-term "threat" of top software engineers outclassing professional managers in social status and compensation). Thus was born a bunch of design-pattern cargo-cult stuff designed to make programming slow, tedious, and limited but easy enough that mediocre people could do it, if they were stacked on top of each other in large enough numbers. Thus were born bloated, horrible codebases that bastardized "object-oriented programming" beyond imagination-- 21st-century spaghetti code.
People should be required to learn the basics of programming first. They should start with immutable data objects, referentially transparent functions. Mutable reference cells can come next as an optimization. Then, it's a good idea to learn type systems through OCaml or Haskell. After that, they can tackle the hybrid OO/FP of Scala. (Once you've learned Scala, there's no reason to use Java unless you need performance.) There are times to use OO and times to use FP, but if you aren't smart or curious or dedicated enough to grok FP, then you'll never actually understand OO either and you have no business trying to use it.
People learn best when they're presented with one new concept at a time, and the problem with OOP is that it presents tens of new concepts at the same time, with no separation. It leads to cargo-cult programming because people start coupling concepts that don't necessarily belong together.
Immutable data objects and all the stuff are not the basics of programming. They never were. Unless you single-handedly redefine the meaning of "programming".
The whole text you just wrote is full with dumb self-praise and deprecation of others; based on worship of principles that were never proven to produce good software, or any software at all. This receiving upvotes makes me sad.
If you're coming from the first perspective, than mutation is fundamental. Registers are always changing in value and everybody likes self-modifying assembly.
However, if you're coming from the second direction--which is at least as fundamental as the first--the basis of computation does not involve mutation. This is where the lambda calculus comes in. It's the abstraction that underlies most of the mathematically well-behaved languages. And in the lambda calculus, as well as a bunch of its popular variations, there is no mutation.
From this second perspective, immutable data is a basic building block of programming. Essentially, all you have are functions that can bind names to arguments and be applied to each other. It's a surprisingly simple and elegant model.
There are some other popular models of a computer program like the SKI calculus. However, it's easy to translate between the lambda calculus and SKI calculus, so for the purpose of this discussion they are effectively the same.
So from a more mathematical standpoint, functional programming is more fundamental than imperative programming. Redefining the meaning of "programming" is not required!
When you argue that programming is something else, you're doing just that: redefining.
Because from the first days programming meant building computational devices or programming programmable devices. And those have changing state, and then they have machine code, which mutates state. It's how it always was and now some people want to redefine it but I say no to them. Programming is not CS. Programming is about producing programs. Historically and statistically programs are written to work by mutating their state.
Programmers need to understand the difference between the abstract algorithm they're trying to express and the representation they've chosen (and the ones they didn't) inside the computers they're using, just as astronomers need to distinguish between the stars they study and the measurements coming out of the various telescopes they can choose.
Hacking: getting shit to work in a fast manner/making something faster.
These are two orthogonal philosophies that give you very different perspectives, and they are both labeled as "programming."
So, how about this: the next time you want to deride someone's opinion because they are misusing a term, why don't you clue the rest of the class into what your definition of the term is?
Consider function composition which is commonly taught in required pre-calc courses.
f(x) = ......
f(g(x)) = ......
I will submit that first-class functions map more directly to function composition than polymorphism does. In turn, this background helps new developers have a stronger understanding of polymorphism and when to use it.
Whether or not fp principles were ever "proven to produce good software, or any software at all" is besides the point. What's more important is whether or not fp ideas make for better DEVELOPERS. Maybe they do.
And by the way, I don't think anybody should first know anything before learning how to program. Programming is like breathing. Do you need to study anything before you breathe? No you don't!
So anybody who argues that you should learn all sorts of not useful things before having the privilege of trying useful things, is a strange person indeed to me.
Immutability was considered to be more fundamental when I took my first programming course at MIT. I received a very good education.
We, of course, eventually moved onto objects with mutable, but they were definitely considered to be more dangerous and less fundamental.
Me, not really interested in what people who never wrote any widely used software consider more what and less what.
Programming is what happens (and always happened) on top of computing devices that have, you know, memory, registers and opcodes. It's just the hard truth. That's what programming is. Writing code that compiles (interprets) as machine code for said computing devices. All other kinds of stuff - not programming. Call it CS, call it whatever.
Parent of your comment might have been talking the Structure and Interpretation of Computer Programs. Likely it needs no introduction, but it is absolutely about programming, and goes right down the rabbit-hole to implementing interpreters, virtual register machines, and a compiler for said machine. Yes, the first couple of chapters is mostly purely functional, but that doesn't detract from the rest, which includes mutable code as well.
Really, I don't know why you're so hostile to this pedagogical approach. Do you have experience with teaching CS and/or programming, and have found using C or assembly or following some kind of Java school curriculum more effective? Have you found teaching functional programming first deficient? Or maybe you're looking at this from the perspective of an employer and have had to deal with hiring new grads who are brain damaged by functional intro CS classes?
I, for one, welcome this kind of experimentation or change of pace on the part of CS educators like Robert Harper at CMU (http://existentialtype.wordpress.com/). It can't be worse than what I had (mediocre, big box state Java school)
Oops, my mistake. I took you for a serious poster, not a troll.
The class I took at MIT (SICP) and the textbook that was used are world-famous, and it was certainly a programming class.
As to having "never written any widely used software": Among other things, I wrote the software that was used to configure a NASA space telescope (Rossi X-ray Timing Explorer), from which about 1,000 peer-reviewed astronomy papers were published. I've worked on brain surgery software (3D Slicer) and now I work on software used for doing RNA Interference-based cancer research.
But I guess you've made your point: All that is just "Computer Science" noodling, not real programming. So, sure don't listen to what I say.
This argument is getting really really really old. Anyone with 5 minutes and a working internet connection can find hundreds of successful widely used applications written with a focus on immutability, either at the language level or the design level.
You've pretty much blown any credibility you had right there.
I think you are making two mistakes:
(1) Assuming that any good API/interface must be object-oriented; and
(2) Assuming that, when using object-oriented programming, that good APIs/interfaces come naturally.
Cells are obviously a very successful kind of module. What does that really mean? It's just an analogy. Erlang, the "non-OOP" language under discussion, seems to resemble cells at least as well as "OOP" languages (perhaps more so, because you don't have to synchronously wait for a response for every interaction).
This is part of the reason that people call erlang an OOP language. So clearly there is a major confusion over terms here, because the creator of erlang didn't originally consider it to be OOP.
OK, so let's assume that we're actually talking about something that is as non-OOP as I can imagine: haskell. Let's also assume that haskell doesn't resemble cells as much as OOP does. There are still problems:
* Many interfaces in haskell are very well-designed, so it's hard to argue that OOP has a monopoly on good interface designs
* It's not clear that the goals you mention, such as unexpected dependencies, are actually reduced by using OOP.
* It's not clear that a superficial similarity with cells really translates to anything meaningful. If nothing else, evolution of cells takes place on million-year timescales, and doesn't drive toward any one particular kind of outcome other than self-perpetuation; which are not a good set of properties when it comes to project management.
Neither argue that FP can't be built modularly with a wonderful structured API. OOP, conceptually, is simply one way to accomplish that goal. FP is another.
In both cases, the underlying philosophies are sound, it is the humans that implement the solutions that fall well short of the mark.
For an analogy to have any use at all, it must illustrate a contrast between two relevant ideas.
The article is entitled "Why OO Sucks" and written by the author of Erlang.
I "projected" that the comment to which I replied was defending the non-suckiness of OO by using the cell analogy to contrast with erlang. Are you saying that was a leap?
What you are saying makes sense: there is more than one useful model. But that point should be made in the context of Joe Armstrong's specific criticisms; not claiming that OOP is as modular as a cell and erlang is not.
No matter what paradigm anyone comes up with, no matter how awesome and brilliant, we're always going to push it to its limits, then it's going to suck.
It's the same with CPU, network speeds, and highway congestion. If it's so wonderfully useful, we're going to use it.
That's news to me, although I dont claim to be an OO historian. The original OO language was Simula which was devised to do discrete event simulations. Its direct antecedent was work done on Monte Carlo simulations. Smalltalk and C++ were both inspired by Simula.
This should be a gigantic red flag waving at you.