4 ms·
Is it just me - but writing correct and clear code depends less on the language and more on the problem being solved and the domain - and ones understanding of
by lifeisstillgood 8y ago
Is it just me - but writing correct and clear code depends less on the language and more on the problem being solved and the domain - and ones understanding of both.
Someone with a detailed grasp of both can write clear code in C, Haskell, Python even BASIC
If you don't grasp either and have no time to be allowed to do it, no language will save you.
- throwawayjava 8y ago> If you don't grasp either and have no time to be allowed to do it, no language will save you. That is certainly true. But the language can have a big impact on the difficulty of getting the implementation correct.
- mattnewport 8y agoGiven a certain level of understanding of the problem, certain languages can make it easier to write clear and correct code. For example, code that does physics or 3D graphics calculations is clearer in a language that can represent matrices and vectors as types providing the expected operations (e.g. C++ over C) and if the code involves physical quantities it can be easier to enforce correctness in a language that supports units in the type system.
- _n_b_ 8y agoAgree. This is one of the reasons that Fortran remains popular for scientific computing: * dead-simple array/vector operations (http://www.mathcs.emory.edu/~cheung/Courses/561/Syllabus/6-Fortran/array.html http://www.mathcs.emory.edu/~cheung/Courses/561/Syllabus/6-F...) * many useful built-ins (e.g., DOT_PRODUCT, MAXVAL/MAXLOC, MATMUL, TRANSPOSE) * standard math libraries (e.g., LAPACK) with lots of very fast functions for linear algebra
- jcora 8y agoThis. I hate this relativism about the merits of languages. There's an entire field of study dedicated to that and just because you can write a web app in all your languages of choice doesn't actually invalidate the vast conceptual differences that exist and have real effects on how you program
- majkinetor 8y agowhat field of study?
- vraivroo 8y agoProgramming Language Theory
- fauigerzigerk 8y agoBoth C and C++ can represent matrices and vectors as types with related operations. In my view, the key difference between these two languages is RAII.
- jcelerier 8y agobut only C++ allows you to write `c = a * x + b` instead of mat a, b, x, tmp, c; // ... mat_mul(&tmp, &a, &x); mat_sum(&c, &tmp, &b); which is what OP meant if I'm not mistaken.
- fauigerzigerk 8y agoTrue, operator overloading is definitely convenient for math.
- Mister_Snuggles 8y agoAs a real world (-ish) example, I wrote some Python code to do some effects on DMX lights. OpenLighting did all the talking to the lights, so the Python code was really just focused on constructing a list of numbers that would eventually find their way into OpenLighting and onto a DMX cable. Inside the Python code, each light has a Colour, and I built the Colour class with support for various math operators. Want to make a Colour that's half as bright as another? Colour = OtherColour * 0.5. Want to blend two Colours? BlendedColour = OneColour + AnotherColour. Doing this made all of the stuff that the code was doing incredibly obvious and straight forward. The alternative would have involved non-obvious helper functions and object methods or doing math directly on the rgb components encapsulated by each Colour object. This was, for me, somewhat of a "light bulb" moment for operator overloading.
- maxxxxx 8y agoIf it's done in good taste overloading is fine. But if abused it makes code totally unreadable and unmaintainable.
- 8y ago