Posted by xeonmc 5 days ago
If the lower (negative) score, the better (given a fixed set of features).
“Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.” ― Antoine de Saint-Exupéry, Airman's Odyssey
[0]: https://en.wikipedia.org/wiki/Halstead_complexity_measures
print([i * 2 for i in range(10)])
vs
squared_numbers = []
for i in range(10):
squared_numbers.append(i \* 2)
print(squared_numbers)It's not even a readability thing, assuming list comprehensions don't bother you they're about equally readable
These 5 lines are probably my favorite example.
One of the criticisms of microservices is that factoring a system correctly is already a hard problem, and introducing a network call between them makes it even harder.
Enforcing service LoC limits is equivalent to forcing further factoring of a system, which might not be necessary, especially not into a microservice arch.
Sometimes code is tightly coupled because it needs to be tightly coupled.
For what it's worth, here's quicksort in 5 lines of haskell https://stackoverflow.com/questions/7717691/why-is-the-minim...
How long would a quicksort (say, of integers) be in 68000 assembly? Maybe 20 lines? My 68000 isn't very good. The real advantage of writing it in Haskell is that it's automatically applicable to anything that's Ord, that is, ordered.
About 70 lines, once you strip out the comments and blank lines.
https://github.com/historicalsource/supermario/blob/9dd3c4be...
I'm trying to code up a version in ARM assembly to compare, and it looks like it'll be about 30 lines; when I get that working I can compare to see why the difference. In some ways the 68000 is more expressive than ARM, like being able to reference memory directly, even twice in one instruction.
(Am I misunderstanding this, or is this the source code to Apple System 7.1? There seems to have been a mailing list about this codebase from 02018 to 02021: https://lists.ucc.gu.uwa.edu.au/pipermail/cdg5/)
quirks: push {r4, r5, r6, lr}
4: subs r2, r0, r1
bhs 3f @ Exit if carry set (no borrow).
mov r5, r1 @ This frees up r1 as a temp.
mov r6, r0
ldr r3, [r5]
1: ldr r4, [r5, r2]
cmp r4, r3 @ Is element at r2 ≤ pivot?
bgt 2f @ If so, swap elements at r2 and r6,
ldr r1, [r6] @ Load previously first element in > side,
str r4, [r6], #4 @ and postincrement r6,
str r1, [r5, r2] @ and save previous element at end of > side.
2: adds r2, #4 @ Increment offset. Reached the end (>0)?
ble 1b @ Loop if ≤ 0 (either N && !V && !C, or !N && V && C)
subs r1, r6, #8
bl quirks @ Recursively sort left partition.
mov r0, r6
mov r1, r5
b 4b @ Tail-recursively sort right partition.
3: pop {r4, r5, r6, pc}
Fully commented source with Makefile and test C program at http://canonical.org/~kragen/sw/dev3/quicksort.S.More or less, yes. It only encompasses the system (i.e. not applications like the Finder) and isn't entirely complete, but it's still a great window into the world of Apple pre-OS X.
> There seems to have been a mailing list about this codebase from 02018 to 02021: https://lists.ucc.gu.uwa.edu.au/pipermail/cdg5/
This mailing list was for a set of projects which focused on taking this code dump (among other things) and making it compile, ideally to reproduce released binaries.
That's the problem with comparing lines of code: you're comparing apples and oranges. In this case you aren't even solving the same problem.
Lol - ok that's genuinely funny :). slow clap
QuickDraw was a graphics library, not a sorting algorithm
It would be a much better story if they stopped asking everyone to fill out the form.