Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. If C had the template keyword I'd probably use C++ a lot less

If C had the template keyword I'd probably use C++ a lot less

Scheduled Pinned Locked Moved The Lounge
designc++csscomgraphics
8 Posts 4 Posters 25 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    honey the codewitch
    wrote on last edited by
    #1

    The main reason I prefer C++ over C is template** and constexpr. Recently they've added constexpr to the latest C standard, but I don't know how deep it goes - if it's as functional as it is in C++. I have very little reason to use C++ otherwise. I'd actually prefer things if I wasn't dealing with classes with things like non-trivial constructors, destructors, and assignment operators. Why? Because RAII isn't very practical without exceptions, and if you're working with multiple different heaps at runtime. I actually like C's simplicity, but dislike the preprocessor. I'd much prefer something typed, and with specializations and recursion. ** They'd have to allow template function specializations, or allow static functions in template structures in order to be particularly useful though. Not sure which route they'd take.

    Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

    M L P 5 Replies Last reply
    0
    • H honey the codewitch

      The main reason I prefer C++ over C is template** and constexpr. Recently they've added constexpr to the latest C standard, but I don't know how deep it goes - if it's as functional as it is in C++. I have very little reason to use C++ otherwise. I'd actually prefer things if I wasn't dealing with classes with things like non-trivial constructors, destructors, and assignment operators. Why? Because RAII isn't very practical without exceptions, and if you're working with multiple different heaps at runtime. I actually like C's simplicity, but dislike the preprocessor. I'd much prefer something typed, and with specializations and recursion. ** They'd have to allow template function specializations, or allow static functions in template structures in order to be particularly useful though. Not sure which route they'd take.

      Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

      M Offline
      M Offline
      Mary Rushton
      wrote on last edited by
      #2

      This article discusses the differences between C and C++, especially regarding templates and constexpr. Just like in io games, the choice of programming language is a trade-off between features and performance. The final decision usually depends on the specific needs of each project.

      1 Reply Last reply
      0
      • H honey the codewitch

        The main reason I prefer C++ over C is template** and constexpr. Recently they've added constexpr to the latest C standard, but I don't know how deep it goes - if it's as functional as it is in C++. I have very little reason to use C++ otherwise. I'd actually prefer things if I wasn't dealing with classes with things like non-trivial constructors, destructors, and assignment operators. Why? Because RAII isn't very practical without exceptions, and if you're working with multiple different heaps at runtime. I actually like C's simplicity, but dislike the preprocessor. I'd much prefer something typed, and with specializations and recursion. ** They'd have to allow template function specializations, or allow static functions in template structures in order to be particularly useful though. Not sure which route they'd take.

        Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

        M Offline
        M Offline
        Mary Rushton
        wrote on last edited by
        #3

        This article discusses the differences between C and C++, especially regarding templates and constexpr. Just like in io games, the choice of programming language is a trade-off between features and performance. The final decision usually depends on the specific needs of each project.

        1 Reply Last reply
        0
        • H honey the codewitch

          The main reason I prefer C++ over C is template** and constexpr. Recently they've added constexpr to the latest C standard, but I don't know how deep it goes - if it's as functional as it is in C++. I have very little reason to use C++ otherwise. I'd actually prefer things if I wasn't dealing with classes with things like non-trivial constructors, destructors, and assignment operators. Why? Because RAII isn't very practical without exceptions, and if you're working with multiple different heaps at runtime. I actually like C's simplicity, but dislike the preprocessor. I'd much prefer something typed, and with specializations and recursion. ** They'd have to allow template function specializations, or allow static functions in template structures in order to be particularly useful though. Not sure which route they'd take.

          Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

          M Offline
          M Offline
          Mary Rushton
          wrote on last edited by
          #4

          This article discusses the differences between C and C++, especially regarding templates and constexpr. Just like in io games, the choice of programming language is a trade-off between features and performance. The final decision usually depends on the specific needs of each project.

          1 Reply Last reply
          0
          • H honey the codewitch

            The main reason I prefer C++ over C is template** and constexpr. Recently they've added constexpr to the latest C standard, but I don't know how deep it goes - if it's as functional as it is in C++. I have very little reason to use C++ otherwise. I'd actually prefer things if I wasn't dealing with classes with things like non-trivial constructors, destructors, and assignment operators. Why? Because RAII isn't very practical without exceptions, and if you're working with multiple different heaps at runtime. I actually like C's simplicity, but dislike the preprocessor. I'd much prefer something typed, and with specializations and recursion. ** They'd have to allow template function specializations, or allow static functions in template structures in order to be particularly useful though. Not sure which route they'd take.

            Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Interesting, but not for the reason you think. I just checked the moderation queue and three messages there were latched onto your post.

            H 1 Reply Last reply
            0
            • L Lost User

              Interesting, but not for the reason you think. I just checked the moderation queue and three messages there were latched onto your post.

              H Offline
              H Offline
              honey the codewitch
              wrote on last edited by
              #6

              Yeah some presumably "AI" powered spambot hit my inbox.

              Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

              1 Reply Last reply
              0
              • H honey the codewitch

                The main reason I prefer C++ over C is template** and constexpr. Recently they've added constexpr to the latest C standard, but I don't know how deep it goes - if it's as functional as it is in C++. I have very little reason to use C++ otherwise. I'd actually prefer things if I wasn't dealing with classes with things like non-trivial constructors, destructors, and assignment operators. Why? Because RAII isn't very practical without exceptions, and if you're working with multiple different heaps at runtime. I actually like C's simplicity, but dislike the preprocessor. I'd much prefer something typed, and with specializations and recursion. ** They'd have to allow template function specializations, or allow static functions in template structures in order to be particularly useful though. Not sure which route they'd take.

                Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

                P Offline
                P Offline
                PIEBALDconsult
                wrote on last edited by
                #7

                honey the codewitch wrote:

                but dislike the preprocessor.

                You can implement your own. :-\

                H 1 Reply Last reply
                0
                • P PIEBALDconsult

                  honey the codewitch wrote:

                  but dislike the preprocessor.

                  You can implement your own. :-\

                  H Offline
                  H Offline
                  honey the codewitch
                  wrote on last edited by
                  #8

                  Nah. To make it any good it needs access to the type information the compiler has built up. It can be a separate pass like C++ does to make it work, but it needs to be integrated into the compiler to do things like typed arguments and specialization.

                  Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups