Improving the way we write code?

2019-03-17 20:36发布

While thinking about software-engineering in general I came across the question why we don't see any improvements in the way we write/document code.

Think about it: There has not been a revolutionary improvement since we've moved from punch cards to text editing. The last improvement I've seen is syntax highlighting and context sensitive help (e.g. Intellisense or ctags). Not something I would call revolutionary.

That makes me wonder: Why is it so?

I'll start with something I miss badly:

  • Lots of my code deals with geometry. For documentation describing geometric relationships always ends up in a big heap of hard to read mathematical stuff (due to the lack of proper equation type-setting in ASCII). However, if I could embed a little drawing or scribble into the code everything would be much easier, neater and better to be understood.

What can you think up that would make your coding/text editing/documention tasks easier?

30条回答
戒情不戒烟
2楼-- · 2019-03-17 20:44

DrScheme let's you do these things. Here's the things you can insert from the PLT website:

http://docs.plt-scheme.org/drscheme/Menus.html#(part._.Insert)

3.1.6 Insert

  • Insert Comment Box : Inserts a box that is ignored by DrScheme; use it to write comments for people who read your program.
  • Insert Image... : Opens a find-file dialog for selecting an image file in GIF, BMP, XBM, XPM, PNG, or JPG format. The image is treated as a value.
  • Insert Fraction... : Opens a dialog for a mixed-notation fraction, and inserts the given fraction into the current editor.
  • Insert Large Letters... : Opens a dialog for a line of text, and inserts a large version of the text (using semicolons and spaces).
  • Insert λ : Inserts the symbol λ (as a Unicode character) into the program. The λ symbol is normally bound the same as lambda.
  • Insert Java Comment Box : Inserts a box that is ignored by DrScheme. Unlike the Insert Comment Box menu item, this is designed for the ProfessorJ language levels. See ProfessorJ.
  • Insert Java Interactions Box : Inserts a box that will allows Java expressions and statements within Scheme programs. The result of the box is a Scheme value corresponding to the result(s) of the Java expressions. At this time, Scheme values cannot enter the box. The box will accept one Java statement or expression per line.
  • Insert XML Box : Inserts an XML; see XML Boxes and Scheme Boxes for more information.
  • Insert Scheme Box : Inserts a box to contain Scheme code, typically used inside an XML box; see XML Boxes and Scheme Boxes.
  • Insert Scheme Splice Box : Inserts a box to contain Scheme code, typically used inside an XML box; see also XML Boxes and Scheme Boxes.
  • Insert Pict Box : Creates a box for generating a Slideshow picture. Inside the pict box, insert and arrange Scheme boxes that produce picture values.

You also insert your unit tests with the code that you're testing. Pretty neat stuff.

查看更多
对你真心纯属浪费
3楼-- · 2019-03-17 20:44

Diffing and searching pictures is hard. Diff and search are very important to programmers. Using pictures instead of text is only a marginal improvement in many situations, it has some drawbacks, and it requires general acceptance before it's really worth doing (since you don't make things more understandable if your reader doesn't grok what you've done).

Plus, programmers have a million little tricks that make their lives easier, based on text representations of code, that they'd lose if you gave them code to read that was expressed in anything other than text. Sure, they might replace or re-implement those tricks over time, but in the short term they're gone.

You don't see lawyers switching from English to little back-of-a-napkin diagrams in contracts, either (the Creative Commons licenses try, but cannot make the picture be the formal representation of the contract). Probably for similar reasons.

If someone comes up with a programming language and IDE that, on balance, beats text-based ones; and successfully markets it; then you'll see the start of a revolutionary shift from text to a new format. If nobody comes up with any such thing, then we're not missing out. If someone comes up with something that is more productive but it doesn't gain traction because of independent advantages of other technologies, then that loss is the price we pay for free-market capitalism. Perhaps the ideas will be recycled eventually...

That said, integration between code and documentation could clearly be improved, and there are many efforts underway to do so, using various techniques with varying success. Again, the problem is that any particular cunning plan can in practice only really be implemented in one or a few languages and development environments at a time, and so has difficulty proving that it really is better. Embedding documentation in code is possibly the only universal advance since the invention of the API...

I think there's still a lot that can be done with text, though. For example, debugger technology makes a big difference to programmer productivity in certain common circumstances (namely: when a test fails or something else unexpected happens, but it's not obvious what the faulty assumption is in the code you're looking at). There may be lower-hanging fruit in terms of making programming better, than the actual business of expressing the program.

查看更多
Deceive 欺骗
4楼-- · 2019-03-17 20:44

A brain-to-computer translator. Typing is the real bottleneck. It really just needs to derive the algorithms I think up and convert that to machine code.

I would say a lot of the newer languages are pretty great at quickly creating algorithms. The improvements aren't so much revolutionary now as they are evolutionary.

查看更多
小情绪 Triste *
5楼-- · 2019-03-17 20:45

Dare I say it might actually be a new development language (perhaps even a new paradigm) to take us through such revolution;

查看更多
放我归山
6楼-- · 2019-03-17 20:46

One thing I've done recently in some of the more math-heavy sections of my application is to include the LaTeX markup for the particular equation as a comment/docstring. Right now, I just copy-paste into an online equation editor, but it would be very helpful to see the formula itself (with things like Greek letters and sub/superscripts) rather than a bunch of ASCII code.

查看更多
何必那么认真
7楼-- · 2019-03-17 20:46

I'm surprised nobody mentioned it - javadoc is basically HTML, so there's nothing preventing you from embedding images (or anything else) in code. Simple, effective and ubiquitous, it's one of the things Java did right.

查看更多
登录 后发表回答