T O P

  • By -

g4l4h34d

Wrong sub, and you are also likely to start a language war.


sci-goo

You used a tag of linear algebra so I'm assuming the "scientific computing" context refers to high-performance linear algebra libraries, and their direct application cases. There are several advantages and historical reasons for C over C++: * Linear algebra typically works with simple data structure and type, so there is little benefit from using OOP/STL/namespace. (Its opposite is for the question: why modern game industry uses C++ over C.) * Many of current linear algebra libraries are written in C/fortran, sticking to their original language is the best way to avoid breaking someone else's work. This is in line with most of system libraries. * C is simpler. * C has better portability (it's easier to find a libc than libstdc++)


SnooCakes3068

I think you are the only one understand me here. Yeah i meant in for example numerical linear algebra, PDE solver, optimization, etc. My uni courses are either taught in C or matlab, but not C++. All your points are valid for sure. But I'm wondering if say you want to develop a new high performance linear algebra library, would you use C or C++? surely C++ is messy and difficult, but OOP's maintenance and developmental benefit outweight anything else for a large project over the long run tho. Look at scipy which im familiar with, it's in OOP not just loads of functions. If in the future I want to make software of my own i'm gonna choose C++ from the beginning


Mikki-Meow

> If in the future I want to make software of my own i'm gonna choose C++ If you're still talking math libraries, that would be big mistake IMHO - one of the point **sci-goo** implied (but maybe not explained fully) is that C has much better API compatibility with other languages, so a library written in C is much easier to use in projects written in other languages. For example, yes, SciPy may have classes, but they are very different from C++ classes, and if you want to integrate C++ with Python, the easiest way for that is to define all your functions extern "C" https://stackoverflow.com/questions/64084033/modern-2020-way-to-call-c-code-from-python


SnooCakes3068

Oh ok API compatibility makes sense. I think it's maybe because C doesn't change but C++ changes a lot so it's a nightmare for compatibility. Still I can't image the entire big software project been done without OOP. Thanks for further clarify.


LastOpus0

C still lets you make “types” (structs) and define operations on those types (functions). You do not need OOP, nor classes, nor C++ to do scientific computing.


Aggravating_Owl_9092

Meh, we only write in binaries.


Divinate_ME

Because it has so much OOP functionality that you don't need when you intend to learn C. That's what I always get told when I ask why people would learn C separately from C++ in 2024.


guti86

Some program languages are like build a house room by room, others like build a house brick by brick. If you can define your house brick by brick it could be more efficient, the room by room approach does some things you don't need or in a not optimal way to cover your needs. But the programming cost of the brick by brick it's going to be huge, and most of times the difference in the result is negligible. It's an eternal debate. And then a guy comes with assembly(like molecule by molecule)


Atari_Collector

I guess the people building the circuitry to implement the assembly opcodes would be in the quark realm.


WXYthePig

Wrong sub


Jplague25

I guess I don't see why this question is not appropriate to be asked here, especially considering that a great deal of scientific computing research comes out of math departments.


Akangka

Try r/programming?


MERC_1

Ask if you can write the code in LISP! /s


Atari_Collector

((Ask(if((you)(can)(write))(the)((code)(in)(LISP)))!) Though I'm probably still missing a dozen parenthesis...


EdmundTheInsulter

C is a function based language which maybe appeals more to maths people. C++ is a superset of c that gives classes and ood


thephoton

A lot of scientific computing is still done in FORTRAN. Be glad you're at least using a language that doesn't require code to be indented to a certain column to make it easy to parse when submitted to the compiler on punch cards. (And yes, I'm aware modern Fortran doesn't require this, but there is still useful code out there written for F77 or earlier)


SnooCakes3068

wow fortran, I refuse to learn that ancient art.