• Looking to learn C.
    38 replies, posted
[QUOTE=esalaka;25319515]Also, C requires a smaller runtime library, I believe.[/QUOTE] If I am not mistaken, the STLPort implements the C++ standard library in platform independent C++. Even if this is not true, there are probably just few adjustments required to make it compile in the desired environment. Though if you are speaking in terms of memory available on an embedded system, then sure it'll take away a few kilobytes more. My GNU libstdc++ v6 is around 1.0MB.
[QUOTE=ZeekyHBomb;25319846] My GNU libstdc++ v6 is around 1.0MB.[/QUOTE] Mine is 980K — but it's dynamically linked to libm (519K), libc (1,4M), ld (151K) and libgcc (87K). That totals over 3 megabytes. Many embedded devices nowadays might have that three megabytes, but some do not — or are not willing to waste it. Also, they probably won't be using the GNU implementation - I recall there's much smaller ones out there, especially for embedded devices.
[QUOTE=ZeekyHBomb;25318966]That's beside the point I made. I think embedded devices choose C over C++ because the language specification is smaller and thus writing a compiler is less work.[/QUOTE] That and: 1. C++ doesn't provide anything [i]useful[/i] for low-level embedded development. OOP just gets in the way for simple tasks. Why not just use C compiler if you're going to have to write C-style code anyway. 2. [url=http://thread.gmane.org/gmane.comp.version-control.git/57643/focus=57918]It keeps out C++ programmers[/url]. :v:
Lol, my libc.so.6 is 1.4mb, and my libstdc++.so.6 is 996k. However, I ran ldd on libstdc++.so.6 and it links to libc.so.6. So to run a C++ program you need libc. :v: [code] casey@gentoobox ~ % ldd /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.1/libstdc++.so.6.0.14 linux-vdso.so.1 => (0x00007fff3f5ff000) libm.so.6 => /lib/libm.so.6 (0x00007f81b9e01000) libc.so.6 => /lib/libc.so.6 (0x00007f81b9a9b000) /lib64/ld-linux-x86-64.so.2 (0x00007f81ba3bc000) libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00007f81b9883000) casey@gentoobox ~ % ldd /lib64/libc.so.6 /lib64/ld-linux-x86-64.so.2 (0x00007fbcfd8fc000) linux-vdso.so.1 => (0x00007fff047f2000) [/code]
[QUOTE=ROBO_DONUT;25319968]1. C++ doesn't provide anything [i]useful[/i] for low-level embedded development. OOP just gets in the way for simple tasks. Why not just use C compiler if you're going to have to write C-style code anyway.[/QUOTE] That's the first fitting argument I've heard. Though still, bunguer said that some usages may [i]need[/i] C instead of C++. Maybe I'm just being picky with his/her wording... btw, you can write C++ without the C++ standard library, though it also cripples some features that one would have thought were language, nor standard library features. I think static construction is one of them. You could provide a slimmed version of it though.
I choose the language based on what I want to do. If I wanted to code for an embedded device or do low-level work I'd use C. For general programming I'd use C++. For web-applications and quick things I'd use python for its simplicity and the clean code.
[QUOTE=ZeekyHBomb;25320350]That's the first fitting argument I've heard. Though still, bunguer said that some usages may [i]need[/i] C instead of C++. Maybe I'm just being picky with his/her wording... btw, you can write C++ without the C++ standard library, though it also cripples some features that one would have thought were language, nor standard library features. I think static construction is one of them. You could provide a slimmed version of it though.[/QUOTE] I could used a better wording, to be honest I am a lot more familiar with C than with C++ but if I'm not mistaken C++ relies a lot on libraries and that's one thing you may not have at your disposal when dealing with embedded systems for example. C is really close to the hardware, which is why it's the preferred language for that kind of thing, it's a lot more readable than Assembly too.
[QUOTE=ZeekyHBomb;25320350]That's the first fitting argument I've heard. Though still, bunguer said that some usages may [i]need[/i] C instead of C++. Maybe I'm just being picky with his/her wording... btw, you can write C++ without the C++ standard library, though it also cripples some features that one would have thought were language, nor standard library features. I think static construction is one of them. You could provide a slimmed version of it though.[/QUOTE] Technically speaking, you can do anything in any turing-complete language provided you have enough memory. However, certain languages are not conducive to clean code for certain tasks. You "can" use C++ for low-level and embedded work, but it wouldn't be the sort of C++ that most C++ programmers are used to. The "C approach" to many problems work better at this level.
[QUOTE=esalaka;25319515]Also, C requires a smaller runtime library, I believe.[/QUOTE] C requires no runtime library.
Sorry, you need to Log In to post a reply to this thread.