LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch
User Name
Password
Linux From Scratch This Forum is for the discussion of LFS.
LFS is a project that provides you with the steps necessary to build your own custom Linux system.

Notices


Reply
  Search this Thread
Old 04-22-2014, 08:02 PM   #16
Luridis
Member
 
Registered: Mar 2014
Location: Texas
Distribution: LFS 9.0 Custom, Merged Usr, Linux 4.19.x
Posts: 616

Original Poster
Rep: Reputation: 167Reputation: 167

Quote:
Originally Posted by ReaperX7 View Post
I've never really liked plain C code myself. To me C is a dumb language, meaning it's very unoptimized, offers no real compile time benefits, and can't be really updated in syntax. C is just C, it always has been what it is and will be. It's universal and good for porting, but... that's about it.

C++ however was a vastly different story for me. It was highly optimizale, the syntax can be cleaned up more easily, and it has many compiler benefits that can be translated to various architectures.

To me the difference between C and C++ was like comparing Dueling Banjos to one of Beethoven's symphonies.
The optimization of C is not in the compiler, it's in the programmer. The assembly that pops out the other side is predictable. IIRC, C++ programmers have to use templates and such to make sure they don't trip cache misses and what have you. You can find a good overview of the pros & cons of using C at the OS level here.

Torvalds has also talked about this... I tend to agree with his statements except I think C could use some updating. Take a few ideas from Golang and some others. But just a few, the ones that will make the most difference.

I think languages end up dominating the areas they dominate because they're a good fit for that slot in the software layer. C++ is a mid-level API language that still gives some hardware control. C#/Python and all those dominate the top layer, where huge boiler plate libraries are expected and would take too long to write in C.

The way I've tried to explain it to java programmers and what have you is that C addresses the problem domain of the hardware, which doesn't speak object and class, it speaks instructions and data. C is good with those two structures; it was sorta designed for them.

Quote:
In other words, the only way to do good, efficient, and system-level and
portable C++ ends up to limit yourself to all the things that are
basically available in C. And limiting your project to C means that people
don't screw that up, and also means that you get a lot of programmers that
do actually understand low-level issues and don't screw things up with any
idiotic "object model" crap.

So I'm sorry, but for something like git, where efficiency was a primary
objective, the "advantages" of C++ is just a huge mistake. The fact that
we also piss off people who cannot see that is just a big additional
advantage.

If you want a VCS that is written in C++, go play with Monotone. Really.
They use a "real database". They use "nice object-oriented libraries".
They use "nice C++ abstractions". And quite frankly, as a result of all
these design decisions that sound so appealing to some CS people, the end
result is a horrible and unmaintainable mess.

But I'm sure you'd like it more than git.

Linus

Last edited by Luridis; 04-22-2014 at 08:04 PM.
 
Old 04-22-2014, 08:25 PM   #17
ReaperX7
LQ Guru
 
Registered: Jul 2011
Location: California
Distribution: Slackware64-15.0 Multilib
Posts: 6,558
Blog Entries: 15

Rep: Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097
Quote:
Originally Posted by re_nelson View Post
Both forms of music have their places as do the two languages. Nevertheless, as one -- like most -- who started in C and then slowly migrated to C++, I've become more conversant in the latter. Initially, I simply wrote in C++ as if it were a "better C" and ignored the OO aspects. Then as I became more familiar with the essence of the language, the object orientation naturally flowed. I think the real epiphany came when the STL was standardized, especially the really nice things available in <algorithm>. The encapsulating of data and functionality in a class has made my programs less error-prone.

On the other hand, Linus Torvalds has some strong opinions about "Aggie" Bjarne Stroustrup's language:

http://harmful.cat-v.org/software/c++/linus

...and by the way, GCC-4.9.0 is now available and will probably make it into BLFS (if not LFS) before too long. I was pleased to see that <regex> from the C++11 standard was finally implemented after all these years:

http://gcc.gnu.org/gcc-4.9/changes.html
Yeah, same here, though LLVM/Clang has already had them for quite some time.
 
Old 04-22-2014, 08:28 PM   #18
Luridis
Member
 
Registered: Mar 2014
Location: Texas
Distribution: LFS 9.0 Custom, Merged Usr, Linux 4.19.x
Posts: 616

Original Poster
Rep: Reputation: 167Reputation: 167
Here, the folks in this stack overflow thread sum it up well. Why, when, how C is better than ++ and when ++ is better than C.

A nice one for C being this:

