The Case Against Curly Braces {} Languages

C, C++, Java, C#, Go, JavaScript and many more languages use curly braces to group statements or declarations. But is this a good choice?

Image for post
Image for post
Image for post
Image for post
  • Grouping array elements and perform array access. Most use [ and ]. x = array[4]
  • Specifying type parameter. vector<int> items.
xs = Vector{Int}()
ys = Vector{x > 0 ? Int : Float64}()
ys = Vector<x > 0 ? Int : Float64>() # BAD choice!
(3 + 2) * (4 - 2(2 + 1)) 
begin 3 + 2 end * begin 4 - 2 begin 2 + 1 end end
xs[2 + ys[3]]
xs begin 2 + ys begin 3 end end
while 0 < i && i < 10
print(i)
i += 1
end
while 0 < i < 10
print(i)
i += 1
end
while (0 < i && i < 10) {
print(i);
i += 1;
}
  • Each line needs a semicolon at the end. 2 keystrokes Julia doesn’t need.
  • Expressions in if, for and while-statements need parenthesis. Each require holding down shift. 4 keystrokes Julia doesn’t need.

Recap

Syntax choices have to have rational reasons for existing. Benefits must be weighed against downsides. The way modern software is written cannot demonstrate any advantages.

Geek dad, living in Oslo, Norway with passion for UX, Julia programming, science, teaching, reading and writing.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store