Friday, June 16, 2023

Why gravity is different

Gravity seems to act like a force, but has been shown to not be like the other forces.  It's different.

How?  Why?

Prerequisite knowledge:  Both momentum (mass times velocity) and kinetic energy (half mass times velocity squared) are conserved properties.

Forces act with energy.  They use energy to change things.  Two balls hitting each other exchange kinetic energy, thus altering their momentum.

Gravity directly affects a ball's momentum, thus altering its kinetic energy.  Gravity doesn't use energy to achieve its effects.

It's that simple.


Not quite so simple:  There are both objective and subjective time and, thus, velocity.  Objective time ticks along, moving things a certain distance in a certain time.  This is objective momentum, and is how photons move and change over time.  Subjective time ticks along faster or slower, stretching or shrinking perceived space along with itself.  This is subjective momentum (kinetic energy), and is how matter moves.  Photons don't have subjective time.

If momentum and kinetic energy are conserved, where do they come from when gravity accelerates something?  Space-time itself.  Space-time is a field of potential energy, from which all other fields and effects withdraw their energy.  In other words, kinetic energy + potential energy = constant, at every point.

Space-time is the field which governs motion, involving both time and distance.

Sunday, June 11, 2023

Thursday, June 8, 2023

Listack v0.4.0 is live

 I have spent the last few months creating and refining my own new computer language:  Listack.  Originally written in Python, I spent the last two months rewriting it in Nim, so it is now much, much faster.  What is Listack?  Besides a portmanteau of List and Stack, of course.

Listack is a concatenative, stack-based language inspired by Factor and False, among others.  It is interpreted.  It is flat - all functions are in-line functions.  Like all concatenative languages, it encourages the use of "higher" functions (called words) from "functional programming".  Listack has the concept of good/bad data baked into its core.  It has a very basic type system, but user created objects can use user-created types of arbitrary complexity.  

It is polymorphic with limited arity, meaning each command always uses the same number of arguments but the types of those arguments can differ through redefinitions of the word.  For example, '+' is used for both numbers and strings.  1 + 2 --> 3, where "abc" + "def" --> "abcdef".

The main problem with stack-based languages is that their syntax is weird.  Every command word depends on the data it needs to work upon already being on the stack, waiting for it.  This is postfix form:  1 2 +, instead of the more usual 1+ 2 or even + 1 2.  Listack gets around this by employing uniform function call syntax.  Every word except immediate ones can go in front of, between , or after its arguments.  The following are all equivalent in Listack:
+: 1 2        prefix form - before all arguments
1 + 2        infix form - after first argument
1 2 .+        postfix form - after all arguments
+(1, 2)        callable form - immediately before parenthesis surrounding all arguments

You can, to a degree, pick and choose how you want your program to look and feel.  Just keep in mind that every word actually executes in postfix form.  (Immediate words are essentially postfix without the leading period.)  Oh, and the commas are just syntactic sugar.  The parser converts them to spaces when they're not inside a quote.  The following snippets all add 1 to 2 and then multiply the result by 3.
1 2 .+ 3 .*
1 + 2 * 3
(1 + 2) * 3
*: (+: 1,  2) 3
(+: 1 2) 3 .*
*(+(1, 2) 3)
2.inc * 3

The following doubles and also squares a list of numbers to produce 6 10 20 9 25 100.
[3 5 10] {dup .+} {dup .*} bi_apply

This does a similar thing but compiles the numbers into lists [6 10 20] [9 25 100]
[3 5 10] {{dup .+} .map} keep {dup .*} .map


Listack has an interactive REPL.  After you compile it (nim c -d:release listack.nim), execute it by typing: 
./listack

You can run a program file as follows:
./listack filename
with options for -debug and -verbose

Don't have Nim?  Check out their website.