Live data from Hacker News

Pure Python Vim clone

github.com

31–40 of 85 posts

Re: Pure Python Vim clone

#31
post #28
post #23

Earlier quoted context omitted.

Can you elaborate?

print(arr[i]) Compiles, runs, fails if i is out of bounds. Which means that you need to test the code that you write, and that even if you have 100% line coverage (or branch coverage or MC/DC coverage or...), it doesn't mean i won't get the wrong value. People who claim that "once my C++/Haskell/Agda/whatever program compiles, I know it probably has no bugs" thus tempt others to mention "a false sense of security." (…

You can't write this in Haskell:

  print(arr[i])
You can write this, but you probably wouldn't.

  print (arr `V.unsafeIndex` i)

Re: Pure Python Vim clone

#33
post #22

Earlier quoted context omitted.

Types. They Will Save You Tests™ :-)

Types don't tell you if the behavior is correct or not.

Yes they do.

Ignoring trivial cases and dependent types, types tell you one of two things: "this might be correct" or "this is incorrect". Again ignoring trivial cases where exhaustive checking is possible, that's the same thing that tests tell you - and it's a hugely useful thing to be told!

Re: Pure Python Vim clone

#34
post #28
post #23

Earlier quoted context omitted.

Can you elaborate?

print(arr[i]) Compiles, runs, fails if i is out of bounds. Which means that you need to test the code that you write, and that even if you have 100% line coverage (or branch coverage or MC/DC coverage or...), it doesn't mean i won't get the wrong value. People who claim that "once my C++/Haskell/Agda/whatever program compiles, I know it probably has no bugs" thus tempt others to mention "a false sense of security." (…

I've never seen anyone claim that types (even a very strong type system like Haskell or Rust) mean you don't have to write tests. They just mean you don't have to write the very silly tests you would otherwise have to to feel secure in a dynamically typed language.

Re: Pure Python Vim clone

#35
post #20

Earlier quoted context omitted.

Types. They Will Save You Tests™ :-)

Types will create a false sense of security...

You know, I hear people use this excuse to justify bad behavior a lot. I once heard a bike messenger tell me that brakes gave him a false sense of security so that's why he didn't have a brake on his fixed gear bicycle.

Re: Pure Python Vim clone

#36
post #21
post #9

My thought process upon seeing this: "Python, huh? Seems like typos in uncommon branches of the code would cause it to randomly fail at runtime, losing your work!" "Now evmar, don't be such a internet nay-sayer, plenty of people write reliable Python code. You just need tests and... yep, there's a tests directory right there in the repository." "Let's take a look. ...there's only one test!?" It looks pretty neat othe…

It's interesting that your first thought was to post a troll about how Python is a bad language.

[deleted]

Re: Pure Python Vim clone

#37
post #28

Earlier quoted context omitted.

print(arr[i]) Compiles, runs, fails if i is out of bounds. Which means that you need to test the code that you write, and that even if you have 100% line coverage (or branch coverage or MC/DC coverage or...), it doesn't mean i won't get the wrong value. People who claim that "once my C++/Haskell/Agda/whatever program compiles, I know it probably has no bugs" thus tempt others to mention "a false sense of security." (…

You can't write this in Haskell: print(arr[i]) You can write this, but you probably wouldn't. print (arr `V.unsafeIndex` i)

Unfortunately, unsafeIndex is often spelled "!". There is a push (which I support!) away from partial functions, but there are still plenty of partial functions provided by standard libraries under names that sound reasonable.

Re: Pure Python Vim clone

#38
post #9

My thought process upon seeing this: "Python, huh? Seems like typos in uncommon branches of the code would cause it to randomly fail at runtime, losing your work!" "Now evmar, don't be such a internet nay-sayer, plenty of people write reliable Python code. You just need tests and... yep, there's a tests directory right there in the repository." "Let's take a look. ...there's only one test!?" It looks pretty neat othe…

vs random memory bugs that will fail randomly at runtime ;)

Re: Pure Python Vim clone

#40
post #28

Earlier quoted context omitted.

print(arr[i]) Compiles, runs, fails if i is out of bounds. Which means that you need to test the code that you write, and that even if you have 100% line coverage (or branch coverage or MC/DC coverage or...), it doesn't mean i won't get the wrong value. People who claim that "once my C++/Haskell/Agda/whatever program compiles, I know it probably has no bugs" thus tempt others to mention "a false sense of security." (…

I've never seen anyone claim that types (even a very strong type system like Haskell or Rust) mean you don't have to write tests. They just mean you don't have to write the very silly tests you would otherwise have to to feel secure in a dynamically typed language.

> They just mean you don't have to write the very silly tests

I have seen claims and have a hunch that more than just very silly tests can be eliminated by types, but I'm struggling to come up with or remember any examples.

I'm hoping someone who has one will reply with one of these claims or any examples.

Post reply on HN