812
submitted 1 day ago by [email protected] to c/[email protected]
top 50 comments
sorted by: hot top controversial new old
[-] [email protected] 4 points 3 hours ago

If you thought misspelling a variable was bad, then get ready for misreading documentation of OS API, then not realize why your implementation doesn't work for a quite a long time.

[-] [email protected] 5 points 8 hours ago

Programming has its highs and lows. Yesterday I spent four hours trying to write a script that honestly probably won't even be useful to anyone.

Today I felt like a god because I built a recursive query to pull some ridiculously obscure data from our database.

Tomorrow I'll probably delete a table in prod or something.

You win some, you lose some!

[-] [email protected] 2 points 10 hours ago

I spent such a long time the other day trying to figure out why I couldn’t access an application I wrote and served on a home server from my reverse proxy. Next day I take a look at the DNS record I setup again, CNAMEd to the host server instead of the reverse proxy server. Felt dumb.

[-] [email protected] 3 points 11 hours ago

This is me but not with programming, just in my interactions with other people.

[-] [email protected] 1 points 3 hours ago

it feels like it should it work to just poke a stranger when you want to talk to them

[-] [email protected] 4 points 13 hours ago* (last edited 13 hours ago)

The older I get the more impatient I get with stupid tasks that take longer then they should. I simplify my life by focusing on the task ahead of me. Knowing these small tasks compound into the final goal.

So when I am looking through 17 different folders for a file I can't remember what I saved it as and I'm sorting by date and opening things frantically...

'it's been 20 fucking minutes, should I just take the rest of the day to organize my shit? But if I get this fucking thing done I can setup a meeting on this today and fit it in this week before Juan goes on vacation and I have to wait two weeks to place an order that will take 6 months to deliver.'

'Fuuuuuuuuu where the fuck is this file, I'll just start from scratch and I'll be done by 2pm just in time for it to go on the calender so everyone can seee. Or maybe i just look another 15 minutes wheeerreeeee the fuckkkk did I save this?!?!'

'Bullshit bullshit bullshit!"

Google: how to find file.

Google: how to find file just working on.

Google: how to find excel file by date, most recent.

Google: file not in recent, why come?

Google: did I dream a this nightmare wake me, wake me, wake me.'

[-] [email protected] 2 points 8 hours ago

find -iname '*part*' has saved my butt countless times.

find a . | grep part if you're feeling stupid and lazy!

[-] [email protected] 18 points 1 day ago

This literally happened to me yesterday, but with filenames. I was failing to configure a program until an hour later I found out that I mispelled the config file as colors.ini instead of color.ini.

[-] [email protected] 4 points 1 day ago

I like that even here on Lemmy, with inline code format, colors.ini is not being colored but color.ini is. Great symbolism for your issue.

[-] [email protected] 47 points 1 day ago* (last edited 1 day ago)

...for people who refuse to use static types.

[-] [email protected] 31 points 1 day ago

Static types are great, but not exactly what would have helped here, any decent language or at least a linter should catch the use of a not declared identifier.

[-] [email protected] 17 points 1 day ago
def foo(x):
  return x.whatevr

No linter is going to catch that.

[-] [email protected] 12 points 1 day ago
class MyClass:
    def __init__(self, x: int):
        self.whatever: int = x

def foo(x: MyClass) -> int:
    return x.whatevr

Any decent IDE would give you an error for unresolved attribute. Likewise it would warn you of type error if the type of x.whatever didn't match the return type of foo()

[-] [email protected] 4 points 1 day ago

Yes because you used static type annotations. This thread was about code that doesn't use static types (or static type annotations/hints).

[-] [email protected] 1 points 11 hours ago

Nope, don't need to. WebStorm can even detect nonexistent attributes for objects whose format the back-end decides, and tbh I'm not sure what sort of sorcery it uses.

[-] [email protected] 6 points 1 day ago

You're both right. It's possible to write code that gets linted well in Python, yes, but you're often not working with just your code. If a library doesn't use typing properly, not a lot to be done without a ton more effort.

[-] [email protected] 1 points 1 day ago

Python doesn't check the types of function headers though. They're only hints for the programmer.

[-] [email protected] 1 points 1 day ago

OP suggested that linters for python won't catch attribute errors, which they 100% will if you use type hints, as you should.

What happens at runtime is really relevant in this case.

[-] [email protected] 1 points 12 hours ago

Linters 100% won't. A static type checker is not a linter.

[-] [email protected] 1 points 12 hours ago* (last edited 12 hours ago)

