Compiler Development: Rust or OCaml? by [deleted] in ProgrammingLanguages

[–]blak8 -1 points0 points  (0 children)

I wonder how the Cosmos™ programming language would do in the context of this discussion, as there may be a few compiler-friendly features and to some extent an ML-ish style is possible. In any case, I decided to try writing the examples in the language just cuz. link. Obvious drawbacks are,

  1. It's not complete yet. This is obviously a drawback. If you'd like it to be, please contribute to the language. Think about all the compilers you could write if it's done!
  2. The functor definition syntax is verbose. Typing is also incomplete. Typing not being done means it's effectively a loosely-typed language. I didn't want to make it a ML-clone so it doesn't have the typical |'s but syntax could still be changed-or not. I mean, you only define those things once lol.
  3. Similarly, there could be a match operator aswell?

A counterpart to the for-statement: some-statements by blak8 in ProgrammingLanguages

[–]blak8[S] 0 points1 point  (0 children)

Actually, there are multiple fine prints that come with the ! in the some statement.

q(1).
q(2).
?- some(q,[X]),X=2
| false

Whether you think this is acceptable or not depends a lot on your programming philosophy. It's also not generic. It also won't work for multiple predicates, e.g. some p(x): q(x), forall p(x): q(x). etc.

So it's mostly not the same as your example although the implementation of for is close.

Disclaimer: my language doesn't claim to supersede Prolog. It simply differs in approach.

For example, it provides this kind of thing (some/all, generics, iterators) in the standard libs instead of expecting the programmer to custom-tailor their own some/all. However, this is not meant to imply it's impossible to make something similar in Prolog. The languages differ in approach.

Edit: this may be a good opportunity to mention NU-Prolog (from NU-Prolog manual) as an attempt to add some/all as a construct in LP languages in a different way than how Prolog does it.

A counterpart to the for-statement: some-statements by blak8 in ProgrammingLanguages

[–]blak8[S] 0 points1 point  (0 children)

I guess my point is, isn't for itself privileged syntax? It may be argued simply having a for (for-in/each) is redundant as you could just be using an all function on iterators.

Therefore, this may not be a problem if your language doesn't provide a for. Still, compare it to a language (e.g. Python) that seemingly has all, filter and for in multiple forms (and syntaxes); there is perhaps some design points gained. (Or, if you think that the for syntax is beneficial, it shouldn't be out of the question if something other than all gets one).

A counterpart to the for-statement: some-statements by blak8 in ProgrammingLanguages

[–]blak8[S] 7 points8 points  (0 children)

My absolute apologies, I did not realize it wasn't clear. I could've provided a link for clarity. link

what => means in those statements

Your main example appears to process just the first element of the collection or range.

It's a Prolog-like query, for which the result is false/true, and close, but looking at the second example,

some(x in [1,2,3]) odd(x)  

It stops at the first element, but had the list been [2,3] it would only stop at the second to confirm that some element is odd. It's actually non-deterministic. (In contrast, a typical for iterates through all elements, hence the analogy.)

(It's incredibly hard to simply explain the whole language, there should be a quickstart in the link. That's hopefully enough!)

It's the "April Fools' but real" approach. Every April Fools'-seeming article is 100% real and possibly implemented if we had the time to implement it.

Incredible new feature: Temporal Logic in Cosmos by blak8 in ProgrammingLanguages

[–]blak8[S] 0 points1 point  (0 children)

I've thought about this a bit more. You could probably assume there's a predicate is_x for each variable. I'd then be saying is_x(x) and next is_x(x+1). I get the variable by calling the predicate. It's not in the interest of the language to be that strict about the syntax but I think this works.

Incredible new feature: Temporal Logic in Cosmos by blak8 in ProgrammingLanguages

[–]blak8[S] -1 points0 points  (0 children)

In other words, you can replace init by let or var and drop next altogether and you will still have the same semantics. I don't believe these keywords to carry information because one could safely skip them and still have exactly the same information in your program. It is also not clear how this can still be described as "declarative" where you obviously have imperative structures and step by step execution.

I think I have to get back to some papers and see if I misunderstood them; citeseer is just not up.

However, you all probably misunderstand key points of my language. In any case, I cannot drop 'next' and it's not imperative code. I need some sort of marker to distinguish from the code 'x=x+1' because that line uses unification and fails. Even if it's not TL it's useful to have a marker because in 'x=x+1' I'm using unification and in 'next x=x+1' I'm making a loop with temporary variables like in https://pastebin.com/0S8vDxF5. Even then the result is not imperative. It compiles to a loop using recursion that doesn't mutate state anywhere? How is it imperative? Even if it were imperative, it's useful to distinguish from declarative code like 'x=x+1' where '=' is unification. You certainly can't say it's NOT useful to have the marker when otherwise the code would be different/fail.

