比较几种编程语言

简介

最近要使用几种不同的编程语言,C++, java,javascript,php,python和ruby。为了避免混淆,特写此文,以备参考。

数据类型

这里数据类型指的是内部数据类型,不考虑语言内部的自动转换。

 

C++

java

javascript

php

python

ruby

基本类型

bool

char

int, unsigned, long

float, double

pointer

boolean

char

int, long

float, double

 

String

Number

Boolean

integer

string

float

 

int, long, float, double

String

Number

Symbol

逻辑操作

&&, ||, !

&&, ||, !

&&, ||, !

结果不一定是布尔

&&, ||, !

and, or, not

&&, ||, !

字符串操作

strlen

strcat

substr

s.length

s.concat

s.substring

s.matches

s.length

+

s.substr

s.match

strlen

.

Substr

preg_match

len

+

s[n:m]

re.compile().match()

size

+

s[n, m]

s.sub

复合类型

struct

class

union

array

class

array

array

function

可当作对象使用

array

class

list

dictionary

tuple

class

Array,Hash

class

 

语句结构

 

C++

java

javascript

php

python

ruby

条件

if/else

switch/case

if/else

switch/case

if/else

switch/case

if/else

switch/case

if/else/elif

 

if/else/elseif

循环

for

while

do while

for/:

while

do while

for/in

while

do while

for

foreach/as

while

do while

for/in

while

for/in

while

 

l模块

Template function/class

function

 

function

具有层级化的定义域

function

Lamda function

Lamda block

异常

try

catch

throw

try

catch

finally

throw

 try

catch

throw

 try

catch

throw

 try:

except:

else:

finally:

begin/end

rescue

ensure

raise

对象

基于类

多继承

基于类/接口

单继承

基于原型

可实现继承

基于类

单继承

基于类

多继承

基于类

单继承

选择条件

  • C++:高性能,程序员对技术细节很熟悉。
  • Java:跨平台,有大量的编程工具
  • Javascript:浏览器脚本,富客户端
  • Php:服务器脚本,支持模板,支持框架
  • Python:通用脚本,支持模板,支持框架,代码简洁
  • Ruby:通用脚本,支持模板,支持框架,支持元编程

转载于:https://www.cnblogs.com/liuyunfeng/archive/2012/07/31/2616537.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值