Linked by Thom Holwerda on Tue 12th Oct 2010 21:52 UTC
Java "Oracle and IBM today announced that the companies will collaborate to allow developers and customers to build and innovate based on existing Java investments and the OpenJDK reference implementation. Specifically, the companies will collaborate in the OpenJDK community to develop the leading open source Java environment."
Thread beginning with comment 444911
To view parent comment, click here.
To read all comments associated with this story, please click here.
drstorm
Member since:
2009-04-24

Nothing stops me from implementing objects in pure C?

Well, of course I knew that, but what's your point?

OO paradigm is a super-set of procedural programming, thus it is obvious that the same functionality can be achieved in a procedural language.

In a broader sense, any currently used paradigm can be implemented in an assembler, but does that mean that we should use assemblers for everything?

The question is why would you bother to use C to emulate C++ (unless you have to for some reason, e.g. for backward compatibility or to work around compiler limitations)?

Now, whether -you- consider that true object oriented language (as it requires some additional foot work to implement objects), is irrelevant.

It's very relevant because it is not a matter of opinion. C is not object-oriented. Period.

Besides, that OO-C thing is just the bit that caught my eye. When someone claims that C is the way to go for web development, I naturally assume that they don't have a clue. Call it a prejudice, but I'm rarely wrong.

In the world where web apps are barely secure even though they are written in high level languages like Java, the last thing we need it to return to buffer overflows, dangling pointers, etc.

Edited 2010-10-13 14:25 UTC

Reply Parent Score: 3

rom508 Member since:
2007-04-20

Besides, that OO-C thing is just the bit that caught my eye. When someone claims that C is the way to go for web development, I naturally assume that they don't have a clue. Call it a prejudice, but I'm rarely wrong.

In the world where web apps are barely secure even though they are written in high level languages like Java, the last thing we need it to return to buffer overflows, dangling pointers, etc.


If you are constantly having problems with buffer overflows and dangling pointers, then maybe you should go back to college.

I've written huge amounts of C code - stacks, queues, linked lists, concurrent hash tables, multithreaded network servers that can handle 1000s of concurrent connections, using I/O multiplexing (poll, kqueue, epoll, etc). I've also written a fair amount of string/text parsing code, e.g. HTTP parser, and I didn't really have any major issues with buffer overflows or dangling pointers.

When someone says C is insecure, or results in buggy code, it is usually the case of an incompetent programmer who blames his tools.

If you think it's impossible to write reusable software in C, using object-oriented interfaces, then get a book by Eric S. Roberts "Programming Abstractions in C", you may learn a great deal from it.

Edited 2010-10-13 15:06 UTC

Reply Parent Score: 2

drstorm Member since:
2009-04-24

If you are constantly having problems with buffer overflows and dangling pointers, then maybe you should go back to college.

Who said that I had problems with my C code? We are talking about the mainstream here, and the majority of people who write code do have these problems.

Besides, many people who do know about these problems and generally write quality code occasionally make these errors and the reason is simple: Do something enough times and you'll make a mistake eventually. Why should we do something manually if it can be done automatically?

I've written huge amounts of C code - stacks, queues, linked lists, concurrent hash tables, multithreaded network servers that can handle 1000s of concurrent connections, using I/O multiplexing (poll, kqueue, epoll, etc). I've also written a fair amount of string/text parsing code, e.g. HTTP parser, and I didn't really have any major issues with buffer overflows or dangling pointers.

Well, good for you... and bad for you! While it is great that you know C inside and out, from what you've said it is likely that C is the only language you know so well. Don't get me wrong, C is a great language, but you seem to think that one size fits all.

Also, you said that you did not experience any major pointer problems, but if you used a managed language, you wouldn't have any problems at all.

When someone says C is insecure, or results in buggy code, it is usually the case of an incompetent programmer who blames his tools.

Either that or they are talking about the statistics and not about any specific person.

If you think it's impossible to write reusable software in C, using object-oriented interfaces, then get a book by Eric S. Roberts "Programming Abstractions in C", you may learn a great deal from it.

I never said it was impossible. I am saying, however, that it is impractical. That's why we have C++. I will check the book out, though.


