Brace is a dialect of C that looks like Python.
sam.nipl.net/brace/Posted Nov 8, 2009, 5:16 PM UTC
Posted Nov 8, 2009, 5:16 PM UTC
It's a strongly-typed python with all objects removed... so, it's not like python at all.
I don't think adding significant whitespace and "#" comments makes C look like python. Even if it did, wouldn't it be more valuable to have the simplicity and power of python, not just the appearance?
You seem to be confused. It's not intended to be like Python; it's intended to look like it, specifically with the syntactic style (yes, significant whitespace). That's a relatively simple task, and Brace pulls it off. And we already have the simplicity, power, and appearance of Python in a language. It's called "Python."
What's the point of looking like python? Python is great because of it's features not just the whitespace...
Good question.
I have nothing to do with Brace, but I have written systems like this in the past. A lot of the benefits of higher level languages can be achieved by relatively minor tweaks in syntax. If you notice, Brace seems to have other features than whitespace significance, like coroutines and hygenic macros, which would be very nice to use simply in C. That, and the probably removal of syntactical gotchas make it almost certainly worth the effort, if you were going to program in C in the first place.
One major problem with using C as the first language you turn to is that the syntax makes doing things in a safe and robust way is more difficult than doing things in a hackish flimsy manner. So syntax does matter as long as it is a human (with the natural human tendency to cut corners) writing it. I think C is a mildly annoying language that is good for problems that you have a very good idea planned out of what the program will do, or for people with the discipline and patience to perform necessary syntax translations in their heads.
If its whitespace is also great, what's wrong with borrowing just that? How is that not a point?
Yes, but now Brace has the added detriment of this guy's cobbled-together standard library, which looks/acts like neither Python or glibc.
you're right that my library is "cobbled together", the whole thing is a personal project and a work in progress. It needs a lot of work. but it's fun, and I like it :) Personally I prefer draw(100,100) to gtk_pixbuf_random_long_function_name_draw(xwindow, graphicscontext... 0, 0, 100, 100) That's why I'm making my own library.
Keep it up! I did the same thing myself, only it was a preprocessor for Borland Turbo C 3.0 and I stopped working on it after 2 weeks.
I didn't want to discourage you, only point out how the title really oversimplifies your goals. It doesn't help that there's no description text, either.
glibc (or rather, the standard C library) is pretty horrible. Decades of cruft, crap, and bad ideas, collected in one place. It's easy to do better than it, in many places.
t's a statically-typed python
FTFY, Python uses strong dynamic typing, C uses weak static typing.
I agree with you. C is a good thing. Keep it as it is. Just make it easier to pass function pointers around...
make it easier to pass function pointers around
typedef is your friend.
Yeah, there is no problem passing function pointers, maybe davebrk wants closures.
Ohh closures!
Apple did this with Grand Central Dispatch and libdispatch. Last I heard, it was Open Source and already ported to BSD, but I don't know the status of the Linux port. I would assume someone is working on it, though.
does this (brace fortune program) look simple enough? It's not yet as simple as python perhaps, but it's simpler than unvarnished C.
Main:
long n = 1
cstr choice = NULL
eachline(l):
if randi(n++) == 0:
Free(choice)
choice = Strdup(l)
if choice:
Say(choice)
I'm surprised at how sane C could be with such small syntactic sugar.
[deleted]
You're right. I can't think of anything positive to say about this language. Fuck the guy who made it.
I'd prefer a dialect of Python that looks like C.
Why would you want a language with the same syntax as C but 20x slower?
At least it would have a built-in string type.
Pointers are for real men >:D Anyway i think we can all agree on th<Segment fault>
And 200x safer.
Why?
Primarily for aesthetic reasons.
[deleted]
look at who you're talking to. I don't think you're going to be convincing him.
But at least it doesn't have significant indentation.
It's nicer than Python.
I would find Python to be more beautiful if it ditched significant whitespace and went to braces.
What makes C ugly is primarily its lack of a proper for each loop, and the acrobatics you need to do to do one-function-call Python tasks.
You are my antithesis. We must meet on the field of battle.
How about this
if blah: #{
blah
# }
So then could I write:
if blah: #{
# comment_me_out_for_debugging()
#}
?
and behaves like perl
That does sound more like what I'd expect a language named "Brace" to be...
Ho that is exactly what I thought. I've seen the examples and "ouch my eyes, that really hurts just like python". Augh.
edit as usual, the python-fan crowd hit. I don't like python because of meaning space, and so what?
Try reading the source to his web-server, gotos everywhere - not that that's necessarily bad, but it doesn't half make it unreadable :)
Edit: typo (have -> half)
I'll reply to a few comments together..
My "tachyon" web server is a work in progress, like brace. I don't think it's unreadable, it's quite short which helps. The coroutines don't like sub-coroutines much yet, so I use goto. In brace if you just type a bare label, it becomes "goto" :) I like goto, used sensibly. brace is called "brace" because the central little program adds in braces, etc.
Brace can use C libraries directly, it translates cleanly into C, and it is as fast and powerful as C. It really is just C with a different preprocessor. As of now it is very much a work in progress.
Finally, thanks to the people who said encouraging things about it! :)
I put a slideshow (written in brace) up on the page, it explains some of its features and includes several demos. It runs over vnc to my server. I disabled the terminal that was there for now because some troll was trying to break it, it was fun while it lasted though.
Sam
This project looks really interesting. I don't know why so many of the comments have been negative. There hasn't been nearly as much innovation in systems languages as there has in scripting languages, and it looks like this project has some nice new concepts for systems programming. I hope the author keeps going with this.
On a related note, there's Cython, which is actually in use and not just a pet project. :-)
Except these are two different things with two different functions. Edit: But thanks for the information.
It would be helpful to enumerate the senses in which Cython is not appropriate for tasks that PyBraces is.
I haven't used either. I'm just looking at their defined uses.
Cython is Python with some C functionality. It is for Python extension development, itself an extension of Python. "Brace is C dialect that looks like Python." The author apparently uses it instead of C, something Cython's developers do not suggest.
If you want to make a Python extension, use Cython (or Pyrex, what it is based on). If you want to code in C but like the look of Python, use Brace. Maybe Cython is more versatile than described (Python itself is pretty damn versatile). Maybe Brace falls apart when doing anything other than personal servers. shrug
The author apparently uses it instead of C, something Cython's developers do not suggest.
Cython's developers say: "This makes Cython the ideal language for wrapping external C libraries, and for fast C modules that speed up the execution of Python code."
So my question is: what is the difference between a "fast C module" and a C program? The only answer I can think of is that a Cython program carries around the Python runtime and a PyBraces one presumably does not. But I think that for many use-cases, that isn't really much of a disadvantage for Cython.
Maybe there are other disadvantages to Cython, compared to PyBraces, but I just haven't heard them yet.
Sexy. But if it cannot use any includes from C, then it as good as dead
well there goes my april fool's prank for next year :(
Looks neat. I like it. Yay for niche languages.
Anyone else find it funny that a Python style dialect is named Brace?
I think that was the intent.
slow clap
[deleted]
No.
The lucky ones among us get the privilege of sitting around whining about people reinventing previous languages.
see also genie
Load Error?
[deleted]
[deleted]
How is that at all a dialect of C?
The worst thing about Python is the lack of braces.
It's a dogma beyond discussion.
>>> from __future__ import braces
File "<stdin>", line 1
SyntaxError: not a chance
Python has support for the block delimiters of every language ever invented; simply prefix with the appropriate syntax to trigger block-delimiter support.
For example, C-style braces:
if foo: #{
print "Foo"
#}
Note, however, that in block-delimiter mode Python enforces good coding style guidelines, so you will be expected to sensibly indent your code.
Please stop repeating this; it's neither correct nor funny.
It is perfectly correct; so much so that it's linked up in the official Python documentation.
No, it is not correct. These are not block delimiters. For example, this is perfectly valid Python:
if foo: #{
print "Foo"
as is this:
if foo:
print "Foo"
#}
Actually that is the second worst thing, the worst is what they replaces braces with... significant whitespace.
Edit: I think the strong down voting of this entire thread just goes to show how popular Python is on r/programming.
if (!significant(whitespace));
assert(readCorrectly(_this_block));
I don't understand your point, but let me reindent that all nice and proper for you.
if (!significant(whitespace));
assert(readCorrectly(_this_block));
Thank god I can do that since we don't have significant whitespace!
With your re-indentation the behavior is obvious.
What makes it clear is the indentation, i.e. the white space.
This is because white space is significant for humans. When whitespace is significant for the compiler, the humans and the compiler agree on what is going to happen.
The only bad thing about significant whitespace is that there is no one style to do it with. You can use either spaces or tabs. That can prove a pain if you grab some code off the Net, or from your teammates, and you used a different indenting style.
True. But you can mix and match those styles, and the compiler won't give a shit. If I grab some code off the Net, and make changes, I have to make sure I'm still using the same indentation style, or it won't run.
Man if they combined this with PyBraces, it would look just like C!