3 ms·
It makes it easy to type, but does it make it easy to read/maintain? As they say, it's already way too easier to write code than to read it. A programmer shoul
by IlliOnato 5y ago
It makes it easy to type, but does it make it easy to read/maintain?
As they say, it's already way too easier to write code than to read it. A programmer should make every effort to make code more readable.
An editor should make it relatively easy to enter special symbols (especially if you can specify a limited set); it is totally solvable problem.
An editor can only help you so far with reading code...
- kaba0 5y agoI believe it is most definitely easier to read/maintain -- restricted to that small domain-specific function. Some greek letters have very specific meanings, replacing them with long-ass names straight up worsens readability. Writing out density, velocityX, etc will quickly fade the core logic of that function.
- brandmeyer 5y agoI don't think that there is a single example of a greek letter which has been universally adopted by all of the different engineering and mathematics communities to have a single non-overloaded meaning. The use of greek letters in academic writing has a single purpose: Compact notation. It has nothing to do with abstract readability.
- astrange 5y agoGreek letter abuse rarely happens in CS but there are a few cases. Try to guess what "lambda calculus" and "pi calculus" are without looking them up.
- wtallis 5y ago> The use of greek letters in academic writing has a single purpose: Compact notation. It has nothing to do with abstract readability. The compactness of the notation is a major factor in overall readability. Long variable names make it harder to see the overall structure of an expression. When operators, numerical constants and parentheses mostly are represented with one or two characters each but variable names are all much longer, then the only thing you can tell about a long line of code at first glance is what variables it uses as inputs. Mathematical pretty printing can help with some operators (eg. fractions) and make it more visually apparent what's being grouped together by parentheses, but even then long variable names will still detract from the ability recognize the structure of an expression.
- azalemeth 5y agoFor me, the biggest problem with the whole maths ---> code mapping is that of nested brackets. For a random quick example, I mean things like (a*(1+exp(1i*theta[0,:]))+foo(x))/((b-cosh(bar(x))+(b+sinh(y[:,-1])). The sort of thing where it just _looks_ far nicer on a page with like _real fractions_ -- where missing a bracket or changing the order of two brackets can _totally_ bugger you. Yes, changing the form of the expression a bit can make it "far nicer" or simpler -- for example, by defining intermediate terms -- but sometimes there's something to be said for <expression x> matches <equation y> in the paper. Another example where I think ASCII actually _is_ limiting is for entries of matrices directly. I mean, we try, but I'm not convinced we succeed. For an example (picked at random), hands up if you think this is a nice Euler angle transformation, where cphi/sphi etc are the cosine and sine of phi? No matter how you write it, it's going to be ugly. alpha = [cpsi*cphi-ctheta*sphi*spsi cpsi*sphi+ctheta*cphi*spsi spsi*stheta; -spsi*cphi-ctheta*sphi*cpsi -spsi*sphi+ctheta*cphi*cpsi cpsi*stheta; stheta*sphi -stheta*cphi ctheta];
- a1369209993 5y ago> a nice Euler angle transformation I'd probably go with something like: double cf = cos(phi),sf = sin(phi); double cp = cos(psi),sp = sin(psi); double ct = cos(theta),st = sin(theta); alpha = [ cp*cf-ct*sf*sp cp*sf+ct*cf*sp sp*st; -sp*cf-ct*sf*cp -sp*sf+ct*cf*cp cp*st; st*sf -st*cf ct]; but I agree it would look better with: alpha = [ cψ*cϕ-cθ*sϕ*sψ cψ*sϕ+cθ*cϕ*sψ sψ*sθ; -sψ*cϕ-cθ*sϕ*cψ -sψ*sϕ+cθ*cϕ*cψ cψ*sθ; sθ*sϕ -sθ*cϕ cθ]; Either way, I don't think Euler angles are ever going to be "nice".
- b2gills 5y agoIn Raku you can also use × (U+D7) for multiplication # this assumes that ϕ, ψ, and θ have already been set my \cϕ = ϕ.cos; my \sϕ = ϕ.sin; my \cψ = ψ.cos; my \sψ = ψ.sin; my \cθ = θ.cos; my \sθ = θ.sin; my \alpha = [ cψ×cϕ−cθ×sϕ×sψ, cψ×sϕ+cθ×cϕ×sψ, sψ×sθ; −sψ×cϕ−cθ×sϕ×cψ, −sψ×sϕ+cθ×cϕ×cψ, cψ×sθ; sθ×sϕ, −sθ×cϕ, cθ]; I'm not sure if using × helps or hurts in this case since I'm not really experienced in this area. These all work because Unicode defines ϕψθ as "Letter lowercase" say "ϕψθ".uniprops; # (Ll Ll Ll) --- I would like to note that I used the Unicode "Minus Sign" "−" U+2212 so that it wouldn't complain about not being able to find a routine named "cϕ-cθ". (A space next to the "-" would have also sufficed.)