
A calculator for the Terminal that renders beautiful math - pmkary
https://kary.us/nota/
======
nine_k
Ah, such a nice set of features, _and_ case-insensitive identifiers?..

I mean, if I do math or physics, I usually follow conventions, so I expect G
to be usable as the gravitational constant, while _g_ to be usable as the
free-fall acceleration, maybe in the same formula.

~~~
mkl
Yes, that seems a very strange choice (stranger than spaces in identifiers!).
TikZ allows spaces in some identifiers, and it can be quite nice.

~~~
pmkary
Stay tuned and I will push an update for you guys to have lowercase/uppercase
single letters. You can currently use single letter latin instances like Beta
and Beta'

~~~
mkl
Why "Beta" and "Beta'", not "beta" and "Beta"? (Following e.g. Latex.) It
seems like it would be useful to be able to define identifiers like "Φ'"
(though maybe that's "Phi''"). It also seems a bit inconsistent to not allow
an identifier π to be defined - some people use the symbol π for other
purposes.

~~~
pmkary
That is because the language is case insensitive and therefore normalizes the
words so Beta and beta will not differ once they pass the parser.

~~~
IshKebab
That's a bad idea - every system that is case insensitive has eventually
regretted it because it just leads to confusion. E.g. Mac's filesystem, Cmake
([https://stackoverflow.com/a/35034125/265521](https://stackoverflow.com/a/35034125/265521)).
Almost all modern languages are fully case sensitive.

~~~
pmkary
I've been making languages for quite a while now. And between all of them I've
really like the idea of case insensitivity. Nota is mostly about what I wanted
to have and couldn't find in other places. It's way of identifiers too was an
important thing that I wanted to have. Having apostrophes, case insensitivity
and spaces was an important thing that actually even effected the rest of the
grammar design

~~~
samatman
I think what you've done is very beautiful and I hope you'll accept some
feedback with equanimity.

You haven't made a language here, you have implemented one. That language is
mathematical "Nota"tion.

You've implemented it incorrectly, because mathematical notation is case
sensitive. A doesn't mean a, any more than it means α.

It is, of course, your project, and your sense of aesthetics which must
ultimately be satisfied. I hope you will consider what I and others are trying
to communicate to you, because I would use this, if it weren't broken from my
perspective.

~~~
pmkary
It is not that I don’t like or respect your ideas. Truth is that what I
ultimately wanted on my end was to do the challenge of rendering notations
with Unicode and then I thought let’s have a simple calculator with it. Nota
is not a super capable calculator, to what I see it’s only the bare minimum.
It’s for the times when you need quick thinking and wanna do a few quick
calculations.

I personally love case insensitivity because it is really hard for me to
remember the cases. I love macOS for its case insensitive file format and each
time I design a language—and Nota is not mathematical notation, it is its own
language with its own grammar. Just like the way Mathematica is its own
language—I seek to see if having case insensitivity is possible. I loved it
that with Nota, because the language was so simple I could even have spaces in
the names. These are awesome for quick doings.

I haven’t resisted to the idea of case sensitivity though. But to be honest
never thought about it.

For the sake of beauty nota renders each word in first-letter-Upper/rest-Lower
since this was the most beautiful representation I experimented with. I will
add the A and A’ to have both a and A (and the rest of the letters) this was
if someone really loves to have the distinguished cases they can and I can
keep my easy to write and beautiful in print style.

I think this solution is the win-win. And also I think if you regard Nota as a
separate language with separate ideas; You can have more fun with it. It’s
like watching How I met your Mother and trying to use it to replace Friends,
it’ll make a bad experience, but regard it as a its own series and you then
can see its beauty

------
L0stLink
I use _Insect_ [0][1] as my calculator and it is great and does not have the
odd choice of having case-insensitive identifiers plus does not require me to
have _Haskell_ installed. I would prefer if _Insect_ was written in a compiled
language but I am glad that it exists and JavaScript is really not a deal
breaker for me as I need _nodejs_ installed anyway (the same cannot be said
for _Haskell_ and this is going to be true for most people) plus you can get
"compiled" single binaries for it from the release page[2] that you can put in
`~/.local/bin` and not worry about it. I highly recommend trying it out. A bit
slow to start but if your window manager supports hiding/showing bound windows
through user defined shortcuts (like bspwm, awesomewm, i3, sway, herbstluft
and most other tiling window managers) then you can just have it launch in the
background on startup and you will have a convenient calculator just a few
keystrokes away.

[0] [https://insect.sh/?q=%3F](https://insect.sh/?q=%3F)

[1] [https://github.com/sharkdp/insect](https://github.com/sharkdp/insect)

[2]
[https://github.com/sharkdp/insect/releases](https://github.com/sharkdp/insect/releases)

~~~
jsilence
Also python with pint installed can be a handy calculator similar to this.
Many people have python installed, but don't use it as a quick calculator.

~~~
jsilence
And sympy installed of course...

------
tpmx
Looks a bit like Mathcad for DOS back in the 80s:

[https://en.wikipedia.org/wiki/Mathcad#/media/File:Mathcad_25...](https://en.wikipedia.org/wiki/Mathcad#/media/File:Mathcad_252_screenshot.png)

[https://books.google.com/books?id=zjAEAAAAMBAJ&lpg=PA63&dq=m...](https://books.google.com/books?id=zjAEAAAAMBAJ&lpg=PA63&dq=mathcad&pg=PA64#v=onepage&q&f=false)

~~~
dukoid
My favorite tool to double-check O:) my math homework was derive
[https://en.wikipedia.org/wiki/Derive_(computer_algebra_syste...](https://en.wikipedia.org/wiki/Derive_\(computer_algebra_system\))

------
albertzeyer
I hope that we will eventually get image support in terminals, and then
projects like this can be much easier and still much nicer and more powerful,
e.g. also plotting graphs, and much more, similar as what you get in a Jupyter
notebook.

There is a long ongoing discussion about an upcoming standard for image
support in terminals: [https://gitlab.freedesktop.org/terminal-
wg/specifications/is...](https://gitlab.freedesktop.org/terminal-
wg/specifications/issues/12)

~~~
wfdctrl
Kitty

~~~
albertzeyer
Kitty also has their own custom protocol for images. That's exactly what they
try to accomplish in this discussion thread, to get one common protocol which
is used by all modern terminals. The developer of Kitty is also in there.

------
dan-robertson
I guess the Unicode output is nice but I feel like my biggest issue is one
with input. One thing that is annoying is you get half way through your line
and realise you need an opening paren several terms ago. It can take a load of
time to find the place to put it and a load of effort to make sure things are
correctly balanced. I feel like the operator I wish I had is something like
“extend the left operand leftwards” e.g. go from this (with cursor represented
by a bar):

    
    
      a + b * x + c /|
      to this:
      a + (b * x + c) /|
      And apply again to get this:
      (a + b * x + c) /|
    

It (e.g.) let’s you write fractions without needing to use loads of parens
(which have a cost as they must be balanced) or needing to think about whether
the numerator will have more than one term.

I guess with rich input I’d also want to see the output in “big” mode.

Another way to try to make input easier is to use rpn. This has advantages and
disadvantages.

Currently the calculator I most use is gnu Calc (I also use R occasionally for
calculating quantiles). GNU Calc is the calculator built into emacs. It has an
rpn interface and an algebraic one. A nice feature of the algebraic interface
is that you can use $ to mean “the top entry on the stack” and so you can
incrementally build up an equation. A second feature is selections. Their
internal implementation is weird (based on hidden “functions” and rewrite
rules) but they work fantastically well for modifying and manipulating the
inside of a formula or equation. It also has a “big” display format which
looks a bit like this one except that it predates Unicode symbols being common
and so is pure ascii. (It also has tex output and emacs has image support but
no one has put the two together yet)

Mainly I use Calc because I’m in emacs anyway and it has a ton of features
that are easy to access (eg arbitrary precision floats, bignums, modular
arithmetic support, complex numbers, interval arithmetic, vectors, matrices,
algebra, curve plotting/fitting, unit conversions, ...). I feel like the
variable support isn’t great. I feel like I want to eg have some set of
variables, defined to be various input numbers, and write formulae in terms of
them and then get the formula on the left without variables substituted and
it’s numeric evaluation (with them substituted) on the right. There’s
something weakly like this using => but it doesn’t compose well. If you add a
=> 1 to b => 3, you don’t get a + b => 4, you get (a => 1) + (b => 3). (I
think. My memory is a bit rusty for the last example).

------
seanhunter
Looks really cool, but this statement

> Nota approaches identifiers much differently than any other language.

is not actually true. Goldman Sachs have an internal language, Slang, which
also allows internal spaces in identifiers, and where identifiers are case
insensitive. I believe it originated as an MIT research language so probably
there are others with a similar approach.

~~~
saagarjha
> Goldman Sachs have an internal language

I think we can forgive them for saying that if the exception is not readily
available.

------
webdva
Very good design skills.

~~~
rbanffy
I slapped my forehead seeing the dashed borders... Why didn't I think of that
before?

~~~
pmkary
Thanks a lot :D

------
ivan_ah
Nice to have all that power on the command line. The system uses the notation
with square brackets for function calls, e.g. Sin[x], so ppl familiar with
Mathematica will feel right at home.

The SymPy Unicode output mode also does a pretty good job on the command line.
You can try here [https://live.sympy.org](https://live.sympy.org), for example
[https://live.sympy.org/?evaluate=(1%2F2)%2F3%20%2B%202%2Fsqr...](https://live.sympy.org/?evaluate=\(1%2F2\)%2F3%20%2B%202%2Fsqrt\(sin\(pi%2F2\)**2%2Bcos\(pi%2F2\)**2\)%20%2B%20floor\(E%2F2\)%0A%23--%0A\(19%2F6\).evalf\(\)%0A%23--%0A)
(see Settings on the side to turn off LaTeX rendering)

~~~
pmkary
Yeah but it wasn't the prettiest. What I learned through my experiments was
that not all of the notations render beautifully and so I chose a subset that
is pretty and kept the rest rendered just as functions. This honestly wasn't a
try to have full mathematical notation rendering, but rather my own
preferences of notation rendering. Yet, I hope you enjoy it :D

------
lilyball
This looks very neat, but why does the project have zero tags or releases? I
also notice the GitLab instance isn't even accessible over https.

~~~
pmkary
Quite right. I used to be on GitHub and they banned me because of my
nationality. So I had to make my own server. I still haven't had the chance to
made the SSL work, sorry for that, but issues were really bigger than that
so...

~~~
Eugeleo
Oh, hey! I worked with you on a Racket VSCode project a while ago and wondered
why you suddenly stopped responding. The GitHub ban might've been the culprit
there. Glad to see you working on another interesting project!

~~~
pmkary
How cool! Nice to see you again. Yeah I had an overflow of issues coming and
github ban and then a personal trauma that made me put down so many of the
project. Please email me and I'll add you to my GitLab. We can resume the
progress there if you still like :D

------
qubex
The use of brackets to denote function arguments and pretty text output in the
terminal reminds me very strongly of using _Mathematica_ from the command
line.

[https://reference.wolfram.com/language/tutorial/UsingATextBa...](https://reference.wolfram.com/language/tutorial/UsingATextBasedInterface.html)

~~~
Aardwolf
I always found it odd about Mathematica that a low level programming language
like C gets closer to mathematical notation with sin(x) than Mathematica with
Sin[x]

~~~
pmkary
There are two reasons; first is that I tried to render parentheses in the
terminal and they didn’t look good, it was brackets that looked good. So that
is the actual reason but also writing brackets do not require shift so I
prefer it myself to type more easily

~~~
choeger
> but also writing brackets do not require shift

So your target audience is strictly (US) English?

~~~
Cu3PO42
This, and issues like it, bug me so much. So many keyboard shortcuts are
unusable by default on QWERTZ, for example any shortcuts involving /, [ or ].
They require modifiers to be typed, so those are swallowed for shortcut
purposes.

Of course, it is (almost) impossible to account for the enormous amount of
keyboard layouts that exist, so I wish we could agree to use key positions
over the characters they produce for shortcuts, so we can cover a significant
portion of the population with ANSI/ISO layouts. I'm honestly not sure what
keyboard layouts are used in countries with entirely different scripts, but my
cursory Google searches suggest the physical layout is the same as ours.

Sure, you might lose some mnemonics on layouts that aren't QWERTY, but at
least the majority of shortcuts would be usable by default compared to having
to remap them in every application. The application could even resolve what
keys are actually mapped to the physical keys and display the correct shortcut
in menus.

Destiny 2 actually seems to do this and does, as far as I was able to tell, an
excellent job of it.

------
tomxor
view-source:[https://kary.us/nota/install.sh](https://kary.us/nota/install.sh)
-> [http://codes.kary.us/nota/nota.git](http://codes.kary.us/nota/nota.git)

~~~
wizzwizz4
Or fix the SSL. One of those must occur before this works.

------
lilyball
I'm surprised the gitlab page has no issues, and the Nota.cabal file still
points to what appears to be a stale github repo.

------
sriku
Parts of this reminded me of Calca ([https://calca.io](https://calca.io))

~~~
pmkary
Wow you're absolutely right! It was a big inspiration for me

------
setr
A beautiful language with a beautiful notation and beautiful ideas is perhaps
a bit too much beauty for my taste

------
navigaid
A mirror for those who are unable to git clone:

    
    
      https://github.com/pmkary/nota

~~~
JdeBP
That is out of date.

* [http://codes.kary.us/nota/nota](http://codes.kary.us/nota/nota)

------
dukoid
Shameless plug: If you prefer java, try
[https://github.com/stefanhaustein/expressionparser/blob/mast...](https://github.com/stefanhaustein/expressionparser/blob/master/README.md#tree-
building)

Bonus feature: symbolic derivation

------
tempodox
It does look nice, but it seems to be missing complex numbers.

~~~
pmkary
Yeah. those beasts. I really like to have them implemented someday!

------
Wevah
Neat!

One documentation nit: “Parenthesis” is singular; the plural is “parentheses”.

~~~
JdeBP
"Expect for the Pi" instead of "except for pi" is another.

~~~
pmkary
thanks I'll fix that too :D

------
noja
Beauty sure has a low standard these days.

~~~
pmkary
Or we may call it different tastes :D

------
johnklos
It's beautiful! It's a real shame that Haskell isn't portable.

~~~
jdc
What modern desktop or server platforms does it not run on?

~~~
SkyMarshal
It seems not to run well on some platforms like the minds of developers who
don't want to take the time learn it.