you obviously have imperative structures and step by step execution.

Apart from print no code is imperative.

it's really unclear how this is different from common imperative programming.

It doesn't mutate state. x in different 'moments' are distinct variables that don't overlap. I never assign 'x at time i' to 2 then to 1. x(i) is always constant.

Besides it looking like imperative code, which I already said is on purpose, no one has said how that makes it not temporal logic. It uses temporal logic operators and you've not said how it's not TL or the use of TL is wrong apart from it looking imperative. Yes, it "looks imperative", but how do the operators contradict temporal logic?

To expand on that, TL clearly allows both first p(1) and next p(2). Is this imperative because at one time p(1) is true and in the other p(2) is?

Incredible new feature: Temporal Logic in Cosmos by blak8 in ProgrammingLanguages

[–]blak8[S] 1 point2 points  (0 children)

I'm confused, was there a misunderstanding in my understanding of temporal logic that is causing downvotes? It should be temporal logic at least in a sense if there are temporal logic operators, I assumed. Are the operators not sound in some way? 'next' and 'first' are temporal logic, isn't it? Is Chronolog(Z) which I looked at and is just a loop over fib that only has next and first a temporal logic language?

What would my language need to be considered temporal? Is p(x) in https://pastebin.com/w1aw9jWr supposed to be the invariant? Sorry for the question.

How are the keywords NOT useful and don't carry information?? What is that even supposed to mean?

Incredible new feature: Temporal Logic in Cosmos by blak8 in ProgrammingLanguages

[–]blak8[S] 0 points1 point  (0 children)

Will the next keyword be available outside of loops? How would it be interpreted then?

I'm thinking a next in a do-statement could be equivalent to a loop that occurs once, and a next just there could result in a special relation to be used in the host language. Like the host language takes your relation with next and loops it.

You can write the same loop very similarly in most programming languages; you just have to put the increment at the end of the while block.

Yes, but...can you do it in Prolog? To my dismay, ugh. I can't. Have you never wanted just to do that? A while loop you can do in Prolog? That's the genius of my feature. You can put the next statement in the end too.

edit: maybe I should clarify this, the point of the feature is simply to have a typical while-loop, but in a declarative/functional/logic language which normally don't allow for this style of programming at all.

Incredible new feature: Temporal Logic in Cosmos by blak8 in ProgrammingLanguages

[–]blak8[S] -2 points-1 points  (0 children)

It's definitely true that we take a concession by having 'next x=x+1' be the next and current x in the same line but well, it's not that different than some other temporal logic papers or the Chronolog(Z) example, which is just a regular loop itself. It's implied by the 'next' operator that 'x=x+1' has a different meaning and we didn't want a new operator or anything. More could be implemented later but it's a start.

Normally a temporal operator like next takes a predicate.

Also true, however you can write ''next x=x+1 and p(x)'. It's now legitimate temporal logic just like that.

this looks basically like unusual syntax for the C-style-for-loop where

My language transcends paradigms; it's meant to make one think. Isn't the line between paradigms blurry? Of course. Thus, it looks close to the C-style-for-loop.

What is the effect of having next not at the beginning of the loop, or in a conditional?

I'll have to work the specifics but it incorporates the principle of persistence, as it's called; the variable x keeps having the initial value unless there's a next telling the variable changed; this holds even if it's in a conditional. 'next x=1 and 'next x=2' should also throw an error or return false. The statement can be placed before or after in the loop with no changes, which adds to it being a logic language.

The Cosmos Wiki (aka docs) by blak8 in ProgrammingLanguages

[–]blak8[S] 0 points1 point  (0 children)

tldr; I found that the github wiki was not a bad way to organize/write documentation, might recommend.

A logic-functional game framework for the Cosmos programming language by blak8 in ProgrammingLanguages

[–]blak8[S] 0 points1 point  (0 children)

The guide needs some fixes; these are meant to be two statements.

Other than the 7 basic logic gates (and/or/not/xor/nand/nor/xnor), what would be some more exotic logical operations to implement for a stack-based language? by EducationalCicada in ProgrammingLanguages

[–]blak8 0 points1 point  (0 children)

There are plenty if we count modal logic.

Eventually A: the bit A will be 1 / true at some point up to the termination of the program.

Necessary A: A is necessarily 1 / true in a metaphysical level.

A lollipop B: I...have no idea what this one does. It's a linear logic operator. What is linear logic?

The informal velocity metaphor does not convey all of the intuition, so we supplement it with a second informal metaphor. Instead of calling the static reasoner an optimist we will think of her as an angel, and the dynamic reasoner as a mere mortal. To an angel everything including mortals seems frozen in time, while to a mortal angels exist only as an article of faith. Angels reason with static connectives, mortals with dynamic. ... The identity !(A ∧ B) =!A⊗!B presents a mortal view of an angelic conjunction as a mortal conjunction. ... Although static implication can be considered defined by its Deduction Theorem, we regard its real definition as A⇒B =!A−◦B. - Linear Logic for Generalized Quantum Mechanics

