487
top 50 comments
sorted by: hot top controversial new old
[-] Ephera@lemmy.ml 72 points 5 months ago

Honestly, it's still ridiculous to me how slow Python, Java, JS, Ruby etc. continue to feel, even after decades of hardware optimizations. You'd think their slowness would stop being relevant at some point, because processors and whatnot have become magnitudes faster, but you can still feel it quite well, when something was implemented in one of those.

[-] Urist@lemmy.ml 40 points 5 months ago

Many of these have C-bindings for their libraries, which means that slowness is caused by bad code (such as making a for loop with a C-call for each iteration instead of once for the whole loop).

I am no coder, but it is my experience that bad code can be slow regardless of language used.

[-] Ephera@lemmy.ml 30 points 5 months ago* (last edited 5 months ago)

Bad code can certainly be part of it. The average skill level of those coding C/C++/Rust tends to be higher. And modern programs typically use hundreds of libraries, so even if your own code is immaculate, not all of your dependencies will be.

But there's other reasons, too:

  • Python, Java etc. execute their compiler/interpreter while the program is running.
  • CLIs are magnitudes slower, because these languages require a runtime to be launched before executing the CLI logic.
  • GUIs and simulations stutter around, because these languages use garbage collection for memory management.
  • And then just death by a thousand paper cuts. For example, when iterating over text, you can't tell it to just give you a view/pointer into the existing memory of the text. Instead, it copies each snippet of text you want to process into new memory.
    And when working with multiple threads in Java, it is considered best practice to always clone memory of basically anything you touch. Like, that's good code and its performance will be mediocre. Also, you better don't think about using multiple threads in Python+JS. For those two, even parallelism was an afterthought.

Well, and then all of the above feeds back into all the libraries not being performant. There's no chance to use the languages for performance-critical stuff, so no one bothers optimizing the libraries.

[-] TimeSquirrel@kbin.melroy.org 11 points 5 months ago

For example, when iterating over text, you can't tell it to just give you a view/pointer into the existing memory of the text. Instead, it copies each snippet of text you want to process into new memory.

As someone used to embedded programming, this sounds horrific.

[-] Ephera@lemmy.ml 7 points 5 months ago

Yep. I used to code a lot in JVM languages, then started learning Rust. My initial reaction was "Why the hell does Rust have two string types?".
Then I learned that it's for representing actual memory vs. view and what that meant. Since then I'm thinking "Why the hell do JVM languages not have two string types?".

[-] calcopiritus@lemmy.world 2 points 5 months ago

I'm not a java programmer, but I think the equivalent to str would be char[]. However the ergonomics of rust for str isn't there for char[], so java devs probably use String everywhere.

load more comments (1 replies)
[-] aluminium@lemmy.world 7 points 5 months ago

At least with Java, its the over(ab)use of Reflections and stuff like dependency injection that slows things down to a crawl.

[-] GissaMittJobb@lemmy.ml 24 points 5 months ago

There are a few reasons for this, some of the most important being:

  • The languages were not designed with speed primarily in mind and as such made some design decisions that fundamentally cannot be optimized around
  • Authors of programs in these languages prioritize things other than performance when writing the programs.

Speed is not just about processors becoming faster - this is a large part of why DSA is important to learn as a programmer.

[-] possiblylinux127@lemmy.zip 2 points 5 months ago* (last edited 5 months ago)

They do have optimizations however they are interpreted at runtime so they can only be so fast

Frankly you won't notice much unless the program is doing something computation heavy which shouldn't be done in languages such as JavaScript and Python

[-] SuperSpruce@lemmy.zip 12 points 5 months ago

True, plus the bloated websites I see are using hundreds of thousands of lines of JavaScript. Why would you possibly need that much code? My full fledged web games use under 10,000.

load more comments (1 replies)
[-] possiblylinux127@lemmy.zip 9 points 5 months ago* (last edited 5 months ago)

"Slow"

They aren't as fast as a native language but they aren't all that slow if you aren't trying to use them for performance sensitive applications. Modern machines run all those very quickly as CPUs are crazy fast.

Also it seems weird to put Java/OpenJDK in the list as it is in its own category from my experience

[-] Ephera@lemmy.ml 4 points 5 months ago

Java is certainly the fastest of the bunch, but I still find it rather noticeable how long the startup of applications takes and how it always feels a bit laggy when used for graphical stuff.

