“Hello world” in the BCPL language on the Xerox Alto simulator
righto.com
righto.com
C was my first programming language and several years ago I became acquainted with ALGOL 68. I'd never seen BCPL before a few months ago. It's rather interesting how, from the perspective of someone born well after its creation, it is very clearly the link between the ALGOL family and C. I'm sure that's rather obvious to programmers who were around in the mid to late 60's but for me personally it was a lot like discovering a missing link.
[0]: http://www.cl.cam.ac.uk/~mr10/BCPL.html
[1]: https://gist.github.com/seaneshbaugh/e09abd748ccc07c5463f253...
Mind. Blown.
> So ^Z is a case of convergent evolution.
More likely common ancestry, no? DG RDOS also used ^Z to end input (not sure if it was stored in the file); also PARC built their own PDP-10 clones.If I was to hack this into say Neovim, I'd leave color alone and focus on just wysiwyg markup for font size/style. Imagine being able to bold the key call inside a function that does all the important work.
That's if you have a crappy editor. Emacs supports font changes for syntax coloring since... forever? ;). Here is a test I did just now:
[1] No need to get personal, though :p
> What happens when you quit and restart?
I'd lose the changes because I applied them only to the runtime configuration. It'd be a few seconds more of work to save them permanently to my configuration though.
In general, Emacs implements syntax highlighting by applying various "faces" to the highlighted parts. Those faces are highly customizable - including font foundry/family, various sizes, slant, as well as various decorations, foreground & background colors, etc. It has no problem rendering multiple fonts simultaneously (which is actually pretty useful if you're dealing with Unicode characters - your typical programmer's font won't have glyphs for many Unicode characters, so you can set "fallback fonts" for those).
To de-bait the editor war trap, I think Eclipse can also pull that off, but I've left the only instance I have at work so I can't confirm it now :).
---
EDIT: Crap, I think I misunderstood you.
Did you mean "annotating" code with temporary style changes, especially in a semantic way? If so, I don't know of any editor that would support it out-of-the-box. In Emacs, you could probably hack your way around this with temporary font-locking (aka. adding an on-the-spot syntax highlighting for a particular symbol, and applying all the face-configuration-magic I described earlier), which I sometimes do when digging through log-files or grep results - there's a family of functions like "highlight-line-matching-regexp" or "highlight-symbol-at-point" with which you can quickly assign such highlights (and then there's a command that will write out all highlights in the format that you can save as a file-comment so that Emacs will reapply them the next time you open that file). But this is a hacky solution, IMO.
This also brings me to my observation that there's literally zero tools out there for reading code. Something I'd love to change, and I keep gathering ideas, but I sadly lack time ATM to make even a proof-of-concept.
I don't know how to do that exactly. In Emacs per se, you could probably abuse bookmarking facility - there are some built-in ways for Emacs to remember a particular place or region in a file that are somewhat resistant to changes in other parts of the file; AFAIR they involve a combination of storing the line number and the pattern describing the marked text / its surroundings. Or something like that. I've been playing with some Emacs libraries for annotating parts of file that would store those annotations in a separate place, but they were all rather crude. It's definitely an area that needs a lot of work.
Markup seems to be the most robust approach, but sadly, it isn't supported by pretty much any tool in use.
a) Is the formatting saved across restarts?
b) Is the formatting customized for tiny parts of a file?
What I'm looking for is 'temporary' for b) but 'permanent' for a).
> This also brings me to my observation that there's literally zero tools out there for _reading_ code. Something I'd love to change, and I keep gathering ideas, but I sadly lack time ATM to make even a proof-of-concept.
That is very close to my heart, though my theory is that reading code only becomes easier when the very representation of software projects undergoes a sea change: http://akkartik.name/about. I'd love to hear your thoughts!
I still have that experimental buffer opened, so I used the features for highlighting I described to highlight words "let", "buffer" and "create" with highlight-symbol-at-point, and the lines containing word "foo" with highlight-line-matching-regexp:
http://i.imgur.com/ubXumzK.png
The last four lines were generated by calling M-x hi-lock-write-interactive-patterns. If you save them in the file, Emacs can reload and reapply those highlights in the future.
I use it mostly when browsing log files, though the feature is useful for code too. Since I'm addicted to traditional syntax highlighting, I prefer the background change when highlighting code.
> That is very close to my heart, though my theory is that reading code only becomes easier when the very representation of software projects undergoes a sea change: http://akkartik.name/about. I'd love to hear your thoughts!
I read the page you linked (though I didn't browse the other parts it links to - I'll have to leave that for later). Quite a lot of interesting ideas you have there. I've added the Mu project to check out later.
It seems we have similar general goals in mind, but different ideas of making it happen. You seem to be focusing on how to change the programming practice to facilitate understanding of large codebases. I am thinking more along the lines of tools that would help one explore and get the picture of existing codebases in current languages.
So far, I've briefly explored areas like:
- software for generating diagrams of the code
- software for generating runtime diagrams
- time travelling debuggers
- printing out code on paper (per edw519's advice) and annotating it
- annotating code in PDF readers and word processors
I think what resonates with me most in the text you linked is "Deemphasize abstractions in favor of traces". I actually went into the first three bullet points of mine because I had to refactor some code that I couldn't figure out the exact flow of. What I wanted was exactly the "trace" of execution I could inspect. Unfortunately, the time travelling debuggers I tested are too heavy for the task, and don't present the trace itself in any way, they just allow you to navigate it.
A dream tool I'd love to have would be a "read-only" IDE for code, that would let me quickly move around the project with semantic commands ("jump to definition", etc.) and annotate stuff. I want to take notes, highlight stuff in colors, even draw on the code. Kind of a combination of a good IDE and annotation facilities of a PDF reader.
I have a lot of thoughts on the subject; I guess I should publish them somewhere at some point :).
"A dream tool I'd love to have would be a "read-only" IDE for code, that would let me quickly move around the project with semantic commands ("jump to definition", etc.) and annotate stuff. I want to take notes, highlight stuff in colors, even draw on the code. Kind of a combination of a good IDE and annotation facilities of a PDF reader."
Yeah, I spent a few years thinking about a "wikipedia for code" which is almost exactly what you describe. But I eventually gave up on it for 2 reasons:
a) I started learning about the benefits of tests, and I noticed that this idea doesn't really have a good answer to how to make use of tests for reading.
b) I started noticing that in large teams and over time a good tool contains within it the seeds of its own demise. It's a little like creating roads to relieve traffic: for a while things are good, but then people start buying more cars (at least in the US), and eventually traffic is as bad as it used to be. In software, for example, high-level languages make it easier to declare function arguments (compared to say Basic's GOSUB), but now programmers start creating functions with 20 arguments, and that is as bad if not worse than GOSUB. Inheritance makes some kinds of control flow easier but also causes new kinds of spaghetti code. And so on and on..
These are the reasons why I stopped thinking in terms of just a tool. A tool helps existing habits, but loses control of new habits created around the tool. Changing practice, on the other hand, would affect both sides of the feedback loop. Instead of a vicious cycle of new abstractions (language features or tools) that hide details from the user and cause users to abuse them, I'd like to trigger a virtuous cycle where using a tool gradually makes you more likely to understand its internals. Lisp macros have that property: after using them for a few months I was surprised to find when I built a lisp interpreter how easy implementing macroexpansion was. It was as if macros were a (benign) virus that planted themselves in my brain as I used them. I'd like to create more such viruses :) It's a slower approach to changing things than creating a tool, it's true. But I think there's a lot more upside in the long run.
For example being able to do systems programming on memory safe languages, Mesa and Cedar, using a live coding environment, with embedded objects and a rich REPL, which even did suggestions for typos.
Swift and .NET Native are the modern environments that are closer to it in spirit, but it is not the same thing, not really.
Like, a file could have plain text in the data fork and formatting instructions in the resource fork, so an application that can only handle plain text can just read the data fork, and something that knows how to deal with rich text can read the resource fork and apply the formatting.
While the old Mac OS had its problems, it was full of brilliant strokes of design genius like this, and I'm still kinda saddened that these little tricks are almost entirely gone.
Interesting sidenote, Windows has supported resource forks since the days of NT, but the only time I ever saw them used was when virus writers were trying to hide their payload. Even Mac files brought over to Windows tended to have their resource forks stripped out and stuffed into some cryptically named directory. Ultimately, the resource forks on Windows were such a forgotten feature that they couldn't safely be used, because you never knew when a user might try to compress a file with an oblivious compression tool or send it via some old DOS program and strip out the resource fork by accident. They are the kind of clever feature that only works if everybody agrees to honor them, and become a total nightmare otherwise.
His embedded models for example in the editor are stunning.
This raises the question "Why are we still programming in monospace fonts?" If you need a table or an image in a program, why can't it be in the code?
The lines within a method need to be ordered, but beyond that, code should just float to where it's convenient and be hypertext-y. And worrying about whitespace and fitting code on a fixed-length line is pointless.
I don't have the answers to how programs should be written, but the current system just seems wrong, locked into decisions made decades ago. It seems like programming is stuck at a local maximum.
Same reasons books are structured as sequential lines: easier to read for humans.
And the reason why source code is still heavily text based and why introducing more WYSIWIG to it would be disastrous is that all the peripheral tooling would become a nightmare (diffs, code reviews, source control, etc...).
One would naturally wonder how Alto/Mesa managed to have all these features, and the answer is simple: it is effectively a closed proprietary ecosystem, developed by one company with plenty of engineering effort, and with little consideration for interchange with other systems. It also had far more processing power than personal computers of the time.
I don't have the answers to how programs should be written, but the current system just seems wrong, locked into decisions made decades ago. It seems like programming is stuck at a local maximum.
Never underestimate the importance of simplicity and a low "barrier to entry" --- in fact, I'd consider the lack of success of much larger, "fancier", more complex systems like the Alto as a strong evidence that, regardless of how fancy, featureful, and radical your system is, unless it has a low barrier to entry and interoperates with existing ones, it will not endure the test of time.
Working on .NET, Android or Mac OS X/iOS is a much closer experience to working with Alto and Star environments, or even ETHZ Oberon derivatives.
While ST80 has standard textual source code format, it's not something you want to write by hand but essentially an semi-convenient serialization format (with slightly hackish implementation).
Because we want to quickly see patterns in the code, and all characters being the same width helps with that.
>If you need a table or an image in a program, why can't it be in the code?
Because we've found that while nice for casual stuff, it's less flexible than when it's outside.
There's a book https://www.amazon.com/Human-Factors-Typography-Readable-Pro... on typography for more readable programs.
Aside from that, I like having nicely-aligned tables in my code, and it's sometimes useful to align conditional statements across lines. Monospaced fonts just fit into my workflow a little bit better.
http://www.codersnotes.com/notes/a-constructive-look-at-temp...
Mesa, on the other hand, is a good language.
Lisp for the Alto, on the other hand, seems to be entirely gone - I asked around and nobody seems to have a copy. From what I hear, it never worked very well because there wasn't enough memory.
[1] http://xeroxalto.computerhistory.org/Indigo/XMesa/.index.htm... and http://xeroxalto.computerhistory.org/Filene/Smalltalk-76/.in...
https://archive.org/details/bitsavers_xerox?and[]=subject%3A...
But I would rather like to see Cedar being reborn. :)