Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I haven’t read all of it, but the Principia source code has a comprehensive units system and makes effective use of Unicode: https://github.com/mockingbirdnest/Principia/

https://github.com/mockingbirdnest/Principia/blob/master/ast... is a decent example of both:

    // We compute the mean rate (slope) of the mean anomaly M(t), the mean
    // argument of latitude u(t), and the longitude of the ascending node Ω(t).
    …
    Product<Angle, Square<Time>> ʃ_Mt_dt;
    Product<Angle, Square<Time>> ʃ_ut_dt;
    Product<Angle, Square<Time>> ʃ_Ωt_dt;
    …
    ʃ_Mt_dt += (Mt + previous_Mt) / 2 * dt;
    ʃ_ut_dt += (ut + previous_ut) / 2 * dt;
    ʃ_Ωt_dt += (Ωt + previous_Ωt) / 2 * dt;
    …
    anomalistic_period_ = 2 * π * Radian * Δt³ / (12 * ʃ_Mt_dt);
    nodal_period_ = 2 * π * Radian * Δt³ / (12 * ʃ_ut_dt);
    nodal_precession_ = 12 * ʃ_Ωt_dt / Δt³;
The advantages are concise notation plus compile–time guarantees that the units work out. I don’t care much for C# in general (or C++ for that matter), but I like the results here.

Sounding out the Greek names occasionally used as release names is always fun too.



lovely. it's 2022 and I see unknown-glyph-boxes on my up to date smartphone...

I love the use of mathematical glyphs in math code, too, much more readable, _if_ it's readable.

sigh.


The problem is (apparently) no monospace version of the /ʃ/ character, which renders fine in non-monospaced fonts (on Android).


yes in this font I can indeed see it on the same device :-D


I guess you’ll have to install an extra font or two.


Using Unicode symbols wisely in mathematical code is a godsend. I regularly use Julia, which favors this style, and find that this feature improves the readability of code enormously.


How do you then type these characters? google, copy, paste? Or is there a better workflow?


Julia mode for Emacs, Vim, and VSCode lets you to use LaTeX-like sequences: write \pm, press <TAB>, and you get ±

Of course, this only works if your editor supports this and you are using a language similar to Julia. But there are two more general methods that are applicable everywhere. The first was mentioned by db48x: I have customized my Xmodmap file so that greek letters and a few typographic characters I use often can be typed using AltGr combinations. (Unfortunately, this is much more complicated if you use Windows.)

Secondly, I heavily use Espanso [1], so that I can easily type complicated letters/sequences (e.g., my email address) for which it would be too overkill to assign an AltGr keybinding.

Finally, in Emacs and Kitty (my terminal emulator) there is a keybinding that asks for the name of an Unicode symbol and enters it. (In Emacs it's C-x 8 <Enter>, in Kitty Shift+Ctrl+u.)

From the point of view of my workflow, the problem of quickly typing Unicode characters is completely solved.

[1] https://espanso.org/


Two ways: keyboard layout and editor support.

Your OS keyboard layout, at least on Linux, can be customized to include any characters you type frequently. I haven’t gone very deep down this rabbit–hole, but I have turned on some options that make nice quotation marks (“‘«»’”), em–dashes (“–”), ellipses (“…”) and a number of other characters (“²³½⅓¼≠±÷∞×” and so on) readily available with a compose key. I also put arrows on the numberpad, of course (“↙↓↘←↔→↖↑↗⇙⇓⇘⇐⇔⇒⇖⇑⇗”). Very useful for talking about menu items, like File → Save As (it has actually startled people when I can type things like that fluently in conversation).

My editor of choice is Emacs, which has a built–in way to select characters by name. Typing `C-x 8 <RET>` prompts for a character name, with fuzzy searching and autocompletion. It also recently gained a similar facility for Emoji, which is more focused around the visual appearance. `C-x 8 e e` opens it. `C-x 8 e s` lets you search by name.

Between your keyboard layout and your editor’s search capabilities and custom keybindings you can do anything.


Some years back I wrote myself a small SublimeText extension to to pick & insert my favorite math characters but nowadays I prefer using rofimoji[0] because it is application-independent.

[0]: https://github.com/fdw/rofimoji


C#?


Much of it is in C# so that it can be run inside KSP.


> C++ 89.1% > C# 5.4%

It looks like it's mostly just a C# wrapper around the C++?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: