this post was submitted on 01 Sep 2023
337 points (96.2% liked)

Programming

17308 readers
235 users here now

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!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities [email protected]



founded 1 year ago
MODERATORS
top 50 comments
sorted by: hot top controversial new old
[–] [email protected] 163 points 1 year ago* (last edited 1 year ago) (18 children)

Refactoring is something that should be constantly done in a code base, for every story. As soon as people get scared about changing things the codebase is on the road to being legacy.

[–] [email protected] 43 points 1 year ago

Been with a lot of codebases that had no unit tests at all and everyone was afraid to change anything because the QA process could take weeks to months.

The result is you have a codebase that ages like milk.

[–] [email protected] 28 points 1 year ago* (last edited 1 year ago) (1 children)

Only if the code base is well tested.

Edit: always add tests when you change code that doesn’t have tests.

load more comments (1 replies)
load more comments (16 replies)
[–] [email protected] 132 points 1 year ago* (last edited 1 year ago) (10 children)

Until you know a few very different languages, you don't know what a good language is, so just relax on having opinions about which languages are better. You don't need those opinions. They just get in your way.

Don't even worry about what your first language is. The CS snobs used to say BASIC causes brain damage and that us '80s microcomputer kids were permanently ruined ... but that was wrong. JavaScript is fine, C# is fine ... as long as you don't stop there.

