比较javascript和python进行机器学习

Python is a high-level interpreted programming language with dynamic semantics and object-oriented programming that is easy to read and implement. It is a scripting language, such as Ruby/ Perl, which is also used to build web applications.

Python是一种高级解释型编程语言,具有动态语义和易于阅读和实现的面向对象编程。 它是一种脚本语言,例如Ruby / Perl,也用于构建Web应用程序。

Javascript is an object-oriented programming language that you can use to create dynamic websites and is standardized in the ECMAScript language specification. Javascript supports various programming paradigms, such as object-oriented, functional, and imperative programming, but does not support procedural programming.

Javascript是一种面向对象的编程语言,可用于创建动态网站,并且在ECMAScript语言规范中已标准化。 Javascript支持各种编程范例,例如面向对象,功能和命令式编程,但不支持过程编程。

JavaScript与Python比较 (JavaScript vs Python Comparison)

数组,元组和列表 (Arrays, tuples, and lists)

JavaScript provides support for arrays as an integrated data type. Although there is no integrated support for arrays in Python, there is a solution for implementing arrays in Python. This is accomplished with lists that Python should place closest to the arrays.

JavaScript提供对数组作为集成数据类型的支持。 尽管在Python中没有对数组的集成支持,但是有一种在Python中实现数组的解决方案。 这是通过Python应该放置在最靠近数组的列表来完成的。

Python lists are similar to other types of data available in programming languages. The main difference between a list and a tuple is that the former is editable, the latter is unchangeable.

Python列表类似于编程语言中可用的其他类型的数据。 列表和元组之间的主要区别在于前者是可编辑的,后者是不可更改的。

代码块 (Code blocks)

JavaScript uses braces to define blocks of code. On the other hand, Python uses indents to define blocks of code. JavaScript uses ‘;’ as operator terminator, while Python uses a newline character.

JavaScript使用花括号定义代码块。 另一方面,Python使用缩进定义代码块。 JavaScript使用';' 作为运算符终止符,而Python使用换行符。

属性和属性 (Properties and Attributes)

JavaScript objects have properties that can consist of basic attributes. This way you can define properties. In the Python programming language, you can use the descriptor protocol (with getter and setter functions) to define attributes.

JavaScript对象具有可以由基本属性组成的属性。 这样,您可以定义属性。 在Python编程语言中,可以使用描述符协议(带有getter和setter函数)来定义属性。

编码格式 (Coding format)

JavaScript must be coded as UTF-16. Likewise, there is no integrated support for handling raw bytes in programming languages. If no encoding format is specified, the default Python source is ASCII.

JavaScript必须编码为UTF-16。 同样,也没有集成支持以编程语言处理原始字节。 如果未指定编码格式,则默认Python源为ASCII。

哈希表 (Hash Table)

The Python programming language has integrated hash tables called dictionaries, sets, etc. Unlike Python, JavaScript does not support online hash tables.

Python编程语言集成了称为字典,集合等的哈希表。与Python不同,JavaScript不支持在线哈希表。

功能参数 (Function Parameters)

If you call a function with incorrect parameters, Python throws an exception. In addition, the additional syntax is accepted for passing parameters.

如果您使用错误的参数调用函数,Python会引发异常。 此外,还可以使用其他语法来传递参数。

JavaScript doesn’t care if the function is called with the right parameters. This is because, by default, all missing parameters in JS are given “undefined” values. If there are other parameters, JavaScript treats them as special parameters.

JavaScript不在乎是否使用正确的参数调用该函数。 这是因为,默认情况下,JS中所有缺失的参数都被赋予“未定义”值。 如果还有其他参数,JavaScript会将它们视为特殊参数。

隐式转换 (Implicit conversion)

Python is a strongly typed programming language, which means that there is no implicit conversion of the data type in the programming language. On the other hand, JavaScript is poorly typed and therefore offers implicit data type conversions.

Python是一种强类型的编程语言,这意味着在编程语言中不会隐式转换数据类型。 另一方面,JavaScript的类型很差,因此提供了隐式数据类型转换。

移动开发 (Mobile development)

In addition to external and internal development, JavaScript is also a good choice for mobile development. However, Python is not suitable for mobile app development.

除了内部和外部开发之外,JavaScript还是移动开发的不错选择。 但是,Python不适合移动应用程序开发。

遗传性 (Heredity)

Both Python and JavaScript support inheritance. The difference, however, lies in their type. JavaScript uses a prototype-based inheritance model, while Python uses a class-based inheritance model. In terms of inheritance, another difference between Python and JavaScript is that Python does not inherit methods from instances while JS does it.

Python和JavaScript均支持继承。 但是,区别在于它们的类型。 JavaScript使用基于原型的继承模型,而Python使用基于类的继承模型。 在继承方面,Python和JavaScript之间的另一个区别是,Python不会从实例继承方法,而JS却可以。

