/* * title "Computer say hello" * author "Dylan Lom" * date "2021-04-30" * link stylesheet /main.css */ # $(echo "$title") Why does every programming language feel the need to re-locate the `print` function? Here's a summary of the top 20 programming languages' `print`s -- as according to [Github PR's in 2021 Q1][1] and [Rosetta Code's Hello World solutions][2] For languages I haven't used/seen much of I'll take the top example, if I happen to know a more commonly used function I'll include that as well. 01. [JavaScript][101] -- `document.write("Hello world!");` or `console.log("Hello world!")` 02. [Python][102] -- `print "Hello world!"` or `print("Hello world!")` \* 03. [Java][103] -- `System.out.println("Hello world!");` 04. [Go][104] -- `fmt.Println("Hello world!")` 05. [Ruby][105] -- `puts "Hello world!"` 06. [C++][106] -- `std::cout << "Hello world!" << std::endl;` 07. TypeScript -- See **Javascript** 08. [PHP][108] -- `echo "Hello world!\n";` 09. [C#][109] -- `System.Console.WriteLine("Hello world!");` 10. [C][110] -- `printf("Hello world!\n");` or `puts("Hello world!")` 11. [Shell][111] -- `echo "Hello world!"` 12. [Scala][112] -- `println("Hello world!")` 13. [Dart][113] -- `print("Hello world!");` \*\* 14. [Kotlin][114] -- `println("Hello world!")` 15. [Rust][115] -- `print!("Hello world!");` 16. [Swift][116] -- `print("Hello world!")` 17. [DM][117] -- `src << "Hello world!"` 18. [Groovy][118] -- `println "Hello world!"` 19. [Objective-C][119] -- `NSLog(@"Hello, World!");` 20. [Elixir][120] -- `IO.puts "Hello world!"` \* I'll only be counting Python's two print variants once, as it's just different syntax. \*\* I don't really know why the example on Rosetta code uses a variable, I haven't personally tested this exact snippet but elsewhere it seems to be done. It's interesting to note that as we get further down the list we trend towards print(ln). Certainly the Java-lites (Scala, Kotlin, Groovy) have agreed to keep `println`, whereas the rest seem to prefer `print`. Of these examples, only 3 require a ''literal'' newline to be specified -- C/C++ being two of these. In summary: println = 4 print = 4 // including Rust's print! puts = 3 log = 3 // JS, TS and Obj-C (it's close enought right?) echo = 2 << = 2 WriteLine = 1 printf = 1 write = 1 There's obviously a number of flaws in my counts -- why didn't I include Go's printf? Why did I include C's puts? Why did i include Objective-C in the logs? In the end of the day this was just a bit of fun, maybe in the future I'll write an actual script to automate the process but for now it is what it is ;) [1]: https://madnight.github.io/githut/#/pull_requests/2021/1 [2]: http://rosettacode.org/wiki/Hello_world/Text [101]: http://rosettacode.org/wiki/Hello_world/Text#JavaScript [102]: http://rosettacode.org/wiki/Hello_world/Text#Python [103]: http://rosettacode.org/wiki/Hello_world/Text#Java [104]: http://rosettacode.org/wiki/Hello_world/Text#Go [105]: http://rosettacode.org/wiki/Hello_world/Text#Ruby [106]: http://rosettacode.org/wiki/Hello_world/Text#C.2B.2B [108]: http://rosettacode.org/wiki/Hello_world/Text#PHP [109]: http://rosettacode.org/wiki/Hello_world/Text#C.23 [110]: http://rosettacode.org/wiki/Hello_world/Text#C [111]: http://rosettacode.org/wiki/Hello_world/Text#UNIX_Shell [112]: http://rosettacode.org/wiki/Hello_world/Text#Scala [113]: http://rosettacode.org/wiki/Hello_world/Text#Dart [114]: http://rosettacode.org/wiki/Hello_world/Text#Rust [115]: http://rosettacode.org/wiki/Hello_world/Text#Kotlin [116]: http://rosettacode.org/wiki/Hello_world/Text#Swift [117]: http://rosettacode.org/wiki/Hello_world/Text#DM [118]: http://rosettacode.org/wiki/Hello_world/Text#Groovy [119]: http://rosettacode.org/wiki/Hello_world/Text#Objective-C [120]: http://rosettacode.org/wiki/Hello_world/Text#Elixir