WYSIWG is what you get, but not what you want. Anyone who has done serious work in Word, or some other WYSIWG editor has got to the point where the document becomes FUBAR, and you have to copy the plain text, and start again with a new document.
That is not acceptable for a programming environment. Copy an paste is the enemy of correctness.
I'm sorry but, speaking from experience, that is just not true in all cases. Granted, it takes a certain kind of methodic work (and more know-how of the tool than would be reasonable) to work around many of the problems but if you put in the time to learn, Word (and similar software) is more than adequate for large-scale editing work.
It's no wonder the absolute majority of people use it; the learn how to avoid the problems (or live with them) and there is near zero incentive to personally switch. The majority of the onus is paid by the next batch of people who have to learn it.
I'll also agree that it's not what I want for comments and that better models exist for 90% of all text-editing tasks out there. But it does work
Things I've seen fail with Word in my career that would be unacceptable for programming:
- Relatively simple docs being eaten alive, as described in grandparent comment, after several dozen authors make small edits over the course of a few weeks.
- Complete change-tracking disasters when attempting to merge concurrent edits to different parts of a document by several authors.
- Docs where the WYSIWYG behavior completely changed when opened 5-10 years later by newer versions of Word. Attempting to import/export/save as to rescue it involves much of the same cut-paste and hand recovery described previously.
- Docs destroyed by international collaboration, where different locales of each editor seem to accumulate contradictions in the saved document over time.
- Inconsistent WYSIWYG between Word on Windows and Word on Mac OS.
I don't think it is responsible to promote a programming language that does not have a tooling-independent and platform-independent textual representation that carries ALL program semantics as manipulable, printable character sequences. That promotes disposable code and prevents real programming in the large.
(edited to try to rescue bullet list)
Nothing stops you from allowing the user to access the document itself to clean up the automatically-created mess.
It should be more like the XML/visual editing modes of .Net platform UIs.
'canonical view' is raw markdown/tex/whatever with text-editing controls. WYSIWYG view is presentation style with rich text editing controls.
this paradigm could carry over to the code itself with projections omitting/adding type annotations, comments, in-lined documentation, maybe even selectively expanding/eliding parts of the code itself i.e. orthogonal aspects like logging
Sorry. Code is code, that's what your job entails and you can't make programming into something it isn't.
You could replace the subject of your comment with, say, "automatic garbage collection", and it would have been equally true ("that's just what your job entails!"), right up until GC made its way into the first mainstream languages, and it very quickly became a tool used by almost everybody.
We spent about 3 decades arguing back and forth about performance until the wave of bytecode+GC languages took over and accepted those tradeoffs: Perl, Python, Java, Javascript.
Holdouts remain in the high performance, embedded, and deterministic areas of software.
The idea is older than structured programming, older than the C programming language, older than the idea of object-orientation. It's probably even older than McCarthy's LISP.
Safe to say that if it hadn't caught on during this time, then it never will.
It's easy to be parochial about this when Unix like environments force everyone into a lowest common denominator of text streams, but don't take the limitations and bad ideas of Unix as laws of the universe.
Edit:
Summarizing the list of non-text mode programming languages in general use that people have mentioned in this thread:
ANSYS SCADE
Sikuli
Unity
LabView
Simulink
max/msp
SynthMaker
Kyme
LUSTRE
I don't remember how or if people kept the shadow comments lined up with code (I was only there for one summer in high school), but you could extend the editor with ease, so...
Traditionally a block was 64x16 I think (1KB).
I used noweb at a previous employer, and it certainly was difficult to argue with the results; beautiful, readable documentation that existed as a first-class product, alongside the code it was describing. The quality of the software we generated was the highest I've ever seen in terms of things like deadlines and budgets and bugs and testing.
Why would this require a new language? And why would it require a new editor?
For one thing, at a certain scale, code and documentation are examined in a browser more often than in an editor.
Your requirements seem too focused on insignificant details and not enough on the big picture.
Compiliation for an editor (partial/incremental) is a very different beast from "normal" compilation, and any compiler that is first completed for regular compilation and then tries to address tooling as an afterthought, will ultimately never be useful in tools.
I realize writing a new compiler is hard enough in itself, but projects like the Roslyn poject shows it's at least feasible to make a compiler-as-a-service with both regular compilation and tooling in mind.
I completely agree. A few things I think would help with this:
1) Provide a standard "machine readable" concrete syntax for the language, alongside any "human readable" syntax. S-expressions would work well for this; if someone prefers JSON or XML then I won't argue. The implementation (compiler or interpreter) should have a mode which converts the human syntax to the machine syntax. The compiler/interpreter should handle inputs in either format. This avoids tools having to parse human-readable formats (or worse, run arbitrary preprocessors, etc.), and makes it easier to feed auto-generated or modified code into the system (e.g. for type checking, etc.). Machine-readable formats are also be more robust, since everything's delimited in a standard way, so unknown things (e.g. new language constructs) won't mess up the parsing of everything else, making tooling easier (e.g. linting, documentation generators, etc.). Note that Lisps and Schemes have this already, by virtue of using a machine-readable language as their human-readable language. Others can maybe just serialise their parser's output (as long as it's concrete, not abstract).
2) Allow arbitrary metadata to be attached to pieces of the syntax tree (in both formats). This can be used for comments, but also for source location (e.g. if it's been translated from the human-readable format, or maybe even transpiled from something else). The parent's desire for graphics, etc. in comments could be handled by such annotations, since they're data not just ignored bytes, so they could have e.g. entire Scribble documents attached. Tooling can use this for any data they like, e.g. hints for static analysers, dependency information, required language version/features, blame information, optimisation hints, etc. I think Clojure already allows this, but I've not used Clojure.
3) Keep context/configuration close to the code, or at least allow it to be. For example, if the meaning of some code changes depending on language version, it should be possible to specify the language version as part of that code. That way, tooling is able to obtain and use that information. This could use the annotations from (2). The worst case is when crucial information (like language version, or which arbitrary program to run as a preprocessor, etc.) is kept in some external configuration file, in an arbitrary location, in some bespoke file format, such that no other tooling can make sense of the code (I'm looking at you Cabal!). Even if we want separate config files, the tools which handle them should be able to resolve and propagate that information into the code, e.g. we could ask `tool annotate src/foo.lang` to get a copy of `src/foo.lang` which any relevant context/metadata from the config file appended as a file header. IDEs can use this to get more info about the files they're editing, and propagate that info into the snippets they send into the implementation for type-checking, etc.
to top it off, it had the potential for that already since its inception. so not exactly a new paradigm
I don't like init functions; an object should know from its inception the basic things it needs to in order to function, and I think it's a great miss there is no real way to force this.
Sorry, I should've been clearer there. I meant constructors.
> can you give an example of how an init function is used to do something that an object should already know?
The only way to instantiate a new version of an object in Pharo is with the new message to the class, for example with
aDate := Date new
However, that point does not yet know what its time offset from epoch is, which is absolutely vital when trying to use a date. It needs to be instantiated at construction with that information.
How pharo gets around is by essentially creating class messages which hand you back the instantiated object, such as with aDate := Date year: 2015 month: 12 day: 31
However, this is just syntactic sugar (as far as I can tell, please someone correct me if I'm wrong) for a class message calling new and setting the properties on the object it just created. It is a fairly clean way to create objects, in general.However, the method 'new' can still be used (there is no access modifiers in Pharo), so it's still possible to call an object without ensuring it's initialized properly. I have yet to find a good way around this.
Implement the class's new method with an implementation that just throws an UnsupportedOperation exception?
and yes i agree, it should be possible to prevent the creation of uninitialized objects.
There's a thing for everyone, but that dystopian stuff you are describing here I cannot fathom even in my worst nightmares. The text file is a very powerful abstraction for programming and I hope it will never day.
It could take literate programming [1] to the next level. Existing tools like docco [2] can output beautiful documentation [3] with comments set alongside code. The language/editor described above would allow us to input code in the same side-by-side format.
[1]: https://en.m.wikipedia.org/wiki/Literate_programming
Literary Programming, Programming was the first, Literary was the second.
the main purpose of the Code comment area markup method is to live Preview directly in the Code Editor Preview panel without exporting or any preprocessing.
Just add a line comment character of the programming language before each line of Markdown.
In the comments of code, you can draw flowcharts, tasklist, display data visualizations, etc.
The method is to add extension instructions in any programming language comment area:
markdown
manual eval code, live eval code, print result, display data visualization and other directives When previewing or converting a format, you only need to simply preprocess: delete line comment characters with regular expressions, example: sed 's/^;//' x.clj
Note:
line comment character of Clojure(Lisp) is ;
line comment characters of the current file type can be obtained from the editor's API.
when we edit the code, we can preview the effect in real time. Editing literary code has a live preview panel like most markdown editors.
Advantages
fast, live, simple, no interference.
It don't break the syntax of any programming language, you can compile directly. comment area markup method can be applied to any programming language and any markup (including Org,rst, asciidoc, etc.), which is the greatest advantage.
you only need a single line code to delete line comment characters using regular expressions, then you can use any Markdown parse or converter.
Support any code editor that supports Markdwon Live preview, allowing the source code of any programming language to become rich text in real time. In the code's comment area, You can use the markdown to draw flowcharts, tables, task lists, and display images on the live preview panel, enhance the readability of your code.
If you extend the Markdwon tag, you can implement the eval code, print result, display data visualization and other instruction tags, to achieve live programming, live test.
When writing (reading or refactoring) code files, It can modify and live preview directly in the editor without exporting or any preprocessing.
Reliable. Maximum code accuracy is guaranteed, and markup language errors do not affect the code.
It hasn't interfere anyone to read the code. Markdown is simple, so if it doesn’t have syntax highlighting, it doesn’t have much effect on writing and reading. And having a gray comment area doesn’t affect reading code, especially for people who don’t understand the markup language. Strict distinction between markdown and code, and gray comment area can reduce the amount of information in the source code file, conducive to reading code.
https://github.com/linpengcheng/PurefunctionPipelineDataflow...
This specific bit reminds me of the elegant UX implemented in Typora. [1]
[1]: https://typora.io/
Check out Luna
If you haven’t tried a literate programming language, you might like it. You basically write a document with figures, etc. it is, with bits of executable code.
BTW, most of my coding in my last job was in Jupiter notebooks (to use Cloud GPU compute). Really not too bad for short ML scripts when you can still put slow changing library code you write in separate files. That said, not a great environment. I prefer configuring ITerm2 or xterm so I can get matplotlib plots to appear inline in SSH sessions.
Block oriented Forths used to use "shadow blocks" for documentation. You had a block that was code, and a fixed offset to a corresponding block that was documentation, with a keybinding to switch between them.
Various tidbits of this have been done in Smalltalk (of course).
But if you have already invested in a world of tool chains that assume ASCII or Unicode text streams as source code representation, then it's hard to get out of it.
Your comment also reminded me of Godot's editor and gdscript. It's fairly domain specific(though the editor is actually a godot game). Everything's designed to work with gdscript. The language and the editor are designed to work seamlessly together in much the way you describe.
Seriously, read the original "Design Principles Behind Smalltalk" [0] and it still sounds very fresh, even radical today.
[0] https://www.cs.virginia.edu/~evans/cs655/readings/smalltalk....
They have a pretty friendly community too.
It's a dealbreaker if everybody working on the same project has to use the same editor.
Development practices that seem suboptimal for the individual are often optimal for teams. And teams develop all the major pieces of software we use.
https://en.wikipedia.org/wiki/Structure_editor
I've seen that demo from JetBrains MPS, looks good. Hopefully it gets wide usage.
Then what you need is just a git blame(?) to visualize the current code section's comments.
Would this work?
Plus, you would end up in a conflict between recording history and recording the present. What happens if you replace a complex method call across a codebase? The comments should explain the call, but the commit message needs to record how the call changed, and why - which you probably don't care about when coding.
I do believe a lot of code would benefit from better built-in documentation, which it essentially is.
I Will think about this some more
Swift Playgrounds has rich comments, but they are still inlined with code.
And then I want to put rich things into my comments section like graphics and tables and such. And I don't want to have to write table-like Markdown or a shorthand that converts into graphics. I want all the WYSIWYG of Word or PowerPoint or Inkscape just right there feeling 100% natural and native.
Jupyter is pretty darn close to this. And I like it a lot. But I feel like I'm giving up a lot to make a notebook. I want this in a much more heavy lifting format.