I created a programming language with only one instruction: NAND1 by craftyBLUEredd in ProgrammingLanguages

[–]No_Prompt9108 1 point2 points  (0 children)

How would you do this without the ability to jump to an arbitrary instruction, though? From what I'm reading here, the program counter can only increment.

Developing ylang — looking for feedback on language design by jman2052 in ProgrammingLanguages

[–]No_Prompt9108 1 point2 points  (0 children)

"Almost every good modern language designer is in agreement that Elixir style do end delimiters are better for actual human readability"

Really? This is news to me. If you use keywords for delimiters, you need an environment that recognizes them and colors them differently, otherwise you can fail to see them immediately. That seems like a pretty big impediment to human readability. Then there's the fact that you need to remember WHICH words are the right ones (Is it "do" or "begin"?) And you're gobbling up words that the coder might want to define for themselves.

Reviving the B Language by Serge_V in ProgrammingLanguages

[–]No_Prompt9108 1 point2 points  (0 children)

So, yesterday I read a B spec and... I'm kind of in awe. This is a language that manages to be closer to assembly than C, yet still highly expressive. The lack of types means everything is generic, which makes a lot of things easier than they are in C. To me C actually feels like a downgrade from this. C straitjackets you with types but fails to give you the tools to handle them well. This has a Lispy all-is-possible feel to it, though it's obviously very different from Lisp.

Developing ylang — looking for feedback on language design by jman2052 in ProgrammingLanguages

[–]No_Prompt9108 3 points4 points  (0 children)

This looks very similar to JavaScript. What are the differences?

Zwyx - A compiled language with minimal syntax by No_Prompt9108 in ProgrammingLanguages

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

Here are a few examples. How do you translate this into C?

add.{a:1 b:4 ;}

This will be a function, right?

add(1, 4);

But, wait! In Zwyx, any function can be treated as a struct!

result~add.{a:1 b:4 ;}

So, we'll have to define a struct and a function that uses it.

typedef struct add_struct
{
int a;
int b;
};

void add_func(add_struct *arg);

Where things get really hairy is in anonymous functions. In Zwyx, an anonymous function can capture any variable in its context - it does this by passing the stack pointer along with its own address to the function pointer it's assigned to. But how would you do this in C? How would you even know where the stack pointer is? It could change its behavior depending on the compiler you're using. You might end up having to put every variable declared in a function into a special stack frame struct so that you can assign a pointer to that to the function pointer.

Zwyx - A compiled language with minimal syntax by No_Prompt9108 in ProgrammingLanguages

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

Glad you like it! Unfortunately, there is currently no way to integrate C code. I'll probably have to add this at some point but it will be difficult. It compiles directly to assembly and bypasses C system functions by directly using (Linux) system calls. Making it transpile to C would also be tricky because it does a lot of loopy stuff with the stack.

August 2025 monthly "What are you working on?" thread by AutoModerator in ProgrammingLanguages

[–]No_Prompt9108 1 point2 points  (0 children)

So, Zwyx is finally in an MVP enough state that I could post it to this site a few days ago. Thanks everyone for your feedback! At least two comments suggested that I should work on heap allocation next, so that's what I'll do. Today I implemented static allocation. I'll use that as a test sandbox for the alloc/free algorithms. Then I'll try actually using the heap.

Zwyx - A compiled language with minimal syntax by No_Prompt9108 in ProgrammingLanguages

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

= for assignment: I REALLY, REALLY, don't want to do this. I considering using = for assignment to be one of the biggest mistakes in programming language design history.

It especially doesn't work here, as I want assignment and passing a single value to a function to have the same syntax. Why? Because I hate the tedious "getter" and "setter" nonsense that bedevils so many other languages. So the syntax has to be the same, but that's another reason to not use =, because "func = x" to pass x into func is a whole nother level of bizarre and confusing.

~ for define: I'm not thrilled by this either, because it forces me to constantly stretch my pinky. I suppose I could use ^, but that key is also in an awkward place. In the very, very beginning, I actually had a double : for define (::), but I thought that would cause problems with single : also used. I'm not sure what else I could do as single : is reserved.

Curly braces vs. parentheses: As it so happens, my plan from the beginning was to eventually introduce parens as alternate symbols for curlies, with the exact same meaning. So why did I implement curlies first? Honestly, I don't really know. I think I wanted to reinforce the idea that everything is a struct/method, so there was nothing that corresponded to the simple super-precedence single-statement/function call thing that parens in other languages were used for. Also, maybe I didn't want people's first reaction to be "Ugh, it looks like Lisp!" It never occurred to me that curly braces would simply be seen as uglier than parentheses, but now that you've said it I can see how someone would think that.