(One of my first programming languages after BASIC was ZZT-OOP, the scripting language for Tim Sweeney's first published game, back when Epic Games was called Potomac Computer Systems. It doesn't have numbers. If you want to count something, you can move objects around on the game board to count it. If ZZT-OOP doesn't cause brain damage, no language will.)


Please don't say the new language you're being asked to learn is "unintuitive". That's just a rude word for "not yet familiar to me". So what if the first language you used required curly braces, and the next one you learn doesn't? So what if type inference means that you don't have to write int on your ints? You'll get used to it.

You learned how to use curly braces, and you'll learn how to use something else too. You're smart. You can cope with indentation rules or significant capitalization or funny punctuation. The idea that some features are "unintuitive" rather than merely temporarily unfamiliar is just getting in your way.

[–] [email protected] 36 points 1 year ago (8 children)

Please don't say the new language you're being asked to learn is "unintuitive". That's just a rude word for "not yet familiar to me"...The idea that some features are "unintuitive" rather than merely temporarily unfamiliar is just getting in your way.

Well i mean... that's kinda what "unintuitive" means. Intuitive, i.e. natural/obvious/without effort. Having to gain familiarity sorta literally means it's not that, thus unintuitive.

I dont disagree with your sentiment, but these people are using the correct term. For example, python len(object) instead of obj.len() trips me up to this day because 99% of the time i think [thing] -> [action], and most language constructs encourage that. If I still regularly type an object name, and then have to scroll the cursor back over and type "len(", i cant possibly be using my intuition. It's not the language's "fault" - because it's not really "wrong" - but it is unintuitive.

load more comments (8 replies)
load more comments (9 replies)
[–] [email protected] 130 points 1 year ago (11 children)

Dynamic typing is insane. You have to keep track of the type of absolutely everything, in your head. It's like the assembly of type systems, except it makes your program slower instead of faster.

[–] [email protected] 26 points 1 year ago

Nothing like trying to make sense of code you come across and all the function parameters have unhelpful names, are not primitive types, and have no type information whatsoever. Then you get to crawl through the entire thing to make sense of it.

load more comments (10 replies)
[–] [email protected] 99 points 1 year ago* (last edited 1 year ago) (20 children)

If you don't add comments, even rudimentary ones, or you don't use a naming convention that accurately describes the variables or the functions, you're a bad programmer. It doesn't matter if you know what it does now, just wait until you need to know what it does in 6 months and you have to stop what you're doing an decipher it.

[–] [email protected] 36 points 1 year ago (1 children)

However, engineers who rely solely on comments to explain their code, are bad at writing readable code.

load more comments (1 replies)
load more comments (19 replies)
[–] [email protected] 90 points 1 year ago (4 children)

Programing is a lot less important than people and team dynamics

load more comments (4 replies)
[–] [email protected] 81 points 1 year ago (14 children)

My take is that no matter which language you are using, and no matter the field you work in, you will always have something to learn.

After 4 years of professional development, I rated my knowledge of C++ at 7/10. After 8 years, I rated it 4/10. After 15 years, I can confidently say 6.5/10.

[–] [email protected] 29 points 1 year ago

This take gets colder as you get more experience.

load more comments (13 replies)
[–] [email protected] 80 points 1 year ago (10 children)

Tools that use a GUI are just as good (if not better) than their CLI equivalents in most cases. There's a certain kind of dev that just gets a superiority complex about using CLI stuff.

[–] [email protected] 70 points 1 year ago (3 children)

The big thing you can do from the command line is script it.

load more comments (3 replies)
[–] [email protected] 39 points 1 year ago (4 children)

I used to think something like this when I was younger. I spent an inordinate amount of time looking for good gui versions of cli tools. I have come to understand that this is not usually the case and cli tools are more convenient much of the time. I would not classify this as superiority complex, unless I’m being a jerk about it. I don’t care what you use, I just use whatever has the lowest barrier to entry with the most standardization, which is usually the original cli tool.

That said, jetbrains git integration is awesome.

load more comments (4 replies)
load more comments (8 replies)
[–] [email protected] 73 points 1 year ago* (last edited 1 year ago) (8 children)

Not sure if these are hot takes:

  • Difficult to test == poorly designed
  • Code review is overrated and often poorly executed, most things should be checked automatically (review should still be done though)
  • Which programming language doesn't matter (within reason), while amount of programming languages matters a lot
[–] [email protected] 33 points 1 year ago (3 children)

I agree with your first point, but pretty strongly disagree with the other two. Code review is critical. Devs should be discussing changes and design choices. One Dev can not be all things all the time and other people have experience you do not or can remind you of things you forgot. Programming language absolutely matters when you’re not the only dev on the team.

load more comments (3 replies)
load more comments (7 replies)
[–] [email protected] 67 points 1 year ago

Most modern software is way too complex for what it actually does.

[–] [email protected] 65 points 1 year ago (19 children)

Python is only good for short programs

load more comments (19 replies)
[–] [email protected] 65 points 1 year ago (13 children)

SPAs are mostly garbage, and the internet has been irreparably damaged by lazy devs chasing trends just to building simple sites with overly complicated fe frameworks.

90% of the internet actually should just be rendered server side with a bit of js for interactivity. JQuery was fine at the time, Javascript is better now and Alpinejs is actually awesome. Nowadays, REST w/HTMX and HATEOAS is the most productive, painless and enjoyable web development can get. Minimal dependencies, tiny file sizes, fast and simple.

Unless your web site needs to work offline (it probably doesn't), or it has to manage client state for dozen/hundreds of data points (e.g. Google Maps), you don't need a SPA. If your site only needs to track minimal state, just use a good SSR web framework (Rails, asp.net, Django, whatever).

load more comments (13 replies)
[–] [email protected] 63 points 1 year ago* (last edited 1 year ago) (5 children)

The best codebase I have ever seen and collaborated on was also boring as fuck.

  • Small, immutable modules.
  • Every new features was coded by extension (the 'o' in S.O.L.I.D)
  • All dependencies were resolved by injection.
  • All the application life cycle was managed by configurable scopes.
  • There was absolutely no boiler plate except for the initial injectors.
  • All of the tests were brain-dead and took very minimal effort to write. Tests served both as documentation and specification for modules.
  • "Refactoring" was as simple as changing a constructor or a configuration file.
  • All the input/output of the modules were configurable streams.

There is more to it, but basically, it was a very strict codebase, and it used a lot of opinionated libraries. Not an easy codebase to understand if you're a newbie, but it was absolutely brain dead to maintain and extend on.

Coding actually took very little time of our day, most of it consisted of researching the best tech or what to add next. I think the codebase was objectively strictly better than all other similar software I've seen and worked on. We joked A LOT when it came time to change something in the app pretending it would take weeks and many 8 pointers, then we'd casually make the change while joking about it.

It might sound mythical and bullshity, and it wasn't perfect, it should be said that dependency injection often come in the form of highly opinionated frameworks, but it really felt like what software development should be. It really felt like engineering, boring and predictable, every PO dreams.

That being said, I given up trying to convince people that having life-cycle logic are over the place and fetching dependencies left and right always lead to chaos. Unfortunately I cannot really tell you guys what the software was about because I am not allowed to, but there was a lot of moving parts (hence why we decided to go with this approach). I will also reiterate that it was boring as fuck. If anything, my hot take would be that most programmers are subconsciously lying to themselves, and prefer to code whatever it is they like, instead of what the codebase need, and using whatever tool they like, instead of the tools the project and the team need. Programming like and engineer is not "fun", programming like a cowboy and ignoring the tests is a whole lot of fun.

load more comments (5 replies)
[–] [email protected] 58 points 1 year ago (2 children)

You can always solve a problem by adding more layers of abstraction. Good software design isn't to add more layers of abstractions, it's to solve problems with the minimum amount of abstractions necessary while still having maintainable, scalable code.

There are benefits to abstraction but they also have downsides. They can complicate code and make code harder to read.

load more comments (2 replies)
[–] [email protected] 56 points 1 year ago (6 children)

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.

load more comments (6 replies)
[–] [email protected] 53 points 1 year ago* (last edited 1 year ago) (9 children)

This is the only way;

if (condition) {
    code
}

Not

if (condition)
{
    code
}

Also because of my dyslexia I prefer variable & function names like this; 'File_Acces' I find it easier to read than 'fileAcces'

load more comments (9 replies)
[–] [email protected] 52 points 1 year ago (5 children)

Internet would be better if javascript was never invented.

[–] [email protected] 26 points 1 year ago (1 children)

The JavaScript ecosystem is made worse by the legions of "developers" in it which amount to bro-velopers that put no thought into if something is needed before they create it. There's a strong overlap between the idiots in crypto and JavaScript developers that needs to be decoupled drastically.

load more comments (1 replies)
load more comments (4 replies)
[–] [email protected] 52 points 1 year ago (3 children)

Hot take: people who don’t like code reviews have never been part of a good code review culture.

load more comments (3 replies)
[–] [email protected] 50 points 1 year ago (11 children)

Agile in it’s current implementation with excessive meetings wastes more time than the mistakes it tries to avoid.

load more comments (11 replies)
[–] [email protected] 45 points 1 year ago (20 children)

Tabs are better than spaces

load more comments (20 replies)
[–] [email protected] 44 points 1 year ago (5 children)

Dynamically typed languages don’t scale. Large project bases become hard to maintain, read and refactor.

Basic type errors which should be found in compilation become runtime errors or unexpected behavior.

load more comments (5 replies)
[–] [email protected] 41 points 1 year ago (28 children)

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

load more comments (28 replies)
[–] [email protected] 39 points 1 year ago* (last edited 1 year ago) (7 children)

As an embedded firmware guy for 10ish years:

C can die in a fire. It's "simplicity" hides the emergent complexity by using it as it has nearly no compile time checks for anything and nearly no potential for sensible abstraction. It's like walking on an infinite tight rope in fog while an earth quake is happening.

For completely different reasons: The same is true for C++ but to a far lesser extent.

load more comments (7 replies)
[–] [email protected] 37 points 1 year ago (2 children)

Not everything should be beginner friendly. Trying to nerf things because they are not beginner friendly should not be how tools/patterns of languages are designed.

Its ok to have more advanced topic that require more knowledge and that people don't understand from the first moment they see them.

load more comments (2 replies)
[–] [email protected] 36 points 1 year ago (2 children)

You can use all the classes, patterns, functions, methods you want but if it's not readable it's garbage.

load more comments (2 replies)
[–] [email protected] 35 points 1 year ago (2 children)

Make your app use native components instead of making your own crappy theme for the 782th time

load more comments (2 replies)
[–] [email protected] 34 points 1 year ago (4 children)

I am not smart enough to effectively code with certain languages and design patterns and that's ok. There is nothing wrong with accessibility being prioritized or with making tradeoffs for the sake of reducing complexity.

load more comments (4 replies)
[–] [email protected] 34 points 1 year ago (8 children)

In unit testing, a "unit" does not have to be the smallest possible section of code. It can be a while class or module or even set of related classes/modules. Testing individual functions in isolation leads to brittle tests that easily break during refactoring. Testing overall system behaviour results in more robust tests that require fewer changes during refactoring which gives you more confidence then you have not introduced a regression.

load more comments (8 replies)
[–] [email protected] 33 points 1 year ago (15 children)

Shorter code is almost always better.

Should you use a class? Should you use a Factory pattern or some other pattern? Should you reorganize your code? Whichever results in the least code is probably best.

A nice thing about code length is it's objective. We can argue all day about which design pattern makes more sense, but we can agree on which of two implementations is shorter.

It takes a damn good abstraction to beat having shorter code.

load more comments (15 replies)
[–] [email protected] 32 points 1 year ago* (last edited 1 year ago) (10 children)

The programming languages you use, and the variety of languages you learn, deeply influence how you think about software design.

Software would be much more reliable (in general) if Erlang had become one of the dominant languages for development.

Go sacrifices too much for superficial simplicity; but I would like to see a language that's nearly as easy to learn, but has a better type system and fewer footguns.

Unit testing is often overrated. It is not good for discovering or protecting against most bugs.

Build/test/deploy infrastructure is a genuinely hard problem that needs better tooling, particularly for testability.

load more comments (10 replies)
[–] [email protected] 32 points 1 year ago* (last edited 1 year ago) (3 children)

Everybody trashing on code reviews has never worked with a shit coder before

I'm a shit coder and almost every single review I've made big mistakes like forgetting to delete debug/dead code and there's always meaningful improvements being suggested

load more comments (3 replies)
[–] [email protected] 31 points 1 year ago (28 children)
load more comments (28 replies)
[–] [email protected] 30 points 1 year ago (7 children)

We use too many libraries. This may be an actual unpopular opinion though. I find that the more a library tries to do, and the more dependencies it has itself, the more hesitant I am to use it. It just feels like a tower of cards ready to fall at any moment.

I'm not a very trusting person and work alone though so this might just be an emotional decision. But it is nice having a project be composed of code that does just what is needed and nothing else. It makes it easier to fix bugs and especially to maintain the code.

I do use libraries, but only if they're absolutely necessary or if they're very focused and don't try to do a million things. It's not about size but complexity.

load more comments (7 replies)
[–] [email protected] 30 points 1 year ago (33 children)

Using single character variable names is always bad practice

load more comments (33 replies)
[–] [email protected] 30 points 1 year ago (13 children)

Oop is overrated

I never can understand classes

load more comments (13 replies)
[–] [email protected] 29 points 1 year ago (15 children)

Web development feels like it's stuck in the early 2000's. I've ranted a lot about it over the years but I just don't know how everyone is okay with it. I'm sure tons of people will disagree.

HTML is bad. The language itself feels unintuitive and is clunky compared to modern markdown languages, and let's be honest, your webpage just consists of nested <div> tags.

CSS is bad. Who knew styling can be so unintuitive and unmanageable? Maybe it made sense 25 years ago, but now it's just terrible. It's very clunkily integrated with HTML too in my opinion. Styling and markdown should be one easier to use language where 50% of it isn't deprecated.

Javascript has been memed to death so I won't even go there. Typescript is OK I suppose.

And now for my hottest take: ~10+ years ago I saw web building tools like Wix and I completely expected web development to head in the direction using a GUI to create, style, and script from one interface, even allowing you to create and see dynamic content instantly. I've seen competitors and waited for "the big one" that's actually free and open source and good enough to be used professionally. It never happened. Web dev has just gone backwards and stuck in its old ways, now it's a bloated mess that takes way more time than it deserves.

The Godot engine is actually a pretty good option for creating GUI apps and it's exactly what I envisioned web dev should've been this past decade. One language, intuitive interface, simple theming and easy rapid development... Shame it never happened.

load more comments (15 replies)
[–] [email protected] 28 points 1 year ago* (last edited 1 year ago) (7 children)

Computer hardware has been getting faster and faster for decades at this point, but my computer still slows down. Like WTF. The dumbass programmers take the extra power given to them and squander it instead of optimizing their code. Microsoft word could run pretty well on a windows 98 PC, but the new Word can slow down PCs that are 5-10 years old. Programmers are complete idiots sometimes...

load more comments (7 replies)
[–] [email protected] 27 points 1 year ago* (last edited 1 year ago) (3 children)

Oh boy, here we go (inhales):

Agile isn't that bad. People just believe they are more productive if they are "heads down" and not held accountable for what they write/do.

Functional programming isn't that great and doesn't solve all of the world's problems; it just pushes the issues with state to other parts of your design, and doesn't scale well in deeply nested solutions.

IDEs with proper code support (i.e. automatic structure analysis, autocomplete, etc.) are one of the best ways to deal with a large codebase that needs refactoring. Doing widescale refactors without one is asking for trouble. If you believe you don't need it, either your codebase is just that small (which is fine) or playing with fire.

Much of the advice out there on architecture and tooling isn't properly contextualized on the codebase, market, and team situation. If you believe you have the One True Architecture Solution, you are naive. (Ex. Microservices, large complex code pipelines, monorepos, etc.) Be especially wary of anything from FAANG engineering blogs unless you are also in another letter of FAANG.

There. Got it out of my system. Have fun dissecting it.

load more comments (3 replies)
[–] [email protected] 27 points 1 year ago (4 children)
load more comments (4 replies)
[–] [email protected] 27 points 1 year ago (14 children)

Microsoft has not made a good product. Ever. Every program has issues that should not be there if you're selling it. Yet they get away with it

load more comments (14 replies)
load more comments
view more: next ›