• Forum
  • Lounge
  • If you could create your own language...

 
If you could create your own language...

Pages: 123... 5
Alright females, males, transsexuals, natural hermaphrodites, and unsexed... I'm conducting a poll.

If you could create a Turing complete language right this instant and to your exact specifications... what would it look like? I'd like to have an idea of the semantics and syntax and possible features that current languages either don't have implemented or don't have implemented well. Just curious.

-Albatross
I've messed up with compilers and interpreters in the past ( and I am now too )
A language that I came up with was like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
function_name : ( type1 parameter1, parameter2, type2 parameter3 ) -> return_type =
    if condition =>
         something;
    else
        something_else;
        print value1, value2;
        read variable1, "string that will be displayed between input of the variables", variable2
    .
    return expression;
.

simple_function ( parameters ) -> type = expression .

type variable = expression;

undef function_to_remove_from_scope;
delete variable_to_remove_from_scope;

exit;
I never finished the OOP for it
All the few built-in types ( int, float and string ) were implicitly convertible
The type "null" was used for function with no return value and for variable the type of which was to be determined at the first assignment
I've been doing a lot of work on an experiment I call bi0Script, things are changing in it quite rapidly. So this syntax may change, it certainly has from last week
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
; this is a comment

; the 'use' tag is synonymous with 
; the preprocesser directive '#include'
<use>/home/user_name/CLI.bi0</use>


<class="math">  ; open tag for the definition of
                ; the class 'math' 
	<def="floor","arg1"> ; defines function floor 
						 ; with the single argument 'arg1'
		<operation>	; operation is a tag that 
					; allows arithmatic parsing to occur
			arg1 = arg1 - (arg1 % 1)
		</operation>  
		<ret>arg1</ret> ; 'ret' tag specifies what to RETurn
	</def> ; ending of the function floor
</class> ; ending of the class 'math'

<bi0>	; bi0 tags specify the entry point and exit point to the program
	<var="IOBuffer"> new CLI </var> ; creates an object of the CLI (command line interface) class 
	<var="MathObj"> new math </var> ; creates an object of the math class we just created
	<var="float_val"/>  ; creates an uninitialized var
	<call> ; calls functions
		IOBuffer.put( "Input a floatining point number" ) ; prints the argument to the standard CLI for the OS in use
		IOBuffer.get( float_val )                         ; obtains input to be assigned to the argument from the CLI   
		IOBuffer.put( MathObj.floor( float_val ) )        ; outputs the return value of math::floor with our obtained
														  ; value for float_val
	</call> ;end function calls
</bi0> ; end program entry point


There is still a lot to be done. I'm considering adding a <c++> tag that allows you to drop into c++ for the use of making it more Turing complete.
Make sure there's an <asm> tag, I don't know if a <c++> tag is such a good idea, though.
Why not? Just curious, cause I was thinking it's a bad idea as well, but i'm having trouble with some things :T
I think a <c++> tag is a bad idea because I don't think C++ makes a good language for embedding in other code. An <asm> tag is better, IMO, because it allows for hand-optimization of algorithms and is included in lots of other languages. Admittedly, though, inline asm usually isn't necessary or even a good idea. If I need to use asm in a program, I write the function in a separate file and then declare it extern with a header file. The only problem with this is that you need to know what calling convention the compiler is using; but it's no less portable than inline asm, with which you assume that another person's compiler uses the same assembler as yours.
Last edited on
Makes enough sense..Actually the more I think about it, the more a straight up <C> tag is what is needed and if desired one can just call the inline assembly function included in most modern implementations of C. the only reason I wouldnt favor an asm tag over it is I dont know enough assembly to implement it properly. I'd more then likely add one once I learn more assembly (sepcifically for developing the bytecode output for the *OPTIONAL* compiling of the code into an executable file)
Also, I don't really like the way you create a variable:
<var="foo"> new Foo </var>
I would have done it more like this:
<var name="<name>" [type="<type>"] [value="<value>"] [const="<true|false>"] />
Note that things in brackets ('[', ']') are optional (I would assume "int", "0" and "false" for them, respectively).
Examples:
1
2
3
4
5
6
7
8
<var name="i" type="int" value="0" const="false" /> ; Non-const integral variable called i
<var name="j" /> ; Same as i, but with name "j"
<var name="k" value=i const="false" /> ; Declared equal to i; except const-ness must be explicitly stated. Notice the lack of quotation marks around "i"
<var name="p" type="pointer" value=i /> ; Points to i
<var name="a" type="int[]" /> ; Creates an integer array with no elements
<var name="b" type="float[]" size="5" /> ; Creates a float array with 5 elements
<var name="str" type="string" value="Hello, world!" /> ; Creates a string
<var name="rstr" type="ref" value=str /> ; Creates a reference to str; again notice the lack of quotations around "str"


