ITSECURITYCOMPUTER Telegram 26412
پایتون vs جاوا: کد کدوم کوتاه‌تره؟

با یک مثال ساده (فیبوناچی) می‌بینی پایتون چقدر کد رو کوتاه و خوانا می‌نویسه، درحالی‌که جاوا با نوع‌دهی و ساختار صریح، کنترل بیشتری می‌ده.
نتیجه؟ اگر می‌خوای سریع نمونه‌سازی کنی و اسکریپت بزنی، پایتون انتخاب خوبیه. اگر پروژه‌ی بزرگ و استاندارد سازمانی داری، جاوا می‌درخشه.

📱پایتون :
# Fibonacci up to n
n = int(input("n: "))
a, b = 0, 1
while a <= n:
print(a, end=" ")
a, b = b, a + b

📱جاوا :
import java.util.Scanner;

public class Fib {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("n: ");
long n = sc.nextLong();
long a = 0, b = 1;
while (a <= n) {
System.out.print(a + " ");
long next = a + b;
a = b;
b = next;
}
sc.close();
}
}

#java #python

✈️@ITSecurityComputer
Please open Telegram to view this post
VIEW IN TELEGRAM
❤‍🔥14👍82👎1



tgoop.com/ITSecurityComputer/26412
Create:
Last Update:

پایتون vs جاوا: کد کدوم کوتاه‌تره؟

با یک مثال ساده (فیبوناچی) می‌بینی پایتون چقدر کد رو کوتاه و خوانا می‌نویسه، درحالی‌که جاوا با نوع‌دهی و ساختار صریح، کنترل بیشتری می‌ده.
نتیجه؟ اگر می‌خوای سریع نمونه‌سازی کنی و اسکریپت بزنی، پایتون انتخاب خوبیه. اگر پروژه‌ی بزرگ و استاندارد سازمانی داری، جاوا می‌درخشه.

📱پایتون :

# Fibonacci up to n
n = int(input("n: "))
a, b = 0, 1
while a <= n:
print(a, end=" ")
a, b = b, a + b

📱جاوا :
import java.util.Scanner;

public class Fib {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("n: ");
long n = sc.nextLong();
long a = 0, b = 1;
while (a <= n) {
System.out.print(a + " ");
long next = a + b;
a = b;
b = next;
}
sc.close();
}
}

#java #python

✈️@ITSecurityComputer

BY SecurityComputer




Share with your friend now:
tgoop.com/ITSecurityComputer/26412

View MORE
Open in Telegram


Telegram News

Date: |

While some crypto traders move toward screaming as a coping mechanism, many mental health experts have argued that “scream therapy” is pseudoscience. Scientific research or no, it obviously feels good. Today, we will address Telegram channels and how to use them for maximum benefit. Members can post their voice notes of themselves screaming. Interestingly, the group doesn’t allow to post anything else which might lead to an instant ban. As of now, there are more than 330 members in the group. ZDNET RECOMMENDS The best encrypted messaging apps
from us


Telegram SecurityComputer
FROM American