General > General Technical Chat

How many people code in C these days, and if so, why?

<< < (13/99) > >>

engrguy42:
I wouldn't dismiss the benefits of an object-oriented language like C++, or especially C#. As an engineer, it is an incredibly logical and somewhat obvious approach to designing software. A bit like functional programming (eg, FORTRAN functions) on steroids.

You treat stuff as objects, with user inputs/interfaces/controls, internal processes, and outputs. Especially if you're modelling/simulating real world stuff it's extremely logical and efficient, IMO.

For example, if you're going to simulate a car, it has user interfaces (steering wheel, brakes, gas pedal), internal functions, and outputs. And if you build a model of the car engine and its controls, it's a fully functional block of code you can reuse the next time you simulate a car. Just tweak the object's parameters and you have a different engine.

Yeah, some seem to prefer functional, rather than object oriented, and they may have a point in some applications. But if you're simulating real world stuff it's wonderful, IMO.

Of course if you're not simulating real world stuff, and doing more abstract stuff, then maybe it's overkill. I've used it to simulate/model control systems, it's great. You end up with a block of code that defines the hardware, maybe even comprised of sub-objects you connect together, and tweak the parameters and you're ready to go. Wonderful. 

Personally, I couldn't care less what others use, and what's more popular. Different tools for different jobs. And it seems the higher level languages (C++, C#, etc.) are better for more abstract uses, and the lower levels (C, ASM, etc.) for more direct hardware-based stuff.

SiliconWizard:
Note that you can write (as some of us have already pointed out) code in an object-oriented manner in C. Whether it's more clunky than using C++ is all a question of perspective. As long as you know how to do it, and don't want to implement fancy OO features (which are often highly debatable anyway), doing that in C is not really that much clunky. I'm used to it. I've done that both in C and C++, and quite frankly, if done right, it doesn't even take more lines of code in C, or not significantly so. I'll admit that if you do that, you'll get less "verification" from the compiler, so in that respect, you need to be extra careful.

The same goes for functional programming -  you can pretty much program in a pure functional way in C. But to be frank, contrary to OO, where it doesn't really add any overhead compared to C++ (again if done right, and again as along as you don't try super fancy paradigms), pure functional programming in C WILL add overhead (sometimes considerable) compared to true functional programming languages that natively optimize a lot of internal data structures and data passing.

You can of  course also use a mix of approaches.

radioactive:
For me,  it is C99 unless I have to write a user interface that will run on Windows.  In that case,  Java.

If you need some embedded scripting capabilities, why not use 'C' for that too?.  https://github.com/jpoirier/picoc

tom66:
Most of the software I write is C or Python. 

If it's embedded, it's 99% C (and about 1% assembler, processor dependent.)

I've been wondering if I should move to C++ for a certain recent project, but I'm half way in and that's a long curve to get up to speed in a new-ish language.

engrguy42:

--- Quote from: SiliconWizard on May 06, 2020, 02:22:45 pm ---Note that you can write (as some of us have already pointed out) code in an object-oriented manner in C. Whether it's more clunky than using C++ is all a question of perspective. As long as you know how to do it, and don't want to implement fancy OO features (which are often highly debatable anyway), doing that in C is not really that much clunky. I'm used to it. I've done that both in C and C++, and quite frankly, if done right, it doesn't even take more lines of code in C, or not significantly so. I'll admit that if you do that, you'll get less "verification" from the compiler, so in that respect, you need to be extra careful.

The same goes for functional programming -  you can pretty much program in a pure functional way in C. But to be frank, contrary to OO, where it doesn't really add any overhead compared to C++ (again if done right, and again as along as you don't try super fancy paradigms), pure functional programming in C WILL add overhead (sometimes considerable) compared to true functional programming languages that natively optimize a lot of internal data structures and data passing.

You can of  course also use a mix of approaches.

--- End quote ---

Absolutely true. You CAN do just about anything with any software, just like you can probably build a house using only a screwdriver  :D

IMO, what's important is that folks are familiar with each of the tools enough to know what's best for each task, and not restricted by a vague bias based on minimal experience.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod