Topics

Prelim question about Stanza type interfaces

igbi@...
 

Dear Patrick,

This is probably premature. I need to do some experiments with Stanza to see if can duplicate some past experiments that I've done in other programming languages, all of which have ultimately gotten the reject.

In this email, I'll mainly just do some talking. You can ignore any of it. I think I mainly need to write it to get some motivation. However, I'll ask two questions which most likely can be answered.

Q1: Will Stanza ever have something like interfaces or traits, so that the properties of a type can be specified, for the purposes of type inforcement? As an example, Google Dart now has a strong mode, which gives Dart an enforcement feature that it didn't have initially.

Q2: In chapter 4 of your book you say, "Types do not live inside functions, nor do functions live inside types." I need for a struct type to hold a lambda function as a field, to be initialized by the constructor. Can your struct do that, or something else? I'd think that I can easily find this out once I install the software.

*CONTEXT: trying to meld a programming language with standard mathDefinitions-naiveSets-algebraicStructures-andMoreSemiFormalism*

My B.S is in math, so I'm not really a programmer, but I started on the search for the mother-of-all-programming-languages about September 2013. Initially, it was supposed to be Scala.

I prefer for emails like this to serve some purpose and be "on topic". At the very least, maybe this email will show you that there's still room for more programming languages. In my search, four criteria have been good-market-share/good-backing, clean syntax, decent performance, and an amalgam of modern-language-features.

Obviously, you have no market share, so if I'm still looking at Stanza, it must mean something good, at least on paper, or PDF.

I've done proof-of-concept experiments with Rust, Dart, TypeScript, Julia, Python, Haskell-ish languages, and C++. Those gave me enough experience to think through things about the other established and new languages.

As to new languages, a competitor of yours, for my needs, would be Idris, a dependently-typed functional language. But the lack of a basic feature can turn me off, since there's so much risk as to whether a language will have any lasting power. Typical of many functional languages, Idris doesn't have an array/vector type as part of the standard distribution, so I give it the reject.

*Exposure to Proof Assistants as a game-changer*

One starting point for me was exposure to the type class structure of the Isabelle proof assistant.

A logic called Isabelle/HOL is the main logic of the Isabelle product. It's a language very similar to Haskell. In particular, it has what are called axiomatic type classes.

A PDF of most of the logic is in this PDF (click the link 'document'):

https://isabelle.in.tum.de/dist/library/HOL/HOL/index.html

Particular chapter for order, lattices, and algebra would be chapters 4, 5, 6, 10, 15, 16, and 17. Eventually, they build up to the real numbers formalized as Cauchy Sequences. For myself, I'd just like to tie in a language, such as Stanza, semi-formally for natural numbers, integers, and rational numbers.

Anyway, the type-class structure is what I'd call "fine-grained". Drawing from how they do things, to build up to something like an additive group, I'd define more types than many people would. One purpose would be to more closely follow the progression of a standard abstract algebra book, but not quite.

With the standard mathematics of the mind, there's no need to define a syntactic type like 'Zero', since there's only one type, 'set'.

Thanks for your time.

GB

 

Hi Gottfried.

Thanks for your interest in Stanza! To quickly answer your first two questions:

1) Stanza uses multimethods and the defmulti construct to define the interface with which you interact with values of a certain type. The only thing that is currently missing in the current language is a compile-time check that enforces that an appropriate method has been implemented for every type. Currently you get a runtime error that says "The multi plus have no appropriate methods for arguments of type (String, Int)". The compile-time check would be nice to have and we are working towards it, but we have found that the runtime errors do not substantially hinder programmer productivity.

2) A struct can hold any value as its field, including lambdas. I would encourage studying Stanza's multimethod system to see whether you really need it however.

As for your comparisons of Stanza to the other languages, let me start with the family of languages Idris, Isabelle, Coq, Agda, etc. These languages have a strong culture of enforcing correctness and provide an extensive toolkit for accomplishing that. Stanza will never be able to replace these languages for this purpose. I designed Stanza to be a pragmatic practical language to use to attack common programming problems. In daily programming, "correctness" is important but not the only important or difficult aspect of software. For example, I used to program video games. The most important quality of a video game is to be "fun". Isabelle's type system will not help me design a "fun" video game, and on the contrary, will actually substantially hinder my productivity. My sense is that most daily programming is quite similar to programming a video game: correctness is not the most important metric.

Stanza is more aptly compared to Scala, Rust, Dart, Typescript, Python, Haskell, C++. To make these comparisons, I personally choose the implementation language by deciding upon the minimal acceptable performance requirement, and then remove all languages that do not meet that performance requirement. Among the languages remaining, I choose the most productive language among them. There is no reason to use C++ unless you require C++ level performance. Similarly, there is no reason to fiddle with a non-garbage-collected language like Rust, unless you require performance levels exceeding garbage-collected languages. Among the languages above, Stanza is very well regarded in terms of its productivity, and its performance is steadily improving.

  • Patrick

Gottfried Barrow <igbi@...>
 

Patrick,

Unless I try to lock into Stanza and need some help, any further email in this period of mine can be considered noise. But new project forums can need some noise to show that the project is active, and is being supported. The landscape of new programming languages, discovered by means of Google, is a landscape of dead carcasses, many having been left to die in a reasonably mature state.

People who don't know much can still be looking for very specific features, so if I think I need something, others may also be looking for it.

I do actually have two questions.

Q1) I got as far as running 'stanza install -platform windows -path', which produced the '.stanza' file. I got a line in the file like this:

  install-dir = "E:\\E_1\\02-p\\3zz\\(stanza)\\00_wstanza_0_11_10"

Can I change that to a relative path? I'll find out, but even if I can, there's the question "Am I supposed to be able to change that to a relative path?".

My distribution needs to be portable. I zip up my working folder, which contains multiple 3rd-party distributions. People would then simply unzip my file on a Windows machine, in any folder, with spaces allowed in the path. My binaries would then just work. No magic installs. No lengthy "do this and that". Simplicity counts for a lot.

There are some distributions that allow for that simplicity, like Dart, Node.js, and certain MinGW-w64 distributions, but many that don't, recent ones being Kotlin, and the MinGW-w64 distributed with Idris. It's a sad day when I work hard to make sure spaces can be used in paths, but the pros don't.

Q2) Is there a "chaining substitute" operator? Instead of 'f(x)', I'd like something like the usual 'x |> f'.

*Noise: concerning multimethods*

You can thank Julia for warming me up on how to make the switch from object methods to multimethods. Central to all my types are enforcing a domain, using a domain predicate. For example, like in many languages, it appears you only give me 'Int', rather than a large selection of signed and unsigned ints, arbitrary-size and fixed-sized integers. So I would 'Int' in a struct (call it 'Nat'), and use the domain predicate 'x >= 0', which a multimethod would retrieve.

The predicate 'x >=0' would be hard coded for 'Nat', so I assume a multimethod would work for that, and be desirable for that.

However, I  'Nat' would be extended to take a "domain restriction predicate argument", predicates like "x > 24 && x < 42".

*Noise: concerning innovative products and the-future-mathematical-programming-language-of-the-masses*

Innovative products will be used in ways the developers never dreamed of.

Suppose the world's use of languages converges to one programming language, "the mathematical programming language of the masses". What might that programming will be like? Most likely, our imagination, at this point, would get it wrong.

I guess at one point, I thought Haskell had to be the-future-mathematical-programming-language-of-the-masses, but I don't see the masses jumping on the Haskell band wagon, and now I don't even want to use it. Why? I don't explain, for the purpose of noise reduction. As a member-of-the-masses, I know Haskell is great, but I don't want to use it.

*Noise: trying to solve the problem of bridging the mathematical-lanuage gap*

There's ZFC-based math, and then there are programming languages.

It's a free-for-all, so I'm interested in trying to solve the problem of unifying the languages of two different disciplines, math and computer science, where, currently, people mostly work very different.

I don't want to define an algebraic group twice, once using a combination of English and standard notation, and then again using the syntax of a programming language. I want to do it once, in one language, a technical language that gets processed by a computer, for various reasons, and that can be reasonably read like normal. It doesn't have to be perfect, just acceptable.

*Noise: you have an arrow type, chalk one up for Stanza*

Successful people don't waste their time, so I consider all programming languages to be great, for someone, and indirectly, maybe even for me. I try not to get stupid about criticizing languages.

I'm not current on Julia, but it didn't have an arrow type. Dart also doesn't have an arrow type. You have an arrow type. That counts for a lot, I'm pretty sure.

Julia's abstract type only allowed for subtyping one type. You allow subtyping of an intersection type. I guess that will give me a form of multiple inheritance. I need that, because an algebraic group is both an additive group and a multiplicative group.

*End noise*

In the end, no feature of a programming language magically makes things easy for me. Readable syntax is desirable, but not absolutely essential, because it's not like, "Dude, it's almost like reading English. I instantly understand it all, even though it's massively complex!"

I might have some questions, since I don't know much. If you didn't already have the good amount of documentation you have, I wouldn't have made the noise I've made. Chalk one up for Stanza.

Still, regardless of any feature, common sense tells me not to jump on the bandwagon of any language that hasn't established itself, and isn't backed by big funding of some kind.

But then, I repeatedly get to a point with other language where I say, "Dude, nobody who would want to read through an abstract algebra book will want to wade through this stuff of yours". Not that I've ever gotten to the point of implementing much "stuff". It's all risky, and there's no purpose in developing a library that ends up on the landscape of dead carcass.

Regards,
GB



On 5/2/2017 4:48 PM, Patrick S. Li wrote:

Hi Gottfried.

Thanks for your interest in Stanza! To quickly answer your first two questions:

1) Stanza uses multimethods and the defmulti construct to define the interface with which you interact with values of a certain type. The only thing that is currently missing in the current language is a compile-time check that enforces that an appropriate method has been implemented for every type. Currently you get a runtime error that says "The multi plus have no appropriate methods for arguments of type (String, Int)". The compile-time check would be nice to have and we are working towards it, but we have found that the runtime errors do not substantially hinder programmer productivity.

2) A struct can hold any value as its field, including lambdas. I would encourage studying Stanza's multimethod system to see whether you really need it however.

As for your comparisons of Stanza to the other languages, let me start with the family of languages Idris, Isabelle, Coq, Agda, etc. These languages have a strong culture of enforcing correctness and provide an extensive toolkit for accomplishing that. Stanza will never be able to replace these languages for this purpose. I designed Stanza to be a pragmatic practical language to use to attack common programming problems. In daily programming, "correctness" is important but not the only important or difficult aspect of software. For example, I used to program video games. The most important quality of a video game is to be "fun". Isabelle's type system will not help me design a "fun" video game, and on the contrary, will actually substantially hinder my productivity. My sense is that most daily programming is quite similar to programming a video game: correctness is not the most important metric.

Stanza is more aptly compared to Scala, Rust, Dart, Typescript, Python, Haskell, C++. To make these comparisons, I personally choose the implementation language by deciding upon the minimal acceptable performance requirement, and then remove all languages that do not meet that performance requirement. Among the languages remaining, I choose the most productive language among them. There is no reason to use C++ unless you require C++ level performance. Similarly, there is no reason to fiddle with a non-garbage-collected language like Rust, unless you require performance levels exceeding garbage-collected languages. Among the languages above, Stanza is very well regarded in terms of its productivity, and its performance is steadily improving.

  • Patrick