r/programming • u/cruise02 • Sep 02 '12
12 (Really) Controversial Programming Opinions
http://www.billthelizard.com/2012/09/12-really-controversial-programming.html14
Sep 02 '12
If a method has a second line of code, it is a code smell. Refactor.
I would fire any asshat that tried to make that argument in earnest.
And as an aside, I've heard of studies that suggest long methods are actually less error prone than lots and lots of short methods scattered all over the place. I haven't read them yet, but my own experiences suggest that may be true for some types of programs.
7
u/cruise02 Sep 02 '12
It's hard to pick the craziest opinion in there, but this is one of my favorites. I guess it would be easy to get your classes to fit on one screen if all your methods are only one line though. :)
2
4
u/matthieum Sep 02 '12
I agree, but I think that for classes like for methods there are really two types.
Some methods do something: they compute a result, prepare a database query, etc...
On the other hand, other methods organize things, and thread calls to other methods perhaps with some conditional/looping constructs.
I would argue that doers should be kept short because they form a very coherent whole and it may be able to eyeball it. But organizers ? Let them grow if necessary, as long as their flow is mostly linear it's not a problem.
2
22
Sep 02 '12
Classes should fit on the screen.
I've heard that methods/functions should fit on the screen but classes..?
3
u/nroberts666 Sep 02 '12
I think there's a point there but I also think it's a bit extreme. Besides, who's screen?
10
0
Sep 02 '12
[deleted]
3
u/queus Sep 02 '12
Too many people believe you can eliminate complexity by moving it into the call graph or wherever - anywhere other than a chunk of imperative code.
Yes. But I still consider SLAP (Same Level of Abstraction Principle) to be useful guideline/euristic.
1
Sep 02 '12
Same Level of Abstraction Principle
That's pretty much why I had a method that only called one function - part of implementing one abstraction by calling through to another. There was more than one lower-level component involved in implementing the higher level class, but only one was relevant to that particular method.
2
Sep 02 '12
Well, if all your functions and methods are small, you generally need lots of them. It's perfectly possible to lose track.
Point is that you don't lose track of them if you do it properly. Because you write small functions that are then used to write another function which was originally the large function and then you just use the final function and never the other small ones.
The rest is solved by the magic of HOF:s
EDIT: I am obviously talking about bottom-up programming, the one and only programming paradigm that is the silver bullet that will free us all. I also think that I'm still drunk from last night.
4
u/Mjiig Sep 02 '12
Can we quit with this whole thing about how great controversial opinions are? How controversial your opinion is does not interest me, what interests me is how accurate and evidence supported your opinion is.
Now if instead we were using these threads to have structured debates about particular controversial opinions, that might be interesting (does "TDD like you mean it" actually help anyone?) and we might all be able to learn something. These threads are just about showing off how hipster/old you are.
1
1
u/geocar Sep 04 '12
Now if instead we were using these threads to have structured debates about particular controversial opinions, that might be interesting
You can't.
Reddit votes on what it agrees with and downvotes what it disagrees with, which means holding a position in disagreement with the hivemind means you cannot have a conversation with anyone else about it.
It'd be nice if there was a way to have those kinds of conversations with people.
7
u/Gotebe Sep 02 '12
Two lines of code is too many.
Right, that's not an opinion, that's karma whoring.
2. If it's not native, it's not really programming
Dinosaur, huh? Amoebae would say "if it's not card-punching, it's not programming". Take that!
3. The "While" construct should be removed from all programming languages.
See 2.
4. Copy/Pasting is not an antipattern, it fact it helps with not making more bugs
Oh, hi, Jake! (Jake's an ambitious secretary in a place where I work)
5. Developing on .NET is not programming. Its just stitching together other people's code.
Assembly is not programming. It's just stitching together other people's instructions.
6. The use of try/catch exception handling is worse than the use of simple return codes and associated common messaging structures to ferry useful error messages.
Doesn't know what he's talking about. Exceptions are about 80/20, and 80/20 is golden.
7. Test Constantly
Hey! Not controversial.
8. Object Oriented Programming is absolutely the worst thing that's ever happened to the field of software engineering.
Hmmm... That one is so dumb that it's hard to say where to start arguing. But it is well controversial!
9. C (or C++) should be the first programming language
Not necessarily. When learning, there's "hard", and there's useless distraction. I learned much of the "hard" stuff in Pascal (and I tried it with C first).
10. Classes should fit on the screen.
Hey! Not controversial.
6
u/the8bit Sep 02 '12
Hmm Interesting list, certainly more discussion worth than the last one! I think 10 is a good point, but taking the 'dont make long classes' mantra a bit too far.
As someone who has maintained 2000+ line mega classes, they are awful, but 50 line classes that just link me everywhere else are just as bad, I don't want to have 50 files open in my IDE when I am tracing some logic.
1
u/the_satch Sep 02 '12
taking the 'dont make long classes' mantra a bit too far
I took it as an exaggeration of the one-thing rule. Where a function or method should only do one thing, an object should likewise only be one thing. Yeah, but still, one page is being a bit strict.
11
u/pubby8 Sep 02 '12
Two lines of code is too many.
Can someone explain to me the reasoning behind this? I can't even imagine sticking to one line on languages like Factor and Haskell.
4
Sep 02 '12
I think the idea is that a function should do one thing only. Say you want to get the first five items from a list and sort them. Your function should not contain both the sorting and the extraction. Instead of having a function
getFirst5Sorted(list), you should have an expressionsort(getFirst(5, list))at the point where it is needed.Saying "two lines of code is too many" is just to get attention to it without sounding boring, and doesn't actually mean "your function should only have one line of code". You should, however, keep it as small as possible.
-3
u/geon Sep 02 '12
I guess the same reasoning explain the OOP hate. "OOP is not the best solution to all problems." does sound a lot less interesting.
3
1
u/valined Sep 03 '12
I read it as a joke.
1
u/pubby8 Sep 03 '12
Well there were 20 upvotes to the answer and I doubt more than one or two were upvoting for the laughs.
1
u/greyfade Sep 03 '12 edited Sep 04 '12
The reasoning isn't that you must have less than 2 lines of code. It's that you want to have functions that are short, clear, concise, specific, and descriptive.
Keeping your functions extremely short forces you to use clear names for your functions and keep their responsibilities clear. It makes for self-documenting code that is clean and eminently reusable.
That's in stark contrast to functions that are 50+ lines long and that do more than one thing. Longer functions tend to have more places where bugs can crop up, and they're more difficult to maintain than their shorter, well-refactored counterparts. If every line of code has 10 bugs, then a one-line function can only have 10 bugs, but all of them are easier to spot and correct.
Think of it as a rule that is an unattainable ideal that makes for a laudable goal, but that leaves plenty of room for practical work (even if the original writer didn't make that clear.)
1
u/kazagistar Sep 03 '12
Check out some Forth code, it can often be very very terse like this.
I think it is horrible for understandability, but that's just my opinion.
1
u/pubby8 Sep 04 '12
Asked the author on Twitter about it, he responded with:
I'm trying to reset your idea of what a "long function" looks like, so you will keep refactoring.
-1
u/Tekmo Sep 02 '12
Haskell is not a one-line language, for most reasonable interpretations thereof. For example,
donotation lets you write multi-line code:do x <- getLine putStrLn x putStrLn "A third line"Similarly, even for functions that don't use
donotation to assemble code, you can still split them syntactically into several lines:reverser str = let step1 = lines str step2 = map (unwords . reverse . words) step1 step3 = reverse step2 in unlines step4That's a pretty contrived example and definitely not idiomatic code at all, but syntactically Haskell does let you split even single pure functions over multiple lines to help you organize your code.
5
Sep 02 '12 edited Sep 02 '12
Regarding points 4, 5:
4) Using copy and paste by hand is a terrible idea, a linker can do the job much better. If you find a bug in your copied code you'd have to go through all your projects to fix it (and being aware of project specific changes). If you only have to fix one library instead, your goals are reached much more productive and it's less error prone.
5) You're using other people's code all the time anyway, even most C programmers do. And this is a good thing. Not only it's more productive, it's also much safer if it's not your area of expertise (e.g. encryption). Also: Many eyes see bugs faster and earlier. Third party libraries tend to be better tested then your freshly self written code, especially if it solves a common task.
22
u/teknobo Sep 02 '12 edited Sep 02 '12
Even though this seems to be just aggregating some Stack Overflow answers into blogspam, I'll bite.
Two lines of code is too many
If you're seriously going to complain about one extra line of code in a method, I don't see this ending well.
If it's not native, it's not really programming
Semantics. Even if you don't call it programming, you'd damn well better know those things if you want to use them. SQL, Java, and any other VM-based language may not qualify as "programming" by this definition, but they're still damn useful.
The "while" construct should be removed from all programming languages. (In favor of "Repeat...Until")
Semantics again. There is no functional difference between the two, and I would argue that while is actually preferable since it puts the looping condition right there on the same line, instead of having to skip to the end of the block to find out if you even entered the block in the first place.
Copy/pasting is not an anti-pattern.
No, it's not, and it's been proven. I'm having a hard time finding the peer-reviewed study on copy/paste programming right now, but basically, it's been shown to save a lot of time as long as you're using it properly.
Where the hatred for it comes in is that, like GOTO, if you use it too often, you'll probably end up using it wrong.
Developing on .NET is not programming, it's just stitching together other people's code
A reiteration of his 2nd point, but honestly, a huge amount of working as a professional programmer -- hell, almost the definition of working in a team -- is stitching together other people's code. There's nothing wrong with that, and it's hardly controversial.
The use of try/catch exception handling is worse than the use of simple return codes and associated common messaging structures to ferry useful error messages.
This has been getting debated a lot in go-lang circles, but the general consensus seems to be that unless you're working in an embedded environment (or some other highly-constrained environment), you're probably better off with try/catch.
Test constantly
Test-Driven Development is something that I personally agree with, and truthfully has become a very popular practice among Rails people. I don't see how that would qualify it as being controversial.
That said, certain studies have shown evidence that TDD is not as effective as many seem to believe.
Object Oriented Programming is absolutely the worst thing that's ever happened to the field of software engineering.
I've heard this claim semi-often. It seems to mostly come from people having worked with languages that claim to be OO but constantly make exceptions to the rules, like Java, C++, or Python. In fact, the author specifically calls out Java.
Try Smalltalk or Ruby and you'll come to see that OOP done right is actually quite wonderful.
C (or C++) should be the first programming language
Debatable, but certainly not controversial by any stretch of the imagination.
Classes should fit on the screen.
How big is your screen? I can fit any class definition on a 64" monitor.
Some classes simply must be large. It is an unavoidable fact that certain things are simply more complex to model than others. This point isn't controversial, it's just asinine.
Making invisible characters syntactically significant in python was a bad idea
This again? Is it really a controversial opinion if it's been something non-Python programmers have been whining about for decades? Because as far as I can tell, people whine about it for about the first five minutes of Python coding, and then give up because they would've been indenting anyway.
It can cause bugs when transferring code between computers, I'll give them that. Otherwise, it's Python demanding good formatting, something that you should be demanding from everyone on your team anyways.
My main regret with Python is that I haven't found a good tool that auto-formats everything (a la "gofmt").
But otherwise, Python's indentation requirements are so in line with common indentation in almost every programming language that proper indentation comes naturally to more or less everyone. In how many programming languages that you regularly use do you not format your conditional, looping, class/method, or exception blocks?
Singletons are not evil
It's not controversial to agree with Design Patterns. That book is more or less the undisputed truth on the subject, and it thinks the Singleton pattern is fine and dandy.
7
u/MatmaRex Sep 02 '12
C (or C++) should be the first programming language
Debatable, but certainly not controversial by any stretch of the imagination.
It's not controversial to you because you agree with it. I, for one, don't; the first language should be something nice and giving instant gratification, like Ruby or Python (or maybe Perl or JavaScript, although IMO these two are less nice ;) ); a language where you can write a simple Hello world! GUI application in 5 lines of code, an useful script in 30, and a simple game in 200.
C or C++ should be the second, so that you can see what sorcery made the first one possible, and maybe one time understand it.
6
u/anvsdt Sep 02 '12
The "while" construct should be removed from all programming languages. (In favor of "Repeat...Until")
I actually half-agree with this, but both constructs should be expressed as functions in the language, expressed as tail recursion. Language constucts should be general, special cases are bad for you, and that's what looping statements are: special cases.
2
u/notfancy Sep 02 '12
while B do Sis equivalent toif B then repeat S until ¬B.repeat S until Bis equivalent toS; while ¬B do S. In the first case (emulatingwhilewithrepeat) you just duplicate the condition. In the second case (emulatingrepeatwithwhile) you have to duplicate the entire loop body. It is actually a very sensible opinion to hold, if you have to choose one control structure over the other.4
u/anvsdt Sep 02 '12
Let me quote myself:
but both constructs should be expressed as functions in the language,
Or, don't give privileged status to a looping construct over another, make it easy to express them all.
while B do Siswhile (λx.B) do (λ_.S),repeat S until Bisrepeat (λ_.S) until (λx.B)(I'm borrowing Agda's mixfix syntax here). Even better if you can makewhile,untilandrepeatseparate and composable functions.1
u/SplinterOfChaos Sep 02 '12
Tail recursion is only efficient in certain languages, or in some languages only with specific implementations. While possible to implement and use in replace of the built-in constructs in almost all languages, it seems too "one size fits all".
I think that the while, for, repeat, etc., constructs should be thought of as optimizations. Using the right one for right problem offers the most optimal solution for whatever iteration you require.
2
u/anvsdt Sep 02 '12
Tail recursion is only efficient in certain languages, or in some languages only with specific implementations.
Then require proper tail call semantics. My controversial opinion is that we should remove specific contructs (optimizations shouldn't live in the language) and use the most general solution (proper tail calls). It has next to no downsides (you can get useful stack traces), it can be implemented fast, and OOP and FP break without PTC. Builtin constructs just trick the programmer into thinking ``how do I shoehorn this problem in terms of these builtins?'' because we assume that builtin = faster than a homegrown/library solution.
1
u/SplinterOfChaos Sep 02 '12
The problem is not semantics but implementation. Unless a language is specifically designed to deal with recursion, one has no guarantee that tail recursion optimization is even possible. An infinite loop could easily cause an infinite stack in such a case.
optimizations shouldn't live in the language
A converse opinion: A language exists to give us choice in what optimizations to use. If you choose Pthon, you choose to optimize your time. Haskell: your algorithm. C/C++: the hardware. I feel the need to repeat that this sounds very "one size fits all".
It has next to no downsides
when the language is designed for that specific purpose.
1
u/polveroj Sep 02 '12
The only language feature I can think of that precludes proper tail calls would be one that allows you to inspect the call stack at runtime. Unless the language standard includes features that make PTCs impossible, it's a very minor burden on implementors to make them mandatory, with great expressivity gains to the programmer.
Whether the language should also contain primitive looping constructs is another matter. At the very least, languages that make programming with higher-order functions painful (e.g. C) can't get away with replacing built-in looping constructs with library functions.
0
u/G_Morgan Sep 03 '12
The only language feature I can think of that precludes proper tail calls would be one that allows you to inspect the call stack at runtime.
Which is an indispensable feature of a number of popular languages.
Stack traces are better than language theory purity.
1
u/smog_alado Sep 03 '12
Stack traces are only relevan after the program crashes and are probably something the implementation should be doing for you. Allowing the programmer to inspect the call stack at runtime is a misfeature and a recipe for disaster (see Javascript's arguments.callee as an example that).
And even then, this is a non issue. In a language without tail recursion the code would end up having to be rewritten with explicit while loops or trampolining anyway and then BOOM! There goes your stack trace.
In the end, proper tail recursion is basically just as powerful/useful as the primitive goto while also baing much more amenable to writing structured code (both for the human and for the compiler). Really, the implementation is just a goto behind the scenes!
1
u/polveroj Sep 03 '12
Stack traces are usually provided by the runtime, and can be provided by the runtime with tail calls just as well.
Some implementations of Python, Ruby, R, and several other interpreted languages have APIs that let user code inspect the stack. You couldn't keep these APIs working the same way if you added proper tail calls to the language; you'd need to add a way to report that some parent frames have already been freed. These are the language features I was talking about; fortunately, they're not widely-used enough to make keeping strict backwards compatibility a priority.
4
u/mreiland Sep 02 '12
I've seen you mention studies for several of your rebuttals. I would love to see links to the studies themselves, I would be interested in reading them.
4
u/nroberts666 Sep 02 '12
"I'm having a hard time finding the peer-reviewed study on copy/paste programming right now, but basically, it's been shown to save a lot of time as long as you're using it properly."
In other words, not at all ;)
"My main regret with Python is that I haven't found a good tool that auto-formats everything (a la "gofmt")."
Would it even be possible? I have to admit that it's been years since I even looked at Python because I really, seriously hated it but isn't the difference between something being within and without a block simply the level of indentation? If that's the case I don't see how an auto-indent program could ever be created unless it knew the intent of the program, which would be ridiculous and perhaps impossible to do universally.
3
u/ninjeff Sep 02 '12
It could normalise your random mix of tabs and spaces into a defined number of spaces per indentation level. This would reduce the occurrence of indentation bugs when collaborating.
4
2
u/nroberts666 Sep 02 '12
Yeah, I can see how that would be useful.
A language with character tokens that represent blocks rather than "visual tokens", lacking a term to call indenting a block, can actually be processed by a computer program in a lot more ways. You can send beautifiers over code for example that can actually greatly alter how it appears without altering its behavior. I suppose this doesn't seem like a big deal to a python developer because I gather all python standards have to be the same.
One thing I have to say I really like and what probably throws me off about Python so hard, is that I like to just write out code until I notice my editor is doing something stupid. Simply finishing a block with '}' sets up my next line on the correct indent level, rendering my code readable...which is actually the most important part of all this. When the indent level is not where I expect it I then go looking for something I've done incorrectly, which is usually a missing token :P
I suppose a python developer would respond by saying that being forced to use whitespace as a part of the language makes sure the code is readable rather than relying on tokens and a tool to do it. I wonder though how the two compare with regard to error detection. In C++ if something is off then the indentation will be wrong, but in Python if something is off it all looks like whatever the developer made it look, no? It seems to me that this would make catching things during code review (which generally catches any readability problems for us) a little harder because you can't actually use whitespace as an indicator.
This is all predicated of course on a modern editor that actually does all this indenting stuff for you, which many are not.
2
u/matthieum Sep 02 '12
The use of try/catch exception handling is worse than the use of simple return codes and associated common messaging structures to ferry useful error messages.
When I see each method up the call tree with its own try/catch, I shudder. Exceptions are great to quickly escape/abandon an operation and unwind the stack unconditionally up to a dedicated place where the error they incarnate can be dealt with appropriately; it does not mean this is the only way to report issues, or that you should always catch them anywhere.
In this sense, the checked exceptions of Java may be one of the worst offenders, in that people have grown used to translate exceptions.
Singletons are not evil
I would argue to the contrary. Global variables may be useful (though their access better be well coordinated), and a Logger is a primary example of something you don't really want to thread through all function calls: it's just unnecessary clutter.
On the other hand, I would argue against the uniqueness property of Singletons. I have never seen any case where uniqueness was really necessary. Even the example given of a message pump is not so convincing. Sure, you could make an error and instantiate a new message pump from which nothing would come because it's not hooked up anywhere; it's just a logical error and if your message pump is correctly written it'll gently tell you that it's not hooked up or that there is no message in there.... on the other hand, you might also at one point read from 2 or more fluxes at the same time or alternatively => with a Singleton you are stuck, great...
2
u/bobindashadows Sep 02 '12
On the other hand, I would argue against the uniqueness property of Singletons.
This is the kicker. Your application only needs 1 instance of a given class, but the class's architecture shouldn't reflect that. Instead, just make 1 instance in your application's initialization. Dependency injection frameworks make this easy, too. I'm personally a fan of Guice's scopes, the abstraction under which Singletons fall.
1
u/nroberts666 Sep 03 '12
It really depends. Is it true that it is only the fact that your application needs one instance of a given class? If so then singleton is inappropriate.
If on the other hand the concept the class is mapping into code only makes sense as a single item in ANY application it is very appropriate to make it a singleton.
1
u/bobindashadows Sep 03 '12
Until that concept gets reused and configured differently in two different ways in the same address space by two independently developed modules.
In my experience, you can't be sure that won't happen unless you're writing a kernel.
1
u/smog_alado Sep 03 '12
| Global variables may be useful (though their access better be well coordinated), and a Logger is a primary example of something you don't really want to thread through all function calls.
I feel that the best way to solve this kind of issue would be either some way of having the language help you thread those implicit values around (a-al Haskell's type class dictionaries) or some for of well though out dynamic binding.
Global variables force too much rigidity onto the program and make it a pain if you ever want two kinds of loggers coexisting at the same time.
That said, this is just theoretical rambling here. In real life we have to make do with what we actually have.
2
Sep 02 '12
The "while" construct should be removed from all programming languages. (In favor of "Repeat...Until")
Semantics again. There is no functional difference between the two, and I would argue that while is actually preferable since it puts the looping condition right there on the same line, instead of having to skip to the end of the block to find out if you even entered the block in the first place.
Repeat...Until is the same as Do...While(Not). You will enter the block once regardless of whether the condition is true or false.
It is in fact not even the same thing as While, since While is a looping If.
1
Sep 02 '12
on python: it wouldn't be such a big deal if the compiler treated a tab as 4 (or 2 or 8 or some other constant) number of spaces. GHC treats tabs as 8 spaces, and as a result, you don't have people arguing about whitespace in haskell.
another good solution would be to have a compiler error when there are spaces at the beginning of a line (or when there are tabs at the begining of a line). it doesn't really matter what style they choose, but the compiler/interpreter should enforce one.
2
u/Brian Sep 03 '12
on python: it wouldn't be such a big deal if the compiler treated a tab as 4 (or 2 or 8 or some other constant) number of spaces
Isn't that what it does? It's the same as GHC, I believe, with Tab=8 spaces. The issue comes in only if you both have your editor set to display tabs differently, and mix tabs and spaces. As you say, the obvious solution for this is just to give an error when this happens, and require only one type of indent. Python3 now does this by default (and python2 has long supported a commandline option to do so)
1
u/smog_alado Sep 03 '12
IIRC, in Python 1 tab = 1 space. I could be wrong though.
2
u/Brian Sep 03 '12
Actually, checking it, it's actually (in python2) up to 8 spaces to reach the next tab-stop. Ie. "space+space+tab" is equivalent to just "tab", which is equivalent to 8 spaces, but "8*space+tab" is equivalent to 16 spaces. It's always equivalent to 8 spaces if you don't mix it with spaces on the same line.
1
Sep 04 '12
oh. it seems that python does it properly, then. I guess the confusion is due to the knowledge that tab = 8 spaces being harder to find for python.
most of the things i have read about python just say "don't mix tabs and spaces" and go into detail about tab width, but never mention that the correct tab width is 8.
edit: nevermind. i just read how pythons tabs work from your other post, and it doesn't make any sense.
1
u/Brian Sep 04 '12
most of the things i have read about python just say "don't mix tabs and spaces"
I think generally because it's a better idea. People will edit with different editors and different tab settings, and so a mix will lead to displaying these differently. This is a good guideline even in non-indentation sensitive languages, since messing up the layout for different readers is bad enough even when it doesn't alter the actual flow from what is shown.
i just read how pythons tabs work from your other post, and it doesn't make any sense.
It's just the same rule Haskell uses, and the same way an editor (with a tabstop of 8) will display it - it's just "bring the indent to the next tab stop" where tabs are 8 spaces apart.
1
Sep 04 '12
Is it really a controversial opinion if it's been something non-Python programmers have been whining about for decades? Because as far as I can tell, people whine about it for about the first five minutes of Python coding, and then give up because they would've been indenting anyway.
My main regret with Python is that I haven't found a good tool that auto-formats everything (a la "gofmt").
Well, that would be impossible because Python infers meaning from spacing, so you're proposing a program that reads the programmer's mind. Maybe now you agree that Python's dependence on whitespace is a little annoying? (I'm coding in Python as we speak if that makes any difference).
0
Sep 02 '12
[deleted]
3
u/matthieum Sep 02 '12
I only have one problem with OOP: inheritance. Apart from that the idea of bundling data and methods that act on them is quite useful.
3
u/BufferUnderpants Sep 02 '12
It separates state in manageable chunks, or at least chunks whose individual state should be manageable. This is a very good idea.
But it's nowhere near as helpful if you don't apply the equally good idea that there should be less state in the first place, otherwise you are just spreading the stuff around. Most people don't seem to make the logical leap here.
3
u/pipocaQuemada Sep 02 '12
Apart from that the idea of bundling data and methods that act on them is quite useful.
What do you mean by that? Colocating data & functions in code (i.e. would you consider a Haskell module to bundle data and functions)? Or including function pointers with your data, so you can dispatch dynamically based on the object itself?
The first meaning of bundling is useful, but I remain unconvinced about the utility of the second. If you want dynamic dispatch, why priveledge a single argument? Hell, even Haskell, if you use multiparameter typeclasses and fundeps, can dispatch dynamically based on any number of arguments.
1
u/matthieum Sep 02 '12
It was more about encapsulation actually: the idea that your data is only open for access to a limited number of functions through a well-determined interface.
Of course it's nothing new in OOP either. C does it with forward declared
structand opaque pointers for example.3
Sep 02 '12
I agree that inheritance causes more trouble than it is worth. I also believe it is not useful to throw encapsulation, inheritance and polymorphism together in one concept.
As for bundling data and methods, I haven't seen a good solution in OOP to the whole problem that most actions in any RL system you want to model involve two or more entities. Well, other than the generic methods in CLOS (Common Lisp Object System).
3
Sep 02 '12
Most of these are controversial due to their inherent nature of being gross generalizations.
... is absolutely the worst thing that's ever happened to the field of software engineering.
No matter what you put in the blank, the result is something inherently controversial, because "the worst thing" is a divisive, flaming, trollish, unhelpful, terribly subjective phrase. The metric is whatever people want it to be.
Another example:
... is not really programming.
No true Scotsman argument. Derp.
The "While" construct should be removed from all programming languages.
That's a better conversation topic, because it doesn't use harsh language, nor does it describe why while should be removed from programming languages. It simply suggests that it should, and you can go from there. It's open ended without being stupidly subjective.
The use of try/catch exception handling is worse than the use of simple return codes and associated common messaging structures to ferry useful error messages.
Another interesting thought. The fact that so many error control mechanisms are continually being used in multiple programming languages suggests that no one has an entirely desirable solution yet.
The first language should NOT be the easy one.
If you don't know whether P=NP, your students can't be expected to know everything about computer science either, so stop expecting them to learn everything C.S. before typing print "hello world". Don't be a stupid fuck, don't scare away your future peers who could revolutionize computer science because you like learning "the hard way". Teach generally, and when students seem to get the highlights, then and only then drill down into the niggling trudgy boring details that you wrote in your nobody-cares dissertation.
7
Sep 02 '12
Here's my opinion: Declaring OOP to be the worst thing for programming is written by a someone who shouldn't be giving advice. You don't have to like it or use it, but respect it. In fact, the more options/languages/paradigms/etc. out there, the better. OOP is just the popular kid at the moment.
4
Sep 02 '12
OOP being the popular kid is actually the problem. As a tool it is fine, OOP the ideology is certainly one of the worst things that happened to programming, in particular the GoF book has done a great deal of harm.
3
u/matthieum Sep 02 '12
Actually, OOP may be popular, but right now it's perhaps not that trendy amongst the cool kids.
3
2
u/SplinterOfChaos Sep 02 '12
9 . C (or C++) should be the first programming language
IMO: x86 assembly and Python. One language teaches you what a computer does, and the other what a computer can do. x86 might seem to outdated to teach as new, but i find it easier to read that x64, x64 CPUs can run x86 instructions, and one can easily transition from one to the other.
6
Sep 02 '12
This is just getting ridiculous. I agree that the first wasn't controversial, but do we have to keep coming back to this until everyone is upset? How about:
Programmers are worthless scum.
And we move on.
2
u/el_muchacho Sep 02 '12
A more interesting opinion of mine: code generation is evil.
I've yet to find a code generator that doesn't suck, i.e that generates code that you can adapt to your problem without blowing everything up. Given the choice, I prefer 100x to use a framework that's sufficiently well engineered to do want I want, and code to it, rather than using a push button code generator that spits out hundreds or thousands of LoCs that are so obscure and so rigid that it fits your problem like a straightjacket.
1
u/Bananoide Sep 03 '12
I'd rather say that only adhoc code generators with a very specific purpose are acceptable. Overly general code generation toolkits suck big time.
2
u/A_for_Anonymous Sep 03 '12 edited Sep 03 '12
The "While" construct should be removed from all programming languages.
Enjoy your extra if and copypasta'd condition for no gain. If somebody can't tell while and repeat apart, he shouldn't be making money with this.
Copy/Pasting is not an antipattern, it fact it helps with not making more bugs
Successful Java professional. Wouldn't hire him because he doesn't do decent programming languages where you can use functions or macros instead of copypasta.
The use of try/catch exception handling is worse than the use of simple return codes and associated common messaging structures to ferry useful error messages.
Biggest program this guy ever worked in is 5K LOC and it doesn't work anywhere outside his computer.
Object Oriented Programming is absolutely the worst thing that's ever happened to the field of software engineering.
No. Alan Kay's idea is great. Smalltalk is great. C++ and Java may very well be the worst thing that happened to software engineering, though. Guy who wrote that was clueless on actual OOP.
C (or C++) should be the first programming language
Yeah, and when you go get your driver's licence they should start teaching you about metal alloys.
Making invisible characters syntactically significant in python was a bad idea
They are pretty visible in my screen; they take space. But hey, significant whitespace would be the least of my concerns regarding Python syntax and design. Shitty statements is my first.
Singletons are not evil
Singletons are a fucked up pattern used to workaround fucked up language design. In the future, use a decent programming language.
Finally,
If it's not native, it's not really programming
2
u/notfancy Sep 02 '12
Here's mine: "If you haven't been programming for 20 years in at least 5 different languages, you don't get to have an opinion about it, controversial or not."
1
1
u/SplinterOfChaos Sep 02 '12
The primary problem with OOP is the total lack of a rigorous definition that everyone can agree on. This easily leads to implementations that have logical holes in them, or language like Java that adhere to this bizarre religious dogma about what OOP means, while forcing the programmer into doing all these contortions and "design patterns" just to work around the limitations of a particular OOP system
Isn't it always the fans who ruin a good thing? Far too often i have seen people think OOP means writing everything in terms of classes. That tall inheritence trees make code easier to reason about (perhaps true, but harder to read, thus maintain).
Someone once said that objects are a form of optimization. I forget who, but i strongly agree with this. The rule of premature optimization applies: if something can be done more easily or efficiently without objects, it should be.
As an example, i think it makes things too overly complicated when a library requires the user to adhere to an abstract interface of inheritence in order to use its functions compared to an API that implements generic objects.
1
1
1
Sep 04 '12
Instead of fitting a class on one screen (really?!), my rule of thumb is a class should be <10 scrolls... however, code folding still means I have classes ~1500 lines that are ok.
1
1
u/ModernRonin Sep 06 '12
Littering code with try/catch blocks is not a solution.
It is a solution, it's just a cruddy one that isn't necessarily better in all cases than return codes. (Which are also cruddy in some cases.)
"No silver bullets." -Brooks
1
1
u/NicknameAvailable Sep 02 '12
This list is about as controversial as the view the moon doesn't exist.
Wrong isn't controversial - controversial thing have large numbers of people both for and against them.
Hell, How To Write Unmaintainable Code is more controversial than this because some people actually do it.
1
1
0
u/ErstwhileRockstar Sep 02 '12
8. Object Oriented Programming is absolutely the worst thing that's ever happened to the field of software engineering
10. Classes should fit on the screen. Contradiction? Not really. Uncontroversial rule 13: If it sounds good it is good.
4
Sep 02 '12
They aren't the opinions of the blog author. They come from different people, so it isn't a single person holding contradictory beliefs.
0
u/dethb0y Sep 02 '12
Reading the list, it sounds like someone's upset they learned how to program in the dark ages and are now upset that not everyone has to walk up hill five miles in the snow each way to learn how to open a text file, and all that.
0
Sep 02 '12
[deleted]
32
u/nroberts666 Sep 02 '12
Half of them just had me shaking my head saying, "Bill, Bill, Bill..."
I don't know that being dumb is being controversial.
Copy paste helps reduce bugs? Only when compared to writing the same thing out over and over again maybe. Neither is the right way to do things at all.
If it's interpreted it's a "script" and not "programming"? That's just silly bigotry. Some pretty damn brilliant programming goes on in scripting languages and if the difference is between it running "native" vs. interpreted then where do you put Java? Some of the embedded systems speak Java byte code natively.
Only a couple were mildly controversial in that one could legitimately see both sides and have a reasonable discussion about it. The rest were people trolling I think though I do have to admit to having seen some really insane opinions out there (my last boss was afraid of local variables and preferred globals!!). Just like creationism vs. evolution though...just because there's two sides doesn't mean there's a controversy.
16
u/cruise02 Sep 02 '12
Just to be clear, those aren't my opinions (I'm the author of the blog).
If it's interpreted it's a "script" and not "programming"? That's just silly bigotry.
Totally agree with you there. Not sure where his definition of "program" comes from.
13
u/rooly Sep 02 '12
Hell, where does that definition put x86 programs, which are converted at execution time to microcode by the pipeline?
3
u/geon Sep 02 '12
Or if you turn it around; the same code can be interpreted, compiled or jit:ed. Does that mean you are programming or scripting?
6
u/ellicottvilleny Sep 02 '12
I thought it was clear that you said "I copied these from the StackOverflow post in question". I think it's hilarious that people are arguing with you over these things.
These are the things which were, if you like, the most "Troll" like things said on the original question. And the troll bait is still rather full of troll-power, it would seem.
W
1
u/aaronla Sep 03 '12
Oddly, though, I know of a lot of programmers that think this way, without thinking through the implications.
-25
u/nroberts666 Sep 02 '12
I'm the author of the blog
You probably didn't want to tell me that because to be fair, I actually kind of hate that fucker in addition to thinking he's an idiot.
1
u/cruise02 Sep 02 '12
Just to be clear, those aren't my opinions (I'm the author of the blog).
If it's interpreted it's a "script" and not "programming"? That's just silly bigotry.
Totally agree with you there. Why arbitrarily draw the line at "talks directly to the CPU and the OS." Why not design our own circuits and write machine code? :)
4
u/aaronla Sep 02 '12
So, if I understand, the "program-ness" of a thing depends not on the contents of this thing, but which implementation of the language is applied to it? So an executable for an Amiga, run on an emulator is not a program but instead a "script", but if I fabbed a chip that ran Python bytecode, then a Python file run on it is a "program"?
1
u/nroberts666 Sep 03 '12
Yeah, I am guessing that would be the result of this line of thinking. Doesn't sound right to me so I'm thinking this is an incorrect definition of "programming".
0
Sep 02 '12
[deleted]
3
u/shub Sep 02 '12
It sounds like strict TDD. Write the test, see it fail, write code to make the test pass. Repeat. Never, ever, write code before the test exercising it.
That approach appeals to me, but I'm dubious about the benefit of applying it in all situations. Gnarly existing codebases are an obvious example of a place where it can be incredibly difficult to implement effective tests for the change you want to make, but other times it just seems pointless. Why would one bother to test a three-line controller method? Verify that it returns the view name I expect? Hell, IDEA does that for me, and will create a view with that name if that's what I want!
2
u/cruise02 Sep 02 '12
That's what it sounded like to me as well, a very strict "test first" approach. That's one of the reasons I included it, because I know a lot of people love TDD but just as many seem to think it's a waste of time.
1
Sep 02 '12
Never, ever
You know you're reading uneducated bullshit when you see these words in regards to absolutely any programming topic.
1
u/shub Sep 03 '12
Hey, I'm explaining what the "Test Constantly" thing is about. It's not something I agree with, but it's not bullshit either. At worst it's a practice for an ideal world, not our real one.
1
Sep 02 '12
Well, I'm willing to bet that given any class, there is a screen large enough to hold it.
Visual Studio now allows you to set a zoom level on your editor, so even normal laptop screens aren't much of a problem.
1
u/queus Sep 02 '12
Test Constantly
How often is that?
On the limit you do not write any code at all, just tests. Your program will do nothing but will be - rolls eyes - Oh, so thoroughly tested..
1
u/oqa Sep 02 '12
Those two are the ones I can almost agree with. Automated tests and keeping classes small. The rest, meh...
12
u/drb226 Sep 02 '12
ಠ_ಠ
Is there anyone that really supports this one? If you are copy/pasting a lot, then either your code needs to be refactored, or your language of choice does not provide adequate abstraction techniques.
The suggestion that copy/paste programming can reduce bugs seems laughable to me. It indicates that you probably don't know how the code you pasted actually works. Is there a more potent source for error than modifying code that you have not carefully thought about?