[HN Gopher] Circle: C++ Automation Language
       ___________________________________________________________________
        
       Circle: C++ Automation Language
        
       Author : pjmlp
       Score  : 72 points
       Date   : 2021-10-16 10:29 UTC (12 hours ago)
        
 (HTM) web link (www.circle-lang.org)
 (TXT) w3m dump (www.circle-lang.org)
        
       | conradev wrote:
       | This project feels similar in spirit to Zig, which has robust
       | compile time evaluation and reflection.
       | 
       | The cool part about Zig is that it uses this ability (via the
       | `comptime` keyword) to power it's generic system, and not vice
       | versa (looking at you, Turing complete type systems)
       | 
       | https://ziglang.org/learn/overview/#generic-data-structures-...
        
         | dnautics wrote:
         | Technically comptime makes zig Turing complete (except that you
         | have a finite number of branches available to consume during
         | comptime).
        
       | gavinray wrote:
       | Ah yes, we've come full _" circle"_ and C++ has tacked on D's
       | metaprogramming and CTFE abilities.
        
         | gumby wrote:
         | This was an explicit design intent from early days of C++. I
         | remember discussing Lisp's macro capabilities with Stroustrup
         | back in the early 90s and him saying he had always wanted to
         | have that in C++ and templating was the first step.
         | 
         | Shame it took so long to actually arrive.
        
         | [deleted]
        
         | pjmlp wrote:
         | Which reveals the problem D has finding any relevant niche, as
         | the community cannot decide into which direction to head into.
         | 
         | Java and C# also have acquired many capabilities that for 10
         | years were a plus from D over them.
        
       | a_t48 wrote:
       | This is really neat. I've done similar things with jinja
       | templates plus heavy use of c++ template magic - with the
       | downside that there's a bit of disconnect between the two
       | syntaxes. I'll have to keep an eye on this for the future.
        
       | wellwised123 wrote:
       | Why are the examples in C code rather idiomatic Modern C++?
        
       | justicezyx wrote:
       | This seems useful for code generation. Cannot relate this to any
       | previous problems I encountered using c++
       | 
       | Any other interesting use of this?
        
         | rahimiali wrote:
         | Imagine using this to build a balzingly fast serialization
         | library that you'd use like protobufs. Or to explore lots of
         | configurations of your code to search for the variant that runs
         | fastest. Or to write a linear algebra library that doesn't
         | generate temporary values that are dynamically allocated.
        
         | bialpio wrote:
         | Seems that it could be used to solve an old-time classic:
         | generate a mapping from an enum value to its string
         | representation. Another use case that comes to my mind is maybe
         | automating test case generation. Occasionally I was running
         | into situations where I thought code generation could be
         | useful, but not sure what could be a "killer app" equivalent
         | for this feature.
         | 
         | Related topic: standardizing reflection in c++.
         | https://youtu.be/ARxj3dfF_h0
         | https://en.cppreference.com/w/cpp/keyword/reflexpr
        
           | seanbax wrote:
           | Enum to string is a one-line expression in Circle:
           | https://godbolt.org/z/93f5o77zv
           | 
           | Circle has dozens of special traits for accessing useful
           | stuff about types, packs, etc. Don't need to overengineer
           | such a simple thing.
        
           | ggrrhh_ta wrote:
           | that would be great :-)
        
       ___________________________________________________________________
       (page generated 2021-10-16 23:00 UTC)