pythonista_我如何克服成为Pythonista的阻力

pythonista

by Semi Koen

通过Semi Koen

我如何克服成为Pythonista的阻力 (How I overcame my resistance to becoming a Pythonista)

For over a decade, my main ‘mother tongue’ has been C#. I have been using it since version 1, and loved the journey through features such as generics, anonymity, LINQ, and async and combining this with design patterns, SOLID principles, architectural styles and TDD/BDD, I now live and breathe C#. I used to snobbishly look down to the scripting languages…

十多年来,我的主要母语是C#。 从版本1开始,我就一直在使用它,并且热爱通过通用性,匿名性,LINQ和异步之类的功能并将其与设计模式,SOLID原理,建筑风格和TDD / BDD相结合的旅程,现在,我生活和呼吸C#。 我过去常常势利地看不起脚本语言……

How can you call yourself a software engineer and use a scripting language? Doh!

您如何称呼自己为软件工程师并使用脚本语言? h!

I work in a financial organisation in the City. The languages of choice have been Java and C#, for both Front and Back Office applications. Data Science and Machine Learning are becoming two of the most hyped modern technologies and they are now scaling in financial institutions too. As my background is in Computer Science (with my dissertation on data mining and artificial intelligence), I thought I should check it out…

我在纽约市的一家金融机构工作。 对于前台和后台应用程序,选择的语言是Java和C#。 数据科学和机器学习正在成为最被炒作的现代技术中的两种,它们现在也正在金融机构中扩展。 由于我的背景是计算机科学(以及有关数据挖掘和人工智能的论文),我认为我应该检查一下……

I had to refresh my maths knowledge, and after an introductory ML on Pluralsight and another on Python, I didn’t understand what the whole fuss was about.

我必须刷新自己的数学知识,并在介绍了有关Pluralsight入门ML关于Python入门ML之后,我不明白到底是怎么回事。

Why use Python? I can do all of these things in C#… and in fact much better!

为什么要使用Python? 我可以用C#完成所有这些事情……实际上要好得多!

I proudly said to my colleague: “I am not a ‘cowboy coder’… You cannot write a SOLID Python application”.And he said: “Why not? SOLID are just principles. You can apply them in any language”.

我自豪地对我的同事说:“我不是'牛仔编码器'。。。您不能编写SOLID Python应用程序。”他说:“为什么不呢? SOLID只是原则。 您可以使用任何语言来应用它们。”

This was eye opening for me.

这让我大开眼界。

I started researching Python: It is in the top three programming languages (as of Dec 2018) according to TIOBE. StackOverflow confirms that it has surpassed C#. So does the HackerRank Report.

我开始研究Python: 根据TIOBE的说法,它是前三种编程语言(截至2018年12月)。 StackOverflow确认它已超过C#HackerRank Report也是如此

What? Am I missing a trick?

什么? 我想念一个把戏吗?

This is how my journey to becoming a Pythonista started… I had to be convinced that it was worthwhile.

这就是我成为一名Pythonista的旅程的开始方式……我必须确信这是值得的。

Here are the answers to two of my main reservations, i.e.:

这是我的两个主要保留意见的答案,即:

  1. I love my career in the finance sector. What makes financial organisations use Python?

    我热爱我在金融领域的职业。 是什么使金融组织使用Python?

  2. I am not a ‘cowboy’ (‘cowgirl’ rather). Do SOLID principles apply in Python?

    我不是“牛仔”(而是“牛仔女孩”)。 SOLID原则是否适用于Python?

金融机构为何使用Python? (Why do financial organisations use Python?)

My research showed me there are several reasons:

我的研究表明,有以下几个原因:

— Quick Time to Market: You can go ‘from zero to hero’ pretty quickly. There is a rich set of libraries that have pretty much everything you will ever use. Writing Python programs is like building a tower with Lego. You can find the individual blocks and all you need to do is to glue them together to build your algorithm.

—快速上市:您可以很快地从“零到英雄”。 有丰富的库集,这些库几乎包含您将要使用的所有内容。 编写Python程序就像用Lego建造一座塔。 您可以找到各个块,而您所需要做的就是将它们粘合在一起以构建算法。

— Bridges Economics and IT: Quants and tech savvy business people can understand and also write their algorithms in Python. Developers can then integrate it in a full stack application.

—在经济学和IT之间架起桥梁:精通数量和技术的商人可以理解并用Python编写算法。 然后,开发人员可以将其集成到完整的堆栈应用程序中。

