DEV Community

Discussion on: why are there so many programming languages when they all do the same thing?

Collapse
 
abhinav1217 profile image
Abhinav Kulshreshtha

Just because it looks like its doing the same thing, doesn't mean it is. Answer to this will have different perspectives. 'Printf()' does not print on console for these languages. printf() prints on a default standard output consumer. If you run your program from console, your standard output device is console. If you run it on network, that will be standard output consumer. If you run it from another program in another language, its output will be a pipe(or something similar) that will ingest the output egest it as input for that program.

Mostly it boils down to their specific approach to specific problems.

PHP began as template system for CGI. So it process a request and forward them and then kill itself. Nodejs approach this with Event-Loop enabling them to maintain a connection even after serving the request. ASP / JSP primarily targets run time security for business logic, that's why there is so much setup and configuration needed before creating any website using them, compared to PHP or Node.

Another example is the final executing code. Swift and Obj-C compiles down to Apples Hardware and OS and its own instruction set ( Even Intel Mac has modified instruction set specific to them. Intel for windows will not have those) Kotlin and Java compiles down to JVM bytecode. And for android, there is a different compiler and linker which will compile it to Dalvik/ART. Which will then execute them to different chipsets.

But even Kotlin and Java are very different programming language (even though they both target JVM ) Kotlin architecture for lambdas and coroutin is different from Java threaded model. Lambdas in Java work differently than lambdas kotlin.

You can cross compile provided you can take the extra work. Dropbox earlier used C++ for both ios and android, but cost of developing for multiple platform was much higher than cost of maintaing two codebase. So they gave up. Flutter uses C++ api for targeting both platforms reducing your work, but you need to learn Dart for it. Kotlin Native has different approach, they emulate generation of Swift bytecode when building for ios.

Collapse
 
brunner1000 profile image
Brunner

Thanks for your feedback. Your comment is very informative

Collapse
 
abhinav1217 profile image
Abhinav Kulshreshtha • Edited

There is a compiler explorer godbolt.org/ , Write Hello world or something similarly small on multiple language and see what kind of bytecode is generated. If you know little bit of assembly, you can go through it and see how different language and compiler works. C program on GCC and on LLVM has different output for same program, there you can see how each compiler has different approach to the problem of compiling to machine code.

There is a youtube channel ContextFree there he talks about how different programming language works, why they were created, what problem area they focus on, etc.