Question about C language.

So I should focus on the top 3?
No. That is a popularity index. For example, specialized languages are perhaps below only because
of the demand of the speciality.

Python, on the third position, became very popular, even for numerical tasks, although as scripting languages
are Mathlab and R sure much better for numerical tasks, although as general purpose language perl and tcl in
my opinion better.

An example of a specialized language that cannot be replaced by the top 3 and is under "next 50 languages"
is postscript. It makes sense to learn postscript, as also tex (not mentioned in the web page).

And SQL is in the 9th place. If you want to deal with data bases, then SQL is first choice.
 
Tricky question. C has structs, which give it all the ability to take the data members of a class and put then together. You can also put function pointers into the struct, which means you can have behavior of objects. You can do inheritance and containment by putting structs into structs. You can do virtual methods by changing the function pointers in the struct. So it is perfectly possible to do OO with C. There was actually a book written in the 90s titled something like "object oriented programming using C", by a guy I used to work with.
 
I am still wandering around aimlessly trying to learn programming languages.

My question:
If C++, Python and java are "object oriented programming" what is C considered?
Classless?

Only clueless dorks that never learned anything post-1990 consider C++ to be "object oriented" (I'm thinking of one of my previous site managers whose narrow mindedness forced an entire project to have to reinvent virtual functions and templates in C).

C++ is "multi-paradigm". The emphasis for the last 15 years has been on generics and functional programming.

C is an imperative language https://en.wikipedia.org/wiki/Imperative_programming.
 
As much as I love C++, and prefer to do jobs that are well suited to C++, I have to respect and unfortunately agree with what was written on another forum, that I've attached here as a graphic. It does concisely point out a huge problem with C++ that shows no sign of going away.
 

Attachments

  • screen.png
    screen.png
    348.6 KB · Views: 118
C++ is "multi-paradigm". The emphasis for the last 15 years has been on generics and functional programming.
So that is your reality...In my reality the past 15 years of C++ have been on efficient and scalable abstractions to model complex systems in applied engineering, so I believe our experiences have been very different, thus supporting my point metioned in my previous post above.
 
To OPs original point, yes...C is classless and is a "purely functional" language. You can write code in C that appears to support some object oriented principles, but OO is not implicit in the language...in fact, C++ was originally termed "C with classes" thus explaining the shared syntax and common grammar rules between the two languages.
 
Tricky question. C has structs [...]
I don't think it's that tricky after all. Languages are classified by what their constructs directly support, so yes, as already mentioned, that makes C a "procedural" (or "imperative") language.

It's still interesting which programming paradigms are possible at all using some language, and indeed, C offers the most basic things you need to do some OOP yourself (which is probably used by almost any C project of a certain complexity). Still, that doesn't make C object-oriented or even multi-paradigm, it doesn't offer classes, methods, inheritance, polymorphism, etc. It just happens to have constructs you can use to implement all of that yourself.

One thing C certainly is not: "Functional" (just because that was claimed in this thread as well ....). In fact, the functional programming style is almost impossible to do in C. Functional programming means functions are first class objects, so you can construct higher-order functions. It also means functions are "pure" (they can't have side effects and their result can't depend on anything other than the parameters given), and it means you're working without any mutable state (you can't "assign" a variable in functional programming).
 
So I should focus on the top 3?
Have you thought about what you want to build?

If you want to understand OS code, learn C. The language is small, so read the K&R and learn to build the sample code, then try modifying the source for a command line tool like cat.

If you're interested in web development, learn JavaScript. You'll just need a text editor, a static web server and a browser to get started. This will give you enough to write client-side apps and browser extensions.

If you don't have anything specific in mind and just want to learn how to build lots of useful things quickly, learn Python.
 
To OPs original point, yes...C is classless and is a "purely functional" language. You can write code in C that appears to support some object oriented principles, but OO is not implicit in the language...in fact, C++ was originally termed "C with classes" thus explaining the shared syntax and common grammar rules between the two languages.