Certainly possible to ignore that on a rational level, but that's why I'm talking about how it feels.
I'm guessing, this has to do with just the basic UX principle of giving the user feedback. If I click a button, I want feedback that my click was accepted and when the triggered action completed. The sooner those happen, the more confident I feel about my input and the better everything feels.

[-] possiblylinux127@lemmy.zip 4 points 5 months ago

I've never experienced that. Also Android is OpenJDK based and the applications in Android work well and the system is well optimized

[-] Ephera@lemmy.ml 1 points 5 months ago

Yep, I also don't fully agree on that one. I'm typing this on a degoogled Android phone with quite a bit stronger hardware than the iPhone SE that my workplace provides, e.g. octacore rather than hexacore, 8GB vs. 3GB RAM.

And yet, you guessed it, my Android phone feels quite a bit laggier. Scrolling on the screen has a noticeable delay. Typing on the touchscreen doesn't feel great on the iPhone either, because the screen is tiny, but at least it doesn't feel like I'm typing via SSH.

[-] possiblylinux127@lemmy.zip 1 points 5 months ago

I've never experienced that and I am running a several year old phone

load more comments (1 replies)
load more comments (2 replies)
[-] Treczoks@lemmy.world 7 points 5 months ago

It is always a question of chosing the right tool for the right task. My core code is in C (but probably better structured than most C++ programs), and it needs to be this way. But I also do a lot of stuff in PERL. When I have to generate a source code or smart-edit a file, it is faster and easier to do this in PERL, especially if the execution time is so short that one would not notice a difference anyway.

Or the code that generates files for the production: Yes, a single run may take a minute (in the background), but it produces the files necessary for the production of goods of over 100k worth. And the run is still faster than the surrounding processes like getting the request from production, calculating the necessary parameters, then wrapping all the necessary files with the results of the run into a reply to the production department.

[-] mexicancartel@lemmy.dbzer0.com 2 points 5 months ago

This is because they are meant to be simpler for complex logic. They don't want to be faster by ditching the simplicity

[-] kaffiene@lemmy.world 1 points 5 months ago

Java isn't slow

[-] Viking_Hippie@lemmy.world 34 points 5 months ago

Damn, that's a fast ass-cheetah!

What with passenger planes like the one depicted typically going 575-600 mph and the bar only 3 times as long, that dude is sprinting at upto 200mph!

(Link is to classic xkcd comic, not furry porn)

[-] VonReposti@feddit.dk 17 points 5 months ago

Link is to classic xkcd comic, not furry porn

Damn, you got my hopes up for a second there.

[-] FuglyDuck@lemmy.world 11 points 5 months ago* (last edited 5 months ago)

(Link is to classic xkcd comic, not furry porn)

I am both disappointed and pleased.

[-] roguetrick@lemmy.world 6 points 5 months ago* (last edited 5 months ago)

Well if it's linear the cheeta is going somewhere around 100 million miles per hour. Air resistance would quickly make it a no-ass cheeta.

[-] Throw_away_migrator@lemmy.world 4 points 5 months ago
[-] Viking_Hippie@lemmy.world 4 points 5 months ago

Probably, but it's much more fun to imagine a cheetah hauling ass at the speed of a modern supercar 😂

[-] ReveredOxygen@sh.itjust.works 3 points 5 months ago

Did you notice how it also mentions the speed of light?

[-] roguetrick@lemmy.world 1 points 5 months ago

The airplane is actually a spaceship that uses reaction mass to reach c/2.

[-] ICastFist@programming.dev 2 points 5 months ago

That's just the FreePascal Compiler

[-] eskuero@lemmy.fromshado.ws 30 points 5 months ago

As someone who only codes solutions for himself I don't relate. All the extra time I would spend writting a C solution it would never attone the runtime loses of doing it in maybe python.

[-] sxan@midwest.social 32 points 5 months ago* (last edited 5 months ago)

Anyway, this is only relevant if you're writing only for yourself. It's your poor users who suffer for your expediency.

[-] 30p87@feddit.org 1 points 4 months ago

Shaves off 1 sec and I do it 50+ times a day, checks out.

[-] adhocfungus@midwest.social 11 points 5 months ago

I used to write extensively with C++, but it has been a long time since speed mattered that much to one of my applications. I still marvel at the cache-level optimizations some people come up with, but I'm in the same mindset as you now.

