Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #27336
| From | Joshua Cranmer đ§ <Pidgeot18@verizon.invalid> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: What's the best non-JVM native language to look at? |
| Date | 2014-01-17 15:44 -0600 |
| Organization | A noiseless patient Spider |
| Message-ID | <lbc882$g2n$1@dont-email.me> (permalink) |
| References | <428f8206-d4f7-4fe6-b93c-8f881b498be6@googlegroups.com> <99qdnVXamdWBRErPnZ2dnUVZ8mOdnZ2d@bt.com> <lbblnm$o3j$1@dont-email.me> <u6qdnds8oLoA7ETPnZ2dnUVZ8mGdnZ2d@bt.com> |
On 1/17/2014 12:08 PM, lipska the kat wrote:
> On 17/01/14 16:28, Joshua Cranmer đ§ wrote:
>> On 1/16/2014 7:05 AM, lipska the kat wrote:
>>> I can't think of a language that isn't ultimately implemented in C.
>>
>> Zero-cost exception handling cannot be expressed in (ISO) C code (or, at
>> the very least, not in a way that a C compiler will faithfully compile
>> it--in the situation that would arise, clang and gcc are both extremely
>> happy to mangle the code, even at -O0). Well, MSVC has __try/__catch,
>> but that's not ISO C.
>
> I've been reading up on this Zero-cost exception handling thing.
> It seems that while there may be no overhead for exception handlers if
> no exception is raised, the performance of exception propagation is
> poor. Maybe it should be called 'Zero-cost exception handling if no
> exception occurs'. It's not impossible though is it, it's a compiler
> thing so it *could* be implemented ... if the compiler supported it.
> It's not a fundamental shortcoming of the language per-se is it?
Zero-cost exception handling simply cannot be expressed in ISO C code.
In essence, it requires building external unwind tables, which can be
thought of as "if an exception reaches between these two points, jump to
that location instead"--which requires some notion of computed goto
(more specifically, the ability to take the address of a label). gcc's
computed goto extension is not formally specified, but experimentation
with both clang and gcc indicate that taking the address of a label and
not jumping to it [in the same function] is insufficient to preserve the
existence of the code after that block, even when compiling at -O0.
In general, C strongly believes that there exists only a single entry
point to every function; constructs where this notion doesn't really
hold true (exceptions, generators, coroutines, continuations) can't be
effectively expressed in C code.
>>> If you think about it, any language *other* than C is simply a high(er)
>>> level interface to C (ignoring assembler of course). Even C compilers
>>> are written in C (go figure :-)
>>
>> Clang is written in C++. GCC is written in C++ as of 4.8. MSVC is
>> written in C++. I'm pretty sure icc is also written in C++. Open64
>> appears to be in C++ as well. Which means that all the C compilers which
>> find major use are written in C++, not C.
>
> According to lots of references on the intertubes the first C++ compiler
> was written in something called 'C with classes' which was written in ... C
The assertion I was disagreeing with was "C compilers are written in
C"--the major C compilers are in fact written in C++. That C++ was once
bootstrapped by a compiler written in C doesn't particularly
matter--Java was probably bootstrapped by a C++ compiler and Rust was
bootstrapped by OCaml. I suspect OCaml, Haskell, and Scheme are likely
to be more popular languages than C for bootstrapping, largely because
PL people are the ones who like to design new languages, and they prefer
the more powerful constructs in those languages for design than C.
> I'm sure you can but implementing simple dynamic data structures (Linked
> List for example) in C is trivial isn't it ... I've never really been
> attracted to C++, don't know why TBHWY, I have a couple of books. Too
> busy earning a crust I suppose.
But I shouldn't *have* to reimplement simple dynamic data structures.
Compare the simple task of reading in a text file in different
languages. In Python, I can write this:
with open('file.txt') as fd:
words = [line.split(' ') for line in fd]
In Java:
List<String[]> words = new ArrayList<>();
BufferedReader reader = new BufferedReader(new FileReader("file.txt"));
String line;
while ((line = reader.readLine()) != null)
words.add(line.split(' ');
In C++ [after looking up a split on stack overflow]:
std::ifstream file("file.txt");
std::vector<std::vector<std::string>> words;
while (true) {
std::string line;
std::getline(file, line);
if (file.eof()) break;
words.push_back(split(line));
}
[It's worth noting that the C++ committee is considering adding split to
the standard library].
In C... I'm not even going to attempt it. C++'s split was 10 lines of
code. C's split is a good 50 lines of code. I'd have to come up with a
representation for an ArrayList or LinkedList-equivalent datatype in C,
make sure it works, write unbounded file parsing, double-check I'm not
leaking memory, etc., just to read in a bloody file. And that's why C is
unusable for me: I spend my time trying to debug my implementation
instead of debugging my algorithm.
--
Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
What's the best non-JVM native language to look at? Saxo <jeti789@web.de> - 2014-01-16 04:35 -0800
Re: What's the best non-JVM native language to look at? lipska the kat <lipskathekat@example.com> - 2014-01-16 13:05 +0000
Re: What's the best non-JVM native language to look at? Saxo <jeti789@web.de> - 2014-01-16 07:05 -0800
Re: What's the best non-JVM native language to look at? lipska the kat <lipskathekat@example.com> - 2014-01-16 16:11 +0000
Re: What's the best non-JVM native language to look at? Martin Gregorie <martin@address-in-sig.invalid> - 2014-01-16 20:39 +0000
Re: What's the best non-JVM native language to look at? Jeff Higgins <jeff@invalid.invalid> - 2014-01-16 16:18 -0500
Re: What's the best non-JVM native language to look at? Martin Gregorie <martin@address-in-sig.invalid> - 2014-01-16 21:50 +0000
Re: What's the best non-JVM native language to look at? Jeff Higgins <jeff@invalid.invalid> - 2014-01-16 17:27 -0500
Re: What's the best non-JVM native language to look at? Joshua Cranmer đ§ <Pidgeot18@verizon.invalid> - 2014-01-17 10:28 -0600
Re: What's the best non-JVM native language to look at? lipska the kat <lipskathekat@example.com> - 2014-01-17 18:08 +0000
Re: What's the best non-JVM native language to look at? Joshua Cranmer đ§ <Pidgeot18@verizon.invalid> - 2014-01-17 15:44 -0600
Re: What's the best non-JVM native language to look at? Martin Gregorie <martin@address-in-sig.invalid> - 2014-01-18 02:09 +0000
Re: What's the best non-JVM native language to look at? Arne VajhĂžj <arne@vajhoej.dk> - 2014-01-17 22:15 -0500
Re: What's the best non-JVM native language to look at? Martin Gregorie <martin@address-in-sig.invalid> - 2014-01-18 17:21 +0000
Re: What's the best non-JVM native language to look at? Arne VajhĂžj <arne@vajhoej.dk> - 2014-01-18 12:41 -0500
Re: What's the best non-JVM native language to look at? Martin Gregorie <martin@address-in-sig.invalid> - 2014-01-18 19:46 +0000
Re: What's the best non-JVM native language to look at? Arved Sandstrom <asandstrom2@eastlink.ca> - 2014-01-18 03:56 -0400
Re: What's the best non-JVM native language to look at? lipska the kat <lipskathekat@example.com> - 2014-01-18 08:58 +0000
Re: What's the best non-JVM native language to look at? Martin Gregorie <martin@address-in-sig.invalid> - 2014-01-18 02:02 +0000
Re: What's the best non-JVM native language to look at? Arne VajhĂžj <arne@vajhoej.dk> - 2014-01-17 22:17 -0500
Re: What's the best non-JVM native language to look at? Martin Gregorie <martin@address-in-sig.invalid> - 2014-01-18 17:36 +0000
Re: What's the best non-JVM native language to look at? Arved Sandstrom <asandstrom2@eastlink.ca> - 2014-01-28 10:13 -0400
Re: What's the best non-JVM native language to look at? lipska the kat <lipskathekat@example.com> - 2014-01-28 16:21 +0000
Re: What's the best non-JVM native language to look at? Martin Gregorie <martin@address-in-sig.invalid> - 2014-01-28 22:09 +0000
Re: What's the best non-JVM native language to look at? Arne VajhĂžj <arne@vajhoej.dk> - 2014-01-18 20:02 -0500
Re: What's the best non-JVM native language to look at? leif.roar@invalid.com (Leif Roar Moldskred) - 2014-01-16 11:30 -0600
Re: What's the best non-JVM native language to look at? Silvio <silvio@internet.com> - 2014-01-16 23:27 +0100
Re: What's the best non-JVM native language to look at? Arved Sandstrom <asandstrom2@eastlink.ca> - 2014-01-17 01:08 -0400
Re: What's the best non-JVM native language to look at? Roedy Green <see_website@mindprod.com.invalid> - 2014-01-17 01:43 -0800
Re: What's the best non-JVM native language to look at? Saxo <jeti789@web.de> - 2014-01-17 01:53 -0800
Re: What's the best non-JVM native language to look at? Jeff Higgins <jeff@invalid.invalid> - 2014-01-17 11:03 -0500
Re: What's the best non-JVM native language to look at? Jeff Higgins <jeff@invalid.invalid> - 2014-01-17 11:27 -0500
Re: What's the best non-JVM native language to look at? Arne VajhĂžj <arne@vajhoej.dk> - 2014-01-18 19:49 -0500
Re: What's the best non-JVM native language to look at? Martin Gregorie <martin@address-in-sig.invalid> - 2014-01-19 12:35 +0000
Re: What's the best non-JVM native language to look at? Arne VajhĂžj <arne@vajhoej.dk> - 2014-01-19 17:05 -0500
Re: What's the best non-JVM native language to look at? Martin Gregorie <martin@address-in-sig.invalid> - 2014-01-19 23:44 +0000
Re: What's the best non-JVM native language to look at? Arne VajhĂžj <arne@vajhoej.dk> - 2014-01-19 19:45 -0500
Re: What's the best non-JVM native language to look at? Jeff Higgins <jeff@invalid.invalid> - 2014-01-19 19:55 -0500
Re: What's the best non-JVM native language to look at? Jeff Higgins <jeff@invalid.invalid> - 2014-01-19 20:04 -0500
Re: What's the best non-JVM native language to look at? Arne VajhĂžj <arne@vajhoej.dk> - 2014-01-20 15:38 -0500
Re: What's the best non-JVM native language to look at? Jeff Higgins <jeff@invalid.invalid> - 2014-01-20 18:30 -0500
Re: What's the best non-JVM native language to look at? Arne VajhĂžj <arne@vajhoej.dk> - 2014-01-20 19:43 -0500
Re: What's the best non-JVM native language to look at? Jeff Higgins <jeff@invalid.invalid> - 2014-01-20 20:16 -0500
Re: What's the best non-JVM native language to look at? Jeff Higgins <jeff@invalid.invalid> - 2014-01-20 20:30 -0500
Re: What's the best non-JVM native language to look at? Arne VajhĂžj <arne@vajhoej.dk> - 2014-01-20 20:43 -0500
Re: What's the best non-JVM native language to look at? Jeff Higgins <jeff@invalid.invalid> - 2014-01-21 00:55 -0500
Re: What's the best non-JVM native language to look at? Martin Gregorie <martin@address-in-sig.invalid> - 2014-01-20 21:41 +0000
Re: What's the best non-JVM native language to look at? Arne VajhĂžj <arne@vajhoej.dk> - 2014-01-20 17:10 -0500
Re: What's the best non-JVM native language to look at? lipska the kat <lipskathekat@example.com> - 2014-01-21 08:59 +0000
Re: What's the best non-JVM native language to look at? leif.roar@invalid.com (Leif Roar Moldskred) - 2014-01-21 04:03 -0600
Re: What's the best non-JVM native language to look at? lipska the kat <lipskathekat@example.com> - 2014-01-21 11:53 +0000
Re: What's the best non-JVM native language to look at? Martin Gregorie <martin@address-in-sig.invalid> - 2014-01-21 22:09 +0000
Re: What's the best non-JVM native language to look at? Martin Gregorie <martin@address-in-sig.invalid> - 2014-01-21 22:05 +0000
Re: What's the best non-JVM native language to look at? Martin Gregorie <martin@address-in-sig.invalid> - 2014-01-20 21:39 +0000
Re: What's the best non-JVM native language to look at? Arne VajhĂžj <arne@vajhoej.dk> - 2014-01-20 17:21 -0500
Re: What's the best non-JVM native language to look at? Martin Gregorie <martin@address-in-sig.invalid> - 2014-01-21 22:17 +0000
Re: What's the best non-JVM native language to look at? Jeff Higgins <jeff@invalid.invalid> - 2014-01-19 22:34 -0500
csiph-web