This is rather confusing. C is definitely not "purely functional". I'm sorry if the 'standard' names for programming paradigms are rather confusing but the name "functional" is used in the mathematical sense of functions without side effects. That means that languages like Haskell and Erlang are considered functional. Compile-time template metaprogramming in C++ can also be considered functional.

C is imperative (a list of commands) or procedural (where procedures can have side effects whilst functions can't).
 
One thing C certainly is not: "Functional" (just because that was claimed in this thread as well ....). In fact, the functional programming style is almost impossible to do in C. Functional programming means functions are first class objects, so you can construct higher-order functions. It also means functions are "pure" (they can't have side effects and their result can't depend on anything other than the parameters given), and it means you're working without any mutable state (you can't "assign" a variable in functional programming).
That may be a "pure functional language". That is not LISP or Scheme, and perhaps no functional language
other than the ones for pure theoretical purposes. C is as a functional language as an object oriented one,
just because it allows the recursive call of functions, that is the main characteristic of functional languages.
 
So that is your reality...In my reality the past 15 years of C++ have been on efficient and scalable abstractions to model complex systems in applied engineering, so I believe our experiences have been very different, thus supporting my point metioned in my previous post above.
How does that conflict with what I said? It's not just my opinion, Bjarne Stroustrup calls C++ multi-paradigm and there are a couple of books on multi-paradigm delevelopment with C++.

I do tend to agree with the view that C++ is getting terribly over-bloated. One of the big problems is that features have been added at an accelerating rate over the last couple of decades but features very rarely get deprecated and removed.


The initial implementation of Concepts (think of asserts on streriods) got canned basically because it was so complex that no ordinary programmer could use it, only experts and library writers.
 
everything in C is a function. int main(), (xx==1) returns a value...etc
by that definition it is "functional". Lemme guess...you guys went to comp-sci school AFTER Nikolas Wirth (master quiche eater) came onto the scene. LOL!

so "functional" isn't the right word...function oriented instead.
 
everything in C is a function. int main(), (xx==1) returns a value...etc
by that definition it is "functional". Lemme guess...you guys went to comp-sci school AFTER Nikolas Wirth (master quiche eater) came onto the scene. LOL!

so "functional" isn't the right word...function oriented instead.

I studied Electronics. Niklaus Wirth is one of my heroes (as well as designing several languages he was was also a Professor in Electronics at ETHZ in Switzerland).
 
"object oriented" "procedural" are really ways of designing and writing software, not really "the language" at least in my opinion.
One can write object oriented code in C (a lot of the VFS bits in the kernel can be considered object oriented).
 
It is true that C++ is complex or too complex. But complex does not mean that it is fantastic. The main problem is that in most cases the project does not need OOP. It is much simple to implement it with procedural programming than trying to do simple things in complex way with OOP. I have seen many cases when programmers use C++ or C# and think "we do OOP" and in practice the work is clear procedural programming - but they don't know it. The endless upgrades of C++ language are another topic.
 
"object oriented" "procedural" are really ways of designing and writing software, not really "the language" at least in my opinion.
One can write object oriented code in C (a lot of the VFS bits in the kernel can be considered object oriented).
If you need to, you can do that in Fortran. Not even '95, which has objects.
And regarding C++, I seldom find me using anything more complex that map, vector and string. They should not cram more stuff into the language or runtime, but instead into packages which are to work with a decent C++ compiler and language level, regardless of OS and so on. No dependencies. THAT would help, not throwing in the kitchen sink. Next thing to throw in is the towel then.
 
And regarding C++, I seldom find me using anything more complex that map, vector and string
Yep. Lots of good stuff in the STL that is useful, maybe overkill for a lot of things, but it can save time from remembering all the little corner cases in things like linked list traversals and other stuff.

Complexity for it's own sake is usually never good. Appropriate level of complexity can be good.
Original definition of C++ by Stroustrop was "C with objects" and original compiler implementations used a tweaked C preprocessor on the C++ code.
So just because C++ has complexity built in does not mean you must use it. Most of the time people "write C in C++".
 
Back
Top