Sign in to follow this  

Just another thought (designing a fast but powerful language)

This topic is 1426 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Well, if we define a stupid metric, we'll get stupid code:

bool any(vector const&v){return find(v.begin(),v.end(),1)!=v.end();}
i don't like code like that and i could never write that. Code should be clearly written and understandable.
The any() wins in this case.

Share this post


Link to post
Share on other sites
{} to me makes code clearer and arranged even more than begin and end. If you removed the {} from all the code in that 390,000 LOC program, you could get >= 90,000 less lines of code but also an unfunctional and probably unreadable program.
@alvaro: after that, your program has 2 lines, the return part and the function name part.

Share this post


Link to post
Share on other sites


Perhaps you didn't mean to compare an iterator and a boolean constant...

 

Correct, I did not.  The perils of writing unchecked code (I went back and fixed it). ;)

 

As has been pointed out, it's also not the most efficient way of writing the function, but it served to illustrate the idea I was trying to get across.

 

Something I also meant to mention earlier, but forgot to, is that there is a downside to having a lot of built-in functions.  Sure it allows for writing less code, but imagine there was a language with 10,000 built-in functions.  Trying to remember them all would be near impossible, and implementations of the language would be too big to be usable.  The best languages strike a happy medium somewhere between that and assembly.

Share this post


Link to post
Share on other sites

Perhaps you didn't mean to compare an iterator and a boolean constant...

Sure it allows for writing less code, but imagine there was a language with 10,000 built-in functions. Trying to remember them all would be near impossible, and implementations of the language would be too big to be usable. The best languages strike a happy medium somewhere between that and assembly.
10,000 is huge! Assembly?

Share this post


Link to post
Share on other sites


10,000 is huge! Assembly?

 

Yes, 10,000 is huge.  I deliberately chose it as an over-exaggerated example.

 

Assembly is the complete opposite. It has an extremely limited number of commands.

Share this post


Link to post
Share on other sites

 


10,000 is huge! Assembly?

 

Yes, 10,000 is huge.  I deliberately chose it as an over-exaggerated example.

 

Assembly is the complete opposite. It has an extremely limited number of commands.

 

what? pc assembly got a hundreds of different commands with different adressing modes and many characteristics for me very hard to memorize (dont know how many but this is not small amount)

Share this post


Link to post
Share on other sites


what? pc assembly got a hundreds of different commands with different adressing modes and many characteristics for me very hard to memorize (dont know how many but this is not small amount)

 

Many of them are just variations of one another.

Share this post


Link to post
Share on other sites

i took a somewhat different approach to the issue of increasing productivity by reducing typing (lines of code).

 

i wrote a macro preprocessor for C/C++.

 

i can code in a shorthand macro language, then run it through the macro processor to expand it into full blown c++ code.

 

the macro language (Cscript) allows me to freely mix macro and c++ code for maximum flexibility.

 

translation speed for the macro processor is on the order of 100,000 lines per second. so it only adds a second or two to the build pipeline.

 

i now do all my coding this way.  

 

legacy code can be edited in c++ syntax.   new code or large changes can be done with the faster Cscript.  and complex expressions can always be done in c++, even in the middle of a block of Cscript code.

 

i considered writing a compiler, but determined that a macro processor got one the best of both worlds: an easy scripting language designed to minimize keystrokes, and the full power of commercial quality c++ compilers.

 

http://www.gamedev.net/gallery/image/4227-cscript-code-generator/

Share this post


Link to post
Share on other sites

After reading the wikipedia article on functional programming, i see that that's where c++ got recursivity from and functional programming seems to be concerned with only mathematics.

 

Functional programming is a programming paradigm and C++ inherit recursion directly from C and not from functional programming (officially C++ acquires functional programming capability  with the 2011 standard).

 

Recursion is a (powerful) methodology to find a solution of a problem starting from a mathematical definition of it, and it is not strictly dependent to functional programming paradigm. Note also most of times you can switch from recursion to iteration (and even vice versa) with just some "mechanical" steps..

 

@apochPiQ: that's why i started the thread. You could just talk about some things that are more important.
Thanks smile.png

 

To begin, you should tell us what the goals of this "new programming language" are. And these are not:

 