My workload split of Data Movement vs Data Transformation is like 95:5 these days, which means almost all the optimizations I do are changing batch/cache/page/filter settings. I can do that in any language with http bindings, so I choose those that are faster to write.

[-] RacoonVegetable@reddthat.com 28 points 5 months ago

And I like rust programs for their memory safety

[-] possiblylinux127@lemmy.zip 1 points 5 months ago

Or even JavaScript as it takes away all the difficulty with complex applications

[-] h0bbl3s@lemmy.world 24 points 5 months ago

I used c++ in college, and I think it's useful to know c because so much relies on it. That said if I'm going to do something that needs performance I'll look to go first, then rust if go isn't a good fit, but that's mostly because I know go better. Both are excellent languages.

If I just need something functional quick and easily I'll turn to Python. If I need a net service quick node.js is great.

[-] Opisek@lemmy.world 5 points 5 months ago

I was a huge C++ fan back when I was doing a bunch of competitive programming. If I need a performant project nowadays, I look to golang first. It gives me the speed of a compiled language with the usability of high-level language. I still solve the occasional Advent of Code in C++, though :)

[-] WalnutLum@lemmy.ml 20 points 5 months ago

https://github.com/hykilpikonna/hyfetch

I like hyfetch because it has the largest os compatibility.

It feels like the spiritual successor to neofetch tbh.

[-] DmMacniel@feddit.org 6 points 5 months ago

yeah and it allows for queering up the distro logo, which I absolutely love.

[-] unrushed233@lemmings.world 2 points 5 months ago

It's still slow and written in Bash/Python

[-] xenoclast@lemmy.world 10 points 5 months ago

amateurs.asm

(Calm down, I'm joking)

[-] Sammy@lemmy.dbzer0.com 10 points 5 months ago

Honestly, love to see a lil CatchyOS representation. So far my favorite Arch flavor.

[-] missphant 6 points 5 months ago

It's fitting for this image too since CachyOS kernel + packages + defaults go zoom.

[-] kala_telo 8 points 5 months ago

I decided to run it on system without bash as neofetch replacement. It feels unreasonably complex, I spent unreasonable amount of time fighting with cmake. On normal system I have pfetch in my bashrc, since it's basically instant, and neofetch for screenshots. It's not instant, but I don't run it every second or something.

And btw I do love speed and simplicity of C, but for fetch tool, POSIX shell is the best choice, I think.

[-] possiblylinux127@lemmy.zip 2 points 5 months ago

Just use pfetch or neofetch. Neofetch isn't really maintained however it still works. Pfetch is nice because it is a shell script and very portable

[-] spikespaz@programming.dev 5 points 5 months ago

Neofetch has always been stupid and slow

[-] Ghoelian@lemmy.dbzer0.com 1 points 5 months ago

Why does speed even matter this much for a program most people only run once to show off their new builds? Or do these programs have some other purpose than printing system specs?

[-] possiblylinux127@lemmy.zip 2 points 5 months ago

Pfetch works well with curl

load more comments
view more: next ›
this post was submitted on 14 Jul 2024
487 points (100.0% liked)

linuxmemes

21601 readers
494 users here now

Hint: :q!


Sister communities:


Community rules (click to expand)

1. Follow the site-wide rules

2. Be civil
  • Understand the difference between a joke and an insult.
  • Do not harrass or attack members of the community for any reason.
  • Leave remarks of "peasantry" to the PCMR community. If you dislike an OS/service/application, attack the thing you dislike, not the individuals who use it. Some people may not have a choice.
  • Bigotry will not be tolerated.
  • These rules are somewhat loosened when the subject is a public figure. Still, do not attack their person or incite harrassment.
  • 3. Post Linux-related content
  • Including Unix and BSD.
  • Non-Linux content is acceptable as long as it makes a reference to Linux. For example, the poorly made mockery of sudo in Windows.
  • No porn. Even if you watch it on a Linux machine.
  • 4. No recent reposts
  • Everybody uses Arch btw, can't quit Vim, and wants to interject for a moment. You can stop now.
  •  

    Please report posts and comments that break these rules!


    Important: never execute code or follow advice that you don't understand or can't verify, especially here. The word of the day is credibility. This is a meme community -- even the most helpful comments might just be shitposts that can damage your system. Be aware, be smart, don't fork-bomb your computer.

    founded 2 years ago
    MODERATORS