Pure Python Vim clone
61–70 of 85 posts
Re: Pure Python Vim clone
#62Earlier quoted context omitted.
Types. They Will Save You Tests™ :-)
I had actually gone and looked for Lua static type checkers. Some exist, but none that'll work with Lua 5.2. I had a really hilarious bug today where under some circumstances all the text in the display would be replaced by numbers. Small integers, each placed where the word should be. What had happened is that I'd added a layer of indirection; where previously, after line wrapping, the data structure for a rendered…
int[] bodies = {1, 2, 3};
for (int body : bodies) {
String formatted_body = "" + body + "
";
callMethodWithStrArg(formatted_body);
}
And if in this hypothetical case it was previously a `String[] bodies` and a `String body`, I bet a lot of programmers would use an auto-refactoring tool because "static types and auto-refactoring go together for being confident in changes like apples and pie" and I bet the error wouldn't have been noticed even at review time. God help you if you're using a static language without generics that has implicit type conversions. In Python, though, this raises an error: bodies = [1, 2, 3]
for body in bodies:
formatted_body = '' + body + '
'
The error is: "TypeError: cannot concatenate 'str' and 'int' objects".Dynamically typed languages still have types.
Re: Pure Python Vim clone
#63Is there any vim clone that actually have full support to vimfiles?
Re: Pure Python Vim clone
#64Earlier quoted context omitted.
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
#65My 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…
Re: Pure Python Vim clone
#66Earlier quoted context omitted.
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!
No they don't. They only tell you that you are matching function signatures correctly. This is valuable but it's not a substitution for unit tests.
Re: Pure Python Vim clone
#67Earlier 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.
Re: Pure Python Vim clone
#68Re: Pure Python Vim clone
#69My 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…
Maybe not - Python itself can provide some crash protection. Run it this way: python -i run_pyvim.py. Then if pyvim crashes, Python will still be running with all your work still there. Maybe you can just type run() at the Python prompt to resume the session in almost the state you left it -- depending on how run() is coded, how much re-initialization it does.
Re: Pure Python Vim clone
#70Earlier quoted context omitted.
Not really, no. yi badly needs some more love.
Care to elaborate on where it falls down emulating vim?
I don't remember all of the issues, but there are a ton of small things that make the editor unusable to me. I used it for a couple of weeks, and I spent some time working on these issues, but never had PR-worthy code. Here's what I can remember off the top of my head:
- Startup time is very slow because of the way configuration works. In my local copy, I made a version without runtime configuration, and that solved this problem. This conflicts pretty badly with the whole architecture, so I didn't make a PR.
- :n :N don't work. Opening multiple files from the command line doesn't work.
- :cq doesn't work. I fixed this, but my fix was a hack, so I didn't make a PR.
- Operating on regions with '{' and '}' is off by one line in some directions.
- You can't replace regions with shell commands. For example, using '!}sort' to sort a paragraph.