Jump to content

  • Log In with Google      Sign In   
  • Create Account

Just another thought (designing a fast but powerful language)


Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
77 replies to this topic

#21 Nathan2222_old   Members   

-396
Like
0Likes
Like

Posted 18 February 2014 - 07:28 AM

What do you mean by functions disappear etc.?


Imagine I had the following function in C++:
bool SomeElementIsTrue(std::vector<bool> vec) {    for(std::vector<bool>::iterator it = vec.begin() ; it != vec.end(); ++it)        if (it == true)  return true;    return false;}
If I converted my program to Python, I can remove the entire function, and use the built-in 'any' function.
that is a lot of line difference :o.
Instead of that, you use:

any()
-6 lines for you and -7 for me.
That is exactly what i meant by reducing the amount of code needed to be typed to do something.

UNREAL ENGINE 4:
Total LOC: ~3M Lines
Total Languages: ~32
smile.png
--
GREAT QUOTES:
I can do ALL things through Christ - Jesus Christ
--
Logic will get you from A-Z, imagination gets you everywhere - Albert Einstein
--
The problems of the world cannot be solved by skeptics or cynics whose horizons are limited by the obvious realities. - John F. Kennedy


#22   Members   

20267
Like
0Likes
Like

Posted 18 February 2014 - 07:52 AM

What do you mean by functions disappear etc.?

 
Imagine I had the following function in C++:
bool SomeElementIsTrue(std::vector<bool> vec) {

    for(std::vector<bool>::iterator it = vec.begin() ; it != vec.end(); ++it)
        if (it == true)  return true;

    return false;

}
If I converted my program to Python, I can remove the entire function, and use the built-in 'any' function.


If I wrote that program in C++, I could remove the entire function and use the library `find' function, or just provide a one-line implementation of the function:

bool any(std::vector<bool> const &v) {
  return std::find(v.begin(), v.end(), true) != v.end();
}
Perhaps you didn't mean to compare an iterator and a boolean constant... smile.png

#23 Nathan2222_old   Members   

-396
Like
-5Likes
Like

Posted 18 February 2014 - 08:01 AM

What do you mean by functions disappear etc.?

 Imagine I had the following function in C++:
bool SomeElementIsTrue(std::vector<bool> vec) {

    for(std::vector<bool>::iterator it = vec.begin() ; it != vec.end(); ++it)
        if (it == true)  return true;

    return false;

}
If I converted my program to Python, I can remove the entire function, and use the built-in 'any' function.
If I wrote that program in C++, I could remove the entire function and use the library `find' function, or just provide a one-line implementation of the function:
bool any(std::vector<bool> const &v) {
  return std::find(v.begin(), v.end(), true) != v.end();
}
Perhaps you didn't mean to compare an iterator and a boolean constant... :)

3 lines. Yes, the {} is counted.

UNREAL ENGINE 4:
Total LOC: ~3M Lines
Total Languages: ~32
smile.png
--
GREAT QUOTES:
I can do ALL things through Christ - Jesus Christ
--
Logic will get you from A-Z, imagination gets you everywhere - Albert Einstein
--
The problems of the world cannot be solved by skeptics or cynics whose horizons are limited by the obvious realities. - John F. Kennedy


#24   Members   

20267
Like
5Likes
Like

Posted 18 February 2014 - 08:04 AM

*
POPULAR

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

bool any(vector<bool> const&v){return find(v.begin(),v.end(),1)!=v.end();}


#25   Members   

20267
Like
0Likes
Like

Posted 18 February 2014 - 08:09 AM

Also, if you insist on making things as short as possible, you'll end up with a programming language that looks like ASCII noise. Take a look at J for an example of a language that goes too far in that direction.

#26 Nathan2222_old   Members   

-396
Like
0Likes
Like

Posted 18 February 2014 - 08:10 AM

@alvaro: would the zip() function in python be 2-lined in c++ :)

UNREAL ENGINE 4:
Total LOC: ~3M Lines
Total Languages: ~32
smile.png
--
GREAT QUOTES:
I can do ALL things through Christ - Jesus Christ
--
Logic will get you from A-Z, imagination gets you everywhere - Albert Einstein
--
The problems of the world cannot be solved by skeptics or cynics whose horizons are limited by the obvious realities. - John F. Kennedy


#27 Nathan2222_old   Members   

-396
Like
0Likes
Like

Posted 18 February 2014 - 08:14 AM

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.

UNREAL ENGINE 4:
Total LOC: ~3M Lines
Total Languages: ~32
smile.png
--
GREAT QUOTES:
I can do ALL things through Christ - Jesus Christ
--
Logic will get you from A-Z, imagination gets you everywhere - Albert Einstein
--
The problems of the world cannot be solved by skeptics or cynics whose horizons are limited by the obvious realities. - John F. Kennedy


#28 Nathan2222_old   Members   

-396
Like
0Likes
Like

Posted 18 February 2014 - 08:25 AM

{} 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.

UNREAL ENGINE 4:
Total LOC: ~3M Lines
Total Languages: ~32
smile.png
--
GREAT QUOTES:
I can do ALL things through Christ - Jesus Christ
--
Logic will get you from A-Z, imagination gets you everywhere - Albert Einstein
--
The problems of the world cannot be solved by skeptics or cynics whose horizons are limited by the obvious realities. - John F. Kennedy


#29   Members   

5415
Like
1Likes
Like

Posted 18 February 2014 - 10:10 AM


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.



#30 Nathan2222_old   Members   

-396
Like
0Likes
Like

Posted 18 February 2014 - 10:53 AM

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?

UNREAL ENGINE 4:
Total LOC: ~3M Lines
Total Languages: ~32
smile.png
--
GREAT QUOTES:
I can do ALL things through Christ - Jesus Christ
--
Logic will get you from A-Z, imagination gets you everywhere - Albert Einstein
--
The problems of the world cannot be solved by skeptics or cynics whose horizons are limited by the obvious realities. - John F. Kennedy


#31   Members   

5415
Like
0Likes
Like

Posted 18 February 2014 - 11:02 AM


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.



#32 fir   Members   

-464
Like
1Likes
Like

Posted 18 February 2014 - 11:37 AM

 


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)



#33   Members   

5415
Like
0Likes
Like

Posted 18 February 2014 - 12:38 PM


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.



#34   Moderators   

21412
Like
8Likes
Like

Posted 18 February 2014 - 12:48 PM

*
POPULAR

I just want to say that designing a good language involves a lot of decisions that aren't even being remotely considered here.

 

Reducing LOC count is a ridiculous metric for the strength (or quality) of a language. You guys are all arguing about standard library contents and not even anything pertaining to actual language design.

 

 

I predict that any attempt at producing a language in this thread will end in tears.


Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

#35 Nathan2222_old   Members   

-396
Like
0Likes
Like

Posted 18 February 2014 - 01:26 PM

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

UNREAL ENGINE 4:
Total LOC: ~3M Lines
Total Languages: ~32
smile.png
--
GREAT QUOTES:
I can do ALL things through Christ - Jesus Christ
--
Logic will get you from A-Z, imagination gets you everywhere - Albert Einstein
--
The problems of the world cannot be solved by skeptics or cynics whose horizons are limited by the obvious realities. - John F. Kennedy


#36   Members   

6339
Like
0Likes
Like

Posted 18 February 2014 - 02:21 PM

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/


Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

 

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

 

 


#37   Members   

14154
Like
5Likes
Like

Posted 18 February 2014 - 02:54 PM

*
POPULAR

You can't really design a fast language -- certain language decisions influence the potential of a program to run quickly, but you're talking about taking a plaintext program description and ending up with something that runs quickly -- there's a metric crapton of magic that goes on between one and the other.

 

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.


throw table_exception("(ノ ゜Д゜)ノ ︵ ┻━┻");


#38   Members   

4384
Like
0Likes
Like

Posted 18 February 2014 - 03:16 PM

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, 18 February 2014 - 03:23 PM.

"Recursion is the first step towards madness." - "Skeggǫld, Skálmǫld, Skildir ro Klofnir!"
Direct3D 12 quick reference: https://github.com/alessiot89/D3D12QuickRef/

#39 Nathan2222_old   Members   

-396
Like
0Likes
Like

Posted 18 February 2014 - 03:24 PM

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.

UNREAL ENGINE 4:
Total LOC: ~3M Lines
Total Languages: ~32
smile.png
--
GREAT QUOTES:
I can do ALL things through Christ - Jesus Christ
--
Logic will get you from A-Z, imagination gets you everywhere - Albert Einstein
--
The problems of the world cannot be solved by skeptics or cynics whose horizons are limited by the obvious realities. - John F. Kennedy


#40 Nathan2222_old   Members   

-396
Like
-1Likes
Like

Posted 18 February 2014 - 05:19 PM

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.

UNREAL ENGINE 4:
Total LOC: ~3M Lines
Total Languages: ~32
smile.png
--
GREAT QUOTES:
I can do ALL things through Christ - Jesus Christ
--
Logic will get you from A-Z, imagination gets you everywhere - Albert Einstein
--
The problems of the world cannot be solved by skeptics or cynics whose horizons are limited by the obvious realities. - John F. Kennedy





Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.