6 ms·
I feel that it is in fact possible to learn from history, and what humans tend to be good at and bad at, and derive useful directions for the future. "Use the r
by tolmasky 7y ago
I feel that it is in fact possible to learn from history, and what humans tend to be good at and bad at, and derive useful directions for the future. "Use the right tool for the job" and "no silver bullets" are certainly tautologically correct, but they seem to miss the point of these discussions: we have a choice in what paradigms we teach, what frameworks we write, and what tools we use. How do we choose the right tool? These platitudes often have the (unintended?) consequence of effectively serving as veiled gate-keeping: "silly novice, you thought learning X was sufficient? No no, you must learn all the possible paradigms, and at some point you will become aware of which one to precisely apply for any given problem. Me merely telling you the solution would be cheating!"
Practically speaking, in my opinion, beginning teaching programming with an OOP approach can be detrimental to students. When I see students work in procedural (not even functional!) environments, they seem to piece together "the puzzle" of the programming task, whereas in OOP environments they often seem to devolve into strange taxonomical metaphysical questions "Is a Car a Vehicle? Or does it implement Drivable? Is a Window a Widget itself, or does it only own Widgets? If it's a Widget itself, then could a Window contain sub-windows?" So at least for the very constrained question of introductory languages and techniques, I think there is nothing wrong with specifically calling out certain approaches, vs. vaguely attesting to the truism that you can write bad code in any language. This feels similar to when people discover the concept of Turing Complete, and thus conclude all languages must thus be equivalent and any programming language discussion is thus moot. No. If that were the case, we should have never bothered going past assembly.
- yoz-y 7y agoWhat courses or universities actually start with OOP? In my uni we started with functional programming (Scheme) and then went to C, only then we learned Java, C++, Prolog and so on. In another uni when I supervised some exercise classes all students started with Python but using only imperative paradigm.
- tolmasky 7y agoIn high school AP Computer Science uses Java (20 years ago when I was in high school, they were just transitioning off of C++). You can see what the earliest programmers are being taught here: https://apcentral.collegeboard.org/pdf/ap-computer-science-a-course-a-glance.pdf?course=ap-computer-science-a https://apcentral.collegeboard.org/pdf/ap-computer-science-a... Edit: When I was in HS, the AP CS courses (now there is only on since the second one was discontinued) used the "Marin Biology Case Study" ( https://en.wikipedia.org/wiki/AP_Computer_Science_A#Marine_Biology_case_study_(2000-2007) https://en.wikipedia.org/wiki/AP_Computer_Science_A#Marine_B... ). It has apparently been replaced with the "GridWorld" similar case study. I think it highlights one of the issues of OOP: a fascination with modeling, or perhaps over-modeling, the real world. Throughout the course you are expected to develop deep knowledge of a myriad of Fish and Fish Tank-related classes, which while perhaps an accurate preview into what working in an environment like Java is like, is not something that in my opinion succeeds in either exciting most students nor teaching them the "fundamentals" of algorithms and such. I think it can very much feel like a very complex and convoluted exercise in meeting the abstract goals of "categorizing" the world. Ironically, the insistence on modeling the world makes it feel frivolous and disconnected from any practical use -- which is incredibly sad since IMO CS could be the most practical math/science course you take. In my experience when you show kids the cool things that they can get computers to do for them, it can be more inspiring -- such problems do not lend themselves well to formalized class hierarchy drawing though.
- topkai22 7y agoThey are back to two, and the new one appears much further down the “not only OOP” path. It’s more about the grand ideas of CS and less about programming. https://en.m.wikipedia.org/wiki/AP_Computer_Science_Principles https://en.m.wikipedia.org/wiki/AP_Computer_Science_Principl...
- Rapzid 7y agoWent through AP comp-sci 20 years ago too. We learned with C++ via DJGPP. Can't recall if the AP test was in C++ or pseudo code.. Certainly covered data structures, recursion, graph traversal, and etc. High School. Something to consider for those complaining about basic data structure questions in interviews :)
- invalidOrTaken 7y agoMy university began with OOP. I had to discover FP myself! Uphill both ways!
- DaiPlusPlus 7y agoMy uni had a semester-long course on Haskell which I took - but it was mostly about the syntax, understanding `foldr` and writing trivial programs - I can’t say I really learned anything from the experience - I guess because we never did any large-scale examples (I dare say “real-world examples”). Yes, we can do quicksort in 3 lines - but how can I use Haskell for an OLTP workload? How can I use Haskell to program a GUI? (More to the point: how do we reconcile the mental-model of a GUI (the canonical example of mutable OOP!) with Haskell’s immutability? Unrelated: Haskell needs a more approachable alternative syntax. People bash VB.NET - but it’s a great way to transition people from beginner and PHB-friendly languages (where people completely unfamiliar with a language can still generally understand what’s going on, like Fortran, COBOL, the BASIC family, etc) into an environment where the full .NET library is available before fully transitioning to the alien-seeming curly-braced C#. ...even as a C# programmer, I prefer writing functional-style code with immutable data. I’m not so far as to write the core of a program using Reactive Extensions - but things like Linq - for example.
- Multicomp 7y agoBased on your last paragraph, it sounds like you are describing F#. F# is an immutable by default functional-first programming language in .net.
- ferzul 7y agomodule Main { IO<Void> main() { Integer n <- read$(getLine) // or: fmap(read)(getLine) print(fib(n)) } Integer fib(Integer n) { Integer go(Integer !n, Integer !a, Integer !b) { if (n==0) { return 0 } else { return go(n-1, b, a+b) } } } } pros: it looks plausibly like Java. cons: all the things that haskell syntax makes easy like partial application become obscure at best. omg, i'm dying in squiggly and round brackets, what is this, lisp? there's too much stuff that has to become ad hoc builtin syntax, like <$> becomes $(...). i don't know if you can program applicatively with this syntax, but i doubt you could have invented it.
- pjmlp 7y agoMy degree in the mid-90's used Pascal on the first year, than moved into C++, which back on those days meant 2nd year students would all be implementing their own string, vector, list, double list, priority queue, ... classes. C was never though, it was thought to be mostly relevant for UNIX coding and students could anyway get into it via the C++ lectures. Then there was Prolog, Smalltalk, Lisp, Caml Ligh (OCaml's percursor), Algol, x86 and MIPS Assembly. Those that opted into compiler design/software engineering lectures also got into a myriad of other programming languages even if only as overview of what used to exist out there, namely Ada, Eiffel, Sather, Oberon, BETA, PL/I,...
- DaiPlusPlus 7y agoDon’t most university courses worldwide start with Java - or use Java as a mainstay? There are practical benefits: everyone knows it, it’s easy to learn (the language, while the library is straightforward too), and there’s a huge ecosystem. ...and it’s OOP. Back when I was finishing HS and touring ~5-6 different universities - every single one said they used Java - one said they were about to switch to teaching most of their first two years using JavaScript (this was a few years before NodeJS was even released so the notion of using JavaScript as a serious didactical language wasn’t taken seriously by me.
- p1esk 7y agoIn my school currently they offer intro to programming in Python. For those who already know the basics the first course is using C. The next one is C++ and after that Java.
- repsilat 7y agoIt rings true to me, at least in CS and especially software engineering. In mathematics, physics and "real engineering" departments I haven't seen it at all, though, and my experience may date me. It was my first semester of university programming in '05. Anecdotally, I wasn't as bothered by "public static void main string args" as I was by - Starting execution in MyClass.main, - Instantiating a MyClass, then - Calling MyClass.run(). That took some head-scratching. It's an argument against Java as an introductory language, but not much of one, because "Just ignore that bit until CS102" (or forever if you're never going to do another CS paper) actually works pretty well.
- DaiPlusPlus 7y ago> It rings true to me, at least in CS and especially software engineering. In mathematics, physics and "real engineering" departments I haven't seen it at all, though, and my experience may date me. Ah - yes. My friends at uni doing physics said they had to learn C++ - but only enough to write simple C-style programs and using simple classes without going into OOP design, design patterns, and large-scale concerns (I guess because they were all using some physics tool, and I understand it's good for interfacing with Fortran too). My friends doing EE (excluding those doing embedded work) said they all had to do Matlab, some friends doing mathematics reported the same. EE people also said they did some C too.
- bitwize 7y agoToday, Java and, increasingly, JavaScript have supplanted the Pascal, BASIC, and C kids in the past started with. Scheme is cursed. No one wants to teach it, especially to beginners. MIT abandoned it in favor of Python for its introductory course more than a decade ago, and even the Racket folks are backpedaling hard on Lisp syntax, proposing a conventional infix syntax as the default for Racket2.
- brlewis 7y ago> How do we choose the right tool? We choose the right tool the same way a painter chooses among oil paint, watercolor, etc. Step back and look at the subject, and think how well each type of paint would represent it. Also consider one's own skill with each type of paint, one's interest in exploring new paints, and the cost of obtaining and storing another kind of paint.
- tolmasky 7y agoRight -- this is exactly the kind of language that turns people off. It is a vague analogy with no practical advice that compares the act of programming to the art of a skilled painter, giving a field that strives to have the restraint and responsibility of engineering a sort of weird "you have to hear the music" feel. I want to make clear that I do not necessarily disagree with your assessment, but understand that there are people who are deciding whether to pick up an FP book or OOP book. They have to start somewhere, and this "wholistic" advice isn't tremendous help. Similarly, as an industry, it's hard to translate what you just wrote into the next UI framework. I think we can agree that we feel comfortable enough with loops to not take a completely neutral stance on the "loops vs. lngjmp opcode" debate? If someone asks you whether they should uses gotos everywhere it isn't strictly necessary to say "depends on the problem!" given that they probably aren't writing assembly-level filters for Adobe Photoshop where using a goto might actually make a difference -- since they probably wouldn't be asking in that case? This isn't even an "all things being equal" situation. We are actively encouraging OOP to entry-level programmers today -- it is fair to ask whether that is the right move, because doing nothing is actually just choosing that OOP should be the default. It is totally fine to say "maybe OOP has not delivered on its promises, and while there may be useful lessons here, I think its safe to say that its probably not the tool you should choose FIRST for any given problem."
- ljm 7y agoI suppose it's an aside to your main point, but after 15 years of doing this stuff (and learning to code by writing procedural PHP first, back in the 4.0 days), I've spent a portion of it investing in OOP and now I'm starting to take a step back from it, and I'm having much more fun writing code without having to worry about classifying the code I'm writing. The things that OOP does well can be achieved quite nicely using other programming paradigms: you don't need a class system or a hierarchy to encapsulate your state and behaviours. And a good OOP language gives you the resources to model your behaviours in functional and procedural ways so long as you have first-class functions and good support for expressions in favour of statements. OOP fits much better into an organisational model where you can think about domains, roles, and responsibilities, and all of a sudden your Factories, Validators, Services, Commands, Builders, Entities and Repositories map to the same way of thinking your hierarchy of teams and managers does, with all of the overthinking and bike shedding that comes with it. You could build the same feature without all that but I think you need an experienced and disciplined team to pull it off well. And I think that supports your point: if the entry point to programming wasn't OOP (like with Java or PHP or even Ruby) but something more fundamental, then maybe that gives you the opportunity to decide when you need the power of abstraction that OOP gives you.
- Aeolun 7y agoThere’s little point in teaching either functional or procedural programming, as they’ll both be more or less covered when you’re learning Object Oriented programming. There’s nothing preventing certain functions from being procedural or functional.
- Aeolun 7y agoIf you disagree, I’d love to know why. Every time I see a post like this, or my comment get downvoted, I read the Wikipedia article again, and am forced to conclude that no, I still don’t appear to be wrong. - Procedural programming: programming with procedures (e.g. functions) - Functional programming: programming with only functions - OO programming: programming with procedures and classes.
- willtim 7y ago> I still don’t appear to be wrong. Procedures are not functions! I can understand the confusion since both Java and OCaml will let you define both. Procedures have side-effects, e.g. mutating global state, (pure) functions don't. Functional programmers work with predominantly immutable values and this requires a very different style of programming - one that many people struggle with if they have not had much exposure to it. Functional programming languages also have syntax and abstractions (often taken from maths) that are not used in object oriented programming. Why program with functions and immutable data? It enables better composition.
- Aeolun 7y ago> Procedures are not functions https://en.m.wikipedia.org/wiki/Procedural_programming https://en.m.wikipedia.org/wiki/Procedural_programming I guess I just happen to be reading an article that doesn’t make any distinction. > Functional programming languages also have syntax and abstractions (often taken from maths) that are not used in object oriented programming. True, but this is nothing related to functional programming an sig.
- monster99 7y agoThe problem is the human mind is not made to understand computers, the reason we have C is because assembly language was tedious, the reason we had assembly language is because direct programming binary was tedious... You see at each layer we've created abstractions. The problem is what we want to do or is easy for us in the real world is a giant list of millions of instructions for a computer turning a switch on or off according to some mathematical function. When we want to draw we get a pencil and paper because the universe already provides the 'infrastructure'. Programming however means you're creating entire universes from scratch. That means you have to create atoms, define their characteristics and functions and you basically end up having to understand the behavior of the machine to get it to do what you want it to do. At scale this completley out-stripes what the human brain is capable of grasping. The reality is research into translating machine or human models back and forth between mind and machine needs to be a field unto itself. The hardest part about programming when you start is wrapping your mind around how the machine works underneath it's a foreign language to most peoples minds. So I have serious doubts most people can comment on it with intelligence. Most people are not experienced enough to know what they don't know. What are valid and not valid criticisms, etc. Because it takes a lot of tim and expertise to understand different models, abstractions and approaches.
- csande17 7y ago> How do we choose the right tool? A good rule of thumb is that your code should be as close as possible to a plain-English description of what you want the code to do. So if you're trying to write a program like "When you click the button, it turns grey, and then sends the message, and then turns blue when the message is done being sent", imperative programming is probably your best bet. If you're writing "find all the posts that contain the word 'donut'", something like SQL or functional programming is probably a good fit. You can usually tell when you made the wrong choice when you end up needing to think really hard about how to fit the behavior you want into your paradigm, or when you have to write a big long comment saying, "This isn't very clear from the code, but here's what it's trying to do..." And as GP says, there isn't any one paradigm that's good for everything, so well-written programs will often use a mix of them. If someone tries to tell you that one size fits all (all programs should be imperative C! all programs should be object-oriented Enterprise Java Beans! all programs should be functional TypeScript!), that's usually because they aren't a very good programmer.
- jplayer01 7y agoExcept there's no book or course or whatever that can teach somebody these things. Instead, everybody has to figure it out on their own, and usually they just don't. Engineering disciplines don't work this way. I don't understand why it's okay for software development.
- locoman88 7y agoVery well put, that's why I cringe every time a fellow soft dev considers himself an engineer
- fanf2 7y agoThere are books and courses that try, eg https://www.info.ucl.ac.be/~pvr/book.html https://www.info.ucl.ac.be/~pvr/book.html
- jplayer01 7y agoThis looks great, thanks. Definitely gonna give it a read.