News for hackers. Stuff that matters.
Re:“Hello world” in the BCPL language on the Xerox Alto simu... by alayne on Monday June 27, 2016 @02:02PM (#11988040)
Maybe 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.
Re:“Hello world” in the BCPL language on the Xerox Alto simu... by akkartik on Monday June 27, 2016 @02:29PM (#11988304)
No, 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?!
Re:“Hello world” in the BCPL language on the Xerox Alto simu... by smitherfield on Monday June 27, 2016 @08:18PM (#11990576)
But that or something along the same lines is how syntax highlighting is typically implemented.
Re:“Hello world” in the BCPL language on the Xerox Alto simu... by akkartik on Monday June 27, 2016 @08:27PM (#11990613)
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.

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.

Re:“Hello world” in the BCPL language on the Xerox Alto simu... by TeMPOraL on Monday June 27, 2016 @09:02PM (#11990765)
> 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

Re:“Hello world” in the BCPL language on the Xerox Alto simu... by akkartik on Monday June 27, 2016 @09:07PM (#11990784)
Nice![1] What happens when you quit and restart?

[1] No need to get personal, though :p

Re:“Hello world” in the BCPL language on the Xerox Alto simu... by TeMPOraL on Monday June 27, 2016 @09:13PM (#11990806)
Didn'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.

Re:“Hello world” in the BCPL language on the Xerox Alto simu... by akkartik on Monday June 27, 2016 @09:19PM (#11990832)
I have no doubt that you can apply various decorations to text, but that is also the part relatively less interesting to me. I'm more interested to see in what format you would save emacs's runtime configuration that would allow it to embiggen just one '&rest' in a file. Can you show an example of what this elisp would look like? Markup seems the most natural approach to me, to avoid issues with files getting renamed, etc.
Re:“Hello world” in the BCPL language on the Xerox Alto simu... by TeMPOraL on Monday June 27, 2016 @09:27PM (#11990863)
Yeah, I've missed your point initially.

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.

Re:“Hello world” in the BCPL language on the Xerox Alto simu... by akkartik on Monday June 27, 2016 @09:23PM (#11990849)
Ah, just saw your edit. I'm not sure what you mean by 'temporary', but there's two axes here:

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!

Re:“Hello world” in the BCPL language on the Xerox Alto simu... by TeMPOraL on Monday June 27, 2016 @09:52PM (#11990953)
Re a) and b), I replied below your comment about your Vim plugin.

> 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 :).

Re:“Hello world” in the BCPL language on the Xerox Alto simu... by akkartik on Monday June 27, 2016 @10:19PM (#11991056)
We certainly should continue chatting :)

"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.

Re:“Hello world” in the BCPL language on the Xerox Alto simu... by akkartik on Monday June 27, 2016 @09:27PM (#11990866)
As an example of persistent-but-customized, check out this plugin of mine (in an inferior editor, sadly ;) which lets me highlight specific words in a random but persistent color: https://www.reddit.com/r/programming/comments/1w76um/coding_.... When I'm reading a strange codebase, finding a couple of key variables to colorize immediately causes the data flow of a function to "pop out" to my eyes.
Re:“Hello world” in the BCPL language on the Xerox Alto simu... by TeMPOraL on Monday June 27, 2016 @09:40PM (#11990908)
Nice work on a plugin.

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.

Re:“Hello world” in the BCPL language on the Xerox Alto simu... by akkartik on Monday June 27, 2016 @09:48PM (#11990934)
Yeah, I think what you showed is exactly what my plugin was going for. To get more fine-grained than that we'd need a smarter editor that understands markup. Fun conversation! I just shot you an email.
Re:“Hello world” in the BCPL language on the Xerox Alto simu... by andrewchambers on Monday June 27, 2016 @08:38PM (#11990679)
That's sort of what literate programming does.
Re:“Hello world” in the BCPL language on the Xerox Alto simu... by akkartik on Monday June 27, 2016 @09:05PM (#11990775)
Yes, certainly a connection to Literate Programming there. Probably why I like the idea (http://akkartik.name/post/wart-layers). That said, I think wysiwyg is a huge deal here (http://akkartik.name/post/literate-programming) because it makes the difference between maintaining a document for others vs yourself.
Re:“Hello world” in the BCPL language on the Xerox Alto simu... by jonsen on Monday June 27, 2016 @02:10PM (#11988101)
Inlined formatting commands could be recognised and skipped, just like the //-comments.
Re:“Hello world” in the BCPL language on the Xerox Alto simu... by alayne on Monday June 27, 2016 @02:17PM (#11988168)
Okay, 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."
Re:“Hello world” in the BCPL language on the Xerox Alto simu... by adf on Monday June 27, 2016 @02:23PM (#11988248)
So Bravo begat Word, and ^Z survived as EOF into DOS...
Re:“Hello world” in the BCPL language on the Xerox Alto simu... by Sanddancer on Monday June 27, 2016 @02:47PM (#11988448)
^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.
Re:“Hello world” in the BCPL language on the Xerox Alto simu... by kps on Monday June 27, 2016 @03:39PM (#11988862)

  > 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.
Re:“Hello world” in the BCPL language on the Xerox Alto simu... by jandrese on Monday June 27, 2016 @03:26PM (#11988752)
It's an easy mnemonic for Ctrl-Z to represent the end of something. Also fairly easy to type on a Qwerty keyboard.