DEV Community

Discussion on: Which mainstream programming language has the ugliest syntax?

Collapse
 
david_j_eddy profile image
David J Eddy

Does BASH count? :|

if [! -d './directory']; then
  echo 'nope'
else
  echo 'yep'
fi

:|

Collapse
 
casperbraske profile image
Luis

It's beautiful, IMO. <3

Collapse
 
vorakl profile image
vorakl • Edited

Sorry but it's ugly only because it's wrong (there should have been additional spaces before and after square brackets) ;)

The BASH is powerful and its syntax allows to write easy to read code. It just needs some rules to follow. For instance, there can be found a quite good Shell Style Guide from Google

In this particular example, it could be written even simpler

[[ -d directory ]] && echo yep || echo nope
Collapse
 
david_j_eddy profile image
David J Eddy

That is going to be very helpful! Thank you.

Collapse
 
joseprl89 profile image
Josep

that is even harder to read

Thread Thread
 
sent2null profile image
David Saintloth • Edited

That's the funny thing about these questions (and variations of them can be found in developer forums going back to the early 80's and usenet groups) they are highly subjective.

This should not be surprising as language to large degree encapsulates methods of thinking and psychologists and linguists will tell you quickly that there are vastly many different ways of thinking.

The fluidity of spoken languages ability to relay information comes not from their terseness it comes from their interpretability.

Programming languages are syntactically terse means of conveying information about how to shift bits in low level computer memory cores which in their abstractions from that low level task must necessarily replicate the possible interpretability of the syntax and that will vary with the mode of thinking of the reader. It's a paradox of information transfer between beings with vastly different ways of thinking about the particular ingredients of language revealing itself.

To me, a person who prefers syntax that is explicit over implicit the first version looks more interpretable than the second (my main criteria for this are two fold, a) my personal preference and b) how I think most other engineers would think about it and in particular to ensure that as many as possible would have as little effort as possible in capturing the meaning of the code )

Everything beyond that is subjective bickering....

Collapse
 
ben profile image
Ben Halpern

Bash counts!

Collapse
 
dserodio profile image
Daniel Serodio

IMHO the worst bash quirk is not being able to put whitespace around the assignment operator, ie.:


foo = bar # syntax error
foo=bar # works as expected

Collapse
 
moopet profile image
Ben Sinclair

*cough* set -o to turn an option on and set +o to turn it off *cough*

Collapse
 
elmuerte profile image
Michiel Hendriks

That would be Bourne Shell's fault, not BASH.