Friday, 15 May 2015

Adding some python flavor to C++ -



Adding some python flavor to C++ -

curly braces for(int i=0; i<10; i++) { line 1 line 2 } if (something) { line 3 line 4 } else if(something) { line 5 line 6 line 7 } else { line 8 line 9 line 10 }

i lazy typist , in recent years i've developed dislike curly braces in c++. not think unnecessary; can't live without them in long pieces of code. when branch of code contains 3 5 lines, increased indentation lone seems sufficient in making context clear, , curly braces don't seem much more taking precious screen space (especially when utilize vertical splits) , requiring me press more keys, which, owing not-so-convenient positions on keyboard, add together more strain fingers.

so, i'm thinking of doing preprocessor allow me utilize python-flavored c++, this:

for(int i=0; i<10; i++) line 1 line 2 if (something) line 3 line 4 else if(something) line 5 line 6 line 7 else line 8 line 9 line 10

so create curly braces optional in short branches of code, , doing code becomes cleaner. if have lot of functions consist of no more 8 lines, getting rid of curly braces create huge difference me. things seem more compact, clean; , beingness able see more useful code in 1 screen somehow makes me sense better. people kind of thing below thankful well:

void blahbalh(){ code... }

apparently people started doing decades ago sake of screen space. now, wouldn't improve if curly braces become optional? is, utilize them when code contained becomes relatively long.

symbols in general

to add together more python flavor c++. think braces surrounding conditions can done away with. looks really different c++, after got used python found quite elegant:

if something: line 3 line 4 elif something: line 5 line 6 line 7 else: line 8 line 9 line 10

generally, i've found python tends utilize far fewer symbols, thing:

symbols cause more finger strains plain text, because of relatively inconvenient positions on our keyboards , because of need press shift (qwerty , dvorak same here) since alphanumerical keys easier press, can type faster if avoid using symbols. , experience sense more natural flow when don't have press shift key.

so have more plain-text operators, using and in place of &&, , or in place of ||, etc. , can have python-styled loops, easier type

what guys think of python-flavored c++? suggestions?

i'm thinking of doing preprocessor simple source-to-source transformation. looks easiest way go without having define new language.

i lazy typist , in recent years i've developed dislike curly braces in c++ ... , curly braces don't seem much more taking precious screen space

write code this, , switch ide types braces you. can go on write code rest of understand.

for (int i=0; < 10; i++) { line 1 line 2 } if (something) { line 3 line 4 } else if (something) { line 5 line 6 line 7 } else { line 8 line 9 line 10 }

c++ python

No comments:

Post a Comment