this post was submitted on 01 Sep 2023
2 points (100.0% liked)

Programming

23894 readers
290 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 !webdev@programming.dev



founded 2 years ago
MODERATORS
top 50 comments
sorted by: hot top controversial new old
[–] million@lemmy.world 6 points 2 years ago* (last edited 2 years ago) (3 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.

[–] brettvitaz@programming.dev 2 points 2 years ago* (last edited 2 years ago)

Only if the code base is well tested.

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

[–] NoXzema@lemmynsfw.com 2 points 2 years 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.

[–] myersguy@lemmy.simpl.website 0 points 2 years ago (1 children)

Who is in the wrong? Your manager, for not giving you time to refactor? Or you for giving him the option?

[–] nous@programming.dev 1 points 2 years ago

Why do you need time to refactor? It is just part of the work you need to do and should be accounted for when doing any other work. IMO a big mistake people make is thinking refactoring is some separate thing they need permission to do. You don't, if you need to make a change in some area refactor it first to make it easier to accept your change, then add your change then refactor to clean up. This is not three separate tasks, just three steps in one task. You should be given enough time to do the whole task, not just part of it.

[–] fubo@lemmy.world 5 points 2 years ago* (last edited 2 years ago) (4 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.

[–] flumph@programming.dev 1 points 2 years ago

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".

Yeah. I've written in six or so different languages and am using Go now for the first time. Even then, I'm trying to be optimistic and acknowledge things are just different or annoying for me. It doesn't mean anything is wrong with the language.

load more comments (3 replies)
[–] MrTallyman@programming.dev 3 points 2 years ago (4 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.

load more comments (4 replies)
[–] words_number@programming.dev 2 points 2 years ago

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.

[–] argv_minus_one@beehaw.org 2 points 2 years ago (3 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.

[–] Cratermaker@discuss.tchncs.de 2 points 2 years 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.

[–] uniqueid198x@lemmy.dbzer0.com 2 points 2 years ago

You can do typing through the compiler at build time, or you can do typing with guard statements at run time. You always end up doing typing tho

[–] Boomkop3@reddthat.com 1 points 10 months ago

I kinda wanna say... skill issue? But really, dynamic typing is great as long as it fits the problem your solving and you keep your types simple or even just primitive

[–] lysdexic@programming.dev 1 points 2 years ago

Duplicate code can be a code smell, but it's far better to have the same function definition or code block appear twice in the code than extracting a function that tightly couples two components that should not be coupled at all.

See Write Everything Twice (WET) principle.

[–] uniqueid198x@lemmy.dbzer0.com 1 points 2 years ago (2 children)

Programing is a lot less important than people and team dynamics

load more comments (2 replies)
[–] Elderos@lemmings.world 1 points 2 years ago* (last edited 2 years ago)

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.

[–] escapesamsara@discuss.online 1 points 2 years ago

Python is legitimately the best language by far for the vast majority of non-performance critical tasks, and most tasks that need to be developed for are not performance critical.

[–] popcar2@programming.dev 1 points 2 years ago (2 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 (2 replies)
[–] lefixxx@lemmy.world 1 points 2 years ago (1 children)

I like 1-index because its what I learned first, and you like 0-index because that's what you learned first

[–] Weirdfish@lemmy.world 1 points 2 years ago

We just need to compromise, arrays start at 0.5

[–] Kushan@lemmy.world 1 points 2 years ago

That the entire industry is cyclical and the current trends are yesterday's anarcisms. Oop Vs functional, separating concerns Vs vertical slices, there's examples all over the place.

All of this has happened before and all of this will happen again.

[–] IcecreamMelts@lemmy.world 1 points 2 years ago (1 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

[–] darcy@sh.itjust.works 1 points 2 years ago

typescript? i know its a bandaid on a severed leg at this point but still

[–] OADINC@feddit.nl 1 points 2 years ago* (last edited 2 years ago)

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'

[–] gpopides@lemmy.world 1 points 2 years ago

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.

[–] qwerty@discuss.tchncs.de 1 points 2 years ago

Internet would be better if javascript was never invented.

[–] pelotron@midwest.social 1 points 2 years ago

Carbon? Just what we were all hoping for, yet another programming language from Google. They can keep it.

[–] Masterkraft0r@discuss.tchncs.de 1 points 2 years ago* (last edited 2 years ago)

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.

[–] enemenemu@lemm.ee 1 points 7 months ago

Don't be afraid to drop a tool although you've spent years mastering it if there is something new that is much more efficient. Some day you have to switch anyway.

[–] witx@lemmy.sdf.org 1 points 2 years ago

Python is only good for short programs

[–] corstian@lemmy.world 1 points 2 years ago

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

[–] Buttons@programming.dev 1 points 2 years ago (1 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.

[–] TanakaAsuka@sh.itjust.works 1 points 2 years ago (1 children)

I mostly agree with this but more than shorter code I value readability, I would rather take 3 lines to be clear to any developer than use some obscure or easy to misunderstand structure to write it in 1.

[–] StudioLE@programming.dev 1 points 2 years ago

Yep. And three functions is better than one for legibility even if one would be fewer lines of code

[–] NBJack@reddthat.com 0 points 2 years ago* (last edited 2 years ago) (2 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 (2 replies)
[–] eeleech@lemm.ee 0 points 2 years ago (3 children)

I find that S-expressions are the best syntax for programming languages. And in general infix operators are inferior to either prefix or postfix notation.

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