Today I learned - Programming languages can be brought together
Andew
Posted on November 3, 2023
In my understanding, each project would be written using only one programming language; however, today I learned that it is possible to combine different languages in one project.
For example:
Let's say we have a script written in Ruby*:
# my_ruby_script.rb
puts "Hello from Ruby!"
We can execute this Ruby script in a Python script*:
import subprocess
# Execute the Ruby script from Python
result = subprocess.run(['ruby', 'my_ruby_script.rb'], capture_output=True, text=True)
# Print the output of the Ruby script
print(result.stdout)
Although programming languages can be used together, mixing languages can make it more difficult to read and modify code; it must be done cautiously.
*Code examples from ChatGpt
💖 💪 🙅 🚩
Andew
Posted on November 3, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
watercooler Why does a reboot make your PC run SO much faster than running all the cleaning tools you can possibly imagine?
November 30, 2024