Re:How Many Lines of C It Takes to Execute a and B in Python?
by jefftk on Monday December 11, 2023 @09:21AM
(#38600846)
If you're being silly you don't need a lot of that:
$ cat tmp.c
main() {
printf("%d\n", 3+4);
}
$ gcc -w -o tmp.out tmp.c && ./tmp.out
7
You can even do away with types entirely, as long as you're working with ints: $ cat tmp.c
foo(x) {
return x+5;
}
bar() {
return 4;
}
main() {
printf("%d\n", foo(bar()));
}
$ gcc -w -o tmp.out tmp.c && ./tmp.out
9
Rarely a good idea, though!
Re:How Many Lines of C It Takes to Execute a and B in Python?
by benj111 on Monday December 11, 2023 @10:36AM
(#38601507)
True, but then someone will pop up and announce UB! (This probably isn't ub though).
Anyway, my main point was that c has more boilerplate. It's never 'a+b'.
Second, printf is complicated, that's aimed more at the op though.
#! /Usr/bin/python
Print(a+b)
V
#include <stdio.h>
Int main (){ Printf("%i", a+b); Return 0; }
And printf is basically a DSL, so it still isn't 'simple' And this is assuming a+b fits into an integer