Python with Braces(web.archive.org)
web.archive.org
Python with Braces
https://web.archive.org/web/20140209225815/http://www.pythonb.org/
35 comments
We changed the URL to the archive.org version because the original domain now points to malware.
This is bad, and you should feel bad.
Maybe I'm being too harsh, but I feel like anyone who considers this a good idea isn't a sufficiently-Pythonic thinker to be writing Python anyway. Python isn't just a language--it's a culture, and one of that culture's core principles is that there should be one way to do it.
I can't believe someone skilled enough to do this has actually not realized why it is a colossally bad idea. Having a working compiler is just one tiny aspect of the problem. Unless there is a transparent way to interoperate with the rest of the Python ecosystem (libraries, tools), it is dead in the water.
Even then, this seems like a lot of work to overcome a non-problem, akin to developing a C++11 compiler which uses "begin" and "end" instead of braces because of some emotional attachment to Pascal. Really, if you are a programmer and the only thing stopping you from using Python to solve some problem is its indentation rules, you should stop and reevaluate your priorities.
Even then, this seems like a lot of work to overcome a non-problem, akin to developing a C++11 compiler which uses "begin" and "end" instead of braces because of some emotional attachment to Pascal. Really, if you are a programmer and the only thing stopping you from using Python to solve some problem is its indentation rules, you should stop and reevaluate your priorities.
[deleted]
[deleted]
The examples kind of feel like an introductory page to coffeescript, in reverse. I think it does a great job of showing why meaningful indentation is cleaner. Now I want it for ruby :)
from __future__ import braces
File "<stdin>", line 1
SyntaxError: not a chanceWhat if you want to make a dictionary?
you = {'are': 'screwed'}
you = {'are': 'screwed'}
Ok, I don't want to be mean but, why would some do all this work to workaround one of the coolest Python features?
Why do some people feel like meaningful indentation is a deal-breaker with Python? It makes for readable code even in curly brace languages like JS, Java, and C. In fact, I found the first curly brace example with the odd indentation jarring. Being able to quickly scan a block of code and get a sense for what belongs to which block is incredibly valuable.
I don't understand, this is already available with
>>> from __future__ import bracesIsn't this a bit early? It's not even March yet.
Please, no :(
I literally shuddered when I read this.
Significant whitespace to me is one of the fundamental parts of Python that if messed with, makes it not Python.
Perhaps this will make it slightly easier for people coming from PHP, Javascript or one of the many languages that do use curly braces, but significant whitespace is a selling point, not a hinderance IMO.
Significant whitespace to me is one of the fundamental parts of Python that if messed with, makes it not Python.
Perhaps this will make it slightly easier for people coming from PHP, Javascript or one of the many languages that do use curly braces, but significant whitespace is a selling point, not a hinderance IMO.
I love it. If this could transparently convert to and from normal Python I could see wrapping it in an editor plugin so that the braces could be visible to those of us who prefer them, while the output could remain traditional Python for interoperability with an established codebase.
You know, when I first started programming and got attached to Python, I longed for significant whitespace in other languages, such as Javascript (which drove me to Coffeescript) and C (which just drove me nuts). I avoided languages like Java and C# because they had so much syntactic "noise"., because they were statically typed, and because they were clearly inferior languages.
And Lisp...well, I shuddered at the thought of learning Lisp because of all those parentheses.
Now, however, I don't give a damn about braces. I use Java if the job calls for it, and I've developed quite an appreciation for C#. I enjoy playing around with Lisp and recognize that it shares a lot of fundamental features with Python. I have a strong appreciation for C's power and control (but use it only under very certain circumstances and with great trepidation).
Python is still my go-to language because of its incredible ecosystem, but I no longer insist on using it for everything. I use the right tool for the job. I dropped Coffeescript in favor of pure Javascript, which I've come to appreciate as not a bad language, as long as you're aware of the traps.
For larger jobs, I usually seriously consider using a statically-typed language, because I know I'll either have to religiously write unit tests, or suffer a world of pain (and even then odd bugs will happen that otherwise would not have).
Point is, I suspect that very often, those people that insist on bringing the syntax from one language to another are either early in their career, or they're focused on the wrong thing. If the presence or absence of braces is the feature of a language that bothers you most, then you want want to reevaluate your priorities.
(that said, if this project was just a fun way to explore Python's internals and lexers/parsers, please carry on!).
And Lisp...well, I shuddered at the thought of learning Lisp because of all those parentheses.
Now, however, I don't give a damn about braces. I use Java if the job calls for it, and I've developed quite an appreciation for C#. I enjoy playing around with Lisp and recognize that it shares a lot of fundamental features with Python. I have a strong appreciation for C's power and control (but use it only under very certain circumstances and with great trepidation).
Python is still my go-to language because of its incredible ecosystem, but I no longer insist on using it for everything. I use the right tool for the job. I dropped Coffeescript in favor of pure Javascript, which I've come to appreciate as not a bad language, as long as you're aware of the traps.
For larger jobs, I usually seriously consider using a statically-typed language, because I know I'll either have to religiously write unit tests, or suffer a world of pain (and even then odd bugs will happen that otherwise would not have).
Point is, I suspect that very often, those people that insist on bringing the syntax from one language to another are either early in their career, or they're focused on the wrong thing. If the presence or absence of braces is the feature of a language that bothers you most, then you want want to reevaluate your priorities.
(that said, if this project was just a fun way to explore Python's internals and lexers/parsers, please carry on!).
I almost did a spit-take when I read this. I actually do very little work in Python so I have no personal opinion on the subject, but I have a few close friends that are hard-core python programmers. I imagine the nerd rage that braces would incite. I'm gonna send this link to them now, sit back and watch chaos ensue. Bwa ha ha (rubs hands together)!
I would actually use it with iPython
This makes no sense at all.
Score:
+1 : the idea of braces in Python
-1 : The fact that the project addresses an out-of-date Python version (2.7 instead of 3+).
Result: 0
+1 : the idea of braces in Python
-1 : The fact that the project addresses an out-of-date Python version (2.7 instead of 3+).
Result: 0
Just playing Devil's advocate, but one very good use of {} is for real anonymous functions. I.e.
map([1,2,3], lambda (x) {
print x
return x * 2
})
That's one of the limiting reason why we can't have that in Python right nowI think I need to add a disclaimer:
- I'm not the one who behind this project - actually, I'm a not a real programmer (I'm a graphic designer who also code) - the people behind this project can be found in Github. At least I can say about one of the who is a close friend, that he codes in Python about 8 years as a profession - I'll ask him to open a user and add his thoughts to this discussion (if he doesn't have yet)
- I'm not the one who behind this project - actually, I'm a not a real programmer (I'm a graphic designer who also code) - the people behind this project can be found in Github. At least I can say about one of the who is a close friend, that he codes in Python about 8 years as a profession - I'll ask him to open a user and add his thoughts to this discussion (if he doesn't have yet)
Huh? Lack of braces is one of the things I like about Python. Additionally, on many non-English keyboards braces are somewhat hard to write (e.g., on a Danish Mac keyboard it's a three-letter combo: Alt + shift + 8). Not having to write braces is nice.
One of the examples on the page says "indentation doesn't matter". But the thing is, it does matter - even if there are braces. Correct indentation means that your code is more readable. Python (the normal version without braces) enforces correct indentation, which is brilliant.
One of the examples on the page says "indentation doesn't matter". But the thing is, it does matter - even if there are braces. Correct indentation means that your code is more readable. Python (the normal version without braces) enforces correct indentation, which is brilliant.
WHY?????
Do you have endless empty time?
Depressing to think anyone on this earth finds curly braces an improvement to Python. I always prefer languages without, curly braces are ugly!
Kudos for having the motivation to pull this together, I guess!
I must admit, I don't get why anybody would be interested in using this. Even the headline snippet is an example of "what not to do."
Python's significant whitespace incurs the small overhead of requiring attention to detail when copying and pasting code - that's pretty much the only downside, and it seems strange to add a feature while boils down to "allow slopping indentation practice at the cost of extra syntax."
I thoroughly believe syntactic noise is an enemy of productivity. Good editors will help to some extent, but I find the process of reading (say) CoffeeScript much more pleasant than JavaScript. Each to their own, of course.
I must admit, I don't get why anybody would be interested in using this. Even the headline snippet is an example of "what not to do."
Python's significant whitespace incurs the small overhead of requiring attention to detail when copying and pasting code - that's pretty much the only downside, and it seems strange to add a feature while boils down to "allow slopping indentation practice at the cost of extra syntax."
I thoroughly believe syntactic noise is an enemy of productivity. Good editors will help to some extent, but I find the process of reading (say) CoffeeScript much more pleasant than JavaScript. Each to their own, of course.
What really bugs me is when spaces and tabs get mixed together in the same file. That's godawful.
i'm sorry, don't mean to be harsh at all, but this is just a bad idea.
This should be implemented as a editor plugin...with the actual files having none
Worst idea ever! It's like "upgrading" humans to walk on 4 legs.
Blasphemy!
{
{because;}
{language;}
{improves;}
{when;}
{you add;}
{curly braces;}
{and;}
{semicolons;}
{to it;}
}
Can we have this with explicit typing? (Not even a joke)
If someone really loves curly braces so much, there is no shortage of languages that offer them. This is like making a Lisp dialect without parentheses or a Smalltalk without messages.
Fair disclosure: I used a language called Actor that was pretty much Smalltalk without messages. I mean, there were messages. They just looked like function calls with the receiver as first parameter.
Fair disclosure: I used a language called Actor that was pretty much Smalltalk without messages. I mean, there were messages. They just looked like function calls with the receiver as first parameter.