你们肯定有些人学过代码,比如说Java,Python,C++等(Scratch这个东东就不配进来)
但是你们真的懂得怎么写代码吗?
Groovy语言输出Sum of x + y = 35是这样的
def x = 10
def y = 25
print 'Sum of x + y = ' + (x + y)
Assembly语言输出Hello,World!是这样的
section .data
hello: db 'Hello world!',10 ; 'Hello world!' plus a linefeed character
helloLen: equ $-hello ; Length of the 'Hello world!' string
section .text
global _start
_start:
mov eax,4 ; The system call for write (sys_write)
mov ebx,1 ; File descriptor 1 - standard output
mov ecx,hello ; Put the offset of hello in ecx
mov edx,helloLen ; helloLen is a constant, so we don't need to say
; mov edx,[helloLen] to get it's actual value
int 80h ; Call the kernel
mov eax,1 ; The system call for exit (sys_exit)
mov ebx,0 ; Exit with return "code" of 0 (no error)
int 80h;
(说实话,是真的很复杂,还不如C++呢)
R语言输出Hello,World!是这样的
myString <- "Hello, World!"
print ( myString)
是不是很简单
VB.NET输出Hello,World!是这样的
Module Module1
Sub Main()
Console.WriteLine("Hello World!")
End Sub
End Module
TybeScirpt就更简单了
const hello : string = "Hello World!"
console.log(hello)
Kotlin是这样的
fun main(args : Array<String>){
println("Hello World!")
}
Pascal是这样的
program Hello;
begin
writeln ('Hello, world!')
end.
很无语这个代码段都没有兼容的
下面有请最简单的代码语言Lua出场!
print("Hello World!")
是不是很惊讶,就这么简单
然后是Node.js语言输出Hello,World!是这样的,也是一样简单
console.log("Hello World!");
Go语言输出Hello,World!是这样的!
package main
import "fmt"
func main() {
fmt.Println("Hello, World!")
}
Swift语言是这样的
/* Write swift code in this online editor and run it. */
var myString = "Hello, World!"
print(myString)
RUST语言是这样的
fn main() {
println!("Hello World!");
}
Bash语言是这样的
#!/bin/bash
echo 'Hello World!'
Perl语言是这样的
#!/usr/bin/perl
print "Hello, World!\n";
Erlang语言是这样的
% escript will ignore the first line
main(_) ->
io:format("Hello World!~n").
Scala语言是这样的
object Main {
def main(args:Array[String])
{
println("Hello World!")
}
}
C#语言是这样的
using System;
namespace HelloWorldApplication
{
class HelloWorld
{
static void Main(string[] args)
{
/* Write C# code in this online editor and run it. */
Console.WriteLine("Hello World!");
Console.ReadKey();
}
}
}
Ruby语言是这样的
#!/usr/bin/ruby
# -*- coding: UTF-8 -*-
puts "Hello World!";
感情这个也不支持
C++语言是这样的
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World";
return 0;
}
#include <cstdio>
using namespace std;
int main()
{
printf("Hello,World!");
return 0;
}
C语言是这样的
#include <stdio.h>
int main()
{
/* Write C code in this online editor and run it. */
printf("Hello, World! \n");
return 0;
}
Java语言是这样的
public class HelloWorld {
public static void main(String []args) {
System.out.println("Hello World!");
}
}
Python语言是这样的
Python3:
#!/usr/bin/python
# Write Python 3 code in this online editor and run it.
print("Hello, World!");
Python2:
# -*- coding: UTF-8 -*-
# Write Python 2 code in this online editor and run it.
print 'Hello World!'
PHP语言是这样的
<?php
echo 'Hello World!';
?>
现在你们再问一下自己,这些自己都会吗,而且会灵活运用吗