Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person’s post makes sense in another community cross post into it.
Hope you enjoy the instance!
Follow the wormhole through a path of communities !webdev@programming.dev
Mandatory pull requests + approvals within a team are a waste of everyone’s time.
Big hot take to me; especially in an organization with a large size and code high standard
We’v known this for twenty years and had the data ta back it up for ten. Github flow is one of the most damaging things to ever happen to software teams
what data? just curios because there are so many ways to do PRs properly… like for everything, if it’s done badly better not do it. does not mean it is inherently bad
Check out the dora reports and the data Nicole Forsgren lays out in her book Accelerate. DORA reborts are free to access. She has found clear links between trunk based (no branching) development and a whole host of positive metrics. There is some suggestion that PRs are not too bad if always done at high quality and within the same day, but its weaker.
Omfg yes! Have nothing to add, but an upvote was not enough to express my hate for gitflow. So fucking stupid. And you’ll show stats from Jez Humble etc about trunk based, and my boss was still “eh not convinced”
Git Flow and GitHub Flow are entirely different branching strategies.
Gitflow is has the same issues
Git Flow is awful I absolutely agree. On the other hand I like GitHub Flow.
Github flow has the same issues, in practice. Branching is the root cause, not the kind of branching. Even anonymous branches. Its the frequency of integration that matters.
gitflow != github flow
Gitflow is far more complex and unnessaray for most places. You do not need a dev, main, and release branches. Github flow is far closer to trunk based dev - create a branch of master, PR back into master when done. If you keep your PRs small it gives you most of the benefits of trunk based dev with a CI check before you merge to the mainline.
Source?
Got asked about this twice so I’m cut/pasting my answer, but happy to discuss further
Check out the dora reports and the data Nicole Forsgren lays out in her book Accelerate. DORA reborts are free to access. She has found clear links between trunk based (no branching) development and a whole host of positive metrics. There is some suggestion that PRs are not too bad if always done at high quality and within the same day, but its weaker.
You must trust your team’s abilities more than I trust my own. How often does your team merge bugs into main? We use CI primarily for running the full test suite, including integration tests and e2e tests that would be very difficult to run locally due to them using specific credentials to access testing resources.
If your team consists of people you don’t trust, that’s the problem to fix first.
I trust my team. I don’t trust my or their ability to write and merge perfect code each time. I’m not sure how we’d fix that problem aside from becoming programming gods.
My point is, having PRs desn’t result in perfect code either. They might help sometimes, maybe 10% of the time if I’m being generous, but the rest of the time they are a hindrance. The problems people tend to try and solve with them, validation and indoctrination are better solved with a good CD pipeline, and pairing sessions.
Depends how good you are at what you’re doing. I’d argue that humans err and it saves a bunch of time to catch bugs before debugging in the wild
Unless you have people that are known to delivery garbage code. Which is more common than you would imagine, lol.
The solution to that is pairing - spending a few hours collaborating with, and teaching this person will get them up to speed much faster than asynchronously nitpicking their code.
depends on the company/team culture. are other people gonna have to fix or extend code you wrote? are you the sole engineer working on entire modules? do you hate feedback?
deleted by creator
sounds like your company sucks. I’m sorry, must be lonely
deleted by creator
deleted by creator
PHP aint all that bad
the stack is cool, the language itself sucks, unless compared to javascript
JS is horse shit. Instead of trying to improve it or using that high level scripting language as a compilation target (wtf?!), we should deprecate it entirely and put all efforts into web assembly.
How is this a hot take?
Adoption is a feature you can’t design.
Is this a hot take? You’re absolutely correct lol.
“JS is bad” is hardly even a lukewarm take.
To me it seems like the internet is full of JS apologists. Maybe it’s just YouTube xD
“show hn: I made a JavaScript engine in webassembly using rust”
At that point, just make a typescript engine so people don’t have to build their TS projects anymore
deleted by creator
Idk anything about web assembly but I 100% agree that JS is absurd and feels like it was created in a weekend by some schmuck who just wanted to be able to edit html on the fly because it was.
That’s basically how it happened.
(That’s the joke!)
Why exactly is it horse shit? It does have it’s quirks but I wouldn’t go that far
I think it suffers from the same problem as SQL. A bunch organizations and companies would need to agree to make improvements, you don’t want to break compatibility, so nothing really improves. You just get some extensions to it here and there which just makes it messier.
Isn’t the “extension” problem the same with almost all programming languages?
For example, does 80s C compile under gcc with 2015 features? If it does, then it’s no better than JS.
Yeah but with JS, you have to consider the browsers that are out there already. I think this is getting better now that IE is killed off, but there’s still a consideration about whether to use a new feature that doesn’t work on older browsers.
With C, it’s compiled so if you’re distributing the binary, you’re done. And if you’re sharing the source to another developer, that dev will be likely to be technically proficient enough to update gcc and any needed libraries to the right version to get it to compile.
When it’s an interpreted language that is interpreted by browsers made by different companies and organizations (so they have to agree on changes), with users not being reliable of keeping their browsers up to date, it’s going to be messy. Also there’s security concerns, you need to make sure when implementing the extension it won’t allow bad actors to make scripts to take over the users computer.
It’s not anyone’s fault, it’s just a significantly more difficult problem to extend a language that is going to be sent to user’s computer on the fly from arbitrary websites and have those extensions be reliable, secure, and consistent across the various companies implementing it.
JS makes heavy use of pollyfills where needed, bridging the gap between old browsers and new ones.
A binary might still require a specific shared lib version, specific architecture, whatever, it’s not a magic bullet.
Doesn’t always work when working with legacy unupdated dependencies.
Wouldn’t having compiled code running in the browser (via webassembly) be actually worse for security? With JS you can at least see the source that’s being run, with compiled WA, not so much. Don’t really understand this point.
Yeah but those issues are dealt with at compile time by a developer. The problems don’t manifest themselves at runtime as they do with an interpreted language.
Also compile time, not runtime.
You could disassemble compiled code and read the assembly code. Yeah that’s difficult, but about the same difficulty as reading JS that’s been run through an optimizer. Nobody has time for that, and users certainly don’t have the skill to do that, so the the organizations that make the browsers are ultimately responsible for making sure any new addition to JS isn’t going to cause the security problem.
About the same for security. I don’t know much about web assembly but it has similar problems. I mean the reason I don’t know much about it is because it’s too new, can’t count on it being widely supported, etc. Similar problems as JS. But being compiled to a common language might shift the pain of dealing with a lot of problems with language changes to the people who write the compilers for it. Time will tell.
But the thing is, most languages aren’t designed to be primarily interpreted by a browser. Nobody is going to say “Hmmm we better think about how this will affect web browser security if we add to the language.” Because use by browsers as a web assembly isn’t the primary use case. If a language change negatively affects a browser, that’s their problem to sort out.
But with JS it is primarily being used as an interpreted language implemented by browser makers. Which means the browser makers have a huge amount of influence over the decision making process. If google says “we have concerns over security with this feature so we aren’t using it in chrome” then well it’s not a feature that developers can use because it’s not going to work for most users.
I think you’re trying to make this a fair comparison, but my point is that it is not a fair comparison. What the languages are used for and how they’re deployed impacts process for improving them. The requirements for JS in terms of what it’s primarily used for and how it gets deployed makes it difficult to change, which is why it is as messy as it is. Takes a lot longer to get changes accepted by all the parties that need to accept them.
[Object object]
undefined
If white space carries any function that the compiler/interpreter needs to know about like structure or scope, it’s probably not a very good programming language.
In Ruby,
foo?a:b
parses differently thanfoo ?a:b
and the first one isn’t parsed a ternary expression.Consider the following code snippets and execution:
Nothing surprising there. Let’s replace that
3
with the call that returns3
.But that parsed as
"foo".length?
and was looking for a method call because ruby methods can end in?
but couldn’t find the method so returned an error.Let’s put a space in there so that its the
length
method again without trying to becomelength?
It’s apparently expecting something with the
"stuff"
. Lets put in more spaces.And this returned what was expected… but this needed a lot more spaces in a lot more places than the
puts 3?"stuff":"empty"
that worked in the first call.Personally, I think that if you’d rather write
foo?a:b
thanfoo ? a : b
, you’re probably insaneBut why would
3?"stuff":"empty"
work andfoo?"stuff":"empty"
not work?Syntactically significant whitespace is a nightmare to deal with.
I agree! I don’t think
3?”stuff”:”empty”
should work at all because I think it’s an insane way to type a ternary :) I’m also very open to admitting that it’s just my own strongly worded opinion.I think that in most cases, syntactically significant whitespace is a horrible idea - the one exception being that you should have space between operators/identifiers/etc. I don’t care how much, and 4 spaces should have no more special meaning than 1, but I do think that using a space to indicate “this thing is a different thing than the thing before it” is important.
Talking with a rubyist:
3?"bar":"qux"
only has the ternary expression as a valid parsing of?
foo?"bar":"qux"
fails becausefoo
may be a method andfoo?
is also a valid method identifier.foo ?"bar":"qux"
fails because?"
uses the?
unary operator that makes the next character a string. So?"bar"
becomes the string"
followed by what looks to be an identifier.And so…
?
character is a valid part of an identifier (but only at the end of a method name)?x
unary operator to create a String from a characterexpr?expr:expr
ternary operatorAnd so…
Genuine question: why? What makes, say a semicolon, so superior to the the newline or tab characters?
To be clear: I don’t think whitespace as a part of syntax is an awesome idea which should be more popular. It’s definitely a bit more error prone in some ways. It’s not perfect. But it’s okay.
I’ve written a lot of Python and I don’t think I have ever seen a syntax error caused by incorrect whitespace. I’m not exaggerating. I regularly forget semicolons in other languages but I never type out incorrectly indented code. Maybe that’s just me though…
I honestly think the scripting languages like fish have got it right.
Newline by default completes a line and can optionally be escaped. Saves you most of the semicolons and even implicitly highlights multi-line statements.
Whitespace doesn’t matter except for separating names.
Blocks are explicitely ended without braces you can confuse with brackets or parentheses, no matter the coding style.
If Rust and fish had a baby, I think it would be the best language to have ever been created.
How much of that python is written in a shared codebase with multiple active contributors? When was the last time you refactored a module?
Tabs and spaces are invisible. Semicolons are not.
A vast majority of the code in question is the code I’ve written for my work projects with multiple active contributors and refactoring is very common too. We all like to shit on Python for various reasons but no one in my environment ever complained about whitespace.
Like I said, I don’t think whitespace is perfect as a part of syntax but I’m much more likely to forget a semicolon than a proper indentation and this applies to any language. I guess it’s not universal tough, because you can often see code with messed up indentation on online forums etc. TBH this is just unthinkable to me, indentation is absolutely necessary for me to be able to read code and reason about it. When I’m thinking about blocks and scopes it’s not because I counted semicolons and braces, it’s 100% indentation.
From some one who used Python as it was the easiest solution to few of my problems, and having to experience languages with brackets and/or endif/fi/done as ways to limit scope, I find that having things like brackets and/or scope terminators easier to parse and less error-prone. I’m thinking about moving on to Ruby whenever I had a need where Python would be a good choice, but the time it takes for me to understand a new language is blocking me from that.
How do you feel about line breaks?
Not who you asked but I think they’re important for humans, but syntactically I don’t think they should matter.
It should be ok to add a line break wherever it makes the code more readable, but I don’t think a compiler should care whether some code is all on one line or 10
Intmain(intfoo){std::out<<“HelloWorld”;}
Is a great program and should totally be valid cpp. White space sucks.
/S
Load-bearing whitespace is the fucking devil. This thread about hot takes is topped by a comment highlighting how people can’t even agree what kind of whitespace to use.
Python - you want code to fail if someone from one camp copy-pastes code from another camp, and the characters that make a difference are invisible?
Load bearing whitespace. Damn, I love that phrase.
Also, if you have to have agreement on the tabs or spaces argument in your codebase in order to get it to compile, you have already lost.
People who insist on using semicolons in Javascript don’t understand why and are just following a cargo cult.
Remove the semicolons, be free.
Edit: lmao I hit some nerve here
It’s also because my fingers automatically type them for the sake of most other languages. Let me have my muscle memory.
iirc semicolons are required in JavaScript strict mode.
They’re absolutely not
JavaScript isn’t bad. Sure it has its quirks, but it’s not as bad as everyone makes it sound it is
I mean it used to be way worse before before google and whatnot poured hundreds of millions into making it better.
Have you heard about our lord and savior, TypeScript?
Praise the Lord
Hallelujah!
Answering my own question here. If you don’t have any interest in how the tools you use work, programming isn’t “for you” (take that with a grain of salt). If you are writing code and have never looked into how compilers/interpreters work or are using a library and haven’t even taken a peak at the library’s source code you should because it will make you a better programmer in the long run. And I’m not saying you can’t get anything done without that curiosity but curiosity is a major part of being a programmer. Also you don’t need to have a deep understanding of the tool just a overview of what it’s doing. Like for a compiler understanding what lexers, parsers, ASTs, code generators are will allow you to write code with that in mind.
The amount of unqualified people is staggering beginning with those who have no university education.
Degrees are meaningless, excepting places like CalTech. I’ve known too many ‘programmers’ who had a CS degree yet were damn near useless to think otherwise. Not to mention my own CS degree taught me almost nothing.
Agreed. I’ve known a lot more self-taught folks worth their salt than those with degrees. And those with degrees almost all started coding before they got to the university age.
Seems like you went to a shit university
I wouldn’t say it was a shit university, part of it is that I knew how to write code before I got there. But the CS program wasn’t great. My entire point is, if someone has a CS degree from University X and you don’t know if that program at that university is any good, the degree is meaningless. If the university’s CS program isn’t any good, you can’t count on the degree meaning anything.
If you’re worried about your degree’s worth then you are certainly not he right person to talk about going through a shit university.
I think you meant that your degree was meaningless?
My entire point is that any CS degree from any university is meaningless unless you know that university’s CS program is actually good
I don’t see it as a problem, because qualifications without competence are meaningless.
You should be more concerned with how qualified people end up performing worse and being less educated, knowledgeable, and prepared than unqualified people.
There are also a lot of e-commerce agencies who just don’t have their sh1t together. Was expected to work on 3 different clients a day who all had different platforms, different requirements etc. Yes, you can dump some new code into the project that looks like it’s working, but then you don’t have time for any unit tests, exception handling if the user won’t cooperate etc. and it’s basically just some dodgy, untested code that will come back a few days later with some issues related to something nobody told you about.
The other “senior” programmer in the company never set up any local environment but instead ftp’d all changes directly to the live server. I asked him if needs help to set up a local server and debugger, but instead he would just dump vars on the live server and stream the contents of error.log to his second screen to catch any issues…
Go with what works
Error messages should contain the information that caused the error. Your average Microsoft error “error 37253” is worthless to me
Keep functions or methods short. Anything longer than 20 - 50 lines is likely too long
Comment why is happening, not what
PHP is actually a really nice language to work with both for web and command line utils
Don’t over engineer, KISS. Keep It Simple Stupid
SOLID is quite okay but sometimes there are solid reasons to break those rules
MVC is a PITA in practice, avoid it when possible
Hahaha this is great! All points are basically entirely obvious and common sense and then you hit us with that ridiculous statement about PHP. Outrageous!
From what I’ve seen is that 99% of the PHP hate is people parroting slogans others came up with, and the rest is that there are inconsistencies with the function signatures.
That last part is very true, of course, but not really an issue with modern editors as they will already tell you what’s expected. On the other hand, the inconsistencies are still there for a reason: compatibility. JavaScript what’s a nightmare to work with because every week an update would break shit because of changing method signatures in JavaScript packages. PHP always worked and remained working because it changed so little in that respect.
In all other areas it hugely improved and matured over the years, just like all programming languages.
So yeah, I find the PHP hate childish, really.
PHP grew “organically” out of a perl library. There was never a consistent plan/idea about the set of abstractions it provides, the type system, builtin functions etc… Everything has been bolted on here and there, some additions good, some bad, some terrible pitfalls. A language with builtin operators that are basically unusable (comparison!) and where some functions return false when the input is invalid, is really fundamentally broken. I agree that many of the worst failures of PHP have been (kind of) fixed after PHP5 and that’s nice for large existing PHP codebases (mediawiki, wordpress, nextcloud, typo3). But I just can’t understand why one would start new projects in PHP in a world where so many very well designed and well thought through languages exist.
Edit: First sentence is misleading. Of course it wasn’t a perl lib, but basically a thrown together bunch of functionality, unified into one package, so it can replace using various perl libraries. The syntax was also very inspired by perl.
Yes, PHPs beginnings were very messy and even today we see results from that.
But PHP was and remains hugely popular because it’s so easy and fast to work with and today it is very nicely designed and worked out. Yeah there are many details open but editors help you out with that. Other languages may be more consistent at the core but they have their own issues. JavaScript is a nightmare to work with for me, personally, but I o dont bitch about it every opportunity I get.
I guess I’m just slightly annoyed with people complaining about PHP while it’s just another language and it’s success speaks for itself
Yes, JS is equally terrible! At least we can agree on that :-P
And I also understand that PHP (just like most technologies) can be very efficient to work with if you are used to it and know it very well.
Well, if it comes to web development (my main focus since the last decade at least) I think it’s fair to say there is little that nears PHP (or, begrudgingly, JavaScript)in functionality. With current frameworks (my own included) I can churn out highly complicated and fast sites in no time. Can’t say that for many other languages.
Java? “Fast”? Lol no. “No time”? Lolol no.
Python? Honestly I have too little experience with it to say, but at least frameworkoptions are much more limited anyway
Honestly, “it’s better than JavaScript” is a pretty low bar.
I don’t like PHP because I think the syntax is ugly and I’ve only used it on systems that are old and a pain to maintain, but I’ll also very freely admit that I have absolutely not written enough PHP to have an informed opinion on it as a language.
True enough on JavaScript but I mention it because people always take that for comparison. I’ve used it for hundreds of projects now and for me it’s become my default goto language because I can slap together anything with it. It now has good (optional but encouraged) type safety, which greatly improves code quality so yeah… love it
If it doesn’t fit on my screen it’s too long.
This is a security thing. A descriptive error message is useful for troubleshooting, but an error message that is useful enough can also give away information about architecture (especially if the application uses remote resources). Instead, provide an error code and have the user contact support to look up what the error means, and support can walk the user through troubleshooting without revealing architecture info.
Another reason can be i18n/l10n: Instead of keeping translations for thousands of error messages, you just need to translate “An Error Has Occurred: {errnum}”
Those benefits both make sense, but are those really the original motivation for Microsoft designing the Blue Screen of Death this way? They sound more like retroactive justifications, especially since BSODs were around well before security and internationalization were common concerns.
Linux has something similar, kernel panics. However, with Linux you get useful information dumped on your screen.
Nothing gets logged on Linux either, just like windows and that makes sense. The kernel itself messed up and can’t trust its own memory anymore. Writing to disk may cause you to fuck up your disk, so you simply stop everything.
Still though, Linux dumps useful info whereas windows just gives you this dumb useless code.
Not when it’s my own computer. My computer needs to give me useful messages.If it’s a website then the site MUST log correctly in the log files…
If it’s a translation issue then just use English, everyone that can understand logs can (or at least should) understand that
I don’t have issue with methods being 200 lines, as long as they have a singel concept and is easy to follow.
There are various exceptions where up to 200 lines is still okay, yes. The 50 lines rule is more a good rule of thumb.
If the method does a long thing, the keep it long. I do a lot of data analysis and simulation, and so often people who came before had this urge to shorten methods, so we get:
Sometimes there’s a place for that, like if
calculation
could be swapped for a different function, or ifcalculation
is used all over the program. It’s a pretty good clue that something is up though when the signatures are almost identical. Of course, that has just led to people writing:Pervert.
Yeah, why?
I know it’s popular to bitch on php but I’ve found it’s all for the wrong reasons. The vast majority of the internet still runs on it and it’s a breeze to work with, I love it. It’s safe, it’s fast, it’s great.
I’ve worked with a variety of JavaScript frameworks and they all give me headaches.
It’s just that it’s an ugly and weak language, overly verbose, and riddled with inconsistencies. There are few good things you can do in PHP without huge frameworks.
Not sure what qualifies as ugly but I find PHP codes much easier to read than JavaScript (if that is what you meant)
If with weak you mean weak typed then you’re partially correct: most of it can be typed and ever since … I dunno, years ago, I’ve worked exclusively with strict typing. Things have improved considerably on that front
What part is verbose? Genuine curiosity
The inconsistencies are true. It’s also PHP’s strength that they kept everything like that and kept everything compatible. Every JavaScript framework I have worked with caused the weekly update nightmare headaches where 5 bugs were resolved, but now 10 more were added due to changing method calls. I hated it and I love PHP for at least keeping that consistency. Over time they have worked little by little to mitigate things but at the core, yes, you have function call inconsistencies. However, good editors these days for that for you and tell you the function name and give you the parameter order.
Then that there are few good things you can dowithout frameworks is nonsense.
If you want to do it right you use a framework, but that goes for every language. But I’ve sen and worked on (admittedly a horrible) system that would scrape millions of pages per day and its first version was just hacked together code. Ugly but super quick and simple, no frameworks. I’ve built many similar systems and sites like it over the years.
Now I recently built my own new framework in PHP, all strict, and it’s just fast and beautiful
You’re comparing to only JavaScript, have you worked with another language like python, ruby, lisp, rust? Maybe then you’d see what I mean.
By verbose I mean that mostly PHP lacks syntactic sugar, mostly it lacks powerful features of other languages. You can mostly write very simple procedural code.
Well I compare to JavaScript because that’s what most people bring up. On web development, I guess JavaScript is the biggest competitor.
I’ve worked with many languages. I even worked with assembly for a while in another life over 25 years ago, I worked with visual basic, .net, c, c++, Java, JavaScript and it’s many frameworks, loads other more obscure languages too, and I’ve played with some python over the years. Still though, php has my favorite since a loooong time
Can you give an example of missing syntactic sugar or features that are missing?
Type hints and comprehensions as in Python, borrow checker, traits, code interface checking in Rust. Most functional features.
IDK; I just don’t like anything about PHP and I have worked with it. It seems bad at every task.
PHP the language has become pretty nice, but I recently had to work with a PHP CMS deployment, and it was an absolute pain to do. PHP frameworks seem to still exist in a world where you manually upload code to a manually configured server running apache. Dockerizing the CMS (uses Symfony) is/was an absolute pain.
I know that there are loads of solutions out there that can do this for you, though I don’t have much experience with it myself directly. Not a great fan of docker, still, as it’s not a requirement and in many cases that extra piece that fails and then is a PITA to fix.
I’ll look to include it in my own framework, though
Compiler checked typing is strictly superior to dynamic typing. Any criticism of it is either ignorance, only applicable to older languages or a temporarily missing feature from the current languages.
Using dynamic languages is understandable for a lot of language “external” reasons, just that I really feel like there’s no good argument for it.
Dynamic languages are good for prototyping, especially if a lot of libraries available
true but i dont think is really a hot take?
It’s much easier to work with streams of untyped data in a weakly typed language.
I do believe that static typing is at least a local optimum, but I am still not entirely convinced. Rich Hickey is a very convincing presenter and I can’t help but think that he is on to something — with Clojure the chosen direction is contract-typing, which is basically a set of pre- and post-conditions for your functions that are evaluated at runtime. Sure, it has a cost and in the extremes they are pretty much the same as dependent types, but I think it is an interesting direction — why should my function be overly strict in accepting a “record” of only these fields?
Even when you’re using a dynamically typed Lang you should be using all the appropriate scanners and linters, but so many projects just don’t.
I joined a large project half way through and I ran pylint and stared as the errors (not just style stuff) poured out…
Yeah the error list is my friend. Typos, assigning something to the wrong thing or whatever is fixed without having to run the code to test it. Just check the error list and fix any dumb mistakes I made before even running the thing. And I can be confident in re-factoring, because renaming something is either going to work or give a compiler error, not some run-time error which might happen in production weeks later.
Oop is overrated
I never can understand classes
I may not love oop, but it is extremely useful in the cases that you should use it
Wow, nice hot take!
I find the concept super intuitive, like a blueprint or a mold.
It’s intuitive until you realise that not everything fits in a single inheritance hierarchy.
This gives a good example: https://www.youtube.com/watch?v=wfMtDGfHWpA
Here is an alternative Piped link(s): https://piped.video/watch?v=wfMtDGfHWpA
Piped is a privacy-respecting open-source alternative frontend to YouTube.
I’m open-source, check me out at GitHub.
I think of OOP as encapsulation, abstraction, and polymorphism primarily. Inheritance is definitely taught as part of it, but it seems like most people have found that to be the least used part of it.
It seems like you understand oop, but find it overrated, from your post it sounded like you didn’t understand it – but maybe you meant you didn’t understand it’s popularity.
I absolutely understand OOP, its explosion took over everything that took a long time to recover from.
The problem with OOP is that it’s pushed as a cure-all both by teachers who do not the problems it solves and also do not understand its own limitations.
In almost every situation where OOP makes sense, something else makes more sense to use.
So… “thing I don’t understand is overrated”?
I understand OOP. I like it. I also took my first coding classes in the late 90s and we were taught OOP as though it was the last coding paradigm that would ever be needed. It really set me back because I didn’t even understand the principles of the functional paradigm until I was already at my first coding gig
Often it’s just a container for a bunch of related functions and common state variables for all those functions.
Rarely are classes actually used in the OOP way, where you then create many instances of that class…
deleted by creator
OOP isn’t classes though but I get what your saying.
OOP is classes, and their accompanying language features (primarily inheritance) and design patterns (e.g. factories).
Agreed. Inheritance, specifically, is a huge code smell.
When inheritance is acting as a quick way to implement an interface, it’s lovely.
When an object is acting as a fancy dictionary, it’s lovely.
When a class has more than one parent in it’s chain of inheritance (upwards or sideways), that’s a code smell.
It specifically tells us that the developers are trying to manage program state (variables and data) that simply should have been refactored out (or have drifted very far from the code they’re actually needed by).
Python, and dynamically typed languages in general, are known as being great for beginners. However, I feel that while they’re fun for beginners, they should only be used if you really know what you’re doing, as the code can get messy real fast without some guard rails in place (static typing being a big one).
Disagree on this one, even though I can see where you are coming from. I first learnt programming in Java, and it gave me massive problems to understand the structure and typings. Obviously Java isn’t the most beautiful language anyways, but once I picked up python it started to click for me on how to solve problems, because I didn’t have to think about that many things. I could just go for it. Yes, my code was messy in the beginning, but I wasn’t working on any important projects. It was just for fun.
So I think learning how to solve problems is as important as writing clean code. And python really helped me with that.
TDD is overrated. Code coverage is extremely overrated. Both of these tend to lead to a morass of tests that prove the compiler works at its most basic level while simultaneously generating a surplus of smugness about the whole situation.
Tests have their place. Tests can be, and often are, valuable. But the easier the test is to write, the easier it would’ve been to just encode it into the type system to begin with.
Yeah creating tests for every single method is insane. If a feature changes it’s more difficult you either have to figure out how to implement the change without changing the method, or you change the method and have update the unit test. But if you’re constantly updating the unit tests, how do you know if you might’ve broken something else that the test was intended for.
It’s way better just to do integration tests that match the feature request. That way the feature that someone asked for will continue to work even if you decide to refactor the code.
Unit tests are only worthwhile if you refractor code or write the unit tests before writing the code. We started adding unit test for most everything where I work and I think it’s far more effort than it’s worth. It’s not that it catches nothing but it catches so little I don’t think it’s worth the time spent writing them.
Code changes that could affect tests happen all the time. It doesn’t need to be a specific refactoring of that unit.
I don’t think you understood my point. That’s exactly why I think unit tests aren’t all that useful. Most code changes require updating the unit tests so unless you change the unit tests first all that’s being done is saying, yep this works how I programmed it to work.
But if unit tests that other people wrote unexpectedly break, you know that you changed things that you maybe didn’t mean to change.
Ideally. It’s just that more often than not it means you need to update the unit tests. I can still use my fingers to count how many times a unit test has caught a mistake I made, and I’ve been at my job for 10 years.
I’m curious if others have a different experience.
As someone who works on python code and kinda hates it, type annotations and a CI pass for mypy would catch the majority of our bugs. It’s painful
TDD as in religion is overrated. TDD done right is IMHO extremely effective.
The problem is, writing good tests is really hard, and I have seen/committed/experienced a lot of bad tests… just the top of my mind problems with TDD done wrong:
For every non trivial piece of software written w/o TDD, I always saw the same pattern: First few hours/days/weeks, rapid progress compared to TDD, afterwards: hours/days/weeks wasted in debugging, bug fixing etc… and the people can not even catch up with tests if they wanted.
Is TDD always the answer? Of course not, it is a tradeoff like everything else in technology. OTOH I have yet to see a project which benefited from not using TDD by any metric after a few days in.