Re:Carbon: high level programming language that compiles to ...
by shadowmint on Saturday October 20, 2012 @09:08AM
(#4676976)
I wish projects like this wouldn't force you to install their libraries in order to play with them.
Sure, it's just /usr/local, but @#$#@$@# it's annoying when you have to make install on the dependent library before the core application will install.
Use scons. or a makefile. or cmake. Or build a static binary. I don't care; but look at the go source archive for an example of how to do this right.
This isn't a good first touch of a project:
./configure: line 12296: syntax error near unexpected token `CO2,'
./configure: line 12296: `PKG_CHECK_MODULES(CO2, libco2-1.0 >= 0.1.2,,as_fn_error $? "required module missing" "$LINENO" 5)'
hint: you'll notice autoconf isn't in the list above. :P
Re:Carbon: high level programming language that compiles to ...
by 055static on Saturday October 20, 2012 @09:42PM
(#4678632)
It's is one of life's small pleasures when programs (useful programs) compile fast and with relative simpicity.
If you want to experience this, try www.sigala.it/sandro/ and cutils. There's a links to it on the OP's page. Programs as UNIX filters, written with flex and bison. Beautiful.
I like this OP because he includes a grammar file. If every programmer that tries making his own language did this, the world would be a better place. Did he also include the .l file in the src? I'm too lazy to look. I think they should include those too. It makes the whole thing easier to understand (and modify).
I too get annoyed with having to install the author's own libs. Sometimes these libs are better than the standard ones (e.g. everyone knows C's stdio sucks). If the special libs are fixing something that needs fixing, I'm OK with using them. But nine times out of ten, that's not the case.
For this sort of thing, i.e. C code generation, I still like the LISP's that generate C.
Re:Carbon: high level programming language that compiles to ...
by nnq on Saturday October 20, 2012 @10:38AM
(#4677157)
When the first thing I read about a language it on it's description page is "compiles to X" or "runs on Y", this is definitely a sign that the language ha NOTHING INTERESTING TO OFFER whatsoever. Adding insult to injury, underneath is a bulletted list of language features that any language worth it's salt has them! And please... "Named constructors"... WTF?!
(If someone wants to be mean, he could simply compare this feature-wise with one of the Scheme dialects that compile to C...)
Re:Carbon: high level programming language that compiles to ...
by jasim on Saturday October 20, 2012 @11:07AM
(#4677227)
Not every language needs to be one of those that changes the way we think about programming. It is perfectly fine to experiment on mundane languages by adding mundane features. Incremental improvement is a good thing and it is too early to just write off this because it seems to be un-interesting.
I'm sure this project was extremely interesting to the author - maybe from a different perspective than yours.
> (If someone wants to be mean, he could simply compare this feature-wise with one of the Scheme dialects that compile to C...)
I'm not being mean here, but if someone really wanted to be..
Re:Carbon: high level programming language that compiles to ...
by Xcelerate on Saturday October 20, 2012 @12:09PM
(#4677389)
If it's upvoted, then the HN crowd finds the language interesting. If not, then it will fade away like every other article that doesn't get votes does.
Re:Carbon: high level programming language that compiles to ...
by Ogre on Saturday October 20, 2012 @05:13PM
(#4678244)
The Example link contains, I think, only two things that aren't valid C++. "self." (could be replaced by this-> or simply nothing in C++) and the ["stdio.h"] int printf... syntax for including just one thing.
Two and a half things I guess: the methods of MyObject are accessed by main but not declared public (C++ is private by default)
I don't know if that's good or bad, but it's not very compelling to me.
Re:Carbon: high level programming language that compiles to ...
by michaelfeathers on Sunday October 21, 2012 @08:10AM
(#4679527)
My point was that usually a language does more to sell itself. The selling point of C++ wasn't "here's a language that compiles to C" (which it was in the beginning), but rather "Here's a safer, OO version of C with many new features."
Re:Carbon: high level programming language that compiles to ...
by cbsmith on Saturday October 20, 2012 @02:18PM
(#4677770)
Yeah, which is why traditionally a LOT of languages, particularly early in their careers, have compiled down to C. Really aside from JVM targeted languages, it still tends to be the trend.
So it is pretty weird for that to be highlighted as the big distinctive feature.
Re:Carbon: high level programming language that compiles to ...
by rat87 on Saturday October 20, 2012 @06:21PM
(#4678347)
> Yeah, which is why traditionally a LOT of languages, particularly early in their careers, have compiled down to C. Really aside from JVM targeted languages, it still tends to be the trend.
What about .net/mono targeted languages, javasvcript targeted languages? And custom interpreters jit(frequently but not always written in c)
Re:Carbon: high level programming language that compiles to ...
by cbsmith on Friday November 02, 2012 @01:32AM
(#4731381)
CLR targeted languages are few and far between, as are JavaScript targeted languages, so I didn't consider them a big enough factor to impact the "trend".
People focused on entirely new languages tend not to target JITs first for the same reason they tend to not target direct machine code first: it just adds complexity to getting a proof of concept out the door. LLVM, the JVM, and yes, the CLR are starting to change this, but aside from the JVM, there are still only a handful of languages going that route.
Re:Carbon: high level programming language that compiles to ...
by cpeterso on Saturday October 20, 2012 @03:07PM
(#4677926)
LLVM has C backend, though it is not fully supported. It seems like it would.be helpful for bootstrapping LLVM for a new architecture and for A/B testing of other backends' performance and correctness.
Re:Carbon: high level programming language that compiles to ...
by mistercow on Saturday October 20, 2012 @10:55AM
(#4677196)
Sure, but that doesn't make it a good intermediate representation for a programming language. I really like CoffeeScript, but compiling to it would be insanity.
That said, there are some good reasons for compiling to C. Not every architecture has a backend for LLVM yet, after all.
Re:Carbon: high level programming language that compiles to ...
by slurgfest on Saturday October 20, 2012 @01:26PM
(#4677609)
Some would say "I really like JavaScript, but compiling to it would be insanity." And yet CoffeeScript is there. How is that better than a language which compiles to C?
Re:Carbon: high level programming language that compiles to ...
by mistercow on Saturday October 20, 2012 @05:46PM
(#4678297)
If you read the second part of my comment, you'll see that I agree that there is a legitimate reason to compile to C. It turns out to be identical to the legitimate reason for compiling to JS - some platforms can't be targeted directly, so you make do with the options you have.
I was not disputing the conclusion that it can make sense to compile to C. I was just saying that "people like C" doesn't support that conclusion.
It's my language of choice for personal projects. A neat and compact language that is very trivial to pick up, feels light, and yet sufficiently subtle to intellectually engage your mind.
Very productive, good performance, and very portable.
Re:Carbon: high level programming language that compiles to ...
by Someone on Saturday October 20, 2012 @03:16PM
(#4677963)
"it automatically implies a pretty high baseline of performance"
I doubt that. It may be (mostly) true for languages that match the capabilities of C well, but if a language does not match C well, it certainly isn't 'automatically' because the optimizer in your C compiler will not help much in making the implementations of such features efficient.
For example, compiling JavaScript to C, it would be non-trivial to make the result as fast as the current JavaScript engines because the C code would likely have to do the same zillions 'is this a string?' checks that interpreters do (probably even more of them because it is harder to see the wood for the trees in your translated-to-C code)
For example, it would require lots of work to support, for example, Lisp's number system, Dylan's union types, any variant of 'eval', or, to take an extreme example, to map Intercal code sequences to efficient C operations such as '+'.
Re:Carbon: high level programming language that compiles to ...
by FraaJad on Saturday October 20, 2012 @06:37PM
(#4678383)
While not discouraging the original author, Vala from Gnome has taken this thinking a lot further. Vala is actually quite fun to use even for non-GUI projects. And it doesn't have to depend on GTK libraries to produce working programs.
Re:Carbon: high level programming language that compiles to ...
by WalterBright on Saturday October 20, 2012 @03:02PM
(#4677903)
Compiling to C puts some significant constraints on your language. For example, C doesn't have COMDAT support, thread local storage, exception handling is limited to setjmp/longjmp, static uplevel function links are a problem, symbolic debug info is going to all look like C, etc.
Re:Carbon: high level programming language that compiles to ...
by tptacek on Saturday October 20, 2012 @06:20PM
(#4678345)
I'm not sure I understand how C's lack of high-level exceptions makes a difference for a high-level language that compiles down to C. The high-level language can provide exception support, just like large-scale C packages sometimes do using longjmp.
Similarly, are you really suggesting that C programs can't have thread-local storage?
Sure, it's just /usr/local, but @#$#@$@# it's annoying when you have to make install on the dependent library before the core application will install.
Use scons. or a makefile. or cmake. Or build a static binary. I don't care; but look at the go source archive for an example of how to do this right.
This isn't a good first touch of a project:
./configure: line 12296: syntax error near unexpected token `CO2,' ./configure: line 12296: `PKG_CHECK_MODULES(CO2, libco2-1.0 >= 0.1.2,,as_fn_error $? "required module missing" "$LINENO" 5)'
hint: you'll notice autoconf isn't in the list above. :P
If you want to experience this, try www.sigala.it/sandro/ and cutils. There's a links to it on the OP's page. Programs as UNIX filters, written with flex and bison. Beautiful.
I like this OP because he includes a grammar file. If every programmer that tries making his own language did this, the world would be a better place. Did he also include the .l file in the src? I'm too lazy to look. I think they should include those too. It makes the whole thing easier to understand (and modify).
I too get annoyed with having to install the author's own libs. Sometimes these libs are better than the standard ones (e.g. everyone knows C's stdio sucks). If the special libs are fixing something that needs fixing, I'm OK with using them. But nine times out of ten, that's not the case.
For this sort of thing, i.e. C code generation, I still like the LISP's that generate C.
(If someone wants to be mean, he could simply compare this feature-wise with one of the Scheme dialects that compile to C...)
I'm sure this project was extremely interesting to the author - maybe from a different perspective than yours.
> (If someone wants to be mean, he could simply compare this feature-wise with one of the Scheme dialects that compile to C...)
I'm not being mean here, but if someone really wanted to be..
No, but neither does(should) every new language be posted and upvoted to HN.
Two and a half things I guess: the methods of MyObject are accessed by main but not declared public (C++ is private by default)
I don't know if that's good or bad, but it's not very compelling to me.
So it is pretty weird for that to be highlighted as the big distinctive feature.
What about .net/mono targeted languages, javasvcript targeted languages? And custom interpreters jit(frequently but not always written in c)
People focused on entirely new languages tend not to target JITs first for the same reason they tend to not target direct machine code first: it just adds complexity to getting a proof of concept out the door. LLVM, the JVM, and yes, the CLR are starting to change this, but aside from the JVM, there are still only a handful of languages going that route.
That said, there are some good reasons for compiling to C. Not every architecture has a backend for LLVM yet, after all.
I was not disputing the conclusion that it can make sense to compile to C. I was just saying that "people like C" doesn't support that conclusion.
It's my language of choice for personal projects. A neat and compact language that is very trivial to pick up, feels light, and yet sufficiently subtle to intellectually engage your mind.
Very productive, good performance, and very portable.
http://www.youtube.com/watch?v=HxaD_trXwRE
caveat: /imho/ the runtime is not yet fully cooked. ETA is Go1.1 (end of year I believe) for beefed up internals.
I doubt that. It may be (mostly) true for languages that match the capabilities of C well, but if a language does not match C well, it certainly isn't 'automatically' because the optimizer in your C compiler will not help much in making the implementations of such features efficient.
For example, compiling JavaScript to C, it would be non-trivial to make the result as fast as the current JavaScript engines because the C code would likely have to do the same zillions 'is this a string?' checks that interpreters do (probably even more of them because it is harder to see the wood for the trees in your translated-to-C code)
For example, it would require lots of work to support, for example, Lisp's number system, Dylan's union types, any variant of 'eval', or, to take an extreme example, to map Intercal code sequences to efficient C operations such as '+'.
https://live.gnome.org/Vala/Documentation
I realise Apple's Carbon doesn't compile to C but my brain's transderivational search just ignored that fact.
Similarly, are you really suggesting that C programs can't have thread-local storage?
Standard C does not have thread local storage.