시작하기
다음은 네 가지 언어로 된 모든 주요 프로그래밍 개념에 대한 패턴입니다. 웹 사이트를 통해 직접 시험해 보려면 이 언어로 연습 할 수 있는 무료 환경을 만드십시오.
우리는 새로운 언어를 배울 때 항상 따라야 하는 과정을 따를 것입니다.
이러한 빌딩 블록을 마친 후에는 CodeWars.com과 같은 웹 사이트에서 자신을 더 밀어 붙이고 도전을 시작할 수 있습니다.
콘솔에 값 인쇄
일반적으로 명령 줄 셸 (mac / linux의 경우 Bash, Windows의 경우 cmd / powershell / gitBash)을 통해 프로그래밍 언어와 상호 작용합니다. 따라서 컴퓨터에 이러한 언어가 있으면 파일을 작성하고 명령으로 실행합니다. 프로그램이 지침을 따르고 있음을 확인하기 위해 가끔 콘솔에 값을 인쇄하는 것 외에는 코드가 시각적으로 무엇을 하는지 볼 수 없습니다.
언어 |
파일 확장자 |
run script command |
패키지관리자 |
Dep List |
Javascript |
.js |
node file.js |
npm |
package.json |
Python |
.py |
python file.py |
pip |
requirements.txt |
Ruby |
.rb |
ruby file.rb |
Gems |
Gemfile |
PHP |
.php |
php file.php |
composer |
composer.json |
이것이 당신이 항상 만드는 첫 번째 프로그램이 Hello World 인 이유입니다.
Javascript (using NodeJS)
console.log("Hello World")
Ruby
puts "hello world"
Python
print("Hello World")
PHP
echo "hello world";
Variables
프로그래밍은 모두 동적 코드를 만드는 것입니다. 종종 우리가 알지 못하거나 초과 근무 시간에 변경 될 수 있는 가치가 있습니다. 이러한 값을 하드 코딩하고 코드를 더 엄격하게 만드는 대신 변수를 사용하여 코드의 값을 저장하고 참조합니다.
다양한 유형의 데이터가 있습니다.
이 값을 변수라고 하는 작은 구멍에 저장할 수 있습니다. 그런 다음 값을 참조하는 데 사용할 수 있습니다.
javascript (using NodeJS)
let myString = "Hello World"
let myNumber = 5
let myBool = true
console.log(myString)
console.log(myNumber)
console.log(myBool)
Ruby
my_string = "Hello World"
my_number = 5
my_boolean = true
puts my_string
puts my_number
puts my_boolean
Python
my_string = "Hello World"
my_number = 5
my_boolean = True
print(my_string)
print(my_number)
print(my_boolean)
PHP
$my_string = "Hello World";
$my_number = 5;
$my_boolean = true;
echo $my_string;
echo $my_number;
echo $my_boolean;
Conditionals
스크립트를 유용하게 만드는 것은 일련의 작업을 요약 할 수 있을 뿐만 아니라 관련된 데이터의 상태에 따라 이러한 작업이 변경되도록 하는 것입니다. 진술을 통해 우리가 물어볼 수 있다면 이것이 사실입니까? 그런 다음 참인지 거짓인지에 따라 스크립트가 수행하는 작업을 선택합니다.
Javascript (using NodeJS)
let number = 6
if (number > 5){
console.log(true)
} else {
console.log(false)
}
Ruby
number = 6
if number > 5
puts true
else
puts false
end
Python
number = 6
if (number > 5):
print(True)
else:
print(False)
PHP
$number = 6
if ($number > 5){
echo true;
} else {
echo false;
}
Loops
작업을 여러 번 반복해야 하는 경우 반복해서 입력하는 것이 매우 지루할 것입니다. 이 상황에서는 표현식이 참인 한 일련의 명령을 반복하고 거짓이 되면 중지하는 루프가 있습니다.
Javascript (using NodeJS)
let counter = 0
while (count < 10){
console.log(count)
count = count + 1
}
Ruby
counter = 0
while counter < 10
puts counter
counter = counter + 1
end
Python
counter = 0
while (counter < 10):
print(counter)
counter = counter + 1
PHP
$counter = 0;
while($counter < 10){
echo counter;
$counter = $counter + 1
}
Collections
컬렉션은 여러 값을 보유 할 수 있는 언어의 데이터 구조입니다. 일반적으로 두 가지 범주 중 하나에 속합니다.
Language |
Using Numerical Index |
Using Keys |
Javascript |
Arrays |
Objects |
Ruby |
Arrays |
Hashes |
Python |
List |
Dictionaries |
PHP |
Arrays |
Associative Arrays |
Javascript (using NodeJS)
let myArray = ["Alex Merced", 35]
console.log(myArray[0])
console.log(myArray[1])
let myObject = {name: "Alex Merced", age: 35}
console.log(myObject.name)
console.log(myObject.age)
Ruby
my_array = ["Alex Merced", 35]
puts my_array[0]
puts my_array[1]
my_hash = {name: "Alex Merced", age: 35}
puts my_hash[:name]
puts my_hash[:age]
Python
my_list = ["Alex Merced", 35]
print(my_list[0])
print(my_list[1])
my_dictionary = {"name": "Alex Merced", "age": 35}
print(my_dictionary["name"])
print(my_dictionary["age"])
PHP
$my_array = ["Alex Merced", 35];
echo $my_array[0];
echo $my_array[1];
$my_associative = ["name" => "Alex Merced", "age" => 35];
echo $my_associative["name"];
echo $my_associative["age"];
Functions
함수는 마법의 주문과 같으며 지정된 작업을 수행하며 원하는 만큼 언제든지 사용할 수 있습니다. 정보는 인수의 형태로 함수에 제공 될 수 있으며 이러한 인수는 매개 변수라는 변수에 저장됩니다. 함수는 프로그래밍에서 강력한 작업을 수행하는 데 중요합니다.
Javascript (using NodeJS)
// x is parameter variable that will receive the first argument
function addOne(x){
//the return value is what the function gives back when its done
return x + 1
}
//Several invocations of the function passing different arguments
const result1 = addOne(1)
console.log(result1)
const result2 = addOne(2)
console.log(result2)
Ruby
def addOne x
return x + 1
end
result1 = addOne 1
puts result1
result2 = addOne 2
puts result2
Python
def addOne(x):
return x + 1
result1 = addOne(1)
print(result1)
result2 = addOne(2)
print(result2)
PHP
function addOne(x){
return x + 1;
}
$result1 = addOne(1);
echo $result1;
$result2 = addOne(2);
echo $result2;
결론
바라건대, 이것은 당신에게 이러한 언어로 좋은 출발점이 되기를 바랍니다. 다음은 이러한 언어에 대한 능력을 키울 때 찾아보고 시도 할 몇 가지 주제입니다.
그런 다음 언어에 익숙해지면 웹 프레임 워크로 웹 애플리케이션을 구축해보십시오. 이들은 미니멀하고 독단적 인 맛으로 나옵니다. 다음은 각 언어의 기본 프레임 워크를 보여주는 표입니다.
Language |
Minimalist Web Framework |
Opinionated Web Framework |
Python |
Flask, FastAPI |
Django, Masonite |
Ruby |
Sinatra |
Ruby on Rails |
PHP |
Slim |
Laravel, Symphony |
Javascript |
Express, Koa, Fastify |
FoalTS, NestJS, Sails |
https://dev.to/alexmercedcoder/learn-python-php-ruby-and-javascript-in-one-blog-post-2n0p
등록된 댓글이 없습니다.