175

Why are there so many programming languages? And why are there still being so many made? I would think you would try to perfect what you have instead of making new ones all the time. I understand you need new languages sometimes like quantumcomputing or some newer tech like that. But for pc you would think there would be some kind of universal language. I'm learning java btw. I like programming languages. But was just wondering.

you are viewing a single comment's thread
view the rest of the comments
[-] mo_ztt@lemmy.world 24 points 11 months ago* (last edited 11 months ago)

Different programming languages have different types of strengths. C is good for bare-metal performance and hardware interactions, Python is good at versatile interactions with all kinds of software and systems, Node.JS is good for asynchronous operations, and so on. Some esoteric languages aim to make things easy (or make them possible in the first place), or make things faster, or more secure, or etc. The things you can write in one language don't always translate to another, and sometimes people create a new language that makes things possible that didn't used to be possible. Machine learning wouldn't be where it is if everyone who's currently using Pytorch was still using C and doing all their own memory management. I'm currently working on a project in Node that would be much more difficult in Java, because Node's approach to asynchronous operations matches this problem way better than do the primitives that Java's runtime makes available. And so on.

Is any given language that gets created going to be the next Python? Probably not. But everyone who makes one has some kind of idea that there's something unique and wonderful within it, and you can't tell if they're right unless you let it happen and see how it plays out.

Edit: Okay lemme clarify: Node.JS is good for a particular type of (generally I/O bound) asynchronous operations. It makes simple things easy and fast, at the cost of making some complex things pretty much impossible, so there are a bunch of problems it's not good for. Better with the caveat maybe?

[-] TempestTiger@programming.dev 5 points 11 months ago

If you have time (and the inclination!), would you mind explaining why Java's primitives aren't as good as Node visa vie Async ops?

[-] mo_ztt@lemmy.world 9 points 11 months ago

It's not a matter of better or worse (in this particular case -- there is such a thing as languages that are just plain bad). In my opinion, it's just what you're trying to do:

So Node uses a multiprocessing model where your program won't be interrupted in unpredictable spots -- there are very specific places where a function might pause waiting for something to happen, and give way to another function, but during ordinary ("synchronous") operations you can be guaranteed that the program won't be interrupted. That makes things hugely simpler because in general, you don't have to mutex-protect your data structures, you don't have as many weird subtle bugs that only crop up during certain thread interactions that are extremely difficult to debug. That's the upside. The main downside is that because it's a single-threaded model, which means (a) you can't easily scale up your program to multiple CPUs and (b) if you have a long CPU-bound operation, it'll happily block the whole rest of your program from executing no matter how many problems that causes. It's excellent for network-I/O-bound workloads, because you're probably not heavy on computation and it's simpler to program and more robust than using multithreading in that case. Although, you do have to learn some new primitives and make sure to be careful with CPU-heavy operations. Then there are a lot of workloads where it's awkward to try to use.

Java tried to do multithreading all the way from the ground up, to make everything thread-safe (which is actually pretty unusual for a full-featured runtime environment, because it's a lot to take on). The upside is that if you need that, it's gold; you can write your normal application and then run it on a 64-core processor and all of a sudden (relatively speaking) everything just works, which is great for massive-within-a-single-process scalability. The downside is that (a) you will get people who disagree vehemently with you on whether within-a-single-process scalability is worth the complexity cost you pay, and (b) if you're just trying to write some code where you don't care about threads, guess what? You have to care about threads. You need mutexes, you have subtle bugs and deadlocks, you have lots of extra testing headaches, or else: You can sort of close your eyes and run your Java application single-threaded, which defeats some of the purpose, and also God help you if later on you ever want to try to make it multi-threaded.

Neither one I would say is right or wrong. There's a whole third way, which is actually what most environments do, which is that you say that a lot of things in the runtime aren't thread-safe, and so if you want heavy scalability you do it with multiple processes, and if you need threads you need to take on the responsibility of tiptoeing around the non-thread-safe stuff. That's sort of a mess, which is why both Java and Node take different more coherent approaches to it.

[-] TempestTiger@programming.dev 3 points 11 months ago

Tysm for your response! Really appreciate it (⁠◍⁠•⁠ᴗ⁠•⁠◍⁠)⁠✧⁠*⁠。

[-] mo_ztt@lemmy.world 3 points 11 months ago

No problem, glad it was helpful 👍

load more comments (3 replies)
load more comments (3 replies)
this post was submitted on 04 Aug 2023
175 points (94.0% liked)

Programming

16304 readers
174 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 1 year ago
MODERATORS