What do you think?
Last edited on
closed account (EzwRko23)
I think that this language would be terrible to write in.
It is simply too verbose. And it even does not conform to XML standard.
I don't like the <operation> tags, and I will agree that it's a little verbose.
xorebxebx wrote:
And it even does not conform to XML standard.

Who cares? It's not XML!
Definitely a good idea, the only reason I would include the type option though is to specify references, objects or arrays. If I can figure out how to do that implicitly I will likely leave that part out.
Ok, you want a typeless language then? Fair enough. Are you not including pointers? Are you using pass-by-reference?

Edit: I also think you should think about consistancy a little, it looks a little lacking to be honest.
Last edited on
ALSO: as time goes on, and I develop it further. learning new techniques of parsing and interpreting. The language has been becoming simpler and easier to write in. Bare in mind it's not even in the alpha stages yet. I'm barely out of white page designing it, as I still have things I need to figure out how to implement.

EDIT: as for consistancy, like I said, things are changing rapidly :P I'm not even going to pretend to say that it's anywhere near complete. I dont expect it to be consistant elegant or efficient for quite some time.

EDIT EDIT: Yes I'm including pointers, I'm just having trouble getting them to work right :\

EDIT EDIT EDIT: Just compiled a module of the parser that will eliminate the need for the operation tag when preforming mathematic operations inside of a function. huzzah.
Last edited on
Interesting thoughts, interesting syntaxes. Seraphimsan, do send me an alpha or beta copy of the compiler when it's ready, will ya?

Also: What's wrong with verbose languages? A verbose language that's verbose for the sake of being verbose is stupid, but when there's something to be gained from it, I'm all for it personally.

-Albatross
Will do, I'll be sure to post my progress as time goes on. This is a younger project of mine so It'll be a while.
closed account (EzwRko23)

Who cares? It's not XML!


But it looks like and this is confusing.
Why such a strange and irregular syntax? What you gain by this?
How do you perform comparison operations "<" and ">" ?


What's wrong with verbose languages?


More code = more typing = more time wasted.
Verbosity is good if it improves readability. In this case it does not.

I think you should start with a proper grammar first. You do have a grammar file for this?
Last edited on
I think verbose languages are evil. And they're usually verbose because someone thought there was something to be gained, for sure. I know COBOL is the Hitler of programming language discussions, but ADD A TO B GIVING C seemed like a good idea at the time to someone.
Last edited on
I gotta go to class soon so I'll make it sweet and simple. Nothing new or innovative is gained by this syntax. I just liked it and thought it would be fun to try and make.

This project is ENTIRELY for the sake of learning. It may or may not be implemented on a HEAVILY modified version of linux (ERIKA OS) that I've been working on, off and on, for the last 6 months, I dont know yet, nor do i care at this point.

as for those comparisons, I havent coded the boolean evaluation module of my parser yet, but I have some pseudo code around here some where, if I find it I'd be more then happy to share.


I will say again, this isnt meant to catch on or become widely used. It's just a fun little experiment of mine.
Objection.
The Scala fan three posts above me wrote:
More code = more typing = more time wasted.


More code = more typing != more time wasted. If the code for a given operation is short but has semantics that are not intuitive, then one may need to spend more time coding in that language than in a more verbose language that's more intuitive.

EDIT: Aside from that, there are a lot of languages that are verbose that... eh... have a few features that indeed seemed like a good idea at the time.

-Albatross
Last edited on
Are you capable of visiting threads without ruining them with your incessant trolling? Frankly, I'm getting sick of it.

xorebxebx wrote:
But it looks like and this is confusing.

That argument is completely ridiculous. One thing looks like another, therefore it should be exactly the same? Really?

xorebxebx wrote:
Why such a strange syntax? What you gain by this?

The syntax is a little verbose and inconsistent, it's true, but it's no "stranger" than many other languages. Not to mention, "strange" is a subjective term in this context and isn't really applicable here anyway.
Pages: 123... 5