— Embraces Analysis: Anaconda comes with an installation of the Jupyter notebook. This is every developer’s and data scientist’s playground to analyse data and create visualisations. Trading, Market Prices, financial risk modeling are some applicable areas.

—拥抱分析: Anaconda随附Jupyter笔记本电脑的安装。 这是每个开发人员和数据科学家的游乐场,可以分析数据并创建可视化效果。 交易,市场价格,金融风险建模是一些适用领域。

SOLID原则是否适用于Python? (Do SOLID principles apply in Python?)

YES — They do! Principles are not an end in themselves. Rather, they are guidelines to writing better and cleaner code. However, there is no silver bullet on applying them into functional/dynamic languages.

是的-他们做到了! 原则本身并不是目的。 相反,它们是编写更好,更简洁的代码的指南。 但是,没有将它们应用于功能/动态语言的灵丹妙药。

Nevertheless, here is what I have come up with:

不过,这是我想出的:

— Single Responsibility: A class should have only one reason to change.

—单一责任:班级只有一个改变的理由。

This is pretty straight forward, just gather together the functions that change for the same reason into a single class/method/entity. Same as C#.

这非常简单,只需将出于相同原因而更改的功能汇总到一个类/方法/实体中即可。 与C#相同。

— Open Closed: Classes should be open for extension and closed for modification. The base/abstract class is closed for modification. Concrete subclasses are created to modify their behaviour.

—打开关闭:类应该打开以进行扩展,而关闭则可以进行修改。 基类/抽象类已关闭以进行修改。 创建具体的子类以修改其行为。

Many ways to achieve this include: inheritance, composition, design patterns (Decorator, Strategy etc). Python allows for multiple inheritance of classes, other than that it’s the same as C#.

实现此目的的许多方法包括:继承,组合,设计模式(装饰器,策略等)。 Python允许类的多重继承,但与C#相同。

— Liskov Substitution: If S is a subtype of T, then objects of type T may be replaced with objects of type S without altering any of the desirable properties of T. In other words, the derived class should extend its parent class without changing its behaviour.

— Liskov替换:如果S是T的子类型,则可以用类型S的对象替换类型T的对象,而无需更改T的任何理想属性。换句话说,派生类应扩展其父类而不更改其父类。行为。

As long as you can distinguish the difference between composition and inheritance, then Bob’s your uncle. Also be mindful of monkey patching as this will most certainly break this principle.

只要您能够区分组成和继承之间的区别,那么鲍勃就是您的叔叔。 也要注意猴子的修补,因为这肯定会破坏这一原理。

— Interface Segregation: Clients should not be forced to depend upon interfaces that they don’t use.

—接口隔离:不应强迫客户端依赖其不使用的接口。

There are no interfaces in Python, so this is not too relevant. But generally it’s all about keeping the classes and the exposed methods to a minimum as well as the ability to inherit from multiple concrete classes in order to provide clients specific behaviours.

Python中没有接口,因此不太相关。 但是总的来说,这是将类和公开的方法保持在最低限度以及从多个具体类继承以提供客户特定行为的能力。

— Dependency Inversion: High-level modules should not depend on low-level modules. Both should depend on abstractions. Abstractions should not depend on details — details should depend on abstractions.

—依赖倒置:高级模块不应依赖于低级模块。 两者都应依赖抽象。 抽象不应该依赖细节,细节应该依赖抽象。

As a dynamic language, Python doesn’t require the use of abstractions to facilitate decoupling.

作为一种动态语言,Python不需要使用抽象来促进去耦。

What I was hoping to find when I started this analysis is that C# wins the ‘Language Battle’ over Python, but I realised that it is a poor programmer whose development toolkit contains only one programming language!

当我开始进行此分析时,我希望找到的是C#胜过Python的“语言之战”,但我意识到这是一个可怜的程序员,其开发工具包仅包含一种编程语言!

I would personally use C# to build a large scale, enterprise application (especially on the server side), but I am totally converted to Python for quicker development and proof of concepts — predominantly when it comes to the Data Science or Machine Learning domains!

我将亲自使用C#来构建大规模的企业应用程序(尤其是在服务器端),但是我完全转换为Python,以便更快地进行开发和概念验证-主要是在数据科学或机器学习领域!

Thanks for reading my first article ?

感谢您阅读我的第一篇文章?

翻译自: https://www.freecodecamp.org/news/resistance-to-becoming-a-pythonista-f5a734d15c61/

pythonista

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值