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