16 ms·
“Hello world” in the BCPL language on the Xerox Alto simulator
- akkartik 10y agoThe image below shows the Hello World program with multiple fonts and centering applied. Since the compiler ignores any formatting, the program runs as before." Mind. Blown.
- alayne 10y agoMaybe you're being sarcastic, but I think it's just a hack with the formatting appearing after the end of file marker that the compiler uses.
- jonsen 10y agoInlined formatting commands could be recognised and skipped, just like the //-comments.
- alayne 10y agoOkay, I was going off an old comment from Animats where he said "The Bravo file representation was plain text, followed by a control-Z as an EOF, followed by the formatting information. The compiler just stopped at the control-Z."
- adf 10y agoSo Bravo begat Word, and ^Z survived as EOF into DOS...
- Sanddancer 10y ago^Z in DOS was a holdover from its roots as a CP/M clone. CP/M in turn cribbed it from certain DEC OSes, because that's what Gary Kildall used while making CP/M. So ^Z is a case of convergent evolution.
- jandrese 10y agoIt's an easy mnemonic for Ctrl-Z to represent the end of something. Also fairly easy to type on a Qwerty keyboard.
- kps 10y ago> 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.
- akkartik 10y agoNo, not sarcastic at all. It never occurred to me that we could have a simple rich-text rendering for code. For example, render code in html, and strip all tags before passing through to the compiler. Why don't we do this?!
- smitherfield 10y agoBut that or something along the same lines is how syntax highlighting is typically implemented.
- akkartik 10y agoSyntax highlighting is nothing like that. It's one-size-fits-all. All types/keywords/whatever get the same color. It doesn't support font changes. 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.
- TeMPOraL 10y ago> Syntax highlighting is nothing like that. It's one-size-fits-all. All types/keywords/whatever get the same color. It doesn't support font changes. 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: http://i.imgur.com/Xrgaixu.png http://i.imgur.com/Xrgaixu.png
- akkartik 10y agoNice![1] What happens when you quit and restart? [1] No need to get personal, though :p
- TeMPOraL 10y agoDidn't mean to sound personal - I was just involuntarily baiting the editor war discussion ;). > 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.
- kens 10y agoIt seems backwards that on the Alto you could style your code with a WYSIWYG editor but 40 years later putting a <b> tag in your Javadoc is about all you can do to code.
- pjmlp 10y agoThere are lots of things you could do on the Alto and on the Star that one cannot still do today. 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.
- rwallace 10y agoThose systems were impressive for their time indeed, but let's not lose sight of our options today; if you want to do systems programming in a memory safe language you can use Rust, and if you want a live coding environment, with embedded objects and a rich REPL, you can use Racket.
- nickpsecurity 10y agoHe said AND not OR for those features. There might be modern stuff with the AND but they usually ignore something. I had luck in distant past making type-safe 3GL's in a LISP that extracted to C/C++ with checks on. Really kludgy, though. Still haven't seen one do such things as cleanly as the old systems with high efficiency as well.
- pjmlp 10y agoThat is not the same thing, not even close. Swift and .NET Native are the modern environments that are closer to it in spirit, but it is not the same thing, not really.
- amyjess 10y agoThis reminds me of some of the tricks Apple used to pull with the resource and data forks on the classic Mac OS. 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.
- jandrese 10y agoYou could in fact do exactly the kind of formatting in the article on an old mac for exactly this reason. The formatting data was stuffed into the resource fork which the compiler was free to ignore but could be used by the editor. 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.
- jloughry 10y agoIf anyone else is looking for this, Windows calls its version of the technology Alternate Data Stream (ADS).
- gfaure 10y agoHow did it handle the contents of the data fork getting out of sync with the contents of the resource fork? Or was the plain text "view" of the data read-only?
- nv-vn 10y agoNot even joking, take a look at TempleOS and HolyC... Terry Davis has made some wonderful features that allow for formatting code files and embedding a variety of rich content (like images or videos).
- abstractbeliefs 10y agoTemplosOS and especially HolyC and the editor are one of the few instances of something done wonderfully right, but for the wrong intentions, rather than the other way round. His embedded models for example in the editor are stunning.
- kmiroslav 10y agoIt's easy to do this when you don't need to interact with the outside world and you don't even care about memory protection.
- kedean 10y agoIf by 'outside world' you mean legacy systems, then ok, that's valid, but there's not really any reason that idea couldn't be portable across systems, as long as they support common encodings. I fail to see how a ring-0 memory model factors in at all.
- Animats 10y agoIt was customary to boldface the keywords in Mesa programs. The Mesa manual used that style, and I did that when I was using an Alto. 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?
- kens 10y agoGood question! I'd also add the questions Why are we still programming with the semantics of 80-column punched cards? Why are programs even structured as sequential lines? 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.
- kmiroslav 10y ago> Why are programs even structured as sequential lines? 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...).
- userbinator 10y agoThere's been articles posted to HN that have attempted to explain why textual source code has become the norm, but from what I remember it comes down to simplicity (and with it, efficiency of storage and processing) and portability. It's the same reason why files as plain sequences of arbitrary bytes won over structured/more "rich" formats, and the "everything is a file/stream of bytes" model of Unix dominated; all the complexity involved in handling things like embedded formatting instructions, resource forks and other nuances is a huge obstacle to widespread implementation and interoperability. The phrase I remember reading in reference to this is "text is universal", and I agree completely. 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.
- ams6110 10y agoI seem to recall reading that the Bravo editor stored the text and the formatting separately. So having the compiler read the text and ignore the formatting maybe not so mind-blowing after all.
- mpweiher 10y agoThere was a version of NeXT's gcc that handled RTF source code.
- delbel 10y agoIs it me, or does BCPL look like Angular 2.0/typescript? (/runs)
- careersuicide 10y agoIf you're interested in trying out BCPL on your own machine the inventor of the language, Martin Richards, maintains a working environment/compiler[0]. I've gotten it up and running on both Ubuntu and OS X. The readme is structured in a way that makes it kinda hard to follow so I wrote down some instructions[1] for my future self after I figured it out. 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 http://www.cl.cam.ac.uk/~mr10/BCPL.html [1]: https://gist.github.com/seaneshbaugh/e09abd748ccc07c5463f253df97e4de8 https://gist.github.com/seaneshbaugh/e09abd748ccc07c5463f253...
- Animats 10y agoIsn't the Mesa compiler for the Alto available? If you have that, there's no need to write in in the British Cruddy Programming Language. BCPL was written as a tool for bootstrapping compilers. It's one notch above a structured assembler. The only type that BCPL supports is the 16-bit word. Mesa, on the other hand, is a good language.
- kens 10y agoMesa and Smalltalk for the Alto are around [1], so I hope to get them running at some point. The files need to be copied into a disk image that the simulator can read, so I may need to write an Alto file system emulator. 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.html http://xeroxalto.computerhistory.org/Indigo/XMesa/.index.htm... and http://xeroxalto.computerhistory.org/Filene/Smalltalk-76/.index.html http://xeroxalto.computerhistory.org/Filene/Smalltalk-76/.in...
- Samis2001 10y agoIs there any particular reason why you linked to Smalltalk-76 vs say, -78 or -80
- kens 10y agoI linked to Smalltalk-76 because that's the version I found in the Alto filesystem archive.
- Samis2001 10y agoThis directory seemingly contains both a copy of the Alto OS and a Smalltalk-80 image/changes file. Not sure which file is the VM executable though. http://xeroxalto.computerhistory.org/Indigo/BasicDisks/Smalltalk14.bfs!1_/.index.html http://xeroxalto.computerhistory.org/Indigo/BasicDisks/Small...
- 10y ago
- Zardoz84 10y agoIf anyone like to see a clone of B, check this : https://github.com/Blecki/DCPUB https://github.com/Blecki/DCPUB