前后矛盾 (Inconsistency)

Python has editable and immutable data types such as set (variable) and list (immutable). The Javascript has no concept of modifiability and immutability A mutable object is an object whose value can be changed after a value has been assigned to it. On the contrary, an immutable object cannot change its value. Contrary to the Python programming language, JavaScript has no concept of variability.

Python具有可编辑和不可变的数据类型,例如set(变量)和list(不可变)。 Javascript没有可修改性和不变性的概念。可变对象是在为其分配值后可以更改其值的对象。 相反,不可变的对象不能更改其值。 与Python编程语言相反,JavaScript没有可变性的概念。

库和模块 (Libraries and Modules)

Python is called a “battery-powered programming language” because it contains multiple modules. It also has many libraries that can be used to complete data analysis, machine learning, and scientific processing.

Python被称为“电池供电的编程语言”,因为它包含多个模块。 它还具有许多可用于完成数据分析,机器学习和科学处理的库。

Unlike JavaScript, it contains fewer modules such as dates, JSON, and math. Other JS features are available through the host environment (usually a web browser) and there are very few things like operating systems.

与JavaScript不同,它包含较少的模块,例如日期,JSON和数学。 其他JS功能可通过主机环境(通常是Web浏览器)使用,并且很少有诸如操作系统之类的东西。

数值类型 (Numeric type)

JavaScript only has floating-point variables. In contrast, the Python programming language has several types of numeric data types such as int, fixed-point, and floating-point.

JavaScript仅具有浮点变量。 相反,Python编程语言具有几种类型的数字数据类型,例如int,定点和浮点。

访问对象 (Access to objects)

For each method, Python has an argument as its first parameter. In contrast, JavaScript has this method of accessing objects.

对于每种方法,Python都有一个参数作为其第一个参数。 相反,JavaScript具有这种访问对象的方法。

程式设计 (Programming)

Both Python and JavaScript adopt a multi-paradigm approach, in the sense that they support more than one programming paradigm. Both Python and JavaScript offer functional, mandatory, and object-oriented programming techniques. However, Python has several aspects of a procedural programming language, but JavaScript does not.

从某种意义上说,Python和JavaScript都支持多种编程范例,因此它们都采用了一种多范例方法。 Python和JavaScript均提供功能性,强制性和面向对象的编程技术。 但是,Python具有过程编程语言的多个方面,而JavaScript没有。

REPL(阅读评估新闻周期) (REPL (reading the evaluation press cycle))

After installing Python on your system you will receive a REPL. However, no REPL is integrated into JavaScript. This is because JS mainly runs in the browser. However, with Node.js we can provide a REPL for JavaScript.

在系统上安装Python之后,您将收到一个REPL。 但是,没有REPL集成到JavaScript中。 这是因为JS主要在浏览器中运行。 但是,使用Node.js,我们可以为JavaScript提供REPL。

Image for post

Conclusion

结论

The difference between Python and JavaScript is very small because you can use Python and JavaScript for almost all operations because they have common features such as vocabulary, interpretation, object-oriented, functional and mandatory programming. If a language lacks certain features, we have many existing libraries and other extensions, and we can use these libraries to get everything we need.

Python和JavaScript之间的差异非常小,因为几乎所有操作都可以使用Python和JavaScript,因为它们具有共同的功能,例如词汇,解释,面向对象,功能性和强制性编程。 如果一种语言缺少某些功能,则我们有许多现有的库和其他扩展,我们可以使用这些库来获取所需的一切。

You can also ask: should I learn Python or Javascript? We recommend that you focus on the main areas of study. For example, if you are developing the web, it is better to choose HTML, CSS, and JavaScript. Users interested in machine learning, neural networks, or data science should consider learning Python. At the end of the JavaScript debate on Python, it’s also about your experience and preferences. For example, beginners can choose Python for its simple syntax.

您还可以问:我应该学习Python还是Javascript? 我们建议您专注于主要学习领域。 例如,如果您正在开发Web,则最好选择HTML,CSS和JavaScript。 对机器学习,神经网络或数据科学感兴趣的用户应考虑学习Python。 在关于PythonJavaScript辩论结束时,这也与您的经验和偏好有关。 例如,初学者可以选择Python作为其简单语法。

Hope you understand these programming languages better. If you want to suggest the best learning method, I recommend using Python because it has a good IT market and is easy to learn.

希望您更好地理解这些编程语言。 如果您想提出最好的学习方法,我建议使用Python,因为它具有良好的IT市场且易于学习。

翻译自: https://medium.com/@finwintech/comparison-javascript-vs-python-for-machine-learning-b0f351325040

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值