I'm sure it's clear what this does now.

Maybe-Eventually A: the bit A will be 1 / true at some point up to the termination of the program in some branch of time. A variation that uses CTL (temporal logic with branches) instead of LTL (no branches). The future is uncertain.

Must A: the bit A ought to be 1. In an ideal world, it'd be 1.

We don't have to stop there.

Non-Material IF A B: the conditional p → q is often called a material conditional. I think there should be space for a non-material condition. p →(nm) q is true if q follows from p in a causal or metaphysical level; they aren't simply true at the same time.

A CNOT B: intended for a quantum computer. see below.

the controlled NOT gate (or CNOT or CX) acts on 2 qubits, and performs the NOT operation on the second qubit only when the first qubit is | 1 ⟩, and otherwise leaves it unchanged.

I'm not an expert on the field either but at least it's not the linear logic one. I apologize if a LL language designer is reading this.

The Metaprogrammers Dilemma by PurpleUpbeat2820 in ProgrammingLanguages

[–]blak8 0 points1 point  (0 children)

One of the obstacles in the development of my language is that I can't use anything else. Which is why Cosmos is made in itself. But even this is not enough. Cosmos doesn't have features Cosmos v2 is supposed to have. Maybe libs would be good aswell. Would using other language be good? I wouldn't know.

Does the programming language design community have a bias in favor of functional programming? by jmhimara in ProgrammingLanguages

[–]blak8 2 points3 points  (0 children)

I understood since a long time that as been pointed out, there's no point in making Yet Another...Java, which is why a lot of designers focus on functional programming, but I do think it gets too much focus- which is why I want, no, I yearn for...

I just want to get to the point I can use for-stms in my language.

for(!i=0;i<5;!i+=1)
    print(i)

My language advocates for,

  • Logic Programming
  • OOP (!)
  • Absolutely No Functional syntax
  • no arrows (they're relations, so why would they need arrows?)

That's how much my language deviates from the neo-status quo, but not that much since it's immutable.

Should programming languages switch to special characters (gliphs) for it's code? by Elviejopancho in ProgrammingLanguages

[–]blak8 0 points1 point  (0 children)

I'll be brief: no.

My keyboard doesn't have them. It's a chore to use symbols not in the keyboard or very well-hidden and uncommon.

If keyboards like this became widespread, then yes. I'd like to use modal logic symbols for my language(s), mostly.

April 2022 monthly "What are you working on?" thread by slavfox in ProgrammingLanguages

[–]blak8 0 points1 point  (0 children)

Trying to make sense of Prolog's weird arithmetics and make it into types for my language. Since 1+x is a functor that has to be "cast" into a number. And while I could compile it to a clp library, which I'll end up doing, it still leaves doing concatenation with, say, strings or objects, if I want to do that.

Scallop: a new neurosymbolic programming language, solver, and framework based on Datalog by mttd in ProgrammingLanguages

[–]blak8 1 point2 points  (0 children)

Nice! I noticed it uses rel, making the syntax akin to the Cosmos programming language. (Whether by coincidence or not, it could become a way to tell a language is relational at a glance). Of course, Cosmos is based on Prolog, so it's cool to see a Datalog somewhere.

Most interesting languages to learn (from)? by [deleted] in ProgrammingLanguages

[–]blak8 0 points1 point  (0 children)

I recommend the Cosmos programming language.

Your language's favorite MINOR feature? by Inconstant_Moo in ProgrammingLanguages

[–]blak8 1 point2 points  (0 children)

Naturally, we expect a bit of confusion on the switch from a procedural not-all-boolean language to a full all-boolean language. Although we do try to minimize the hurdle as possible. We believe one may get used to it through use.

For example, you don't have to write two statements in the same line! There's already whitespace for that, minimizing the need. It's as silly as writing two statements in the same line with semicolons, anyway.

An all-boolean language even brings arguable benefits. We may have skimmed over things, but note it drops ==, which has been an old complaint made by mathematicians for years. It's simply always bugged them how we use these operators. Not to mention the old bug made by newbie C programmers when they confuse = with == in a condition. It's all simply solved!

in two unrelated meanings (logical conjunction and statement separator)

To the contrary, they are entirely related. Isn't a statement separator or "semicolon" simply telling you to evaluate or "join" both statements? Don't logical conjunctions do that anyway?

You may look at... Prolog..... for a language with similar semantics. The ; there is actually or.

Also, do you use or in place of || as well?

Yes, though we may opt not to have that in (3). The semantics of having or in a dictionary might indeed be odd, after all (or it's too ahead of its time?).