1024programmer Java JavaScript, PHP, Golang, Haskell, Elixir, which is the best programming language?

JavaScript, PHP, Golang, Haskell, Elixir, which is the best programming language?

[CSDN Editor’s Note] Which language is the best programming language in your mind?

Author | Michele Riva

Translator | Crescent Moon Editor | Ouyang Shuli

Produced by | CSDN (ID: CSDNnews)

The following is the translation:

Over the past few years, I’ve had the opportunity to try out a number of different programming languages ​​.

I really enjoy learning different languages, methods and paradigms. I am a curious person and have always been fascinated by programming languages. Every programming language is different. In this article, we discuss the advantages and disadvantages of the following five programming languages.

  • Javascript

  • Haskell

  • Go

  • PHP

  • Elixir

Javascript

Advantages

  • Quick prototyping: You can use Javascript to quickly write some prototypes to verify your ideas. You can even use Node.js to build a proof of concept for the backend in minimal time.

  • Flexibility: Javascript is growing in popularity, aided by the metaprogramming capabilities of ES6. However, even if you don’t use these functions, you can write some very common functions through Javascript and use it to write clients, servers, and even mobile applications (such as React Native, etc.).

  • Community: The Javascript community is great. Every time you encounter a problem, you can find the answer through StackOverflow. The npm repository is an amazing source of packages that allow you to write your entire application using just one language: Javascript.

  • Functional programming: You may know that when it first started, Javascript was “a browser programming language similar to Scheme, but using Java syntax.” Today, even though Javascript is not a purely functional programming language, It also retains some features of functional programming, such as higher-order functions, anonymous functions (arrow functions in ES6+), etc. .

  • Syntax: The latest version of Javascript introduces some syntactic sugar that allows you to easily write more readable code. Such as object/array destructuring, arrow functions, spread operators, etc.

  • Asynchronous: You can try how to handle asynchronous code, I believe you will like it.

Disadvantages

  • Dynamic typing: Javascript’s dynamic typing is terrible. For example, I know why 10 + “10” === “1010”, but I don’t like it this way. Type casts are likely to cause problems at runtime (rather than compile or build time).

    Other compiled languages, such as ReasonML or Haskell, don’t actually require type annotations and can infer types at compile time. But if they encounter an integer and a string sum, they will throw an error (maybe this example is not suitable).

    By the way, both TypeScript and Flow can solve this problem.

  • Absurd features: Some ridiculous features of Javascript are usually caused by type casts.

For example, + {} === [object object], but {} + === 0

typeof NaN === “number”, but NaN actually means: “not a number”.

If you are a Javascript programmer, you will understand these ridiculous features I am talking about.

  • Tail call optimization (TCO): Although EcmaScript specifies TCO for recursive functions, it seems that only WebKit supported.

  • Object/array constants are mutable: just like Java’s final, you can modify objects and arrays after initialization, even if they are constants.

Haskell

Advantages

  • Change in thinking: After being exposed to Haskell, you will think about code in a completely different way.

  • Performance: Haskell is a compiled language and due to its purely functional nature, the compiler can>

  • Rapid prototyping: Like Node.js, I can build a minimum viable product or proof of concept in just a few hours.

  • Easy to use: Sometimes I feel like PHP is the precursor to Node.js. You can write whatever code you want with PHP and it will work without too many problems. This is very different from OCaml, Haskell , Elm and other strongly typed languages, because when using these languages, You spend more time thinking about how to write code than actually writing it.

Disadvantages

  • . htaccess : I don’t understand why this file should be used. Due to the browser’s cache, if you make a mistake once, the website will be completely useless.

  • Module system: PHP itself does not have a proper module system. You need to include the entire file into another PHP file via include (equivalent to copy-pasting).

    You can use PHP’s OOP feature, but then you have to use OOP.

    In addition, all regular functions are accessible from the global scope (if the namespace is not used).

  • Poor design: The PHP language itself has several design errors, such as:

  • Cannot use try/catch to handle trigger_error.

  • Dynamic range is not supported.

  • The scope of static variables in instance methods is not the instance. This means that once a variable is set, it is global to all instances.

  • The integer byte size varies by operating system.

  • Absurd features similar to Javascript: Much like Javascript, PHP also has some very ridiculous features:

  • “foobar” == 0 is true, ”foobar” == true is true, but 0 == true is false

  • The following code will cause an error with the ternary operator:

 <?php   $initial = 'M';   $name = (   ($initial == 'M')  ? 'Mitch'   : ($initial == 'K') ? 'Kevin'   : ($initial == 'J') ? 'John'    : ($initial == 'A') ? 'Andrew'   : 'unknown');   echo $name; // Andrew  ?>  
  • No Unicode support: Unicode support is still being discussed by the PHP committee. PHP 7 introduced Unicode escape syntax.

  • Syntax: I find procedural PHP difficult to read. Object-oriented PHP makes more sense, perhaps because it’s more organized. Have you tried reading the source code of WordPress ?

  • Bad features: Rasmus Lerdorf once said: “It is better to have an ugly feature than to have no feature at all. Function…” Sorry, I disagree.

    I mean, it’s fine if you’re building a blog, a minimum viable product, or something, but you can’t adopt this attitude when building a full-fledged programming language.

    The correctness of the software is far more important than the features the community needs.

Elixir

Advantages

  • OTP: The Open Telecom Platform (OTP) has what it takes to create massively scalable real-time distribution systems everything.

  • Performance: Elixir’s performance is excellent. Although individual functions may be slower compared to Java, after trying to parallelize and scale horizontally, Elixir’s performance easily beatsJava.

  • Metaprogramming: Elixir’s metaprogramming capabilities are excellent.

  • Syntax: Elixir’s syntax is similar to Ruby, making it a joy to read and write code.

Disadvantages

  • Dynamic typing: Elixir is a dynamically typed language. This means you can’t take advantage of Haskell’s strong typing.

  • Magic: Sometimes, Elixir’s metaprogramming features hide the way a program works behind macros.

  • Parents: Parentheses are optional in Elixir, but required most of the time. I prefer the way Haskell handles parentheses.

Original link:

Statement: This article was translated by CSDN. Please indicate the source when reprinting.

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/javascript-php-golang-haskell-elixir-which-is-the-best-programming-language-3/

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索