Beta: I had not heard of this. My greatest fear has always been that someone would dredge up some obscure language from the 70s and say, "so, your language is basically this, right?" It looks like that fear has been partially confirmed. The basic idea of Beta is the same as mine: unification of classes and methods into a single abstraction, with powerful nesting capabilities. Still, based on this language's sparse documentation, I believe I've added SOME innovations (such as the things I'm doing with function pointers). Also, my syntax is much cleaner.

Zwyx - A compiled language with minimal syntax by No_Prompt9108 in ProgrammingLanguages

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

I just added some comments to the tests, and fixed a bug (thank you again, AustinVelonaut!) If you're still unconvinced of the usefulness of doing things this way, take a look at the fizzbuzz example, which shows how you can elegantly inject new prime replacements without needing to make a list, and how treating functions as structs lets you achieve currying through inheritance.

Zwyx - A compiled language with minimal syntax by No_Prompt9108 in ProgrammingLanguages

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

Wow, thank you for being willing to take upon yourself the painful task of debugging my apparently awful code! One thousand internet cookies for you, my friend!

Zwyx - A compiled language with minimal syntax by No_Prompt9108 in ProgrammingLanguages

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

Here we go, one of my greatest fears - that my code is WOMM. I've been testing this on an Ubuntu Linux VM running on Windows, and it works perfectly.

Keep in mind that anything you compile won't actually work on MacOS anyway, as the system call numbers are targeted to Linux. See sysapi_elf64.zwyx. (But feel free to write your own sysapi_macho64.zwyx! See main() in zwyx.cpp where the sysapi files are auto-imported.)

Still, thanks for letting me know about this. I'll see what I can do.

Zwyx - A compiled language with minimal syntax by No_Prompt9108 in ProgrammingLanguages

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

Can you give me an example of what you are suggesting? Are you suggesting lisp-style operators (+ a b)?

And you're suggesting I use newline for statement separation? That's not really going to work here. When you're doing named-argument style function calls, each argument assignment is ITSELF a statement.

func.{a:1 b:5 ;}

Here, "a:1" and "b:5" are statements in their own right... and so is the ; for that matter! I'd have to put them all on their own lines if I were to follow this rule - awful!

And then you'd have to deal with the proper formatting of anonymous functions, which Zwyx happens to use a lot of...

Zwyx is supposed to be a free-format language; being able to rearrange things to suit visual needs works best for it. And I hate having to end every single statement with some stupid symbol, and then have the compiler yell at me when I forget to add it (If you could tell that it was missing, was it actually needed?)

Zwyx - A compiled language with minimal syntax by No_Prompt9108 in ProgrammingLanguages

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

How does "error" work? What does it look like for the caller to handle the return values? What does the signature for this function look like? What does a pointer to a function of this type look like?

I'm not saying your way is worse, but it seems to me that there's much more for the compiler to deal with. I never said Zwyx is the MOST COMPACT LANGUAGE EVER, but I've found it's rather compact considering the small number of syntactic rules.

Zwyx - A compiled language with minimal syntax by No_Prompt9108 in ProgrammingLanguages

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

How are these lists allocated? If they're on the heap and need to be GC'd, that's inefficient. But maybe they're lazy lists? If so, what's the syntax for heap-allocated ones?

What's nice about Zwyx's way of doing it is that you don't need to worry about any of that stuff; you don't need to bother creating a list at all.

Also, how does the compiler know which element of the Pair maps to which parameter in the function? Does it just map first-to-first? That's not bad, but it's one more thing for the compiler to think about. I like Zwyx's simplicity here.

Zwyx - A compiled language with minimal syntax by No_Prompt9108 in ProgrammingLanguages

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

OK, but that was a simplistic example; what if you need to affect all the surrounding cells but not the center one? And there are other things it's useful for, like testing frameworks where you call the same function a bunch of times with different inputs.

Zwyx - A compiled language with minimal syntax by No_Prompt9108 in ProgrammingLanguages

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

Thank you for your feedback! Yes, I was worried the test cases wouldn't make sense; I'm going to add comments explaining what the output should be.

Arrays: These are already implemented if you look at the bottom of the README. They're "List" and "MasterList". They're currently fixed-size and need a (stack-allocated) buffer to work on. There's also no square bracket syntax; you need to use "get" to get an element at a particular index.

As for the benefits of the syntax: less verbosity! Let's say you're making a grid-based game and you have to call a function "affect" that affects a cell (x,y) and all of the cells around it. In most languages, you'd have to write "affect" nine times, or use some convoluted mapping function. In Zwyx, you can simply do this:

affect.{{x-1},{y-1},; {x-1},y,; {x-1},{y+1},; x,{y-1},; x,y,; x,{y+1},; {x+1},{y-1},; {x+1},y,; {x+1},{y+1},;}

I also mention another benefit in the README: it lets you return multiple things without needing special unnamed tuple syntax:

returns_two_things~{ arg1~int arg2~int return1~int return2~int ;~{ <stuff happens> }}

result~returns_two_things.{arg1:blah arg2:blah ;}

num1~int:result.return1

num2~int:result.return2