Researcher question – what's the point of semicolons and curly braces?

qznc via Digitalmars-d digitalmars-d at puremagic.com
Wed May 4 07:39:50 PDT 2016


On Tuesday, 3 May 2016 at 22:17:18 UTC, cym13 wrote:
> That has direct consequences on our problem. The fact that 
> Python's function become harder to work with when they become 
> bigger is a tool, and a useful one. When your Python code 
> becomes hard to work with it raises a flag : “Stop where you 
> are there should be a better, simpler way to do it.” Python's 
> only goal is to produce readable code so it has a lot of tools 
> to help you reduce its size. Keyword arguments are a good 
> example. There are a lot of functions in phobos that share a 
> common prefix just because it was too hard to make them share 
> the same name in a generic way where they would just be 
> separated by a keyword argument in Python.
>
> But Python sacrifices a *lot* of performances to do that. D has 
> its own way and different goals. Being performance-friendly is 
> one of them and that sometimes gets you with long functions and 
> ugly hacks. When it comes to that having curly braces (well any 
> kind of delitmiter really) is a great thing.
>
> tl;dr: syntactic oddities are tools and you can't judge 
> different tools without understanding the context in which they 
> are used and what problem they are meant to solve. D isn't 
> really meant for the kind of code that benefits most of having 
> no curly braces.

I don't understand your reasoning how curly braces makes D faster 
than Python.

There is no causation between syntax and performance.
Design two programming languages which only differ about curly 
braces and semi colons. Once they are parsed into an AST all 
differences are gone. The compiler will output the same code, so 
performance must be the same.

Is Python more readable than D? I believe this is subjective. 
Overall, I believe there is no significant objective difference 
between different syntax. It makes a difference once you are used 
to some style and many people these days are used to curly braces 
and semicolons.


More information about the Digitalmars-d mailing list