Would it be possible to make a compiled language as fast as c and c++, multi paradigm like c++, less complex than them both and can be used like in really complex situations like in making an OS/game engine/IDE etc.

Edited by Alessio1989

Share this post


Link to post
Share on other sites

Ultimately, its my belief that for a new language to be successful today, it has to be compelling in a way that's not already cornered by existing languages. Its not enough to say "My language will be as fast as C++, just as general-purpose, but with a smaller, more-regular, and more-expressive syntax." Even if you achieved all those goals in spades, you will have only an "interesting" language -- one that can be admired for its achievements but still for which almost no one will be willing to retrain their programmers for, or use in production. All existing languages have momentum no matter how bad, your new language has effectively zero momentum no matter how good. Its exceedingly difficult to overcome that disparity without offering something more than a subjectively-better new-old-thing.

Most of the very successful languages have hitched their wagons to emerging/popularizing programming paradigms or development styles. Their sales-pitch was not "A better way to do the same old thing." but "The best way to do the hot new thing." C hitched its wagon to being the first truly usable high-level language that could achieve near-assembly-language levels of performance. C++ hitched its wagon to being the first usable OOP language that, was compatible with C and achieved basically the same performace. Java pitched itself as being the code you wrote once and ran everywhere. C# pitched itself as being the premier language for rapid application development. Perl pitched itself as being the premier language for text processing. Python as the universal scripting language. Lua as the scripting language for games. Javascript as the near-accidental king of client-side code on the internet.

Any new language today that cannot find its pitch, and a voice strong enough to shout above the cacophony of other boisterous languages is doomed.

so it has to do a whole new thing that no language has done.
Like 3sweep plans to do for the 3d world. It's doing the same thing 3d modelling software does but it a way that is new, unbelievably easy and shockingly awesome (I had the same idea until someone pointed me to 3sweep).
It does old things in a completely new way.
The 3sweep of the programming world.

Share this post


Link to post
Share on other sites
In my thoughts, i've created a google chrome style browser with less than 300 lines of code. It involves some sort of AI and the language uses specify a lot.

specify object:
specify object function
{
}
I can't seem to think of console programs in the language. Only GUI programs.

Share this post


Link to post
Share on other sites

In my thoughts, i've created a google chrome style browser with less than 300 lines of code. It involves some sort of AI and the language uses specify a lot.

… and if you could actually do that sort of stuff in the real world instead of in your thoughts, Google (and lots of other companies) would throw so much money at you that you could end all poverty and still have more money than you could ever spend.

If we're going to go all dreamy, I can think of a machine that looks like a really cool hat that you can wear, and makes every game idea you'll ever think of magically appear fully created with the best graphics and gameplay ever. You don't even have to type a single line of code. How can any other invention ever beat that for game development? It'll use some clever neuro-science or something, and you have to focus on your idea for 10 seconds.

There is a world of difference between "I've got this fantastical magical thought-concept for something - I'm sure it's going to be awesome" and "This is a fully-functioning realization of an idea".
The former is easy. Ideas are generally easy.
Execution is hard.
it just seems right and mine involves coding.
I need to think more.
I heard never throw away an idea.

Share this post


Link to post
Share on other sites


I need to think more.

There is an old saying I've been told for years that I think applies nicely to that: "Think less, code more."


I heard never throw away an idea.

That is true. Every game idea I have had, I have wrote into a series of notebooks. If you don't have them, get notebooks to write the idea in or type up the idea, print it out, and then store them in a binder. Above all else, code, always code, even if you just do tests for ideas, you must always code something as it will help you improve.

Share this post


Link to post
Share on other sites

I need to think more.

There is an old saying I've been told for years that I think applies nicely to that: "Think less, code more."

I heard never throw away an idea.

That is true. Every game idea I have had, I have wrote into a series of notebooks. If you don't have them, get notebooks to write the idea in or type up the idea, print it out, and then store them in a binder. Above all else, code, always code, even if you just do tests for ideas, you must always code something as it will help you improve.
I will. I have several ideas in several notebooks, i don't really like typing down my ideas.

Share this post


Link to post
Share on other sites

