Ask HN: Why is programming editing text?
What you care about as a programmer is what your code does, right? Basically whatever the compiler has after lexical analysis (except for comments maybe).
So why do we bother with all that coding style stuff if we could make an IDE that edits the program itself instead of text? (I get that text is a universal format, but that doesn't mean we have to edit it directly.)
Instead of editing text you could choose to "declare a function", "rename this identifier" or "call function x with y and z arguments" and then save it with some coding style.
Is there such an IDE? I know what I'm describing is pretty much visual programming, but I mean for "text" languages.
78 comments
[ 2.9 ms ] story [ 156 ms ] threadIf so, my big question is what interface will be more efficient than text entry?
If not than perhaps I misunderstood your question.
https://developers.google.com/blockly/guides/overview
https://news.ycombinator.com/item?id=6964369
https://news.ycombinator.com/item?id=9495836
https://news.ycombinator.com/item?id=10099611
https://news.ycombinator.com/item?id=13578256
https://news.ycombinator.com/item?id=13773813
https://news.ycombinator.com/item?id=14278605
https://news.ycombinator.com/item?id=14609215
https://news.ycombinator.com/item?id=15160030
Lamdu - towards the next generation IDE (peaker.github.io) Dec 25, 2013 https://news.ycombinator.com/item?id=6964369
Programmer Tooling Beyond Plain Text (joelburget.com) May 5, 2015 https://news.ycombinator.com/item?id=9495836
Prune: A Tree-Based, Home-Row-Oriented Code Editor (facebook.com) Aug 21, 2015 https://news.ycombinator.com/item?id=10099611
Why Don't We Have a General-Purpose Tree Editor? (2014) (pcmonk.me) Feb 6, 2017 https://news.ycombinator.com/item?id=13578256
Cirru – An editor for AST (cirru.org) Mar 2, 2017 https://news.ycombinator.com/item?id=13773813
Code as text is a problem (dohgramming.com) May 6, 2017 https://news.ycombinator.com/item?id=14278605
Frame-Based Editing [pdf] (kcl.ac.uk) June 22, 2017 https://news.ycombinator.com/item?id=14609215
Searching a Million Lines of Lisp (wilfred.me.uk) Sept 3, 2017 https://news.ycombinator.com/item?id=15160030
I don't say that a good UX couldn't exist for such thing, but we already have that good UX in a form of text. Really. Think of it.
The operations you list seem to be related to the kinds of things yo might do when 'refactoring' though. Have you looked into the kinds of operations happening there. "Pull Up", "Extract Method" etc
It turned out, at least with that iteration of tools, that smaller programs were somewhat easier to write, but larger ones took about the same time, and (at least where i worked) people agreed that it was very hard to understand the flow of the program for new people, or even if you had to maintain something after an extended period of time.
Another problem is that you're somewhat limited to what the language designer envisioned, and if the IDE doesn't have a "building block" for what you're trying to do, you will spend a lot of time working around it.
We had maybe a couple hundred large "point and click programmed" programs, and they've all been replaced by something written in a traditional programming language. Maybe it's because it has already been "prototyped", but rewriting it in the traditional programming language has actually been faster than writing the original program Some of these programs have been untouched for 15 years, so i doubt anyone remembers much about how it was implemented to begin with.
Also, DRAKON is a visual programming environment which supports a number of text backing languages.
http://drakon-editor.sourceforge.net/
Visual programming just seems awful - and yet a decent IDE can remove a lot of the pain points from the textual approach while keeping the advantages.
Great minds discuss paradigms. Mediocre minds discuss languages. Small minds discuss coding style.
> ...we could make an IDE that edits the program itself instead of text?
Many IDEs have features that reach into the semantics of the code to allow for refactoring, autocompletion, and so on. This requires a language that is amenable to to such analysis.
Dynamic languages like Python and Javascript (without type annotations) make it difficult or impossible, because a lot of things can only be determined at runtime.
Languages like C and C++ make it difficult because of the text-based preprocessor and templates.
Languages like C# or Java make it easy and hence they have some of the best IDE support.
Code formatting is even more trivial and can easily be done with automated tools - if you can just settle on a particular configuration.
> Instead of editing text you could choose to "declare a function", "rename this identifier" or "call function x with y and z arguments" and then save it with some coding style.
Many IDEs and text editors have snippets that make declaring a function or writing a loop less tedious. Renaming identifiers is also commonly supported. Perhaps you're just not used to proper tools, or your language of choice prevents those tools from existing? Have you tried Visual Studio Code with its language addons?
> I know what I'm describing is pretty much visual programming, but I mean for "text" languages.
What you're describing is pretty much a modern IDE, which is full of visual aids.
And for some reason almost no minds discuss semantics.
Rationale: The modern Apple-using programmer wants something to do with their touch bar, there are more meta keys than they can use, they are running a machine with huge graphics capabilities that are underutilized.
Some ideas: Full screen, keyboard-driven navigation (meta-arrow = codeblock, meta-arrow = window/file), meta keys for compile/test/git commit/diff. Combine tmux, vi/emacs, Visual Studio, FileMerge.
Try it and see. Don't listen to others. Sometimes rethinking things for the ground up is for the best. Worst case you learn. Supportive wisdom:
To be original you don't have to be first - you just have to be different and better. - Adam Grant
Experience doesn't matter. The rate of learning matters. First principles thinking matters. - Vinod Khosla
Light speed analysis: What is the best theoretical performance I could achieve with this design? What is the real information content being transferred and at what rate of change? What is the underlying latency and bandwidth between components? Could the approach ever achieve the performance goals or does it need a rethink? Understand the true performance characteristics of your building blocks rather than focusing on functional characteristics. - Terry Crowley
You can see how the accumulation of these little warts starts warping the rest of the devflow. E.g. since git can't do great diffs, it can't do great automatic merges. So we start using dev styles that minimize the pain of merging, and we start emphasizing continuous integration partly to prevent large merge buildups.
It irritates me to no end that the most important part of any code is the symbol names, but we've solidified and ossified those as the literal unchanging way you reference code. Want to fix a typo in a method name? Too bad, that's a breaking change.
IntelliJ Idea isn't exactly it, but it has many of the features you want (most comprehensively/maturely for Java, but to greater or lesser extents for Python, Go, Rust, Typescript, etc). I find using it feels less like editing text, and more like constructing a program at a conceptual level, than in any other environment I've used professionally.
> declare a function
You can use a function/method in code before creating it, and it can create the declaration for you. There's also support for automatically creating class members like constructors, setters/getters etc.
> rename this identifier
Yep, throughout a project.
> "call function x with y and z arguments"
Not exactly, but completion is comprehensive enough for this. You can also refactor a method/function signature, and it gets changed throughout the project.
VS Code doesn't come close in these terms - editing in it is still 'editing text'. But Microsoft has been very canny with the combination of WSL2 & the VS Code remote extension - allowing essentially a true linux programming environment accessed via Windows GUI. That even tempts me, and I'm a fairly diehard Intellij user.
Windows Forms editors, and similar HTML editors have been around at least since I was a kid (1993 for forms, later for HTML WYSIWYG editors); old versions of visual studio provided tools to let you lay out databases visually, and later on to link those up to related objects. Maybe they still do, I don't know.
Turing-complete visual code editors have also been implemented. Microsoft (again) had a couple - a "Visual Programming Language" (named as such, iirc) for their long-dead robotics framework and something else called "Workflow Foundation" (WF), which allowed you to lay out workflows with arbitrary code built into it. I only worked with WF, and it was pretty terrible.
A much better implementation is Scratch. It's generally relegated to education, because laying code out visually is actually pretty inefficient. It's great when you're getting started, but you'll soon find that the textual representation of a language is a lot denser. Put another way, what takes longer: typing `def` or moving your mouse to a menu and dragging a "function" object into place?
Regarding cross-compilation, that's a different problem, and one which has been solved in various directions. Ideally, one could compile this hypothetical language directly to machine- or bytecode.
I do see the appeal of doing this. If you come up with something you should post it here - I would love to see it.
* SCADE Suite: https://www.ansys.com/products/embedded-software/ansys-scade...
* TargetLink: https://www.dspace.com/en/inc/home/products/sw/pcgs/targetli... (Generates C code from MathWorks SimuLink models)
I suppose the nice thing about these is that you can show some (safety and/or behavourial) properties directly on the model.
LV is super practical for "quick and dirty" device control, but beyond that, it's an inefficient grind of connecting things.
https://scratch.mit.edu/
I think you might find out why test is pretty handy.
I can hammer out a one liner with a bunch of methods to do a thing(s) pretty fast. Dragging stuff around, much much slower and IMO it's harder to understand what is actually going on.
> Programs must be written for people to read, and only incidentally for machines to execute. - Abelson
As to why that might be the case: when the bugs you wrote are found; the edge-cases you missed are discovered; or the vulnerabilities you didn’t know about it are unearthed, another person, sometimes future you, will have to read your intentions; try to interpret them; and address the above. When you code, you are telling a story and are in control of the narrative. When you paint a picture (I.e. graphical) you have less control over the narrative and interpretation.
Or at least that’s my hot-take.
What imagery gives you is an intuitive sense of how you should, or how the artist did, feel about subject matter. Imagine at a glance knowing which parts the artist was proud of, which they considered an unglamorous but necessary hack, and what they considered ugliness that was forced upon them and unnecessary to the program as a whole, and viscerally "knowing" what areas are wrong?
I look forward to a future where we understand how to teach well enough that artist-programmer hybrids are more common-place.
On the other hand, for an instruction manual, there is little room for interpretation as the words only have so many definitions (though read "Authority and American Usage" by DFW to really open a can of worms), so we do not often re-read a manual for a process we know (though it could be argued we ought to). I also concede that for simple tasks entirely visual instruction manuals suffice, and to that end I will say that I've enjoyed writing simple things with Scratch (for example), but I would hesitate to write a program that needed to be maintained with a visual language.
To put a more fine point on it: For the top 1% of programmers it may be the case that they would work best in a visual language, but the maintenance and support of those applications by the bottom 99% would erase many of the gains (I am here assuming programming as a professional activity in support of an organization's goals, not, as it were, a strictly artistic personal activity). In a professional context - I am unfeeling about what my predecessors felt about any part of the code, I only need to know what their intentions were, and I need them to tell me so, as explicitly as possible.
*Edit: I think that there may be use in clarifying whether we are discussing professional programming or programming as a hobby - because I enjoy both, and while I enjoy learning and using some languages (cough Haskell, Lisp) for myself, I would be very hesitant to use them professionally due to the difficulty others have in maintaining/understanding them. (Food for thought: why do Java, Javascript, and Python absolutely dominate our field despite having "better" alternatives?)
>Why is programming editing text?
Because it didn't come out right the first time.
wikipedia.org/wiki/Intentional_programming
Bret Victor would, too:
http://worrydream.com/ (Warning, this site hijacks your mouse scroll and does weird things)
All an IDE should do is not allow freeform editing of text but rather only editing of text that relates to the AST - in other words, creating an AST by carefully selected text.
This would solve the issue of readability while enhancing the programming experience.