• BodePlotHole@lemmy.world
    link
    fedilink
    arrow-up
    6
    ·
    10 hours ago

    Hello programmers, electrical engineer here.

    I work in MEP design, basically power design for commercial buildings and multi-tenant residential.

    I am constantly saying I wish every fucking engineer, architect, interior designer, building manager, etc. had been forced to take a class on project management and accountability.

    Curious if some of you run into a similar desire…

  • nik9000@programming.dev
    link
    fedilink
    arrow-up
    18
    ·
    23 hours ago

    It’d be fun to talk shop with the fast code in slow languages folks. I do that for a living. I remember three ways, but I’m sure there’s more:

    • “Just use a better data structure”
    • “My language is a DSL for a faster language” (Polars, Numpy, etc)
    • “My compiler is surprisingly good if I’m careful” (Julia, JVM, etc)
  • melsaskca@lemmy.ca
    link
    fedilink
    arrow-up
    11
    ·
    23 hours ago

    “Key Search Words 101”. Make it quicker and easier to find other programmers solutions on the web.

  • WolfLink@sh.itjust.works
    link
    fedilink
    arrow-up
    5
    ·
    22 hours ago

    I would actually love to take 3300! That sounds fun.

    As for 4020, writing performant code in Python typically means calling into libraries that are written in C.

  • villainy@lemmy.world
    link
    fedilink
    arrow-up
    101
    arrow-down
    2
    ·
    2 days ago

    Where’s

    Using Solutions that Already Exist

    No, seriously, you don’t have to build everything from scratch by yourself. Other people write code too.

    • the16bitgamer@programming.dev
      link
      fedilink
      arrow-up
      2
      ·
      9 hours ago

      Got caught in that trap at my first coding job. Made a sort formula and a sr dev asked my I didn’t just use the array.sort.

      My answer: I didn’t know it was there.

    • squaresinger@lemmy.world
      link
      fedilink
      arrow-up
      17
      ·
      22 hours ago

      It’s a double-edged sword and understanding when to re-use and when to re-implement is an art that goes wrong more often than right.

    • PolarKraken@programming.dev
      link
      fedilink
      English
      arrow-up
      3
      ·
      1 day ago

      Ah, the ever-elusive, mysterious stage in my process - the one I can’t ever seem to move much before the “planning” and at least “beginning to implement” stages, and sometimes stubbornly comes even later than that.

  • terminatortwo@piefed.social
    link
    fedilink
    English
    arrow-up
    63
    arrow-down
    2
    ·
    2 days ago

    I always find it funny to see calls to “unlearn oop”. It’s a tool, useful in some contexts and not useful in others. At some point industry treated it like a silver bullet, and now people are reacting to it by checks notes treating the hot new paradigm as a silver bullet.

    learn oop, learn fp, learn logic programming, learn whatever you want. Also, learn when not to use them.

    • drosophila@lemmy.blahaj.zone
      link
      fedilink
      English
      arrow-up
      3
      ·
      edit-2
      8 hours ago

      It’s a tool, useful in some contexts and not useful in others.

      In my opinion this is a thought terminating cliche in programming and the IT industry in general. It can be, and is, said in response to any sentiment about any thing.

      Now, saying what sort of context you think something should or should not be used in, and what qualities of that thing make it desirable/undesirable in that context, could lead to fruitful discussion. But just “use the right tool for the right job” doesn’t contribute anything.

      • terminatortwo@piefed.social
        link
        fedilink
        English
        arrow-up
        3
        ·
        4 hours ago

        In my opinion this is a thought terminating cliche in programming and the IT industry in general. It can be, and is, said in response to any sentiment about any thing.

        Sure, I agree it can be. But it doesn’t make it less true that “it depends” is often the answer. As I see it, my job is often to think “what applies in this case”. Including thinking about things like:

        • what matches the mental model the company has about this
        • what’s the shape of the problem
        • what type of abstractions do we already use
        • what aspect do I want to make available, how is this expected to change?
        • etc

        Now, saying what sort of context you think something should or should not be used in, and what qualities of that thing make it desirable/undesirable in that context, could lead to fruitful discussion. But just “use the right tool for the right job” doesn’t contribute anything.

        Sure. I lean towards object oriented design when things represent a simple well known object with a stable set of “nouns and verbs” that are unlikely to change. In my case this tends to be around UI elements or the data layer very basic things, where I don’t care too much about “data transformation”, but want to encapsulate an action (eg. I think being toggleable is intrinsic to a switch, so switch.toggle feels like a stable api and I can design an object like this that others can understand without having to care about the internals)

        Some design patterns that come from the oop tradition (not exclusive to oop, but very much part of the toolkit) that I find exceptionally useful. For example, the strategy pattern is something I’ve used often when building things like data exporter and importer tools. I can structure my logic in this way, move all the specific logic to the leaves.

        I can’t be exhaustive, but for me oop is all about encapsulation, and so I use it when it calls for that. I think it also makes APIs easy to test.

        ——

        Functional programming I absolutely love. Whenever I’m transforming data, i think in functional terms. Composable functions, immutable data. It’s just a lot easier, and for me it makes it easier to test processes and operations. I tend to lean to this this in a business logic layer. If I can describe operations in a way that we talk about them in the company, and make those units of transformation testable, then bigger processes become safer and auditable.

        Another thing from functional programming languages that I love is things like algebraic data types. It just pains me to use a language without sum types now.

        ——

        A while back I used “aspect oriented programming”. That didn’t catch on, but moving some things like logging, event tracking, etc. to aspects makes sense to me. If a language supports function annotations, I /will/ try to move those sorts of aspects to a function annotation.

        ——

        I spent a while doing prolog, and that language is just something else. I wish I had an easy to embed prolog that I could use for constraints on data. This one I don’t “get to mix and match” because multi purpose languages don’t include aspects of it. But thinking in terms of reversing operations (eg. Given this result, what set of constraints produce it) is still a tool that helps me understand how to shape a problem.

        ——

        There’s a lot of nuance to this, more than can fit in a comment, and definitely nuance that doesn’t apply to imaginary problems or problems/sotuations that we don’t share. Also, you and others will probably think about it differently. to me that’s kind of the point, both thinking in terms of a diverse toolkit, and having a team with diversity of thought.

    • squaresinger@lemmy.world
      link
      fedilink
      arrow-up
      3
      arrow-down
      1
      ·
      22 hours ago

      I’ve been working as first a Python and then a Java dev for the last 15 years and I can count the amount of times when I’ve seen actual OOP on one hand.

      I mean, we write “class” at the beginning of our modules and at the beginning of our structs, and we write “interface” at the beginning of our header files, but none of that is actually OOP.

      If you use Spring Boot, you are essentially doing C (not even C++) in Java.

      You have data-only classes without methods (at best there’s a conversion method or something shallow like that) that work identical to C structs. You have service interfaces, which serve the same purpose as C header files. And then you have data-less collections of functions (service/controller classes), which work like .c files.

      Nowhere in this whole process are you actually using OOP techniques.

    • expr@programming.dev
      link
      fedilink
      arrow-up
      9
      arrow-down
      6
      ·
      1 day ago

      FP has been around a long time, and yes, it is outright better than OOP. Sorry. I write Haskell professionally, and never have I ever felt like something would be easier done in an OOP language. Quite the opposite.

      Unrestricted mutation makes programming really hard, and OOP and mutability go hand-in-hand. If you try to make immutable objects, then you’re just doing FP with worse ergonomics.

      • steventhedev@lemmy.world
        link
        fedilink
        arrow-up
        8
        ·
        1 day ago

        An object is a poor man’s closure.

        A closure is a poor man’s object.

        These are two sides of the same coin, and both of them miss the point. You should be dealing with scale, and you should use a language that allows you to concisely describe how to compute large amounts of data easily. The best part is that once you start writing APL, you’ll feel like a wizard.

        • Frezik@lemmy.blahaj.zone
          link
          fedilink
          English
          arrow-up
          1
          ·
          edit-2
          13 hours ago

          Right. A closure can be thought of as an object with a single method.

          Alternatively, the core of OOP is objects sending messages to other objects. There are a lot of different ways to do that. A micocontroller sending “begin <process>” to another microcontroller over SPI is OOP. At some point, the way C++ does things became the way to do OOP, and that was a narrow minded mistake.

        • expr@programming.dev
          link
          fedilink
          arrow-up
          6
          ·
          23 hours ago

          I mean, I have an OOP background. I found FP as a result of my dissatisfaction with OOP. In fact, I used to teach OOP languages to new students and saw the same mistakes over and over again, mistakes that are simply not possible in FP. It’s a very similar story for everyone I work with, too. We all had jobs in various OOP languages before we managed to get jobs writing Haskell.

          Oh, and I’m currently teaching Haskell to someone at work who has a CS degree and has only done OOP languages (and C), and while it’s different than what he’s used to, he’s still picking it up very quickly (working towards making him a junior engineer, which I think shouldn’t take too much longer). In fact, just the other day we pair programmed on a bug ticket I have and he was not only following along with the code, he spotted issues I hadn’t seen yet. Part of it is certainly that’s he smart (which is why I’m doing this in the first place), but part of it is also that, with a bit of familiarity, FP languages are incredibly easy to read and follow. The primary difference is that FP does everything explicitly, whereas OOP encourages a lot of implicit (and hidden) behavior. When you organize code around functions, there’s necessarily more explicit arguments and explicit return values, which makes it far, far easier to follow the flow of logic of code (and test!). Recently I was trying to read through our Kotlin codebase at work (for our Android app), and it was so much harder because so much is implicit.

      • stingpie@lemmy.world
        link
        fedilink
        arrow-up
        3
        arrow-down
        1
        ·
        23 hours ago

        FP & OOP both have their use cases. Generally, I think people use OOP for stateful programming, and FP for stateless programming. Of course, OOP is excessive in a lot of cases, and so is FP.

        OOP is more useful as an abstraction than a programming paradigm. Real, human, non-computer programming is object-oriented, and so people find it a natural way of organizing things. It makes more sense to say “for each dog, dog, dog.bark()” instead of “map( bark, dogs)”.

        A good use case for OOP is machine learning. Despite the industry’s best effort to use functional programming for it, Object oriented just makes more sense. You want a set of parameters, unique to each function applied to the input. This allows you to use each function without referencing the parameters every single time. You can write “function(input)” instead of “function(input, parameters)”. Then, if you are using a clever library, it will use pointers to the parameters within the functions to update during the optimization step. It hides how the parameters influence the result, but machine learning is a black box anyway.

        In my limited use of FP, I’ve found it useful for manipulating basic data structures in bulk. If I need to normalize a large number of arrays, it’s easy to go “map(normalize, arrays)” and call it a day. The FP specific functions such as scan and reduce are incredibly useful since OOP typically requires you to set up a loop and manually keep track of the intermediate results. I will admit though, that my only real use of FP is python list comprehension and APL, so take whatever I say about FP with a grain of salt.

        • expr@programming.dev
          link
          fedilink
          arrow-up
          3
          ·
          12 hours ago

          If your experience with FP is as limited as you say, then, respectfully, you lack the requisite experience to compare the two. It’s an entire paradigm shift that requires you to completely change how you think if you’re accustomed to OOP, and really requires one to program in a language designed for it. The features that OOP languages have cribbed from FP languages are very surface-level and not at all representative of what it actually is (and I’d say they largely miss the point of FP).

          I have been writing Haskell professionally for the last 5 years over the course of 2 jobs developing database-backed web services for web and mobile apps, and spent about ~5 years before that developing in OOP/imperative languages. I have a good deal of experience with both paradigms.

          OOP is more useful as an abstraction than a programming paradigm.

          It’s a very poor (and leaky) abstraction, and you can achieve much more powerful abstractions with FP languages (especially Haskell, which has a type system that is far more powerful than any OOP language is capable of). This is evidenced by the fact that a whole slee of design patterns exist to solve problems created by OOP itself. FP languages, on the other hand, have little need for design patterns, because useful patterns are easy to abstract over and turn into libraries.

          Real, human, non-computer programming is object-oriented, and so people find it a natural way of organizing things.

          I have no idea what this even means. Programming is taking input and producing output. That, at its core, is a function. Pure and simple. Many useful ideas are quite difficult to express as a noun, which is how you end up with a whole array of super awkwardly named classes that try to “noun-ify” verbs (think classes named like Serializer, Resolver, Initializer, and so on).

          It makes more sense to say “for each dog, dog, dog.bark()” instead of “map( bark, dogs)”.

          This entirely misses the point of FP. What data is actually being transformed here? It’s a nonsensical example.

          A good use case for OOP is machine learning. Despite the industry’s best effort to use functional programming for it, Object oriented just makes more sense.

          Not really sure what you’re talking about. No one uses functional programming for machine learning outside of research. To be clear, Python is not functional programming. The reasons for that having nothing to do with the paradigm and everything to do with social reasons and inertia. Python was already used by a lot of academics for some ecosystem reasons, and the ecosystem has grown since then. Had the history of things been different, functional programming absolutely would have excelled at it and would have been a much better fit, because machine learning is fundamentally a pipeline of transformations on data.

          You want a set of parameters, unique to each function applied to the input. This allows you to use each function without referencing the parameters every single time. You can write “function(input)” instead of “function(input, parameters)”.

          This is trivial to do in functional programming languages with a variety of methods. Commonly this is done with the Reader Monad, or even simply partial application of functions (also known as closures).

          • PeriodicallyPedantic@lemmy.ca
            link
            fedilink
            arrow-up
            1
            ·
            11 hours ago

            Imo the main issue with oop is that it’s very easy for people to make bad designs. Generally the feeling I get is that if you work on a well designed codebase, then you’ll come to like whatever the main paradigm of that codebase is, and if you work on a poorly design codebase you’ll come to dislike the paradigm.

  • noughtnaut@lemmy.world
    link
    fedilink
    arrow-up
    48
    ·
    edit-2
    2 days ago

    There’s a lot of humour in there, but this:

    CSCI 3300: Classical Software Studies
    Discuss and dissect historically significant products, including VisiCalc, AppleWorks, Robot Odyssey, Zork, and MacPaint. Emphases are on user interface and creativity fostered by hardware limitations.

    I’d take that course in a heart beat. I’ve read some of Atkinson’s ideas and thoughts, and the man was deeply sane.

    It must be decades now that my LinkedIn background banner is a screen shot of Zork source code.

  • SoftestSapphic@lemmy.world
    link
    fedilink
    arrow-up
    30
    ·
    2 days ago

    I feel like I’m the only CS major to have taken a CS focused ethics class

    Would be nice if all engineers had to take ethics

    • GoMati@lemmy.world
      link
      fedilink
      arrow-up
      1
      arrow-down
      1
      ·
      10 hours ago

      Problem is: non-ethical projects tend to pay more or take advantage of the situation. I know what I mean: when one of my projects fell apart recently I was approached by a “Battlefield Management App” which I could develop, of course for “the good guys”™.

      I chose unemployment because that’s not the world I want to develop, but I can totally imagine that in a more dire circumstances (I’m in debt with family to take care of or it’s war and I’m running out of money fast) my choice could’ve been different.

      Still, ethics would be good, even if it wouldn’t magically save the world 💪🏻

    • mr_account@lemmy.world
      link
      fedilink
      arrow-up
      16
      ·
      1 day ago

      I’m a CS major who had to take ethics, but the REQUIRED textbook was written by the professor teaching the class. Managed to get through the semester with an A without buying it and called him out in the class survey.

    • expr@programming.dev
      link
      fedilink
      arrow-up
      5
      ·
      1 day ago

      I was required to take an ethics class, but it was a complete joke. Guy just wasted a bunch of time on very surface-level, Philosophy 101 stuff like talking about who Aristotle was. I’m not sure we even had homework actually. Real ethics were nowhere to be found.

    • bleistift2@sopuli.xyz
      link
      fedilink
      English
      arrow-up
      8
      arrow-down
      13
      ·
      2 days ago

      Ethics are worthless if you’re not the one calling the shots. Your only options are doing what you’re told or quitting.

        • pohart@programming.dev
          link
          fedilink
          arrow-up
          1
          ·
          10 hours ago

          My first assignment as a professional programmer I balked at. I said it was “Unethical and immoral.” And when they told me I “had to do it” I said that I don’t and that they shouldn’t find someone else. My boss stepped in, chewed me out and told me to she would do it. Instead of putting her foot down there was just always another priority. It never got done in the ten years of the project.

      • fibojoly@sh.itjust.works
        link
        fedilink
        arrow-up
        8
        ·
        2 days ago

        Like everything that’s impressive at first sight, but misunderstood because you never go past that first impression.

      • squaresinger@lemmy.world
        link
        fedilink
        arrow-up
        2
        arrow-down
        3
        ·
        21 hours ago

        Have you ever seen a real-world project that actually uses OOP in any significant capacity? I haven’t.

        When using Java, you might write “class” on top of your structs and modules, but actual OOP with self-contained classes that contain both data and business logic using inheritance and all the other OOP concepts, that’s incredibly rare.

        • zerofk@lemmy.zip
          link
          fedilink
          arrow-up
          1
          ·
          3 hours ago

          I have seen and worked on many projects that use inheritance, polymorphism, interfaces, all the staples of OOP. It’s true that none of these use only OOP principles and applies them rigorously. Real world projects are almost? always a mix of many different paradigms, because the truth is no one paradigm matches all use cases - and every programmer is only familiar with a few anyway.

          This is one of the ways I believe Java went wrong: the program entry point is naturally a function, not an object. Wrapping main in an object makes little sense. Similarly, having absolutely everything inherit “Object” is forcing OOP where it doesn’t belong.

          But that doesn’t mean OOP isn’t used in the real world. It is.

          • squaresinger@lemmy.world
            link
            fedilink
            arrow-up
            1
            ·
            3 hours ago

            I could maybe have been clearer when saying “significant capacity”.

            Most projects I worked in did use OOP in some capacity, but only in quite small amounts.

            My point mainly was that a lot of people think that using the keyword “class” for structs (aka data classes) or modules (aka service/controller classes) counts as OOP and that’s not the case.

            But I agree that Java and similar languages could use some other type of syntactic sugar for modules. But then again, it would literally just be another name for the same thing.

        • mnemonicmonkeys@sh.itjust.works
          link
          fedilink
          English
          arrow-up
          1
          ·
          12 hours ago

          While the concept has it’s uses as a tool, the fallacy that OOP advocates fall into is overusing it.

          I’ve seen many people completely swear off of using scripts, which is absolutely ridiculous. While you may use some tools more than others, swearing off an entire code structure for no reason is ridiculous.

          Say there’s a module of code you need to write that has hundres if not thousands of variables that come into play in combinations that would be extremely difficult to organize as functions. You’re then stuck with passing all those as inputs and outputs between functions.

          Sure, you could organize all those variables as a giant array and pass them around as one big block, but at that point you’re just emulating the shared workspace that you get with scripts, and you’d just be better off working with scripts from the start.

          The issue with OOP is that it completely ignores this reality and insists that nobody should ever need a script, and if they think they do then they just aren’t clever enough.

          • Valmond@lemmy.world
            link
            fedilink
            arrow-up
            1
            ·
            4 hours ago

            Well you’re not wrong, but man, you’re hating the screwdriver because you work in a bolt factory.

            Use the took that best suits your problem, right?

            Also: what’s that code that has thousands of variables that cannot be organised? If it isn’t just an example for the sake of an example, I’m genuinely curious! And how does scripts “fix” that?

            Also: I have always hated java for their overuse of OOP, but also restricting its use, wtf.

            Also: I love a straightforward script, on linux at least!