In my thoughts, i've created a google chrome style browser with less than 300 lines of code. It involves some sort of AI and the language uses specify a lot.

specify object:specify object function{}
I can't seem to think of console programs in the language. Only GUI programs.

Are you planning to write a compiler for this language you have in mind?

Yeah. An ide.
Won't i have to?

Share this post


Link to post
Share on other sites

 

 

Yersterday, i read an article saying that ruby/python programs involve 5x less lines than c and c++ programs. What does this mean?

 

 

dont think so, I was not using python to much but this would

meen (if the function of your code will stay the same and they

if they doing something nontrivial but real code - stay the same)

that every of such function will be compressed  5X of 4X

- i dont see it - it will be about the same [esp if you will remove the blank lines and move code like

 

void f()           {

  if(a==0)        {

      b++;            } }

 

(years ago i was using thic convention, this is not so bad imo)

 

what else python make to short sources compared to c ?

(maybe something but it would be imo more like 20% shorter not 5X 

 

 

You do realize that when we say that Python code is shorter than e.g. C code we're not talking about removing the curly braces and a few comments, right? We're talking about the high-level structure of the code - Python is typically more expressive in less code, because it has a lot of stuff built-in (and cross-platform, for the most part), it's designed for short and concise syntax so that you don't have to implement all the stuff you need manually or use an external library (if even possible, like syntactic sugar).

 

 

 


(if the function of your code will stay the same and they
if they doing something nontrivial but real code - stay the same

 

That's the point - the code doesn't stay the same. It becomes shorter as a lot of the low-level complexity you have to deal with in C or C++ for instance is handled by the language and the runtime itself. Functions disappear because they become built-in, paragraphs of code become shorter because you don't need many lines to declare, initialize and populate a dictionary (key-value store) from a file, you can do it in one, you don't need to formally define complex object relations and dependencies since you have duck typing, variables are automatically freed, nontrivial command-line parsing is built-in and you don't have to go dig up a library on the internet and learn how to use it (more or less everyone uses argparse), big integers are built-in, you can even run Python code dynamically from existing code, etc, etc...

 

If you think Python is just C minus the curly braces then you clearly have never used it. It has its failings and doesn't work for everything (writing a large business application would probably get messy, and it has its warts) but when you use it - or Ruby, by the way, everything I said above almost certainly applies to Ruby even though I've never used it - for what it's meant for, the resulting code is surprisingly short and fluent.

 

 

well, i dont know (i used a python to wrote a simple mandelbrot set viewer a couple of years ago and that is all my knowledge of python)

 

i think 90% of c programs length are user defined labels, the rest is keywords (mostly return float double int) and a dust of symbols (overpresent in c imo)  [your very right about this that declaration 

lines consume space in c thats good point]

 

one could move some code lines by makin things built-in as you said

but could you give some some examples for things that are biult in 

in ptyhon and canot by shortened in c by moving them to library and

just use library (It is maybe possible but i dont see it because idont

know python to this extent)

 

after all i still doubt if python can shorten sources even 3 times not to mention 5 times - the main fail of c is maybe its overuse of symbols here

Share this post


Link to post
Share on other sites


one could move some code lines by makin things built-in as you said
but could you give some some examples for things that are biult in 
in ptyhon and canot by shortened in c by moving them to library and
just use library (It is maybe possible but i dont see it because idont
know python to this extent)

 

You can move the entirety of your program into a library and call it in a single line from your main function. Does that make it the shortest program ever?

Share this post


Link to post
Share on other sites

 


one could move some code lines by makin things built-in as you said
but could you give some some examples for things that are biult in 
in ptyhon and canot by shortened in c by moving them to library and
just use library (It is maybe possible but i dont see it because idont
know python to this extent)

 

You can move the entirety of your program into a library and call it in a single line from your main function. Does that make it the shortest program ever?

 

you could also built-in your program in python so it wold be 1:1

python wouldnt be 5 times shorter or it will be?

 

Im saing that defining things and moving them away of the code 

should be excluded from comparison - I mean if you confront some 

python builtins compare tham against c with library 

 

except when you give examples of things that python could really short and this would be hard to achive in c + lib (Im just interested in examples on this)

Share this post


Link to post
Share on other sites

This topic is 1426 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this