What would your ideal programming language be like ?
Moderator: Moderators
Re: What would your ideal programming language be like ?
I'm gonna create my own programming language, with Blackjack and Hookers. 
Re: What would your ideal programming language be like ?
I figured a trick to code in C without the horrible braces using the pre-processor. However, it probably has more drawbacks, for the simple advantage of sometimes avoiding braces.
Advantates :
- Column can be used for FOR instead of semicolun
- Parenthesis for if, else and for compoud statements. No more finger-torturing for europeans who happens to have braces which aren't as accessible as american keyboard
Drawbacks :
- Compiler errors could be more criptic
- Imposibile to use ',' within directly a compoud statement (could be an issue when declaring variables)
- Compoud statements are mandatory (otherwise a normal if/else/for should be used instead)
- Braces STILL have to be used for funtions
- Brackets STILL have to be used for acessing arrays
- Many people will dislike this non-standard way of C coding
More extreme and simpler is to define BEGIN and END macros for braces, and end up with pascal-style code. I am however not fan of this, "BEGIN" or "END" are as annoying as braces to type if they have to be in caps. In lowercase it could become closer to be a match, but that's encouring the risk of conflicting with the actual code.
Advantates :
- Column can be used for FOR instead of semicolun
- Parenthesis for if, else and for compoud statements. No more finger-torturing for europeans who happens to have braces which aren't as accessible as american keyboard
Drawbacks :
- Compiler errors could be more criptic
- Imposibile to use ',' within directly a compoud statement (could be an issue when declaring variables)
- Compoud statements are mandatory (otherwise a normal if/else/for should be used instead)
- Braces STILL have to be used for funtions
- Brackets STILL have to be used for acessing arrays
- Many people will dislike this non-standard way of C coding
Code: Select all
#define IF_SUB(program) {program}
#define IF(condition) if(condition) IF_SUB
#define ELSE(program) else{program}
#define FOR_SUB(program) {program}
#define FOR(init, cond, incr) for(init; cond; incr) FOR_SUB
#include <stdio.h>
// Let's test the above macros
int isprime(int n)
{
int i;
IF(n < 3)
(
return 1; // Numbers smaller than 3 are prime
)
FOR(i=2, i<=n/2, ++i)
(
IF((n%i) == 0)
(
return 0;
)
)
return 1;
}
int main()
{
int i;
FOR(i=0, i<16, ++i)
(
IF(isprime(i))
(
printf("%d is prime.\n", i);
)
ELSE
(
printf("%d is not prime.\n", i);
)
)
}Re: What would your ideal programming language be like ?
Not as bad as CDiv (although to their defense, CDiv was doing some really weird stuff rather than just making alternatives to the syntax).
Re: What would your ideal programming language be like ?
And what is CDiv, may I ask ?
And yeah I agree it's not really a good idea to do non-standard stuff like that.
And yeah I agree it's not really a good idea to do non-standard stuff like that.
Re: What would your ideal programming language be like ?
Some attempt to get DIV (a game-centric programming language) style programs on top of C... erm, yeah.
Re: What would your ideal programming language be like ?
Now I have another crazy idea. Since you only need variables, ifs and gotos in order to have turning completeness, there is no point in supporting anything else.
But instead of supporting only IFs and GOTOs, I'd rather support only SWITCH statements. Why ? Because switch is definitely more elegant than a long chain of if-elsif-elsif-elsif-else, so even if not technically needed it's a nice ehancement of the "if" that is nice to have built-in the language. A traditional if/else is a switch with only one option and a "default" options, and a if alone is a switch with one option and no "default".
When it comes to loops, they could be simulated with tail recursions into functions that are pre-build in the language, so that when you use them, they appear to be loops. That way, we get loops and don't need the ugly GOTO statement.
So just functions and switch would be enough to build a programming language.
As for types, the more I think about it, the more I belive a programming language without an integer type like I described before is actually not that good of an idea. However, a programming language supporting only integers, and building other types based on integers sounds like a better idea (actually that's why is done in C).
But instead of supporting only IFs and GOTOs, I'd rather support only SWITCH statements. Why ? Because switch is definitely more elegant than a long chain of if-elsif-elsif-elsif-else, so even if not technically needed it's a nice ehancement of the "if" that is nice to have built-in the language. A traditional if/else is a switch with only one option and a "default" options, and a if alone is a switch with one option and no "default".
When it comes to loops, they could be simulated with tail recursions into functions that are pre-build in the language, so that when you use them, they appear to be loops. That way, we get loops and don't need the ugly GOTO statement.
So just functions and switch would be enough to build a programming language.
As for types, the more I think about it, the more I belive a programming language without an integer type like I described before is actually not that good of an idea. However, a programming language supporting only integers, and building other types based on integers sounds like a better idea (actually that's why is done in C).
Re: What would your ideal programming language be like ?
Yes, that can be good, and everything else can be done with macros, then.Bregalad wrote:Now I have another crazy idea. Since you only need variables, ifs and gotos in order to have turning completeness, there is no point in supporting anything else.
Actually I too thought of rather a kind of switch and goto combination as the flow control at the end of a basic block, and then use "register forwarding" between basic blocks; loops (and everything else too, other than some function calls) then basically become a kind of tail recursion just from that.But instead of supporting only IFs and GOTOs, I'd rather support only SWITCH statements. Why ? Because switch is definitely more elegant than a long chain of if-elsif-elsif-elsif-else, so even if not technically needed it's a nice ehancement of the "if" that is nice to have built-in the language. A traditional if/else is a switch with only one option and a "default" options, and a if alone is a switch with one option and no "default".
[url=gopher://zzo38computer.org/].[/url]