also I just realized that Brazil did NOT make a programming language entirely in Spanish and call it “Si” and that my professor was making a joke about C… god damn it

this post is probably too nieche but I feel like Lemmy is nerdy enough that enough people will get it lol

  • DarkAri@lemmy.blahaj.zone
    link
    fedilink
    arrow-up
    1
    arrow-down
    1
    ·
    edit-2
    17 hours ago

    Assembly isn’t really faster than C in many cases, although it is in some cases, C actually compiles to assembly basically. The speed ups you get from assembly come from the fact that you can hand optimize some things that compilers miss, and it can be useful sometimes, like when writing a very high performance part of software like a game rendering loop or something.

    Python uses 10x the memory but probably 100x-1000x the CPU cycles to do the same thing. Also using libraries written for interpreted languages is going to bloat your memory footprint where c libraries are tiny and efficient.

    Memory leaks are an issue with all programming languages, although some use what’s called a garbage collector to handle memory which can be okay with some things but terrible in other things like real time software, operating systems, video games, or just anything you don’t want to hitch and lag and run like a turd. Garbage collectors aren’t some magic fix to memory management, if so they would be a part of C. There are huge tradeoffs to not managing your own memory. If you are using c with objects, then you are pretty safe. The object oriented nature of the language makes it very easy to manage memory. That’s mostly what it’s there for besides reducing the amount of redundant code, if you are using inheritance like you are supposed to. This is called a node graph. You store your data under objects so when you want to remove your data you just call a recursive free function on the highest parent object.

    The difference really is that C code is efficient, in the sense that it doesn’t waste anything. Every thing that seems low level about C is there for a reason. It came from a time where it was important to write code efficiently. Where every MB and cycle counted. Where having a garbage collector freeing and potentially crashing your operating system was unacceptable as well as extremely slow. It’s still slow btw, because programs have scaled with the ability of hardware to run it, so garbage collectors are still mostly as terrible as they always have been.

    C is only low level in the sense that it actually runs on the hardware. There isn’t layers of stuff in-between it and the hardware. There is no good reason to do so, outside of maybe security in some context. You don’t want web resources running on your hardware directly.

    All the other stuff that comes with modern languages is mostly nonsense. Type checking is for lazy programmers. It multiplies the time needed to do an operation. There is no good reason for it to exist other than programmers being bad at their job. C is loosely typed btw. It checks types in the compiler where it belongs. If your android phone was written in c++, your battery would last for days, and you could play games on it for hours, and everything would be extremely fast, nearly instant loading of stuff. The reason web pages were written in JiT languages was mainly just for comparability across many different types of hardware and browsers. They were also relatively small programs. Scripting can be useful sometimes, garbage collectors can be useful for script kitty stuff. It has no place in mainstream software and definitely not in operating systems. Google went from “Don’t be evil” to let’s build an entire operating system out of java and spyware. It’s not good. At this rate we aren’t even going to have guis anymore in 10 years because no hardware will be able to run it without destroying itself, and needing to be plugged in constantly, and have $1000 worth of ram from some slave economy that has overpowered us as we have become so unproductive since most people are using windows 12 or some nonsense.

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

      Perfect C is faster than perfect Python, same as perfect assembly is faster than perfect C.

      But in the real world we don’t write perfect code. We have deadlines, we have constantly shifting priorities, we have non-technical managers dictating technical implementations. We have temporary prototype code that ended up being the backbone of a 20 year project because management overpromised and some overworked developer had to deliver real fast. We have managers still believing in the mythical man month (“If one woman can make a baby in 9 months, 9 women only need a single month to make one”) and we have constant cycles of outsourcing and then insourcing again.

      With all that garbage going on we end up with a lot of “good enough for now”, completely independent of “laziness” or “low-skill” of developers. In fact, burnout is incredibly common among software developers, because they aren’t lazy and they want to write good software, but they get caught in the gears of the grind until they get to a mental breakdown.

      And since nobody has the time to write perfect code, we end up with flawed and suboptimal code. And suboptimal assembly is much worse than suboptimal C, which is again much worse than suboptimal Python.

      If your Python code is suboptimal it might consume 10x as much RAM as it needs. If your C code is suboptimal, it memory-leaks and uses up all RAM your PC has.

      If your Python code is buggy, something in the app won’t work, or worst case the app crashes. If your C code is buggy, some hacker just took over your PC because they exploited a buffer overflow to execute any code they want.


      The main issues with software performance are:

      • Management doesn’t plan right and developers need to do with what they have
      • Companies don’t want to spend incredible amounts of money on development to make things perfect
      • Companies want products to be released in time
      • Customers aren’t happy with simple things. They want pretty, fancy things
      • Customers don’t want to pay for software. In today’s money, Win95 cost around €500 and Office cost around €1000. Would you want to spend that? Or do you expect everything to be free? How much did you pay for all the software on your phone?
      • DarkAri@lemmy.blahaj.zone
        link
        fedilink
        arrow-up
        1
        ·
        edit-2
        2 hours ago

        Perfect assembly is marginally faster than perfect C, but perfect C is way faster than perfect python. You have many valid points though. Also C can be very safe if you don’t use the standard string libraries and stuff. It depends on what you are trying to do. Sometimes it’s worth giving up safety to have a better program.

        Also as a side note, when God instructed Terry Davis to build his third temple do you know what language God told him to use? C… That’s right. God himself endorses C as the greatest language mankind has ever developed.

    • realitista@lemmus.org
      link
      fedilink
      English
      arrow-up
      4
      ·
      edit-2
      15 hours ago

      Python uses 10x the memory but probably 100x-1000x the CPU cycles to do the same thing. Also using libraries written for interpreted languages is going to bloat your memory footprint where c libraries are tiny and efficient.

      You’ve obviously never looked at benchmarks because you’re one or two orders of magnitude off.

      The same reason you don’t use assembly is the reason many use Payton instead of C.

      As someone who was trained in C and did most of my programming in it, yes it does everything you need but it’s a major pain in the ass doing it well. It’s slow to get things done and you need decades to get competent at it. Python allows you to get up and running a lot faster.

      As cpu and ram are cheap compared to the days when C was a necessity, most programmers have made the decision that getting things going fast and easy was worth the trade off. The market has spoken. There is still a place for C or Rust, but there’s also a place for Python and other interpreted languages. You can make good programs in both but it’s a lot easier to make a garbage program in C.

      I’ve used at least 20 computer OS’ dating back to the ‘70s, and despite all your fearmongering, computers keep getting cheaper and easier to use, and for the most part, faster. I’ve got old Macs and PC’s and Linux boxes laying around from 20-30 years ago, and trust me, they aren’t faster or easier to use. There were some good OS’ like AmigaOS or windowing systems like FVWM back in the day that were surprisingly responsive for the time, but Windows and MacOS were all pretty garbage until about windows 7 and Mac OS X. And they costed $4000+ in today’s dollars. You can get laptops these days for $150.

      • DarkAri@lemmy.blahaj.zone
        link
        fedilink
        arrow-up
        1
        ·
        9 hours ago

        Python is really that much slower. It has actually come a long way in the past few years but it’s still a interpreted, strongly typed language. You can use libraries that are written in C or rust or something to make python run much faster but anything you write in actual Python is extremely slow. It can be okay for scripting, like basically bash, but it’s not really good for a programing language and writing applications in it is not good unless it’s a small project made by one programmer that does a specific useful thing.

        Software really is getting terrible. We are hitting a wall in terms of refining process nodes further because we are at 2 nm and it’s really difficult to keep going. There is already way too much terrible code out there just destroying really powerful systems. We are evolving backwards, boot times in the early 2000s on low end hardware were a few seconds for windows XP. When I clicked an application, it either opened nearly instantly or within a couple seconds. It was a much better operating system than windows 10 ever will be.

        The issue is having even a single piece of python or java or electron can just completely saturate your memory bus and halve the speed of every operation you do. i had a PC that had spotty thermal paste but long ago and opening discord would overheat it lol.

        All I’m saying is that writing this type of code for production shouldn’t really be acceptable. It would be nice if we actually benefited from advancing computer technology and new hardware wasn’t just an excuse to write worse software. I think operating systems should warn the users when running terrible code, that this program is low quality and will slow down the system or is taking as much resources as it can. We are in the age of 1000w computers with billions of transitions being taken out by webpages and OS spyware. The standards are just far too low. There is too much terrible software being written because companies are desperate to hire people who have no idea how to program in real languages instead of paying for real programmers or helping people learn to code in those languages and many of these companies are billion dollar companies.

        Like I said, it’s bad for the user, it’s bad for the environment, it bad for your hardrives, and it’s bad for the economy. Not to go full terry Davis on you but computers should boot in under a second these days.