89 points · by thepete2 · 7y ago · 77 comments
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.
> 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.
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
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
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.
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
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.
It is heresy to say, but of course writing programs primarily as simple text files is ridiculous. It’s also ridiculous that we write web pages in HTML etc rather than using elegant WYSIWYG editors, and that we use LaTeX for designing visual artefacts.
It’s probably possible to explain “why” we got here, but not “why” it’s a good idea, because it isn’t.
I put it down to culture. Programmers are strongly opinionated and resistant to change (eg blub). We’re historically been selected from a narrow and strange demographic. Which is why few people agree with what seems obvious to an outsider, and why we don’t fix it.
Imagine if engineers built bridges or engines or satellites by writing XML rather than using CAD tools and modelling suites.
I seem to recall nice ideas around Smalltalk’s editor. It should be possibly to have a hybrid approach that can gradually transform programming from text editor into a mixture of maths and high level engineering design.
There’s actually a move inside engineering of physical objects towards code generated shapes. For better aerodynamics, lighter weight, etc. Your optimization code spits out a 3D file and you just go in and clean up artifacts.
There can be specialized tools that are useable but nothing beats text in the general case.
I am sure there are classical poets that would happily engage in the tabs versus spaces debate, and even some of the other formatting debates in the code world. Concepts like rhythm and structure from the poetry world directly apply to code formatting, because they affect how we as people read the code. Programmers just don't often think to use the same terms for such isomorphic concepts. Yet it also speaks to how so many code formatting arguments get to be so heated: it can be deeply, personal, subjective, aesthetic.
(When we are squashing personal freedom/creativity in our "mandated" formats or automated formatters should we sometimes wonder that maybe we are losing our chance at finding the programming equivalents of great poets that might stun, delight, or otherwise bring emotion to us with their code? We have things like the IOCCC that celebrates one extreme of code formatting [obfuscated], but should we find other ways to celebrate well and uniquely formatted code?)
LV is super practical for "quick and dirty" device control, but beyond that, it's an inefficient grind of connecting things.
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.
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.
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.
On a different note, Lisp would lend itself well to what you seek. While most Lisp/Scheme programming happens in a text editor, Lisp is inherently syntax-agnostic; sure, s-expressions are the most typical, but once upon a time there were M-expressions[1], and Scheme has support for alternative syntaxes[2]. Projects like Scheme Bricks[3] take this even further into visual representation.
[1]: https://en.wikipedia.org/wiki/M-expression
[2]: https://srfi.schemers.org/srfi-119/srfi-119.html
[3]: http://www.pawfal.org/dave/index.cgi?Projects/Scheme%20Brick...
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.
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.
What we need is a standardized representation for tree structures and their schemas. XML is too complex. JSON and YAML isn’t good enough. Lisp is pretty good, but I think the text representation is off-putting for a lot of people and its general focus is not quite in the right direction (recursive lists of data/items rather than having typed nodes that contained list of other typed nodes, like XML, with schemas defining every node type)
If you get rid of all text, what will you use for naming functions and variables? Icons?
Or just don't name anything: to reference anything, draw an arrow to it?
What do numeric literals look like?
A huge benefit of text is that if you learn to read code, you already know how to edit it too. This is because of WYTIWYS: What you type is what you see.
Higher level edits and refactoring are awesome, but when you just start using the environment you can't learn all the refactorings yet, while you only want to enter something similar to the code you saw on the whiteboard in class etc. WYTIWYS makes it easy.
Historically, many attempts at structural or projectional editors didn't adhere to WYTIWYS. I believe that this is a major reason for why they haven't gained popularity.
But recently there are several projects developing projectional editors which do adhere to WYTIWYS!
One is Lamdu (http://www.lamdu.org) (btw I'm one of its developers). In Lamdu we try to create a programming language with a friendly projectional editor which does adhere to WYTIWYS and also offers awesome unique features that projectional editors enable. (for more information see our short videos - https://www.youtube.com/channel/UCgvPEOFglvS4_ZEHi-PEctQ )
Another projectional editor adhering to WYTIWYS is Jetbrains MPS (https://www.jetbrains.com/mps/) . This one isn't limited to a single programming language! It is a general purpose language workbench.
MPS does present a different aspect in the examples shown. It is still text editing, but not the linear word by word syntax we're used to. We can make up 2D, tree, or any other structure that can conceptually and compactly represent our thinking.
One more point I have on this is that the editor itself can recognize 'edit units' that are not mere characters inserted/replaced/deleted. As edits are made, it can make higher level 'checkpoints' whenever a unit is recognized. The examples in this post are great examples: function declaration, renaming, invocation. Then the undo/redo can show text operations as low-level points as well as higher level ones identifying larger logical units. Having that, one could perhaps select a range of these and cut them to be replayed at a later point. This is similar to how I'll make small local git commits and later reorder, squash or drop commits or make them into separate PRs.
Currently, there are several database ETL tools (Talend, Pentaho, etc.) which are graphical (think shitty like Labview), but anybody serious uses python or perl scripts.
Today I would look at Zapier or publishing a Google sheet.
https://zapier.com/learn/forms-surveys/best-online-form-buil...
In the 2000-2005 era, there was national advertising by those sketchy diploma-mill universities like U. of Phoenix to turn military veterans into C++ programmers because the Visual Studio IDE "did all the work for you."
Those TV ads were truly eyebrow-raising to me, since I learned all that the hard way (ie. paid development projects) and couldn't recall the IDE every writing a function for me.
The lightest-weight and most powerful text form builder is likely Perl's CGI::FormBuilder module. I've used it for several years and it is remarkable for building CRUD apps.
Apple's Resedit and Adobe's internal dialog layout editor both allow visual layout that saves to text resources.
OpenAPI has tools for generating a server API skeleton, but I think it has the same problem as all code generators: when you want to substantially change it, you'll want to check it in to git and hand-edit, like always.
As for the mechanism you talk about, that's basically declarative style and a lot of platforms (for the lack of better word) do this, mainly in business logic and scientific applications. The most famous example is Excel. However, this style works like a charm only when the set of possible actions is predetermined, and is not conducive to creating new actions, which is why every single platform has some kind of scripting. And scripting is editing text. So there you go.
Please please please follow whatever style guide is handed to you. I am so sick of looking at gobbledygook code.
You might get either absolute refusal or slow subversion from me there. In my current place of work I was initially handed the utmost horror of horrors of style guides, namely the so-called google style guide. A thing that is optimized to result in code as unreadable as possible. Rebelling against that worked pretty well, so now the thing is gone. And, honestly, if I am ever going to apply for a job and hear that they use the google style guide I am not going to work in that place. I don't follow style guides. Style guides follow me. Currently planning the next rebellion as the utterly evil practice of demanding that every method shall be commented has emerged from whatever wretched place such things emerge.
What you suggest is possible to some extent, it's just hard to standardize, much harder than gluing more stuff on top of the existing systems. You're looking at something that you could build a career on, if you find the right approach. There a lot of companies and projects that have tried to research moonshots and come up with good demos but bad production environments.
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.
Replacing our natural order to process language with a visual scripting environment doesn't really work. The flow control format needs to match the coding requirement, otherwise the default written text style is much better.
The best visual editors I've seen amplify the top-down, left-right structure and sometimes are not saved even then.
Organising ideas into a communicable stack of information has always been the realm of language. The move from pictographs to alphabets was a technology that allowed masses of people to be literate and spread the associated language far and wide, spreading the host civilization with it. Going back to pictographs for coding.. is a deep challenge.
* 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.
Also, DRAKON is a visual programming environment which supports a number of text backing languages.
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.
PS: Charles Simonyi, the inventor of IP, wrote a paper called "The Death of Computer Languages, The Birth of Intentional Programming" which is worth a read.
I mean think about it. Suppose you want to communicate a JSON object to another programmer.
You can say: "the object consists of three key value pairs, the first key is named ... and its value is ..., the second ..."
Or you can say: "the object is that which you get from parsing the string that spells thus: curly bracket, space, double quote, ..."
Of course you'd prefer the former approach! Why then when we wish to communicate to a computer the same object, we adopt the "spelling approach"?
{"x":"bar", "y":"foo", "z":"foobar"}
Not the clearest way of communicating it?
For similar reasons, mathematical notation is used instead of explaining equations in plain English, despite mathematicians' audience not being computers.
Symbolic notation has value: while it takes more initial effort to understand, once you have grasped it, the result is far more concise, unambiguous and generalizable.
The advantage is transparency. I'm actually not sure if the tradeoff is worth it, if symbolic code manipulation would be better, but code as we've written it is no harder for humans to parse than would be a symbolic representation of the same. It already is a symbolic representation of itself, because humans don't see curly brace, double quote, key; humans see things in groups and clumps. Just as when you read these words I'm typing you don't see period, double space, J, u; you see 'clumps. Just'. However, what you see on your screen is exactly the file that's stored on the disc, the bytestream read by your texteditor, the bytestream read by your compiler. And that's worth something.
Seriously, the best thing I ever did was learn to type 140 wpm.
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
If so, my big question is what interface will be more efficient than text entry?
If not than perhaps I misunderstood your question.
wikipedia.org/wiki/Intentional_programming
Bret Victor would, too:
http://worrydream.com/ (Warning, this site hijacks your mouse scroll and does weird things)
If you know of ones that are high quality please point me in the right direction.
We already tried the voice thing and it doesn't work well at all beyond Alexa type personal assistants.
So basically muscle actuation is the only thing remaining. Well time to count the number of actuators your body possesses that it can use to express itself. 2 legs, 2 feet with tandem controlled toes, 2 arms, 2 eyes, 1 neck, two hands with 10 fingers. If we don't count our hands we only have only 7 actuators in total that we can use to control a computer. Our hands are such a tiny part of our body yet they exceed that number. 10 actuators that can be used for our body to express itself. Now imagine you are a dolphin or you are paralyzed and can't use anything below your neck. You have lost almost all ability to express yourself. There are still a few actuators left but compared to the power of 10 fingers they are absolutely nothing. 10 fingers allow humans to transmit 40 bits of information every single second (assuming average 60WPM) to their computer.
Since our hands are our primary way of communicating with a computer we have decided to create an input device that is worthy of their might. A keyboard lets us take advantage of the full potential of our hands. Just think about it. 106 keys at your fingertips. You can transmit a huge amount of information into the computer.
Without a hand you can still use a pointing device like a mouse or touch screen but you are not able to use the scroll wheel and at most you can only have a single mouse button. The biggest flaw: You are limited to interactions that are visible on the screen. The keyboard has no such restrictions, you can just type anything you want.
What I'm getting at is that typing text is the most natural way of interacting with a computer and the method with the highest data throughput. Text based programming languages take advantage of this affinity and this is why they have established themselves.
The type of IDE you are talking about has to be easier to use and faster than simply typing the code directly. Achieving this is a very difficult task and even if you succeed there is no shortage of programmers willing to learn text based languages, it simply isn't difficult enough to warrant a replacement.
The other comments saying this is just because of inertia or fashion(blub?) completely ignore the way humans interact with computers and therefore are not sufficient to answer your question. If it were that simple then we'd already see a reasonable split between the camps. Something like 3 text based languages to 2 visual languages and 1 voice based language.