So you know... which one is better? I'm making a really simple shell in C, but string management was a pain the a**, so I switched to C++, but now I saw an email by Linus Torvalds explaining why C++ is the sh*t and that everyone should use C.
Which one is better?
Feel free to swear... we really don't care.
removed advice because I'm dumb apparently
edit:
also, "the shit" means it's the best
Depends on what you want to do.
Linus prefers C over C++ because of what he does. C++ isn't as good as C for creating kernels and drivers and filesystems and the like.
For everything else, both are fine.
Linus doesn't like C++ because he does low-level kernel work. C gives you a lot more control with less overhead.
[QUOTE]Feel free to swear... we really don't care.[/QUOTE]
okay
[QUOTE=PvtCupcakes;16379184]Depends on what you want to do.
Linus prefers C over C++ because of what he does. C++ isn't as good as C for creating kernels and drivers and filesystems and the like.
For everything else, both are fine.[/QUOTE]
knew linus was going to be mentioned in this topic.
@ op: also, there isn't a "superior" language, every language has it's uses.
[QUOTE=efeX;16379400]knew linus was going to be mentioned in this topic.[/QUOTE]
OP mentioned him.
[QUOTE=Anon in 7chan]Torvalds is a religious asshole. If he disagrees with you (regardless of how small the disagreement is) it's impossible to speak to him.
Not to mention his arrogance which is beyond astronomical levels.[/QUOTE]
wow
I know that "every language has its niche" is the "correct" thing to say, but I've always thought that C++, C#, Java, etc. were in this uncomfortable "middle-level" position, where they try to do everything and do very little well. At the low-level, OOP, operator overloading, encapsulation, etc. aren't at all useful. At the high-level, dealing with strict data typing and memory management is a pain. They're certainly popular right now, so they're probably the pragmatic choices if you want to get a cubicle farm job, but I think that there are better choices from a design standpoint. They certainly [I]can[/I] be used to write good software, but I don't think they're conducive to it.
Not to mention you'd have to be completely out of your mind to write a library in any of the aforementioned languages since it would be completely unportable. A C++ library won't even work across [I]compilers[/I], let alone [I]platforms[/I]. Most interpreted languages expect bindings in C, so you can't simply expose a C++ class to a Python extension, it requires some trickery. You can't use them for writing code for resource-limited embedded platforms (I don't mean like your fancy-ass cell phone gadgetry, I'm talking $2 microcontroller), either.
Personally, I like a clear separation between the low-level and high-level work. C is clearly a low-level language. You work with memory directly and C code translates almost directly to assembly instructions (unless you have optimizations turned on in your compiler). This is good for building core functionality of your application. Decoding files, intensive processing, rendering output, etc. The backend stuff. You can then use a higher-level language (such as Python) to do the organizational work and build a front-end for the core functionality. This way, you don't have low-level micromanagement seeping into your high-level organization or high-level metaphorical nonsense spilling over into your concrete, close-to-the-metal work.
C is probably better to learn with because it makes it exceedingly easy to shoot yourself in the foot. You don't learn anything from success, and you don't learn to ride a bike without ever taking the training wheels off.
It's a matter of personal preference.
[QUOTE=Eudoxia;16379499]wow[/QUOTE]
he's right.
[QUOTE=Eudoxia;16379499]wow[/QUOTE]
Replace "Torvalds" with "Anon" and that statement is equally true.
[QUOTE=Eudoxia;16379499]wow[/QUOTE]
Check this out:
[url]http://lkml.org/lkml/2009/7/28/373[/url]
Linus is always right.
[QUOTE=ROBO_DONUT;16380008]Not to mention you'd have to be completely out of your mind to write a library in any of the aforementioned languages since it would be completely unportable.[/QUOTE]
You're right - Bad programmers write unportable code. Good one manage NOT to use every single compiler extension that exists and write code that works on the main compilers just fine. (Yes, this sentence is mainly aimed at C++)
You're also completely out of your mind, or just lieing when you claim that Java or C# libraries aren't portable. Have you ever *used* Java? Java code can run on basically any platforms with no modifications. C# libraries aren't portable, but they can be used on all the platforms that actually matter, in multiple languages (VB, C#, ASP.NET, ...)
Mind explaining that a bit, maybe?
[QUOTE=PvtCupcakes;16380199]Check this out:
[url]http://lkml.org/lkml/2009/7/28/373[/url]
Linus is always right.[/QUOTE]
yeah um don't turn this into a linus worshipper topic, thanks.
[QUOTE=gparent;16380209]You're right - Bad programmers write unportable code. Good one manage NOT to use every single compiler extension that exists and write code that works on the main compilers just fine. (Yes, this sentence is mainly aimed at C++)
You're also completely out of your mind, or just lieing when you claim that Java or C# libraries aren't portable. Have you ever *used* Java? Java code can run on basically any platforms with no modifications. C# libraries aren't portable, but they can be used on all the platforms that actually matter, in multiple languages (VB, C#, ASP.NET, ...)
Mind explaining that a bit, maybe?[/QUOTE]
I think what he means is that you can't expose Java classes to other languages. Like his Python example, you can't expose a C++ class to a Python application, but you can with C.
I write Java everyday at work, and it is nice that you can use the same compiled file across multiple platforms though. Although, one of my coworkers decided to rewrite an older program I did and convert it from the cross platform Swing toolkit to SWT which requires Dlls and crap. :ughh:
[QUOTE=gparent;16380209]You're right - Bad programmers write unportable code. Good one manage NOT to use every single compiler extension that exists and write code that works on the main compilers just fine. (Yes, this sentence is mainly aimed at C++)
You're also completely out of your mind, or just lieing when you claim that Java or C# libraries aren't portable. Have you ever *used* Java? Java code can run on basically any platforms with no modifications. C# libraries aren't portable, but they can be used on all the platforms that actually matter, in multiple languages (VB, C#, ASP.NET, ...)
Mind explaining that a bit, maybe?[/QUOTE]
As far as I know, a library written in Java can't be used in C, C++, C#, Python, Lua, or anything else. Even if it could, it would likely be the slowest part of the program. I'm also sure that there are plenty of embedded systems that don't have Java VMs available for them. As a general rule, anything that executes instructions has a C compiler available for it somewhere.
[QUOTE=ROBO_DONUT;16380390]As far as I know, a library written in Java can't be used in C, C++, C#, Python, Lua, or anything else. Even if it could, it would likely be the slowest part of the program. Again, I'm sure there are plenty of embedded systems that don't have Java VMs available for them. As a general rule, anything that executes instructions has a C compiler available for it somewhere.[/QUOTE]
This depends entirely on what you're writing. The majority of programmers do not care about some old underused microprocessor not being able to use their XML parsing library. They just want to run on the platforms that matter. And the ones that matter tend to have Java VMs on them, and if they don't, they'll have enough manpower to port the library.
I think limiting yourself to C just so your library works on *insert odd instruction set or platform here* is completely off-track.
On another note, yeah, you're correct that if you want a library to work on multiple languages, then C will be your best bet. However the problem is usually running the library on multiple architectures, as bindings can be pretty awful sometimes.
[QUOTE=gparent;16380449]This depends entirely on what you're writing. The majority of programmers do not care about some old underused microprocessor not being able to use their XML parsing library. They just want to run on the platforms that matter. And the ones that matter tend to have Java VMs on them, and if they don't, they'll have enough manpower to port the library.
I think limiting yourself to C just so your library works on *insert odd instruction set here* is completely off-track.[/QUOTE]
Maybe, but you skipped over the "bindings to other languages" block. I got that right, at least, didn't I?
When I said "writing a library" I didn't mean "writing yet another half-assed XML library". I'm talking about a unique library where it would be beneficial to target as many platforms as possible initially so that you wouldn't have to go back and target the ones you missed later. If you were developing a new protocol for some application, and you wrote the [I]only[/I] library for communicating with that protocol for Java, it probably wouldn't become very popular, would it?
[QUOTE=ROBO_DONUT;16380469]Maybe, but you skipped over the "bindings to other languages" block. I got that right, at least, didn't I?[/QUOTE]
Sorry. I tend to do drive-by replies using EDIT a lot.
[QUOTE=gparent;16380509]Sorry. I tend to do drive-by replies using EDIT a lot.[/QUOTE]
I just did the same thing. :smugdog:
[QUOTE=ROBO_DONUT;16380469]When I said "writing a library" I didn't mean "writing yet another half-assed XML library". I'm talking about a unique library where it would be beneficial to target as many platforms as possible initially so that you wouldn't have to go back and target the ones you missed later.[/QUOTE]
Possibly, assuming you're part of the (usually unixish) camp of "everything must work everywhere." I try to encourage it, but I don't think that attitude is necessary the majority of the time under real-world circumstances. Most of the time it's a novelty if anything that your library runs everywhere.
[QUOTE=gparent;16380449]This depends entirely on what you're writing. The majority of programmers do not care about some old underused microprocessor not being able to use their XML parsing library.
[/QUOTE]
If you're programming for things like Arduinos; there is no JVM for those devices.
But yeah, if you're targeting desktop PCs, Java is a safe bet.
[QUOTE=PvtCupcakes;16380681]If you're programming for things like Arduinos; there is no JVM for those devices.[/QUOTE]
Or just the chip itself. Any of the Atmel AVRs.
[QUOTE=gparent;16380586]Possibly, assuming you're part of the (usually unixish) camp of "everything must work everywhere." I try to encourage it, but I don't think that attitude is necessary the majority of the time under real-world circumstances. Most of the time it's a novelty if anything that your library runs everywhere.[/QUOTE]
This is true. I guess I'm part of the unixy "everything must work everywhere" camp, and I think it is frequently more of an idealistic decision than a pragmatic one. It's a good thing to have, but it's not terribly important for tiny projects.
Linus said that because he's an idiot.
Use C++.
[QUOTE=nullsquared;16380862]Linus said that because he's an idiot.
Use C++.[/QUOTE]
You seem to like oversimplifying things.
[QUOTE=ROBO_DONUT;16380929]You seem to like oversimplifying things.[/QUOTE]
What? He [b]is[/b] an idiot. Look at his email. It looks like some newbie C programmer raged at someone who knows C++ better than him.
[editline]07:17PM[/editline]
[quote]
*YOU* are full of bullshit.
[/quote]
Good comeback, Linus.
[quote]
C++ is a horrible language. It's made more horrible by the fact that a lot
of substandard programmers use it, to the point where it's much much
easier to generate total and utter crap with it.
[/quote]
wat?
[quote]Quite frankly, even if
the choice of C were to do *nothing* but keep the C++ programmers out,
that in itself would be a huge reason to use C.
[/quote]
wat?
[quote]
In other words: the choice of C is the only sane choice. I know Miles
Bader jokingly said "to piss you off", but it's actually true. I've come
to the conclusion that any programmer that would prefer the project to be
in C++ over C is likely a programmer that I really *would* prefer to piss
off, so that he doesn't come and screw up any project I'm involved with.
[/quote]
What is he blabbing about?
[quote]
C++ leads to really really bad design choices. You invariably start using
the "nice" library features of the language like STL and Boost and other
total and utter crap, that may "help" you program, but causes:
[/quote]
This is actually kind of funny.
YA I DON'T USE NICE FEATURES OF LANGUAGE SO I PRO PROGRAMMER
[quote]
- infinite amounts of pain when they don't work (and anybody who tells me
that STL and especially Boost are stable and portable is just so full
of BS that it's not even funny)
[/quote]
That's why they've been tested for many, many years by experts. So the case where "they don't work" doesn't really exist.
[quote]
- inefficient abstracted programming models where two years down the road
you notice that some abstraction wasn't very efficient, but now all
your code depends on all the nice object models around it, and you
cannot fix it without rewriting your app.
[/quote]
I don't think Linus has ever heard of profiling.
[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.
[/quote]
wat?
So all C programmers are pros, and all C++ programmers are noobs? Good one :downsbravo:
[quote]
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.
[/quote]
Come on, you still think he's not an idiot?
[quote]
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.
[/quote]
OH SO U USE C++? UR CODE MUST BE A MESS LOL I USE C MY CODE PRETTY
no guys C is better cause linus ssaid so! he made the linux kernel and stuff so he must be right.
It's all a preference. I like the simplicity of C, but I would never see myself writing any complicated system without OO.
@nullsquared:
I'm sure you would react similarly if someone jumped into your mailing list and started telling you how wrong you were. I would, at least. Read back a few posts.
Anyway, I prefer his honesty to the rest of the computer industry's "our PR people have PR people" responses.
Sorry, you need to Log In to post a reply to this thread.