Just another thought (designing a fast but powerful language)

Started by
76 comments, last by Aardvajk 10 years, 1 month ago

Sure, the infamous LOC metric. Read here for a more recent thread about.

Advertisement

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

Sure, the infamous LOC metric. Read here for a more recent thread about.

yes i have been seeing the lines of code stuff lately.
I personally don't use comments but as for whitespaces and newlines, they're everywhere.
If code isn't clear and readable, then it's not useful. How hard can it be to press spacebar or enter ? You don't really notice it while pressing.
What i want is a language that is easy to understand, make readable programs with as fast as possible (with less or more lines depending on the user) and can be used in many scenarios. I'ld rather write 50 lines of code with white space and without comments than 50 without whitespace and with comments everywhere.
I saw a program that had a total of about 784,000 LOC and about 264,000 were spaces while about 128,000 were comments so that leaves about less than 390,000 executable LOC. It's the 390,000 i'm focused on (if i wrote that program, it'll probably way more spaces).

UNREAL ENGINE 4:
Total LOC: ~3M Lines
Total Languages: ~32

--
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

I would encourage you to have a look at some functional programming languages, SML, Haskell, Ocaml and Erlang.

I am by no means an expert in any of these languages but due to the high level design I find you can reduce your LOC dramatically.

I don't know how much these languages are suited for game programming or what tools are available but if you like a challenge and to expand your programming skills I highly recommend you delve into one.

I would encourage you to have a look at some functional programming languages, SML, Haskell, Ocaml and Erlang.
I am by no means an expert in any of these languages but due to the high level design I find you can reduce your LOC dramatically.
I don't know how much these languages are suited for game programming or what tools are available but if you like a challenge and to expand your programming skills I highly recommend you delve into one.

I've only heard of haskell.
I'm going to be learning assembly later on.

UNREAL ENGINE 4:
Total LOC: ~3M Lines
Total Languages: ~32

--
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


I am by no means an expert in any of these languages but due to the high level design I find you can reduce your LOC dramatically.

It depends on what you're doing. If you're trying to perform mathematical expressions on a list of numbers, a functional language will most likely beat a procedural language hands down (in terms of LOC). I'd hate to try to write an advanced application moreless verbosely though, as it's just not what they're designed for.

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.

“If I understand the standard right it is legal and safe to do this but the resulting value could be anything.”

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 . . .
that's what i mean. It's not the whitespace, it is just, shorter.
What do you mean by functions disappear etc.?

UNREAL ENGINE 4:
Total LOC: ~3M Lines
Total Languages: ~32

--
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

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.

UNREAL ENGINE 4:
Total LOC: ~3M Lines
Total Languages: ~32

--
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


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.

This topic is closed to new replies.

Advertisement