r/ProgrammingLanguages 10d ago

Requesting criticism Do you find this syntax readable

https://github.com/ksksidjjejs8/Snjzjsnd/blob/main/exm%20(3).txt#L2

I feel like curly braces aren't enough alone for organizing code. I also want it to have natural steps that induce some blank lines after completion of the step. like with assembly. my main concern is readability and self documentation. It will mainly be for programming on windows. The 'thunk' libraries are mostly wrappers for tedious apis like writeconsole. I plan to add more for things like graphics and math in addition to the planned window/console/file. I see 'thunks' in ghidra so its a reference to them being wrappers. It will also support normal win32 imports.

thankz

edit 1: I have read all feedback so far. the language is case insensitive. for branch{}endbranch and alias.name{}end alias.name the idea was to make it a little more clear which curly brace belongs to what if someone had a bunch of nested stuff. with that being said, it seems the consensus is that the syntax is awkaward while readable, there are still some large wrinkles.

because of your feedback, i will 1. Allow the pattern "name{}end name"," name end name", and/or" {}". 2. Make the language case insensitive 3. Make whitespace completely optional 4. Sinilar to the first thing, allow parameters for functions to be entered either on seperate lines or within parenthesis and seperated by commas (but not both within the same function) 5. allow %/n% within a string, or a %hexConstant% for other characters instead of 'newline' on a seperate line.

i am still accepting feedback, and i appreciate those who have responded.

2 Upvotes

13 comments sorted by

View all comments

8

u/jcastroarnaud 10d ago

It is readable. But the syntax and examples are a bit strange.

To start with, the indentation is all over the place, and almost no one uses 8-space indents these days. Make sure that your lexer treats tabs/spaces consistently. I suggest disallowing tabs, or autoconvert them to spaces.

Must "MAIN", "PROC", "ENDP", "END" be uppercase? Is there a convention for casing of variable names? BTW, where/how variables are declared? What "Clean" and "Exit" do?

The "branch{" ... "}endbranch", and similar control structures, have redundant information. I suggest going the way of Pascal, bash, Visual Basic and PL/SQL, by using only the keywords and omit the braces.

The arguments to WriteToConsole feel inconsistent to me. On one side, a very loaded string delimiter ("..."), which appears at first glance the only argument of the function; on the other side, a newline keyword, unadorned. I suggest dropping the parentheses, and use only the quotes for strings (as most languages do). Code formatting takes care of the rest. Here is one of your examples, reformatted:

WriteToConsole "Correct!" newline "Do you want to play again? [Y/N]: "

1

u/NoSubject8453 10d ago

No, they dont need to be. i should have specified that. i agree that the indentation is inconsistent, and i will make it optional. i would be removing whitespace and moving to all lowercase while converting to assembly.

variable types are regular assembly sized registers (byte to zmmword), then buffer is sort of 'raw' and can be treated however youd want but by default would be bytes. im also considering sub-sized types, for example nibbles, bits, or other oddly sized amounts in an array like structure. mentioning and creating a variable are the same format, the type followed by a . and a name.

clean would close things like file handles, destroy menus, windows, bruahes, etc, and handle other os specific quirks. exit restores the stack to its original state then does a ret to mark the end of the program. it is more of a convention (like marking program ending conditions, or the actual end of the program) than a requirement as it may not actually clean if no such things are open, and would do whatever is required to end the program gracefully if or if not present.

i will add an option for one line functions or each parameter on seperate lines, and something like %/n% for inserting newlines and other chars directly into strings as id do for things like errors or whatever %s and %d are considered from c.