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. What "advanced" features of programming languages do you use?

What "advanced" features of programming languages do you use?

Scheduled Pinned Locked Moved The Lounge
c++javascripttutorialquestion
35 Posts 17 Posters 2 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.
  • F F ES Sitecore

    I use something called a "debugger". I always knew this was quite a maverick thing to do, but looking at the QA section I didn't realise just how maverick!

    Z Offline
    Z Offline
    ZurdoDev
    wrote on last edited by
    #5

    :laugh: :thumbsup:

    Social Media - A platform that makes it easier for the crazies to find each other. Everyone is born right handed. Only the strongest overcome it. Fight for left-handed rights and hand equality.

    1 Reply Last reply
    0
    • OriginalGriffO OriginalGriff

      I avoid using var and dynamic in C# because they are normally misused to resemble Dim in VB or shortcut strong typing because the developer is too lazy to think about maintenance...

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony AntiTwitter: @DalekDave is now a follower!

      F Offline
      F Offline
      F ES Sitecore
      wrote on last edited by
      #6

      I'll toss the ViewBag into that bucket too.

      1 Reply Last reply
      0
      • OriginalGriffO OriginalGriff

        I avoid using var and dynamic in C# because they are normally misused to resemble Dim in VB or shortcut strong typing because the developer is too lazy to think about maintenance...

        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony AntiTwitter: @DalekDave is now a follower!

        Z Offline
        Z Offline
        ZurdoDev
        wrote on last edited by
        #7

        OriginalGriff wrote:

        I avoid using var and dynamic in C#

        I agree. But I find it interesting how many experienced developers love using var. I feel like I must be missing something.

        Social Media - A platform that makes it easier for the crazies to find each other. Everyone is born right handed. Only the strongest overcome it. Fight for left-handed rights and hand equality.

        W R R 3 Replies Last reply
        0
        • F F ES Sitecore

          I use something called a "debugger". I always knew this was quite a maverick thing to do, but looking at the QA section I didn't realise just how maverick!

          OriginalGriffO Offline
          OriginalGriffO Offline
          OriginalGriff
          wrote on last edited by
          #8

          You have to wonder how any of these people manage to do anything useful. :sigh: I was sent this this morning: Cyanide & Happiness: Millenials[^] (possibly NSFW, very little of C&A is) :laugh:

          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony AntiTwitter: @DalekDave is now a follower!

          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
          "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

          R 1 Reply Last reply
          0
          • Z ZurdoDev

            OriginalGriff wrote:

            I avoid using var and dynamic in C#

            I agree. But I find it interesting how many experienced developers love using var. I feel like I must be missing something.

            Social Media - A platform that makes it easier for the crazies to find each other. Everyone is born right handed. Only the strongest overcome it. Fight for left-handed rights and hand equality.

            W Offline
            W Offline
            Wastedtalent
            wrote on last edited by
            #9

            ZurdoDev wrote:

            I agree. But I find it interesting how many experienced developers love using var. I feel like I must be missing something.

            I used to hate it but got used to it now.

            1 Reply Last reply
            0
            • OriginalGriffO OriginalGriff

              You have to wonder how any of these people manage to do anything useful. :sigh: I was sent this this morning: Cyanide & Happiness: Millenials[^] (possibly NSFW, very little of C&A is) :laugh:

              "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony AntiTwitter: @DalekDave is now a follower!

              R Offline
              R Offline
              rjmoses
              wrote on last edited by
              #10

              They don't! If I see one more "I'm ugly. I bet I won't even get one share." on FB, I'm going to unfriend myself.

              1 Reply Last reply
              0
              • R rjmoses

                I've been digging into a javascript based application lately and tripped across some code that made extensive use of the arity (which is deprecated now), currying capabilities and anonymous functions. Took me a lonnnnnng time to understand what the intent and operation of the code was. So, out of curiosity, I'm wondering what "advanced" features of people's favorite languages they use on a regular basis, how they use them, and why? Or, which ones do you seldom/never use because.... E.g: ....I like using lambdas in C++ because .... (I can't think of a good example because I avoid them!) ....I avoid lambdas in C++ because they are often used where a simple function would be clearer and more readable (truth in advertising).

                Sander RosselS Offline
                Sander RosselS Offline
                Sander Rossel
                wrote on last edited by
                #11

                Depends on what you think is advanced ;) I use lambdas in C# all the time, but they've been around for over 10 years and now also turn up in other languages like JavaScript and, apparently, C++. I use named tuples in C#, they were introduced two or three years ago, I think. I've used pattern matching too. A comment above this one mentions var and dynamic, I use var quite often and dynamic when I need it. Basically, if it's in the language, why shouldn't I use it if I have need for it? Personally, I don't find lambdas difficult to read at all. In fact, a simple lambda can much better convey what you're doing than a function and be better maintainable. For example:

                myCollection.Where(x => x.IsActive).ToList();

                // vs.

                myCollection.Where(IsActive).ToList();
                // Elsewhere in the code.
                private bool IsActive(Something x)
                {
                return x.IsActive;
                }

                If the specs change, for example x.IsActive && x.Status == Status.Done, the first is an easy fix, the second would become IsActiveAndStateIsDone or some such, which gets harder to read every time. In the case when the lambda is an Expression, like with Entity Framework, a function can't even be parsed and you have to use a lambda.

                Best, Sander sanderrossel.com Migrating Applications to the Cloud with Azure arrgh.js - Bringing LINQ to JavaScript Object-Oriented Programming in C# Succinctly

                L 1 Reply Last reply
                0
                • Sander RosselS Sander Rossel

                  Depends on what you think is advanced ;) I use lambdas in C# all the time, but they've been around for over 10 years and now also turn up in other languages like JavaScript and, apparently, C++. I use named tuples in C#, they were introduced two or three years ago, I think. I've used pattern matching too. A comment above this one mentions var and dynamic, I use var quite often and dynamic when I need it. Basically, if it's in the language, why shouldn't I use it if I have need for it? Personally, I don't find lambdas difficult to read at all. In fact, a simple lambda can much better convey what you're doing than a function and be better maintainable. For example:

                  myCollection.Where(x => x.IsActive).ToList();

                  // vs.

                  myCollection.Where(IsActive).ToList();
                  // Elsewhere in the code.
                  private bool IsActive(Something x)
                  {
                  return x.IsActive;
                  }

                  If the specs change, for example x.IsActive && x.Status == Status.Done, the first is an easy fix, the second would become IsActiveAndStateIsDone or some such, which gets harder to read every time. In the case when the lambda is an Expression, like with Entity Framework, a function can't even be parsed and you have to use a lambda.

                  Best, Sander sanderrossel.com Migrating Applications to the Cloud with Azure arrgh.js - Bringing LINQ to JavaScript Object-Oriented Programming in C# Succinctly

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

                  I'm always fighting reading a lambda. How you would express "x => x.IsActive" in words? Maybe this can help me :-O

                  It does not solve my Problem, but it answers my question

                  Sander RosselS 1 Reply Last reply
                  0
                  • L Lost User

                    I'm always fighting reading a lambda. How you would express "x => x.IsActive" in words? Maybe this can help me :-O

                    It does not solve my Problem, but it answers my question

                    Sander RosselS Offline
                    Sander RosselS Offline
                    Sander Rossel
                    wrote on last edited by
                    #13

                    How would you express a function in words? I'd say "x => x.IsActive" translates to "element is active". So in case of a Where you'd get "where element is active" and in case of an OrderBy you'd get "order by element is active". If you're looking for a more literal reading I'd say "x arrow x dot active", which is a lot easier than describing another function in detail. I believe they're even called "arrow functions" in JavaScript.

                    Best, Sander sanderrossel.com Migrating Applications to the Cloud with Azure arrgh.js - Bringing LINQ to JavaScript Object-Oriented Programming in C# Succinctly

                    L 1 Reply Last reply
                    0
                    • Sander RosselS Sander Rossel

                      How would you express a function in words? I'd say "x => x.IsActive" translates to "element is active". So in case of a Where you'd get "where element is active" and in case of an OrderBy you'd get "order by element is active". If you're looking for a more literal reading I'd say "x arrow x dot active", which is a lot easier than describing another function in detail. I believe they're even called "arrow functions" in JavaScript.

                      Best, Sander sanderrossel.com Migrating Applications to the Cloud with Azure arrgh.js - Bringing LINQ to JavaScript Object-Oriented Programming in C# Succinctly

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

                      Thank you for this. I think my confusion comes because I try to read it like mathematical functions e.g. "f: x->x^3"

                      It does not solve my Problem, but it answers my question

                      Sander RosselS 1 Reply Last reply
                      0
                      • Z ZurdoDev

                        OriginalGriff wrote:

                        I avoid using var and dynamic in C#

                        I agree. But I find it interesting how many experienced developers love using var. I feel like I must be missing something.

                        Social Media - A platform that makes it easier for the crazies to find each other. Everyone is born right handed. Only the strongest overcome it. Fight for left-handed rights and hand equality.

                        R Offline
                        R Offline
                        raddevus
                        wrote on last edited by
                        #15

                        ZurdoDev wrote:

                        I agree. But I find it interesting how many experienced developers love using var. I feel like I must be missing something.

                        If you have a framework of Interfaces then var makes far more sense. It's very much related to Dependency Injection and flexibility. Of course, var is abused since any dev can just allow the compiler to set the type for all vars now. But, this is also the way newer (dynamic) languages go about things (Kotlin, Swift).

                        1 Reply Last reply
                        0
                        • R rjmoses

                          I've been digging into a javascript based application lately and tripped across some code that made extensive use of the arity (which is deprecated now), currying capabilities and anonymous functions. Took me a lonnnnnng time to understand what the intent and operation of the code was. So, out of curiosity, I'm wondering what "advanced" features of people's favorite languages they use on a regular basis, how they use them, and why? Or, which ones do you seldom/never use because.... E.g: ....I like using lambdas in C++ because .... (I can't think of a good example because I avoid them!) ....I avoid lambdas in C++ because they are often used where a simple function would be clearer and more readable (truth in advertising).

                          R Offline
                          R Offline
                          RugbyLeague
                          wrote on last edited by
                          #16

                          I am not sure it classifies as advanced but I have used unsafe code with casts and pointer arithmetic in C# a lot and am now switching to Span, ref structs and SIMD instructions

                          1 Reply Last reply
                          0
                          • L Lost User

                            Thank you for this. I think my confusion comes because I try to read it like mathematical functions e.g. "f: x->x^3"

                            It does not solve my Problem, but it answers my question

                            Sander RosselS Offline
                            Sander RosselS Offline
                            Sander Rossel
                            wrote on last edited by
                            #17

                            Try reading it as a trimmed down function (which now also allow for an arrow instead of curly braces).

                            // If you'd write an actual function on a single line:
                            myCollection.Where(bool IsActive(MyObject x) { return x.IsActive; });

                            // Replace the {} with =>, the ; can then also be removed:
                            myCollection.Where(bool IsActive(MyObject x) => return x.IsActive);

                            // The return statement isn't necessary:
                            myCollection.Where(bool IsActive(MyObject x) => x.IsActive);

                            // Neither is a function name:
                            myCollection.Where(bool (MyObject x) => x.IsActive);

                            // Types can usually be inferred:
                            myCollection.Where((x) => x.IsActive);

                            // Remove redundant parenthesis:
                            myCollection.Where(x => x.IsActive);

                            It is pretty close to the mathematical notation. Unfortunately, it doesn't always work that well.

                            // Example with multiple arguments, here you need parenthesis again:
                            myCollection.Where((x, y) => x.IsActive && y > 10);

                            // Sometimes the type can't be inferred:
                            myCollection.Where((MyObject x, int y) => x.IsActive && y > 10);

                            // You can (always) use full argument names if you like, although a single letter is common:
                            myCollection.Where((collectionItem, index) => collectionItem.IsActive && index > 10);

                            Hope this explains it even further.

                            Best, Sander sanderrossel.com Migrating Applications to the Cloud with Azure arrgh.js - Bringing LINQ to JavaScript Object-Oriented Programming in C# Succinctly

                            L 1 Reply Last reply
                            0
                            • Z ZurdoDev

                              OriginalGriff wrote:

                              I avoid using var and dynamic in C#

                              I agree. But I find it interesting how many experienced developers love using var. I feel like I must be missing something.

                              Social Media - A platform that makes it easier for the crazies to find each other. Everyone is born right handed. Only the strongest overcome it. Fight for left-handed rights and hand equality.

                              R Offline
                              R Offline
                              RugbyLeague
                              wrote on last edited by
                              #18

                              I like var, it removes a lot of unnecessary noise

                              Z 1 Reply Last reply
                              0
                              • R RugbyLeague

                                I like var, it removes a lot of unnecessary noise

                                Z Offline
                                Z Offline
                                ZurdoDev
                                wrote on last edited by
                                #19

                                RugbyLeague wrote:

                                it removes a lot of unnecessary noise

                                Like being able to look at the declaration of a variable and know what type of object it is? ;)

                                Social Media - A platform that makes it easier for the crazies to find each other. Everyone is born right handed. Only the strongest overcome it. Fight for left-handed rights and hand equality.

                                R T 2 Replies Last reply
                                0
                                • Z ZurdoDev

                                  RugbyLeague wrote:

                                  it removes a lot of unnecessary noise

                                  Like being able to look at the declaration of a variable and know what type of object it is? ;)

                                  Social Media - A platform that makes it easier for the crazies to find each other. Everyone is born right handed. Only the strongest overcome it. Fight for left-handed rights and hand equality.

                                  R Offline
                                  R Offline
                                  RugbyLeague
                                  wrote on last edited by
                                  #20

                                  That's what intellisense is for.

                                  Z 1 Reply Last reply
                                  0
                                  • R rjmoses

                                    I've been digging into a javascript based application lately and tripped across some code that made extensive use of the arity (which is deprecated now), currying capabilities and anonymous functions. Took me a lonnnnnng time to understand what the intent and operation of the code was. So, out of curiosity, I'm wondering what "advanced" features of people's favorite languages they use on a regular basis, how they use them, and why? Or, which ones do you seldom/never use because.... E.g: ....I like using lambdas in C++ because .... (I can't think of a good example because I avoid them!) ....I avoid lambdas in C++ because they are often used where a simple function would be clearer and more readable (truth in advertising).

                                    D Offline
                                    D Offline
                                    DRHuff
                                    wrote on last edited by
                                    #21

                                    I like to use 'throw' because a 'goto' that allows you to jump out of your current function to some unknown place is just so cool! :-\

                                    I, for one, like Roman Numerals.

                                    1 Reply Last reply
                                    0
                                    • R RugbyLeague

                                      That's what intellisense is for.

                                      Z Offline
                                      Z Offline
                                      ZurdoDev
                                      wrote on last edited by
                                      #22

                                      Hover over each item each time you want to know what is? If you think that's easier and worth it, I hope you never work on my team. :-D

                                      Social Media - A platform that makes it easier for the crazies to find each other. Everyone is born right handed. Only the strongest overcome it. Fight for left-handed rights and hand equality.

                                      R 1 Reply Last reply
                                      0
                                      • OriginalGriffO OriginalGriff

                                        I avoid using var and dynamic in C# because they are normally misused to resemble Dim in VB or shortcut strong typing because the developer is too lazy to think about maintenance...

                                        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony AntiTwitter: @DalekDave is now a follower!

                                        D Offline
                                        D Offline
                                        Dan Neely
                                        wrote on last edited by
                                        #23

                                        I only use var in cases where the type is either given elsewhere on the line of declaration

                                        var frobables = new List();
                                        var frobables2 = GetFrobables(/*params*/);

                                        or is an intermediate value whose exact type is both nasty looking and whose explicit declaration doesn't add much value.

                                        var temp = db.tableName
                                        .Where(x => /*filter*/)
                                        .Select(x => new
                                        {
                                        x.Property1,
                                        x.Property2,
                                        x.Property3,
                                        x.Property4
                                        });

                                        I only use dynamic in one off code, eg single shot tools or data importers; like the fluffy languages it resembles, for anything that needs to be maintained the long term costs exceed the short term savings.

                                        Did you ever see history portrayed as an old man with a wise brow and pulseless heart, weighing all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt

                                        OriginalGriffO 1 Reply Last reply
                                        0
                                        • R rjmoses

                                          Interesting! I had forgotten some languages don't come with a debugger. Good one!

                                          D Offline
                                          D Offline
                                          Dan Neely
                                          wrote on last edited by
                                          #24

                                          rjmoses wrote:

                                          I had forgotten some languages don't come with a debugger.

                                          ... and those languages are hopelessly buggered at a result. :laugh:

                                          Did you ever see history portrayed as an old man with a wise brow and pulseless heart, weighing all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt

                                          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