Knowledge

Comparison of programming languages (strings)

Source 📝

1279:
or "heredoc": A token representing the string is put in the middle of a line of code, but the code continues after the starting token and the string's content doesn't appear until the next line. In other languages, the string's content starts immediately after the starting token and the code
179: 334: 110: 140: 90: 1105:"Dual quoting" means that whenever a quote is used in a string, it is used twice, and one of them is discarded and the single quote is then used within the string. 174: 167: 120: 45: 135: 162: 327: 989:"Escaped" quotes means that a 'flag' symbol is used to warn that the character after the flag is used in the string rather than ending the string. 307: 189: 374:
Different languages use different symbols for the concatenation operator. Many languages use the "+" symbol, though several deviate from this.
320: 40: 1145:"Raw" means the compiler treats every character within the literal exactly as written, without processing any escapes or interpolations. 302: 115: 1521: 247: 184: 68: 145: 1275:
Many languages have a syntax specifically intended for strings with multiple lines. In some of these languages, this syntax is a
150: 1506: 861:
An expression is "interpolated" into a string when the compiler/interpreter evaluates it and inserts the result in its place.
155: 95: 50: 199: 85: 30: 19: 227: 1526: 35: 282: 1008:
C, C++, C#, D, Dart, F#, Java, JavaScript, Mathematica, Ocaml, Perl, PHP, Python, Rust, Swift, Wolfram Language, Ya
262: 277: 194: 695: 424: 408: 297: 125: 1164:
APL, Bourne shell, Fortran, Object Pascal, Pascal, Perl, PHP, Pick Basic, Ruby, Smalltalk, Windows PowerShell
1375:(all strings are multiline), Rust (all strings are multiline), Visual Basic .NET (all strings are multiline) 924: 647: 487: 472: 452: 448: 420: 209: 204: 727: 468: 464: 412: 292: 272: 105: 73: 829: 613: 598: 523: 460: 456: 432: 416: 252: 677: 657: 539: 511: 287: 428: 352: 80: 267: 257: 759: 745: 681: 594: 501: 63: 812:" sign but at the risk of ambiguity if a string representing a number and a number are together. 100: 744:
uses the empty string: two expressions adjacent to each other are concatenated. This is called
763: 762:(along with Python) allows juxtaposition for string literals, however, for strings stored as 58: 1507:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw
840:
macro, of which the latter is the most prevalent throughout the documentation and examples.
766: 363: 8: 222: 476: 805: 555: 643: 617: 576: 815: 703: 527: 1313:<<<EOF I have a lot of things to say and so little time to say them EOF 850: 355: 1515: 1276: 440: 1300:<<EOF I have a lot of things to say and so little time to say them EOF 1020:
CoffeeScript, Dart (alternate), JavaScript (alternate), Python (alternate)
890: 801: 551: 1372: 946: 707: 639: 565: 515: 444: 359: 792: 749: 667: 436: 1124:
Ada, ALGOL 68, COBOL, Excel, Fortran, FreeBASIC, Visual Basic (.NET)
685: 535: 531: 1381:
R"( I have a lot of things to say and so little time to say them )"
1352:""" I have a lot of things to say and so little time to say them """ 396: 1407:[[ I have a lot of things to say and so little time to say them ]] 1339:"[ I have a lot of things to say and so little time to say them ]" 1326:@" I have a lot of things to say and so little time to say them "@ 756:
uses this syntax for concatenation including an intervening space.
1394:
r" I have a lot of things to say and so little time to say them "
717: 602: 491: 1420:` I have a lot of things to say and so little time to say them ` 1365:" I have a lot of things to say and so little time to say them " 1134:
APL, COBOL, Fortran, Object Pascal, Pascal, rc, Smalltalk, SQL
788: 771: 778: 699: 543: 519: 404: 400: 753: 625: 621: 580: 547: 741: 629: 584: 1359:CoffeeScript, Dart, Groovy, Kotlin, Python, Swift 1280:continues after the string literal's terminator. 1513: 308:Comparison of Visual Basic and Visual Basic .NET 849:This section compares styles for declaring a 349:comparison of programming languages (strings) 328: 1433: 785:statement to concatenate string variables. 335: 321: 268:ALGOL 68: Comparisons with other languages 258:ALGOL 60: Comparisons with other languages 362:processing for over 52 various computer 278:Comparison of Pascal and Borland Delphi 1514: 1502: 1484: 1468:Indented with whitespace and newlines 893:, Dart, Perl, PHP, Windows PowerShell 856: 303:Comparison of C# and Visual Basic .NET 1491:still processes string interpolation. 248:Comparison of Java and .NET platforms 1270: 13: 844: 735: 377: 14: 1538: 984: 283:Comparison of Object Pascal and C 1522:Programming language comparisons 1056:"I said, %"Hello, World!%"" 605:(Expression Language component) 369: 253:ALGOL 58's influence on ALGOL 60 1100: 263:Comparison of ALGOL 68 and C++ 228:List of "Hello World" programs 1: 1495: 1234:Cobol, FreeBASIC, Pick Basic 1214:Cobra, D, Dart, Python, Rust 1140: 942:(format nil "Hello, ~A" name) 1089:R"("I said "Hello, world!")" 195:Ternary conditional operator 185:Object-oriented constructors 7: 1465:(indented with whitespace) 1282: 1264:JavaScript (ECMAScript 6) 1077:r#"I said "Hello, world!""# 1066:!"I said \"Hello, world!\"" 180:Object-oriented programming 10: 1543: 1427:JavaScript (ECMAScript 6) 1130:'I said ''Hello, world!''' 1120:"I said ""Hello, world!""" 1036:"I said ^"Hello, world!^"" 1026:"I said `"Hello, world!`"" 1015:'I said \'Hello, world!\'' 1004:"I said \"Hello, world!\"" 958:JavaScript (ECMAScript 6) 293:Comparison of Java and C++ 288:Comparison of Pascal and C 273:Compatibility of C and C++ 1527:String (computer science) 1307:Bourne shell, Perl, Ruby 1260:String.raw`Hello, World!` 798:" to concatenate x and y. 351:compares the features of 298:Comparison of C# and Java 205:Safe navigation operators 200:Null coalescing operators 1477: 1046:{I said "Hello, world!"} 240:Comparison of individual 1434:Unique quoting variants 752:have a similar syntax. 502:mIRC scripting language 111:Functional instructions 106:Conditional expressions 880:C#, Visual Basic .NET 775:function must be used. 141:Higher-order functions 522:(for literals only), 364:programming languages 22:programming languages 923:CoffeeScript, Ruby, 822:" and the function " 91:Algebraic data types 1457:Hollerith notation 1333:Windows Powershell 1030:Windows Powershell 932:%Q(Hello, #{name}!) 857:Quoted interpolated 579:(up to version 5), 223:Evaluation strategy 101:Anonymous functions 1250:raw"Hello, world!" 1190:R"(Hello, world!)" 1050:REBOL (alternate) 954:`Hello, $ {name}!` 909:"Hello, {$ name}!" 899:qq(Hello, $ name!) 808:can also use the " 620:(from version 6), 477:Windows PowerShell 175:List comprehension 121:Associative arrays 81:Exception handling 46:Basic instructions 31:General comparison 1475: 1474: 1431: 1430: 1268: 1267: 1224:Dart (alternate) 1184:Ruby (alternate) 1180:%q(Hello, world!) 1174:Perl (alternate) 1138: 1137: 1098: 1097: 1082:Rust (alternate) 982: 981: 974:f'Hello, {name}!' 964:"Hello, \(name)!" 936:Ruby (alternate) 919:"Hello, #{name}!" 903:Perl (alternate) 876:$ "hello, {name}" 824:=CONCATENATE(X,Y) 806:Visual Basic .NET 733: 732: 556:Visual Basic .NET 345: 344: 131:String operations 1534: 1505: 1490: 1487: 1454: 1453:13HHello, world! 1438: 1437: 1283: 1271:Multiline string 1261: 1251: 1241: 1231: 1221: 1220:r'Hello, world!' 1211: 1210:r"Hello, world!" 1201: 1200:@"Hello, world!" 1191: 1181: 1171: 1170:q(Hello, world!) 1161: 1148: 1147: 1131: 1121: 1108: 1107: 1094:C++ (alternate) 1091: 1090: 1079: 1078: 1067: 1057: 1047: 1037: 1027: 1017: 1016: 1005: 992: 991: 975: 965: 955: 943: 933: 920: 913:PHP (alternate) 910: 900: 887: 886:"Hello, $ name!" 877: 864: 863: 839: 835: 825: 821: 811: 797: 795:use the syntax " 784: 774: 644:Wolfram Language 382: 381: 337: 330: 323: 210:Modulo operators 136:String functions 86:Enumerated types 16: 15: 1542: 1541: 1537: 1536: 1535: 1533: 1532: 1531: 1512: 1511: 1498: 1488: 1480: 1452: 1436: 1421: 1408: 1395: 1382: 1366: 1353: 1340: 1327: 1314: 1301: 1290: 1273: 1259: 1249: 1240:`Hello, world!` 1239: 1230:"Hello, world!" 1229: 1219: 1209: 1199: 1189: 1179: 1169: 1160:'Hello, world!' 1159: 1143: 1129: 1119: 1103: 1088: 1087: 1076: 1075: 1065: 1055: 1045: 1035: 1025: 1014: 1013: 1003: 987: 973: 963: 953: 941: 931: 918: 908: 898: 885: 875: 859: 847: 845:String literals 837: 833: 823: 819: 816:Microsoft Excel 809: 796: 782: 770: 738: 736:Unique variants 380: 378:Common variants 372: 356:data structures 341: 312: 244: 243: 241: 236: 168:Dependent types 21: 12: 11: 5: 1540: 1530: 1529: 1524: 1510: 1509: 1497: 1494: 1493: 1492: 1479: 1476: 1473: 1472: 1469: 1466: 1462: 1461: 1458: 1455: 1449: 1448: 1445: 1442: 1435: 1432: 1429: 1428: 1425: 1422: 1419: 1416: 1415: 1412: 1409: 1406: 1403: 1402: 1399: 1396: 1393: 1390: 1389: 1386: 1383: 1380: 1377: 1376: 1370: 1367: 1364: 1361: 1360: 1357: 1354: 1351: 1348: 1347: 1344: 1341: 1338: 1335: 1334: 1331: 1328: 1325: 1322: 1321: 1318: 1315: 1312: 1309: 1308: 1305: 1302: 1299: 1296: 1295: 1292: 1287: 1272: 1269: 1266: 1265: 1262: 1256: 1255: 1252: 1246: 1245: 1242: 1236: 1235: 1232: 1226: 1225: 1222: 1216: 1215: 1212: 1206: 1205: 1202: 1196: 1195: 1192: 1186: 1185: 1182: 1176: 1175: 1172: 1166: 1165: 1162: 1156: 1155: 1152: 1142: 1139: 1136: 1135: 1132: 1126: 1125: 1122: 1116: 1115: 1112: 1102: 1099: 1096: 1095: 1092: 1084: 1083: 1080: 1072: 1071: 1068: 1062: 1061: 1058: 1052: 1051: 1048: 1042: 1041: 1038: 1032: 1031: 1028: 1022: 1021: 1018: 1010: 1009: 1006: 1000: 999: 996: 986: 985:Escaped quotes 983: 980: 979: 976: 970: 969: 966: 960: 959: 956: 950: 949: 944: 938: 937: 934: 928: 927: 921: 915: 914: 911: 905: 904: 901: 895: 894: 888: 882: 881: 878: 872: 871: 868: 858: 855: 851:string literal 846: 843: 842: 841: 836:macro and the 827: 813: 799: 786: 776: 757: 737: 734: 731: 730: 725: 721: 720: 715: 711: 710: 693: 689: 688: 675: 671: 670: 665: 661: 660: 655: 651: 650: 637: 633: 632: 611: 607: 606: 592: 588: 587: 573: 569: 568: 563: 559: 558: 509: 505: 504: 499: 495: 494: 485: 481: 480: 394: 390: 389: 386: 379: 376: 371: 368: 343: 342: 340: 339: 332: 325: 317: 314: 313: 311: 310: 305: 300: 295: 290: 285: 280: 275: 270: 265: 260: 255: 250: 239: 238: 237: 233: 232: 231: 230: 225: 217: 216: 215: 214: 213: 212: 207: 202: 197: 187: 182: 177: 172: 171: 170: 160: 159: 158: 153: 148: 138: 133: 128: 123: 118: 113: 108: 103: 98: 93: 88: 83: 78: 77: 76: 71: 66: 61: 53: 48: 43: 38: 33: 25: 24: 9: 6: 4: 3: 2: 1539: 1528: 1525: 1523: 1520: 1519: 1517: 1508: 1504: 1500: 1499: 1486: 1482: 1481: 1470: 1467: 1464: 1463: 1459: 1456: 1451: 1450: 1446: 1444:Variant name 1443: 1440: 1439: 1426: 1423: 1418: 1417: 1413: 1410: 1405: 1404: 1400: 1397: 1392: 1391: 1387: 1384: 1379: 1378: 1374: 1371: 1368: 1363: 1362: 1358: 1355: 1350: 1349: 1345: 1342: 1337: 1336: 1332: 1329: 1324: 1323: 1319: 1316: 1311: 1310: 1306: 1303: 1298: 1297: 1293: 1288: 1285: 1284: 1281: 1278: 1277:here document 1263: 1258: 1257: 1253: 1248: 1247: 1243: 1238: 1237: 1233: 1228: 1227: 1223: 1218: 1217: 1213: 1208: 1207: 1203: 1198: 1197: 1193: 1188: 1187: 1183: 1178: 1177: 1173: 1168: 1167: 1163: 1158: 1157: 1153: 1150: 1149: 1146: 1133: 1128: 1127: 1123: 1118: 1117: 1113: 1110: 1109: 1106: 1093: 1086: 1085: 1081: 1074: 1073: 1069: 1064: 1063: 1059: 1054: 1053: 1049: 1044: 1043: 1039: 1034: 1033: 1029: 1024: 1023: 1019: 1012: 1011: 1007: 1002: 1001: 997: 994: 993: 990: 977: 972: 971: 967: 962: 961: 957: 952: 951: 948: 945: 940: 939: 935: 930: 929: 926: 922: 917: 916: 912: 907: 906: 902: 897: 896: 892: 889: 884: 883: 879: 874: 873: 869: 866: 865: 862: 854: 852: 831: 828: 818:allows both " 817: 814: 807: 803: 800: 794: 790: 787: 780: 777: 773: 768: 765: 761: 758: 755: 751: 747: 746:juxtaposition 743: 740: 739: 729: 726: 723: 722: 719: 716: 713: 712: 709: 705: 701: 697: 694: 691: 690: 687: 683: 679: 676: 673: 672: 669: 666: 663: 662: 659: 656: 653: 652: 649: 645: 641: 638: 635: 634: 631: 627: 623: 619: 615: 612: 609: 608: 604: 600: 596: 593: 590: 589: 586: 582: 578: 574: 571: 570: 567: 564: 561: 560: 557: 553: 549: 545: 541: 537: 533: 529: 525: 521: 517: 513: 510: 507: 506: 503: 500: 497: 496: 493: 489: 486: 483: 482: 478: 474: 470: 466: 462: 458: 454: 450: 446: 442: 441:Object Pascal 438: 434: 430: 426: 422: 418: 414: 410: 406: 402: 398: 395: 392: 391: 387: 384: 383: 375: 370:Concatenation 367: 365: 361: 357: 354: 350: 338: 333: 331: 326: 324: 319: 318: 316: 315: 309: 306: 304: 301: 299: 296: 294: 291: 289: 286: 284: 281: 279: 276: 274: 271: 269: 266: 264: 261: 259: 256: 254: 251: 249: 246: 245: 235: 234: 229: 226: 224: 221: 220: 219: 218: 211: 208: 206: 203: 201: 198: 196: 193: 192: 191: 188: 186: 183: 181: 178: 176: 173: 169: 166: 165: 164: 161: 157: 154: 152: 149: 147: 144: 143: 142: 139: 137: 134: 132: 129: 127: 124: 122: 119: 117: 114: 112: 109: 107: 104: 102: 99: 97: 94: 92: 89: 87: 84: 82: 79: 75: 72: 70: 67: 65: 62: 60: 59:Foreach loops 57: 56: 55:Control flow 54: 52: 49: 47: 44: 42: 39: 37: 34: 32: 29: 28: 27: 26: 23: 20:Comparison of 18: 17: 1503: 1489:String.raw`` 1485: 1447:Language(s) 1294:Language(s) 1274: 1154:Language(s) 1144: 1114:Language(s) 1104: 1101:Dual quoting 998:Language(s) 988: 891:Bourne shell 870:Language(s) 860: 848: 802:Visual Basic 575:Autohotkey, 562:concatenate 552:Visual Basic 373: 348: 346: 163:Type systems 130: 41:Basic syntax 1460:Fortran 66 1373:Common Lisp 947:Common Lisp 750:Unix shells 708:Standard ML 640:Mathematica 628:, Standard 566:Common Lisp 516:AppleScript 445:Objective-C 360:text-string 64:While loops 1516:Categories 1496:References 1141:Quoted raw 1070:FreeBASIC 668:Pick Basic 437:JavaScript 388:Languages 96:Generators 36:Assignment 1291:document 781:uses the 764:character 686:Smalltalk 636:<> 536:HyperTalk 532:FreeBASIC 385:Operator 242:languages 190:Operators 69:For loops 832:has the 397:ALGOL 68 74:Do-while 51:Comments 1441:Syntax 1346:Eiffel 1286:Syntax 1204:C#, F# 1151:Syntax 1111:Syntax 1060:Eiffel 995:Syntax 978:Python 867:Syntax 838:format! 834:concat! 718:Fortran 603:Symfony 492:Haskell 1254:Scala 1244:D, Go 1194:C++11 1040:REBOL 968:Swift 925:Elixir 793:Octave 789:MATLAB 783:STRING 772:strcat 769:, the 767:arrays 648:Elixir 508:& 488:Erlang 473:Turing 453:Python 449:Pascal 421:Eiffel 353:string 146:Filter 116:Arrays 1478:Notes 1471:YAML 1401:Rust 820:& 779:COBOL 728:Julia 700:OCaml 618:Maple 577:Maple 544:Seed7 528:Excel 520:COBOL 479:, Ya 469:Swift 465:Scala 413:Cobra 401:BASIC 347:This 126:Scope 1414:Lua 1388:C++ 1320:PHP 1317:Yes 1304:Yes 1289:Here 830:Rust 804:and 791:and 754:Rexx 626:Rexx 622:PL/I 614:Icon 599:Raku 581:Perl 548:VHDL 524:Curl 498:$ + 461:Rust 457:Ruby 433:Java 417:Dart 151:Fold 1501:1. 1483:1. 1424:No 1411:No 1398:No 1385:No 1369:No 1356:No 1343:No 1330:No 742:AWK 714:// 678:APL 658:Lua 654:.. 630:SQL 610:|| 585:PHP 540:Nim 512:Ada 484:++ 405:C++ 358:or 156:Map 1518:: 853:. 826:". 748:. 724:* 706:, 704:rc 702:, 698:, 696:F# 692:^ 684:, 680:, 674:, 664:: 646:, 642:, 624:, 616:, 601:, 597:, 591:~ 583:, 572:. 554:, 550:, 546:, 542:, 538:, 534:, 530:, 526:, 518:, 514:, 490:, 475:, 471:, 467:, 463:, 459:, 455:, 451:, 447:, 443:, 439:, 435:, 431:, 429:Go 427:, 425:F# 423:, 419:, 415:, 411:, 409:C# 407:, 403:, 399:, 393:+ 366:. 810:+ 760:C 682:J 595:D 336:e 329:t 322:v

Index

Comparison of
programming languages

General comparison
Assignment
Basic syntax
Basic instructions
Comments
Foreach loops
While loops
For loops
Do-while
Exception handling
Enumerated types
Algebraic data types
Generators
Anonymous functions
Conditional expressions
Functional instructions
Arrays
Associative arrays
Scope
String operations
String functions
Higher-order functions
Filter
Fold
Map
Type systems
Dependent types
List comprehension
Object-oriented programming

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.