Quote:
C is portable assembly with better syntax, yielding the programmer full control of everything.

C++ on the other hand, does a lot of funky magic (virtual functions, overloading, automatic conversion, etc etc) which may not be desirable when you want to make sure you:

don't use more memory than you want to
don't access memory pages willy nilly (the vtable can be anywhere)
don't invoke to much code accidentally

And want something really simple to work with, since you're focused on performance.

It just has no surprises, and that's very valuable.

If you want to (and I recommend it), read the JSF coding guidelines on what you need to think about when writing C++ for military avionics control. It's a lot of traps in there that you need to be aware of, and it may catch you out. Bjarne was part of that document, so he knows what it's about.

Also, C compiles like a scalded troll struck by lightning. C++, OTOH, was probably sponsored by the same people who invested in SSD companies .

(Personally, I'd prefer C++ though, but I don't like it...... either. ;-P)
BTW: Don't know why so many folks are down on Torvalds, like him or not the guy has been writing kernel code for 25 years... that's got to be worth some insight.
 
Old 04-22-2014, 11:39 PM   #19
ReaperX7
LQ Guru
 
Registered: Jul 2011
Location: California
Distribution: Slackware64-15.0 Multilib
Posts: 6,558
Blog Entries: 15

Rep: Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097
The more portable code is the less you'll want to drift into anything beyond C as C is fairly universal and an be manipulated on the build end rather within the code.

Because Linux as a kernel is multi-platform, you'll want to assign less architecture code into it as things like SIMD instructions and optimizations for platforms like AMD64/EM64T don't translate to ARM6 or ARM7, or even PPC, RISC, etc.
 
Old 04-23-2014, 01:10 AM   #20
Luridis
Member
 
Registered: Mar 2014
Location: Texas
Distribution: LFS 9.0 Custom, Merged Usr, Linux 4.19.x
Posts: 616

Original Poster
Rep: Reputation: 167Reputation: 167
Quote:
Originally Posted by ReaperX7 View Post
Because Linux as a kernel is multi-platform, you'll want to assign less architecture code into it as things like SIMD instructions and optimizations for platforms like AMD64/EM64T don't translate to ARM6 or ARM7, or even PPC, RISC, etc.
Isn't that the whole point of the preprocessor though? So they're not manually dropping in macro's like the older languages... I don't think it's quite portable assembly, even though that's what its used for. But if you need small, simple, fast and optimized; there it is.

If you're linking an Apache WSDL & and LDAP on another OS to a command line(service) on a third heterogeneous system (something I've done). Hells no, I'm not writing that in C. In fact I've never written from-scratch C programs, always tweaking someone else's.

Last edited by Luridis; 04-23-2014 at 01:16 AM.
 
Old 04-24-2014, 01:08 AM   #21
Luridis
Member
 
Registered: Mar 2014
Location: Texas
Distribution: LFS 9.0 Custom, Merged Usr, Linux 4.19.x
Posts: 616

Original Poster
Rep: Reputation: 167Reputation: 167
This VMWare method is turning out to be a gem. I do this with servers and don't know why it didn't come to mind for building software.

When I run into stuff that doesn't work right I just flip back to the last snapshot. When I am done I can create a "full clone" that will merge all the disk snapshots into a single file.

I'm running to quite a few that don't work: S-Lang is the latest. I was going to install it since it's small and might be useful at some point in nano, but if it requires a lot of troubleshooting then it's not worth it to me since I have no concrete plans to use it.
 
Old 06-01-2014, 01:55 AM   #22
corbis_demon
Member
 
Registered: Jun 2004
Distribution: CLFS
Posts: 523

Rep: Reputation: 38
Quote:
Originally Posted by Luridis View Post
The optimization of C is not in the compiler, it's in the programmer.
Succintly put, and to quote Don Knuth, "Premature optimization is the root of all evil" :-)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LFS with systemd, what features will Python give me? McZ Linux From Scratch 1 03-06-2013 01:21 AM
LXer: I hate Unity. I hate GNOME. I hate Windows 8. The ultimate desktop search continues. LXer Syndicated Linux News 1 11-09-2011 07:20 PM
I am really starting to hate google smeezekitty General 35 06-04-2010 11:50 AM
Starting To Really Hate My Linspire irondan433 Linux - Software 2 11-29-2004 08:55 AM
Re-starting LFS finegan Linux From Scratch 4 02-04-2002 09:00 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch

All times are GMT -5. The time now is 03:13 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration