← Home ← Back to /g/

Thread 105743654

35 posts 12 images /g/
Anonymous No.105743654 [Report] >>105743666 >>105743720 >>105743727 >>105743741 >>105743936 >>105744253 >>105744326 >>105745953 >>105746721 >>105746954 >>105747440
bash and python
I don't see the difference.
Anonymous No.105743666 [Report]
>>105743654 (OP)
yeah bro basically the same thing
Anonymous No.105743680 [Report] >>105743721 >>105743992
Scripting in one of them doesn't make you want to kill yourself.
Anonymous No.105743720 [Report]
>>105743654 (OP)
the latter makes the former obsolete in terms of script automation. Plus, it's platform independent.
Anonymous No.105743721 [Report]
>>105743680
This doesn't narrow it down.
Anonymous No.105743727 [Report] >>105743783 >>105743819
>>105743654 (OP)
trying doing floating point operations in bash
Anonymous No.105743741 [Report] >>105743769
>>105743654 (OP)
one is fucking dumb, the other fucking stupid.
Anonymous No.105743769 [Report]
>>105743741
I am fucking both.
Anonymous No.105743783 [Report] >>105743830 >>105747383
>>105743727
easy peasy
#!/usr/bin/env bash

awk 'BEGIN {
printf("°F temp "); getline c;
printf("°C temp %.2f\n", (c - 32) * 5/9);
printf("close enough ;3\n")
}'
Anonymous No.105743819 [Report] >>105743830
>>105743727
.. | bc
wow
Anonymous No.105743830 [Report] >>105743861 >>105743902
>>105743783
>>105743819
thank you for proving that python is the better scripting language
Anonymous No.105743861 [Report]
>>105743830
I only see people pointing out how ignorant that anon was.
Anonymous No.105743902 [Report]
>>105743830
>i-it doesn't count!!
Kek, every time.
Anonymous No.105743936 [Report] >>105743992
>>105743654 (OP)
They have two different use cases.
Neither are good at the other's; You can do both with either, but at the cost of efficiency on either end.
Anonymous No.105743992 [Report]
>>105743680
yes, i also want to kys when using python
>>105743936
i would say that neither is good at its job, but bash at least doesn t act like a kumbaya faggot and isn t held at the same level as real programming languages
Anonymous No.105744253 [Report]
>>105743654 (OP)
Bash is faster and has better syntax than pyjeet.
Anonymous No.105744326 [Report]
>>105743654 (OP)
I need less commitment to make a scriptie in BOURNE AGAIN SHELL
Anonymous No.105745953 [Report] >>105746119 >>105746760
>>105743654 (OP)
Loop example

python
n = 0
while n < 3:
print("Oppression")
n += 1


bash

n=0; while [ $n -le 3 ]; do
echo "Freedom"; ((n++));
done
Anonymous No.105746119 [Report]
>>105745953
Brutal.
pic related.

Beauty.
n=0; while [ $n -le 3 ]; do echo "Freedom"; ((n++)); done
Freedom
Freedom
Freedom
Freedom
Anonymous No.105746675 [Report]
Python is stupid for using spaces instead of tabs and no curly brackets
Anonymous No.105746721 [Report]
>>105743654 (OP)
I prefer pic related, too bad you need Maven shitware to download dependencies, though is good enough as a no dependencies Bash+ language.
Anonymous No.105746760 [Report] >>105746878
>>105745953
You wouldn't write it like this in both languages.

python
for _ in range(3):
print("something")


bash
for _ in $(seq 3); do echo "something"; done


If I need to call programs installed on the system (like with seq in the example above), then I usually use bash. If I need data structures, e.g. a hash map, then I use Python.
Anonymous No.105746878 [Report] >>105746908
>>105746760
bash has associative arrays
>$(seq 3)
{1..3}
Anonymous No.105746908 [Report] >>105746939
>>105746878
I usually try to write posix sh scripts, so I rarely use these, but itt it's about bash, so good point
Anonymous No.105746939 [Report] >>105747088
>>105746908
>try to write posix
can I ask why, as someone who does not
Anonymous No.105746954 [Report]
>>105743654 (OP)
i honestly prefer shell
because code manipulation is integrated at the syntactic level
i could use either
Anonymous No.105747054 [Report] >>105747074 >>105747156
>bash
do you use word 'bash' to describe shell scripts in general? do you mean the fairly recent bash version that comes with your loonix or the very outdated and different 2007 one that comes with tim apple? do you test on both to ensure portability? do you rely on features of exclusive to coreutils or busybox or something else? are your scripts posix compatible? do you know what unavoidable non-posix behaviors modern shell builtins have (e.g. 'echo' having opts)? do you know if and why your sed or grep calls don't work on some systems? do your scripts rely on commands that only linux or bash ships (e.g. disown or pidof)?
Anonymous No.105747074 [Report]
>>105747054
also - do you know about various different regex variants that shell itself and the distributions of sed, grep, awk implement? do you know which ones are portable?
Anonymous No.105747088 [Report] >>105747144 >>105747267
>>105746939
>can I ask why, as someone who does not
When I learned shell scripting, I thought it's a good idea to write portable shell scripts without any "bash-isms", so you could even use them on a system where only plain old sh is available. But for personal scripts this is pointless, so I should probably look into what bash has to offer.
Anonymous No.105747144 [Report]
>>105747088
>But for personal scripts this is pointless
until you got to figure out anyway why your personal script doesn't run on macos (ooold bash) from the work or 'in docker' (ash sh on distros like alpine)
Anonymous No.105747156 [Report]
>>105747054
GNU/Linux is all that matters
Anonymous No.105747267 [Report]
>>105747088
fair enough, 2bh llms are good enough now that they barely require writing
Anonymous No.105747383 [Report] >>105747807
>>105743783
that's awk
Anonymous No.105747440 [Report]
>>105743654 (OP)
one is useful for everything so long as you don't care it's 60x slower than a real programming language like C or Fortran
one is useful for scratching the autistic 'use the right tool for the job' minimalist urges
Anonymous No.105747807 [Report]
>>105747383
It clearly says #!/usr/bin/env bash as well, faggot.