This is an interesting exercise, but most of the suggestions on the page are just cosmetic, and do not address the fundamental challenge of C++ - perhaps the biggest divergence between Python and C++:<p>A core design principle of C++ is that you do not pay (performance-wise) for what you don't use. This leads to all sorts of nasty things like object slicing, law of big 3, template preprocessor hell just to get pseudo-generics.<p>A core design principle of Python is that you should pay the minimum cognitive burden for what you are not using. Don't care to customize object dispatch? Then you don't need to know about descriptors and __slots__ just to write a simple class.<p>No amount of syntactic cargo culting is going to bridge this gap. The whitespace and lack of semicolons is not why people embrace Python. Just as removing integer types and sensible scoping from C++ won't make it Javascript, replacing braces with tabs is not going to make it Python.
This is the exact opposite of what I want in C++.<p>The use of characters to clearly delineate code sections and scope is a strong benefit of C++ over these other languages. They're not a "source of errors" - they allow a competent programmer the opportunity to quickly reason about the structure of the code. If vertical compression is an issue - get a bigger monitor or an IDE that allows for code hiding.<p>It is also far better to have a "oops, I missed a brace" error that your compiler/IDE catches, versus a "man, why does my program keep seg faulting unexpectedly" error that takes hours to track down since you missed a single tab somewhere.
<p><pre><code> $ wc -c a.cpp t.cpp
399 a.cpp
380 t.cpp
779 total
$ cat t.cpp
#include <iostream>
using namespace std;
namespace utils {
template<typename T> T square(const T& n) { return n * n; }
}
int main() {
int input(0);
auto message("Please enter a positive number");
cout << message << ":\n";
cin >> input;
if (input>0) { cout << "Result: " << utils::square(input) << "\n"; }
else { cout << message << "\n"; }
return 0;
}
$ cat a.cpp
#include <iostream>
using namespace std
namespace utils
template<typename T>
auto square(const T& n)
return n * n
int main()
auto input = 0
auto message = "Please enter a positive number"
cout << message << ":" << endl
cin >> input
if input > 0
cout << "Result: " << utils::square(10) << endl
else
cout << message << endl
return 0
</code></pre>
I am not entirely convinced that t.cpp has any more or less noise than a.cpp and where exactly there is any sort of gain from this – I had more trouble indenting the second piece of code properly for HN than the first.
This looks neat on first glance and on small code samples, but I've had so many messed up whitespaces after merging branches that in the real world this would be just another way to shoot yourself in the foot. I really like python for scripting up into the 10k lines-of-code area, but for bigger projects (and teams with more then - say - 3 coders) I wouldn't even consider a dynamically typed language, let alone a language where intendations and newlines are language constructs.<p>I don't really find the example at the end of the article much more readable (even though it "cheats" a bit by using the C++11 auto keyword and range-based for loop), on the contrary, the white space on the left side looks more messy then on the right side to me.<p>C++ code which has a lot of STL containers and complex templates <i>does</i> look ugly though, that's why I prefer to either not use this, or hide it under typedefs and decltypes. I also don't like the new auto keyword very much, the compiler SHOULD complain when someone on the team changes types around.
I love Python and it is one of my primary development languages, but I have come to believe meaningful indentation was a bad idea. As Rob Pike said in the recent Go conference keynote: "It is a profound mistake to have your semantics depend on invisible characters". Braces also make parsing and auto-formatting easier and better. It seems Go struck a good balance with with a newline after statements (no semicolon necessary), and braces for all structures.
> <i>I’m quite fond of languages with minimal syntax.</i><p>Maybe this is the Lisp enthusiast in me, but as someone who does the bulk of their workaday programming in Python I still feel compelled to say that it's a perverse worldview that holds up Python as an instance of "minimal syntax."
This doesn't seem to address <a href="http://en.wikipedia.org/wiki/Most_vexing_parse" rel="nofollow">http://en.wikipedia.org/wiki/Most_vexing_parse</a> at all.<p>On the other hand, if you don't care about backward compatibility, I guess completely eliminating constructor syntax in favor of C++11 uniform initialization syntax is a good solution as any. (But maybe curly brace haters won't like that solution.)
This looks really error-prone to me.<p>Have you looked at previous attempts, such as SPECS? <a href="http://www.csse.monash.edu.au/~damian/papers/HTML/ModestProposal.html" rel="nofollow">http://www.csse.monash.edu.au/~damian/papers/HTML/ModestProp...</a>
How about exploring a modern language like Google GO (Golang)? Go was designed exactly for the purpose of having a performance that could be compared to some extent to powerful languages like C/C++ and in the same time maintains a Python like syntax. I have programmed with both languages and I'd say by the end of the day both languages are powerful tools in your developer's toolbox however Go is a very attractive choice when it comes to rapid to develop performant applications
It has not been mentioned in the original post or the comments yet, so here is a working prototype of a similar idea <a href="https://github.com/pfultz2/Pythy" rel="nofollow">https://github.com/pfultz2/Pythy</a> (for some specific value of working, you will need Clang)<p>Its birth lies here <i>Having it all: Pythy syntax for C++</i> [1]. It was a nice read. Unfortunately cpp-next seems to be down right now. Let me try to find it in Google's cache or internet archive.<p>Here it is <a href="https://web.archive.org/web/20130820172127/http://cpp-next.com/archive/2011/11/having-it-all-pythy-syntax/" rel="nofollow">https://web.archive.org/web/20130820172127/http://cpp-next.c...</a><p>[1] <a href="http://cpp-next.com/archive/2011/11/having-it-all-pythy-syntax/" rel="nofollow">http://cpp-next.com/archive/2011/11/having-it-all-pythy-synt...</a>
This really reminds me of a similar attempt for Go, called iGo [1]. There are a lot more cases to handle for C++.<p>[1] <a href="https://news.ycombinator.com/item?id=7444459" rel="nofollow">https://news.ycombinator.com/item?id=7444459</a>
Since no one has said so yet, and I quickly searched the comments, the answer is basically a language called Nimrod.<p>It shows up here a lot, and not many people use it still. Time will tell.
This doesn't seem to allow single line if or while statements, because parentheses are optional.<p>I like single line if when it is appropriate. (Python allows single line if by using colons.) Apart from my taste, C preprocessor macros can't expand to more than a single line, so this seems to prevent macros expanding to contain control structures. Is there an easy fix?
Python is easier to type but its harder to read. Ides that help you code faster are a better investment of time than a language that's easier to write in notepad. My ide does brackets and indention for me. I never think about them. They're just there for my reading pleasure. I like these things its easier to follow the code when reading.
I would support this if you can remove header files. It is hell to manage function prototypes. Let the compiler figure that out with "public/private" keywords.
What if I wanted to take a peek at this article without giving up my email address? If only there was an easy way to stop JavaScript from blocking my page view with that subscribe request …