Readit News logoReadit News
adamthekiwi99 commented on Show HN: The Sage Programming Language   github.com/adam-mcdaniel/... · Posted by u/adamthekiwi99
lifthrasiir · 2 years ago
That's an interesting approach. So the variant name itself doesn't bear the type information but should be uniquely resolved in the type check time, right? It will be pretty much optimal unless you are doing metaprogramming stuffs.
adamthekiwi99 · 2 years ago
That's right! I think it's a good balance between giving the typechecker the info it needs, but also being flexible in how you can supply it!
adamthekiwi99 commented on Show HN: The Sage Programming Language   github.com/adam-mcdaniel/... · Posted by u/adamthekiwi99
andyferris · 2 years ago
One thing I like is exploring the structural typing.

However I am confused if the enum's are structural or nominal. It seems necessary to state which enum a variant comes from, like `Direction of South` (for that matter it seems the same is true when constructing structs?). Can you cast enum values to a wider enum type? Or combine different enum values (e.g. through branching - the return of `match`) to construct a value of a wider enum?

adamthekiwi99 · 2 years ago
Hello, thanks for the great question! Yes, you do have to specify where a variant comes from, but it doesn't have to be nominal at all! Here's an example:

``` enum Option<T> {Some(T), Nothing}

// Create a value with an inline type that doesn't use the nominal `Option`

let opt1 = enum {Some(Int), Nothing} of Some(5);

// Define a second option value, which is assigned with the first

let opt2: Option<Int> = opt1;

// Print the result

println(opt2); ```

You can create a variant of an inline `enum` type, and then typecheck it against another structurally equal type if you so choose!

I hope this example properly illustrates how powerful the structural type-checking is with enums!

adamthekiwi99 commented on Show HN: The Sage Programming Language   github.com/adam-mcdaniel/... · Posted by u/adamthekiwi99
amir734jj · 2 years ago
I used SageMath for my masters. It was a life saver.
adamthekiwi99 · 2 years ago
I'll have to check it out and reimplement it's good features for THIS Sage hahaha
adamthekiwi99 commented on Show HN: The Sage Programming Language   github.com/adam-mcdaniel/... · Posted by u/adamthekiwi99
sodapopcan · 2 years ago
Rosemary and Oregano are free! Thyme is not.
adamthekiwi99 · 2 years ago
How long until we enumerate all the herbs?!?!?!?!?! The pantry's almost empty!!!
adamthekiwi99 commented on Show HN: The Sage Programming Language   github.com/adam-mcdaniel/... · Posted by u/adamthekiwi99
aeonik · 2 years ago
What are the constraints that you want for the name?

I was thinking "Pragmata", or something along those lines.

Continuing with natureish themes: Alga Moss Myco Wisp Ivy

adamthekiwi99 · 2 years ago
My major constraint is just that the name must lend itself well to artistic representations and fun mottos/slogans hahaha!

I love these suggestions, especially Moss and Ivy! Thank you!

adamthekiwi99 commented on Show HN: The Sage Programming Language   github.com/adam-mcdaniel/... · Posted by u/adamthekiwi99
wavemode · 2 years ago
adamthekiwi99 · 2 years ago
Hahaha I doubt there's an English word left!!!
adamthekiwi99 commented on Show HN: The Sage Programming Language   github.com/adam-mcdaniel/... · Posted by u/adamthekiwi99
NWoodsman · 2 years ago
Sage is a programming language with a low level virtual machine based on a Turing tape. The sage virtual machine has a read/write head and a single register. The read/write head moves around the tape, and uses the register as an accumulator. All worldly input is done through a single instruction, and all worldly output is done through a single instruction. Functionality which cannot be achieved with any algorithm, such as using an operating system’s system calls to write to persistent memory, is also done through two instructions: one for sending values to the virtual machine’s foreign function interface, and one for receiving. The goal of the virtual machine is to allow algorithms to be expressed in the same time complexity as they would on x86, but with the smallest possible number of instructions. This allows sage code to be maximally portable: sage’s core instruction set could be implemented in hardware much easier than any modern architecture due to its very small pool of opcodes and their simplicity

This is an interesting snippet from your website, did this project intentionally start out as an attempt to design around a Turing machine? Or is it just safe to say that all languages executing on a stack with no heap are Turing machines?

adamthekiwi99 · 2 years ago
Thanks for the great question, and for checking out the project! This project started out because I noticed some really interesting properties about compiling brainfuck-like programming languages while writing high level language compilers that targeted these brainfuck-like backends.

This is the work that inspired Sage: Harbor (https://github.com/adam-mcdaniel/harbor). My goal with Sage was to take everything that makes a brainfuck-like programming language easy to compile, while also keeping all the time complexity and optimizations of regular algorithms. So, in that sense, it started out as an attempt to design around a Turing machine -- I wanted this to be a dialect of brainfuck. The VM doesn't use any stack operations, just operations on a tape pointer + an accumulator!

adamthekiwi99 commented on Show HN: The Sage Programming Language   github.com/adam-mcdaniel/... · Posted by u/adamthekiwi99
e12e · 2 years ago
Mint? ;)
adamthekiwi99 · 2 years ago
I like it! And if that's trademarked too I could always fall back on "spearmint" instead haha
adamthekiwi99 commented on Show HN: The Sage Programming Language   github.com/adam-mcdaniel/... · Posted by u/adamthekiwi99
king_geedorah · 2 years ago
The struct composition example with Position + Size is really interesting. I can’t say I’ve seen something that works that way before.
adamthekiwi99 · 2 years ago
Thanks so much! I originally added it to experiment with the structural typing -- the type system is a really cool foundation for some awesome future stuff!

Thanks for checking out the project, I'm glad I was able to surprise you haha! :)

adamthekiwi99 commented on Show HN: The Sage Programming Language   github.com/adam-mcdaniel/... · Posted by u/adamthekiwi99
mbroshi · 2 years ago
FYI, Sage is also the name of a mathematical programming language: https://www.sagemath.org/
adamthekiwi99 · 2 years ago
Thank you!! Sage will eventually change its name (I just recently found out about this), but I haven't had time to come up with a good replacement name and make art + quippy sayings for it yet! :)

I might just go with a completely made up word to avoid any trademarks entirely haha

u/adamthekiwi99

KarmaCake day60July 31, 2020
About
Programmer, musician, student at UTK.

adam-mcdaniel.net

View Original