I don't want to get into an Internet argument over pedantry. Linter is often used as a catch-all term for static analysis tools.

Wikipedia defines it as

Lint is the computer science term for a static code analysis tool used to flag programming errors, bugs, stylistic errors and suspicious constructs.

Catching type errors and attribute errors would fit under this description, if you use a different, more precise definition at your workplace, cool, then we just have different definitions for it. The point is that your IDE should automatically detect the errors regardless of what you call it.

[-] [email protected] 1 points 11 hours ago

In common usage a linter detects code that is legal but likely a mistake, or code that doesn't follow best practice.

Although static type checkers do fit in that definition, that definition is overly broad and they would not be called a "linter".

Here is how static type checkers describe themselves:

Pyright is a full-featured, standards-based static type checker for Python.

Mypy is a static type checker for Python.

TypeScript is a strongly typed programming language that builds on JavaScript, giving you better tooling at any scale.

Sorbet is a fast, powerful type checker designed for Ruby.

Here is how linters describe themselves:

Pylint is a static code analyser for Python 2 or 3. ... Pylint analyses your code without actually running it. It checks for errors, enforces a coding standard, looks for code smells, and can make suggestions about how the code could be refactored.

(Ok I guess it's a bit redundant for Pylint to say it is a linter.)

Eslint: The pluggable linting utility for JavaScript and JSX

Clippy: A collection of lints to catch common mistakes and improve your Rust code.

Ruff: An extremely fast Python linter and code formatter, written in Rust.

You get the idea... Linters are heuristic and advisory. Quite different to static type checking.

[-] [email protected] 7 points 1 day ago

It's python, just use type hinting already and your linter will catch that.

Also some winters can look at the use of food and see the type being passed in.

[-] [email protected] 14 points 1 day ago

Autocorrect got you pretty bad, there.

I was very confused, why we're suddenly talking about rationing food during winter. 🙃

[-] [email protected] 4 points 1 day ago

Holy crap that's wild, new phones autocorrect is out to get me

[-] [email protected] 6 points 1 day ago

Yes you can use static type hinting and the static type checker (Mypy or Pyright) will catch that. Linters (Pylint) won't.

load more comments (12 replies)
[-] [email protected] 52 points 1 day ago

I'm in this picture, and I don't like it.

[-] [email protected] 1 points 13 hours ago

No I’m Spartacus.

[-] [email protected] 5 points 1 day ago

I didn't sign a release!

[-] [email protected] 26 points 1 day ago

I appreciate the "carrot with a bit out of it" icon.

[-] [email protected] 9 points 1 day ago

The problem is the client 🤣

[-] [email protected] 11 points 1 day ago

If you remove the 4th panel then this accurately describes call center customer service

[-] [email protected] 6 points 1 day ago

I spent like 3 hours yesterday deduplicating two functions that were hundreds of lines long and nearly identical. I should probably learn how to use that git command that can diff two files on disk. Luckily I actually enjoy cleaning up code sometimes.

[-] [email protected] 11 points 1 day ago

If you're using a decent development system, you'll have an executable called diff installed already :)

[-] [email protected] 7 points 1 day ago

That's what the diff tool is for.

[-] [email protected] 4 points 1 day ago

Dunno what OS's it supports besides Windows but I use Kdiff for random comparisons regularly, I think it works pretty well untill you get to much larger files (20+ MB slows down a lot). The huge file wasn't code but needed to check output changes for those curious.

I constantly check git comparison with previous versions to see what changed to break things in a build though. Didn't know there was a way to diff any files in git,should probably just learn to use that one.

[-] [email protected] 3 points 1 day ago

Git uses the diff binary under the hood (unless you configure it to use something else).
You can invoke that directly with diff file_a.txt file_b.txt.

[-] [email protected] 2 points 1 day ago

git diff —no-index before.json after.json > showmethegoods.diff

You don’t have to save it to a file but I often do.

[-] [email protected] 5 points 1 day ago

If you use VSCode, open both files and then ctrl-shift-P "Compare active file with ..."

You're welcome.

load more comments (1 replies)
load more comments (3 replies)
[-] [email protected] 3 points 1 day ago

Use spell check in your code editor and never experience this again.

[-] [email protected] 2 points 23 hours ago

Spellcheck? My editor proposes known words after 3 characters.

[-] [email protected] 5 points 1 day ago

Yeah, pretty much

load more comments
view more: next ›
this post was submitted on 25 Sep 2024
812 points (97.3% liked)

Programming

17071 readers
408 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