Personally, I prefer C to C++, because IMO C++ has a rather cumbersome syntax, but if I wanted OOP, C++ would be the logical choice for me.

Your post mostly implies that I am incompetent, while you are the experienced expert. I take my part of the blame for that, because I made it personal in the first place, and I am sorry for that. However, I still disagree with you.

Please, defend your position and convince me that I should use C for OOP instead of C++ with some solid arguments.

Edited 2010-10-13 17:30 UTC

Reply Parent Score: 4

RshPL Member since:
2009-03-13


OO paradigm is a super-set of procedural programming, thus it is obvious that the same functionality can be achieved in a procedural language.

I would say that is rather a mindset of designing an application or a library.


In a broader sense, any currently used paradigm can be implemented in an assembler, but does that mean that we should use assemblers for everything?

Hmm .. not. See pure functional languages. ;)


The question is why would you bother to use C to emulate C++ (unless you have to for some reason, e.g. for backward compatibility or to work around compiler limitations)?

Actually this question is pretty valid. One can code in C++
in a way that is very clean avoiding all the shitty complicated syntax and also making use of more strict type checking and const correctness. C++ is in not even slower in C in a pure sense. If you do OOP in C and do parallelism it will the same speed as virtual methods in C++.
However, what I heard about C++ is that it adds so much to the syntax landscape that it encourages very shitty design.
I think it's the same argument as with Perl / Python.
Python encourages one clean syntax, while with Perl programs
can take a form of an ascii art. ;)


"Now, whether -you- consider that true object oriented language (as it requires some additional foot work to implement objects), is irrelevant.

It's very relevant because it is not a matter of opinion. C is not object-oriented. Period.
"
Well .. it's a strange situation then .. C is a language with no object-oriented design in mind but it allows for designing your programs with object-oriented design. ;)

Besides, that OO-C thing is just the bit that caught my eye. When someone claims that C is the way to go for web development, I naturally assume that they don't have a clue. Call it a prejudice, but I'm rarely wrong.

In the world where web apps are barely secure even though they are written in high level languages like Java, the last thing we need it to return to buffer overflows, dangling pointers, etc.

While C would not be perfect for Web Development one could image a library that could even do garbage collection and be
relatively easy to use. I think writing web apps in C could be a somewhat achievable given a good library.
With C++ however the possibilities for convenient Web Dev are endless .. all the language features you can utilize.

Reply Parent Score: 0

RshPL Member since:
2009-03-13

parallelism

of course I meant polymorphism... Forgive my "something" that made me make that mistake. :p

Reply Parent Score: 2

gilboa Member since:
2005-07-06

The question is why would you bother to use C to emulate C++ (unless you have to for some reason, e.g. for backward compatibility or to work around compiler limitations)?


Of the top of my head:
1. You only need a small subset of CPP OO capabilities (objects), but rather not get hit by the CPP compiler limitations. (E.g. strong types)
2. Memory allocation under CPP is abysmal, at best. (Even if you take the time to replace the new implementation with your own, you still cannot replace informative error codes...)
3. Class constructor (and destructor) are poorly designed (lack of informative error codes), forcing you to use C-like initialization functions.
4. I work in environments (such as kernels) that do no look kindly at linking against the CPP rt libraries, let alone using exceptions (!!!!!) as error handling mechanism...

In short, if you only require objects and limited inheritance, good C implementation is far superior compared to full fledged implementation CPP. (And don't get me started about STL!)

In the world where web apps are barely secure even though they are written in high level languages like Java, the last thing we need it to return to buffer overflows, dangling pointers, etc.


I fully agree. As I said, I didn't really agree with the OP.

- Gilboa

Reply Parent Score: 2

drstorm Member since:
2009-04-24

All valid points. ;)

Reply Parent Score: 2

Neolander Member since:
2010-03-08

Well, Stourstrup himself said that there's not a single favored way to use C++, and that not using every feature is not a crime or characterized incompetence.

In my case (kernel development), I currently use it as a very nice superset of C with classes and (very important) function and operator overloading. I also use references from time to time. That's it.

In that case, the sole runtime requirement is to run the constructors before the kernel. Not a big deal, the assembly snippet required in order to do that is only a few lines long.

Reply Parent Score: 2