zokier 2 months ago

Code typography is such a neglected area, I'm glad to see any projects that touch on that. This reminds me of Suns Fortress language, which was designed also for scientific computing (afaik more in HPC sense), and also allowed rendering code into pdf with improved typography. Unfortunately lot of the original Fortress resources have linkrotted away, but there are some examples in this presentation (by Guy Steele!) https://www.cs.tufts.edu/comp/150FP/archive/neal-glew/mcrt/F...

  • versteegen 2 months ago

    Agreed, I've wondered why it's so ignored since I first learnt to program, and relatedly, why are programming languages strictly English-based?

    Those slides are my introduction to Fortress. Sounds nice, sorry to hear it's discontinued. I'm struck by how very similar to Julia it is (which is officially inspired by Fortress), for example the focus on performance and maths, zero-cost abstractions, type specialisation, very similar syntax, ASCII<->Unicode equivalence, encouragement of unicode identifiers and operators, and some (small) amount of eliding '*' for multiplication. (You can write "2(a + 1)a^2" but not "(a+1)(a+2)" because the latter is a function call. Whitespace between multiplicands not allowed.)

    It seems it would be easy to write a package to display Julia code as HTML or Latex, although I didn't find one. There's already a library to print expressions as Latex, and of course in a Jupyter notebook results are displayed in HTML.

  • WillAdams 2 months ago

    Arguably the most successful effort in this space is:

    http://literateprogramming.com/

    I use it in a current project using LaTeX:

    https://github.com/WillAdams/gcodepreview

    • zokier 2 months ago

      I checked the linked PDF[1] as an example, and the codeblocks are still just basic plain monospaced blocks with practically no typesetting done to them; very different from something like Fortress, or indeed this Forscape

      [1] https://github.com/WillAdams/gcodepreview/blob/main/gcodepre...

      • WillAdams 2 months ago

        Yeah, I've been using the listings package and it doesn't have much support for Python and I had to hack together the settings for OpenSCAD.

        If you know of a better LaTeX package to use, or better settings for Python or languages like OpenSCAD I'd be glad of them.

        Mostly I need the LP stuff for managing multiple files, and the overview of the PDF and hyperlinked ToC and Index and so forth.

xelxebar 2 months ago

This is super cool! Recently, I've been musing about the potential ergonomics of programming directly with rich typography, and here Forscape's kind of gone and done it.

The project seems to be specifically targeting working scientists, but I think there's real potential for using mathematical and math-like notation in a general programming language. The array language family does adopt a few of the affordances from math, and even that partial pick-up gives them some ergonomic features not seen elsewhere.

At the moment, we're kind of stuck in the paradigm of linear input, only using very limited typography for somewhat dumb syntax highlighting. Math-like notation is really nice at conveying semantics and intent in ways that are really challenging in current languages. For example, sub- and superscripts effectively act as function parameters but give extra freedom for conveying the different meaning and use of said parameters. Things like Haskell's generic infix syntax, named parameters, optional arguments, etc. can be seen as ways of trying to work around current limitations.

The biggest question for me is input, which Forscape seems to address quite nicely. We don't just want to typeset our code prettily, we want to have all the affordances of advanced typography directly available as we code.

I'd love to hear user stories from Forscape: Do you like the mouse-oriented editor experience or do you prefer keyboard shortcuts? What is easiest for you to express in Forscape the language? What is most challenging? Where does the system diverge most from the natural expression? For those with a programming or CS background, how easy is it to reason about memory access and execution? Etc.

Thanks for sharing!

  • cobbal 2 months ago

    Mathematica also has some fairly advanced typographic syntax. Matrices, subscripts, integral signs, with a decent input system to match. Type <ESC>dint<ESC> to get a definite integral with placeholders.

    One particularly nice thing about it is that it's completely optional sugar over a lispy "FullForm" syntax, and it's easy to convert between the two.

    I'd encourage everyone to play with it, but it's sadly non-free.

    • Iwan-Zotow 2 months ago

      > it's sadly non-free.

      you could get Wolfram engine for free (use your home e-mail address) which is basically text io single seat Mathematica.

      Then you download WLJS notebook interface and voila, you all set...

    • 7thaccount 2 months ago

      Upvoted. I have a love/hate relationship with Mathematica, but it is so far ahead of its time in a lot of ways. It's like Jupyter Notebooks dialed up by 100 and fully integrated with everything from linear algebra to calculus to graphics to graph theory to plotting to optimization and machine learning so on. I just find the functional like language (a term rewriting system) to be hard to grasp at times and it being a commercial product means it will eventually lose out in some ways.

      • seanhunter 2 months ago

        Yes. And Theodore Grey actually invented the notebook UX I believe for Mathematica around 2000-ish or maybe a bit before. Jupyter notebook came after that.

        • 7thaccount 2 months ago

          Yeah I understand Mathematica notebooks came first. I meant for my comment to allude to that, but when re-reading see I forgot to mention it. Thanks for adding context. I assumed Nathematica's notebook UI was even older than that.

auggierose 2 months ago

Insane. This must have been so much work, and it looks great, but I know I will never use it.

WillAdams 2 months ago

Why this rather than LyX, Texmacs, Jupyter Notebook, LaTeX (and a suitable editor), or Typst (and a suitable editor)?

  • cryptonector 2 months ago

    LyX is great, and if only LyX could a) generate code from math, b) run that code and also any other embedded code, c) produce and embed graphs and other illustrations from the results of running that code, then LyX would be perfect.

    Basically we need to marry LyX and Jupyter.

  • Onavo 2 months ago

    If you asking this, you are the wrong audience. All academic journals accept submissions in Microsoft Word, this is a similar tool targeted at the WYSIWYG crowd.

    • zokier 2 months ago

      you both are missing the main point here, Forscape is not for writing documents, but for writing executable code.

      • wdkrnls 2 months ago

        TeXmacs can execute code too. Honestly, if it had 1/10 the community of Emacs, I would be using it for everything from running my window manager to driving my statistical simulations. It's already what Stallman keeps asking Emacs to become.

        • kayvulpe 2 months ago

          TeXmacs and mathacademy are the reasons I've successfully rebooted my mathematical education after so long. Both are great products.

      • Onavo 2 months ago

        Good point

cryptonector 2 months ago

Reminds me of https://github.com/mtarek/compitex which is a very barebones LaTeX math to C compiler. I've done a bit of work to make it better, but it really needs a lot of work, and it needs to compile to languages with polymorphism.

TFA makes me really like the idea of literate papers, with math, code, and data embedded in the paper.

sdqri 2 months ago

It makes the code significantly easier to read but equally harder to write. In my opinion, mathematical formulas, while elegant and precise, aren't always designed with machine computation in mind. You often have to compromise on their beauty or precision to achieve reasonable time complexity, and sometimes it's necessary to make a mess to get there. But kudos to them for their work and effort.

etbebl 2 months ago

I may be missing the point, but I'm not sure there is really an audience for this...obviously nice math typography is important for publishing, but I doubt the set of people who are comfortable with advanced math but who see translating those operations into a traditional plain-text programming language as a barrier, but would be fine with a more math-like syntax, is very large.

  • cryptonector 2 months ago

    It's almost certainly not a large set of people. It's probably no larger than the set of professors and grad students who could use it. But it does seem very useful to those people. Incidentally, that's basically the same people that TeX was meant for originally.

    • etbebl 2 months ago

      My point is, wouldn't most of these people be fine with coding in Python/Matlab/Fortan/whatever?

      Not that it isn't a cool idea!

      • cryptonector 2 months ago

        My kid's writing a bunch of math in Tex and using it with tools like Desmos and Wolfram Alpha, and Lyx and what not, and then when it comes time to build simulations based on that math... he has to transpile it by hand to a programming language. This is terribly sub-optimal. Sure, one can build a transpiler to do it, but it'd be even neater if the authoring tool was more integrated with TeX math.

Kye 2 months ago

Is the name a play on Farscape, or is that coincidence?

wiz21c 2 months ago

Why a new language ? Honest question ? Couldn't it be done on top of say, Julia ? The typography thing is really cool, but having to code in yet another MatLab-clone is a bit annoying (or maybe I'm missing the point)

  • cryptonector 2 months ago

    If you have a very complex equation then it will be a lot easier to read it and think about it if it's typeset correctly than if it's written in monospaced ASCII in Julia/Python/Java/C++/Rust/Haskell/Whatever.

    So then you have two options:

      - compile the typeset equation to code
    
      - hand-code the equation
    
    Forscape is a third option, perhaps more akin to a Jupyter-style notebook, where you write equations and text but you can "run" those equations. Literate programming isn't quite this, not unless you automatically get codegen from your equations.
    • narcraft 2 months ago

      Here's a matrix-focused DSL that compiles to LaTeX, MATLAB, Python/NumPy or C++/Eigen:

      https://iheartla.github.io/

      Not exactly wysiwyg typeset coding, but a close concept, compiling relatively more legible equations to code

    • wiz21c 2 months ago

      I get that, sure. But the language forscape proposes will soon need to be a general one if one wants to do big projects with it.

      (And I'd love to rewrite my simulation code with something like forscape, because then the math code would appear as such and not as a mubojumbo of numpy operations)...

      • cryptonector 2 months ago

        Yes. I've a feeling that something like Forscape + something like Jupyter, and maybe something like LyX, might make the right combo.