3 ms·
I agree. It's such an illogical and unreadable construct to me. Even after working with a typed language for awhile my instinct is to declare the type before th
by matthiaswh 8y ago
I agree. It's such an illogical and unreadable construct to me. Even after working with a typed language for awhile my instinct is to declare the type before the variable name.
I've been envisioning a future programming environment that automatically aids in code readability by hiding unnecessary information when you're not using it. Manual code folding was sort of a first step, but this environment would take it further by hiding things like types until you need them. So something like
proc eval(c: Criterion, token: Token): bool =
let tokenCrit = (token.identifier, token.token)
return tokenCrit == c
Might look like
proc eval(c, token) =
let tokenCrit = (token.identifier, token.token)
return tokenCrit == c
Or even
proc eval(c, token) =
...
return tokenCrit == c
It would have to be smart enough to expand the hidden blocks when you need them and in an unobtrusive way. It's also possible that the type declarations wouldn't actually expand in this editor, but would be set by some sort of popup selector (similar to how autocomplete works, but you'd select the variable type).
This is just a rough idea and I'm not sure how well it works in reality. But when code starts looking like `proc add*[T](root: var BinaryTree[T], n: var seq[BinaryTree[T]]) =` it starts to lose its at-a-glance readability.
- angleofrepose 8y agoGary Bernhardt has a good take on this in his talk A Whole New World [1]. He introduces an editor which has these layers which can display or hide orthogonal information such as types, a short view or profiling details. That talk, and your comment and my inability to find anything that does this kind of work simply surprises me. Are there no good examples of systems that allow these kind of simple transformations out there? I remember someone pointing me to a clojure editor a while back, maybe? I can't remember. Seems to me there is a desire for editors that allow a user to transform code, whether it be annotations or raster graphics as Bernhardt puts it. The closest I know of is org mode, and how it works on a plaintext interface but has no qualms about displaying it in wildly different ways than an org file might look opened up in vim, though it still does maintain readablity. I think this is the way to go and I've been playing around with a personal workflow on top of org mode lately. What do you think? [1]: https://www.destroyallsoftware.com/talks/a-whole-new-world https://www.destroyallsoftware.com/talks/a-whole-new-world