lisp语言是最好的语言_Lisp可能不是数据科学的最佳语言,但是我们仍然可以从中学到什么呢?...

lisp语言是最好的语言

This article is in response to Emmet Boudreau’s article ‘Should We be Using Lisp for Data-Science’.

本文是对 Emmet Boudreau的文章“我们应该将Lisp用于数据科学”的 回应

Below, unless otherwise stated, lisp refers to Common Lisp; in general, lisp refers to the lisp family of languages, just like the C-family of languages. There are functional lisps like Clojure and Scheme, and there are general purpose lisps such as Common Lisp and Racket.

以下,除非另有说明,否则lisp指的是Common Lisp; 通常,lisp指的是 lisp语言家族 ,就像 C语言家族 一样 有诸如Clojure和Scheme之类的功能性lipps,还有诸如Common Lisp和Racket之类的通用lisps。

The primary hurdle to using Lisp for Data Science, I believe, is the non-infix syntax common in mathematics.

我相信,使用Lisp进行数据科学的主要障碍是数学中常见的非中缀语法。

[Edit: Added note about parentheses balancing wrt paredit, and mentioned slima for atom. A redone note about formatting lisp code. Mention of PAIP. Thanks to comments at r/lisp!]

[ 编辑:添加了有关括号与wrt paredit平衡的注释,并提到了原子的slima。 关于格式化Lisp代码的重做说明。 提及PAIP。 感谢r / lisp的评论 !]

但是,有什么要学习的语法吗? (But, is there anything to learn from its syntax?)

Lisp base syntax follows prefix notation and “everything is a list” convention. In this notation, the first element of the list is the operator while the remaining elements are the operands.

Lisp基本语法遵循前缀表示法,并且“一切都是列表”约定。 在此表示法中,列表的第一个元素是运算符,而其余元素是操作数。

To some, the lack of commas in lisp can feel cleaner than their presence in non-lisps. YMMV.

在某些情况下,与没有口吻的人相比,没有口吻的人感觉更干净。 YMMV。

Further, lisp symbols can actually be *anything*.

此外,lisp符号实际上可以是*任何*。

Image for post
Syme examples of lisp symbols
Lisp符号的Syme示例

The lisp reader is also, by default, case insensitive; so you don’t need to bother about whether something is called “fooBar” or “foobar” or “FOOBar”. It’s usually just “foo-bar”. Hyphens also feel more natural than underscores. In daily language, we rarely use — at least I don’t — underscores; but hyphens just feel more natural while writing compound-words.

默认情况下,lisp阅读器也不区分大小写; 因此,您不必为某个东西叫做“ fooBar”还是“ foobar”还是“ FOOBar”而烦恼。 通常只是“ foo-bar”。 连字符也比下划线更自然。 在日常语言中,我们很少使用-至少我不使用-下划线; 但是连字在写复合词时会感觉更自然。

All of that is significantly subjective. Where lisp shines is when it is used in conjunction with a structured editing mode like the paredit mode.

所有这些都是主观的。 Lisp的亮点是与结构化编辑模式(如paredit模式)结合使用。

演示地址

Paredit mode demonstration (jump to 0:35)
演示模式演示(跳至0:35)

The alternative in other languages happens to be

其他语言的替代品恰好是

  1. Hold your mouse and place the cursor at the start of the code block.

    按住鼠标并将光标置于代码块的开头。
  2. Drag your mouse to the end of the code block

    将鼠标拖到代码块的末尾
  3. Ctrl+X

    Ctrl + X
  4. Ctrl+V

    Ctrl + V

That’s about 100–300% more effortful than if you know paredit. And if you are gonna be alive for more than a decade, paredit is definitely worth the learning! Plus, did you notice that you do not need to count parentheses? The editor keeps track of it for you! Even for non-lisps, there are equivalent modes like smartparens-strict-mode you could help yourself with.

这比您知道paredit时要省力100–300%。 而且,如果您要活着超过十年,那么paredit绝对值得学习! 另外,您是否注意到您不需要计算括号? 编辑器会为您跟踪它! 即使对于非嘴唇,也可以使用smartparens-strict-mode等等效模式来帮助自己。

But is this something unique to lisp? No, in fact, there is a related open issue for julia. So, if you did understand the power of paredit, do try smartparens-strict-mode or equivalent with other languages!

但这是Lisp独有的东西吗? 不,事实上, 茱莉亚 有一个 相关的公开问题 因此,如果您确实了解paredit的功能,请尝试使用smartparens-strict-mode或其他语言的等效语言!

Idiomatic lisp code looks nothing unreadable the way the other article states. Here’s the same code, completed and formatted.

惯用的Lisp代码看起来没有其他文章所述的方式不易理解。 这是相同的代码,已完成并格式化。

Image for post
Better formatted lisp with paren-face-mode (with slightly different building blocks)
使用paren-face-mode格式更好的lisp(具有稍微不同的构建块)

On the extensibility of lisp syntax

关于Lisp语法的可扩展性

Lisp is characterized by its extreme extensibility. You can extend the reader. You can introduce new syntax.

Lisp的特点是具有极高的可扩展性。 您可以扩展阅读器。 您可以引入新的语法。

I’d also consider it to be objective that the prefix lisp syntax isn’t particularly well suited to sharing mathematical code.

我还认为前缀Lisp语法不是特别适合共享数学代码是客观的。

Image for post
Math infix vs prefix
数学中缀与前缀

In almost all written mathematics, the prefix syntax in code and paper/text-book takes away the overhead of checking whether you typed the expression correctly. I, as a lisper, don’t find the former syntax to be “harder” than the latter; if anything, it states exactly what is to be done — namely, we have to add 5, x, and another expression. However, that isn’t how I find mathematics written in books!

在几乎所有的书面数学中,代码和纸质/教科书中的前缀语法消除了检查是否正确键入表达式的开销。 我作为一个傻子,没有发现前一种语法比后者更“硬”。 如果有的话,它确切说明了要执行的操作-即,我们必须添加5,x和另一个表达式。 但是,这不是我发现书本中写的数学的方法!

But lisp is extensible. There is a library called cmu-infix that introduces the required mathematical syntax; so the following is perfectly valid lisp code once you use it.

但是Lisp是可扩展的。 有一个名为cmu-infix的库,它引入了所需的数学语法。 因此,以下是使用后完全正确的Lisp代码。

Image for post
infix notation in lisp using cmu-infix
使用cmu-infix的Lisp中的中缀表示法

And that is hardly different from the math syntax above!

这与上面的数学语法几乎没有什么不同!

However, in 2020, in my opinion, cmu-infix needs more polishing, particularly to deal with array slicing. And, it’d be great to have superscripts to mean power too, just very like usual mathematics!

但是,我认为,到2020年,cmu-infix需要更多地抛光,尤其是要处理阵列切片时。 而且,也很像上一门数学一样,有上标也能表示幂!

Quicklisp和Ultralisp (Quicklisp, and Ultralisp)

Where I found myself significanly disagreeing with the author was on quicklisp. Quicklisp is one of the best package management I’ve known, thanks to its guarantee that “all packages build together”. So, as long as you haven’t moded your lisp system, loading a library is as simple as (ql:quickload “library”). This is actually a dist system, akin to what one’d find with the linux package system apt. There are almost monthly updates to quicklisp, and if something does break due to the upgrade, you simply go back to a known working dist.

我发现自己明显不同意作者的观点是在quicklisp上。 Quicklisp是我所知最好的软件包管理之一,这要归功于它保证“所有软件包都可以一起构建”。 因此,只要您没有设置Lisp系统的模式,加载库就和(ql:quickload“ library”)一样简单。 这实际上是一个dist系统,类似于linux软件包apt中的系统。 quicklisp几乎每月都有更新,并且如果由于升级而导致某些问题确实中断了,您只需回到已知的工作区即可。

Quicklisp works with ABCL, Allegro CL, Clasp, Clozure CL, CLISP, CMUCL, ECL, LispWorks, MKCL, SBCL, and Scieneer CL, on Linux, Mac OS X, and Windows.

Quicklisp可与ABCL , 快板CL , 扣 , Clozure CL , CLISP , CMUCL , ECL , LispWorks , MKCL , SBCL和Scieneer CL ,在Linux,Mac OS X和Windows。

So, I don’t really get the author’s point about using a quicklisp compatible compiler. It’s just ubiquitous!

因此,我并没有真正理解作者使用与quicklisp兼容的编译器的观点。 随处可见!

The monthly update cycle can, indeed, be painful for projects in active development; for which, there happens to be ultralisp, that updates every 5 min!

实际上,每月更新周期对于正在积极开发的项目可能确实很痛苦; 为此,每5分钟更新一次Ultralisp !

Of course, there are facilities like qlot to help manage dependencies, if quicklisp dists ever happen to be insufficient for you.

当然,如果quicklisp dists碰巧不足以帮助您解决问题,则可以使用qlot之类的工具来帮助管理依赖项。

还有什么? (What else?)

While macros are one thing, I don’t tend to find them of as much use as SLIME.

虽然宏是一回事,但我并不倾向于发现它们的用途与SLIME一样多。

Your usual development cycle consists of

您通常的开发周期包括

  1. Write/Edit code.

    编写/编辑代码。
  2. (Optionally) Compile.

    (可选)编译。
  3. Run and debug.

    运行和调试。

I’ve found myself waiting for 10 sec on the smallest of changes while working on a largish python system. SLIME is a god-send in that it takes this waiting period to under 1 sec, unless perhaps you are doing something in the base of your system.

我发现自己在使用大型python系统时,等待最小变化的时间为10秒。 SLIME是一个天赐良机,因为它将等待时间缩短到1秒以内,除非您可能正在系统基础上做某事。

演示地址

An excelllent demonstration of SLIME
SLIME的出色示范

Are there alternatives in other languages? Sorta yes. In python, if you fire up a REPL inside emacs, it is connected to python buffers; however, the lack of a lisp like package system limits this to single file workflows. For julia, there is julia-snail.

是否有其他语言的替代品? 排序是的。 在python中,如果您在emacs中启动REPL,它将连接到python缓冲区; 但是,缺少像Lisp这样的软件包系统,将其局限于单个文件工作流程。 对于茱莉亚,有茱莉亚蜗牛 。

What about jupyter notebooks? Consider SLIME to be the next step in the jupyter-notebooks evolution :p. Okay, one place where jupyter notebooks (can) shine is when you need to display images and graphs to management folks. Though, emacs-ers do have the awesome org-mode for the same, that does allow inline latex and images, and multiple language blocks in a single file. YMMV.

那么Jupyter笔记本呢? 认为SLIME是jupyter-notebooks进化的下一步:p。 好吧,当您需要向管理人员显示图像和图形时,jupyter笔记本(可以)发光的一个地方。 尽管emacs-ers确实具有出色的org-org模式,但确实允许内联乳胶和图像以及单个文件中的多种语言块。 YMMV。

看到? 您学到了很多东西,却没有真正学过一口气。 (See? You learnt so many things without actually learning a lisp?)

Well, I’d say you are already about one-third way on your path to learning lisp. May be help yourself learning the full thing!

好吧,我想说您已经走近了学习口齿不清的道路上的三分之一。 可能会帮助您学习完整的东西!

那图书馆呢? (What about libraries?)

In theory, it is entirely possible to write SBCL that is almost as performant as C. For instance, one of my past-times has been working on a library called numericals that gets at least as fast as numpy using SBCL.

从理论上讲,完全有可能编写出与C 几乎一样性能的SBCL。例如,我过去的一个时光一直在研究一个称为“ 数值”的库,使用SBCL至少可以得到与numpy一样快的速度。

Image for post
A comparison of SBCL against numpy
SBCL与numpy的比较

While, not tested for performance by me, there are much more complete libraries like clml for machine learning.

虽然没有经过我的性能测试,但还有更多完整的库(例如clml)可用于机器学习。

Depending on your use case, you might also find py4cl2 suitable for you. py4cl brings python libraries to common lisp, with quite a few limitations; check if those limitations apply to you!

根据您的用例,您可能还会发现适合您的py4cl2 。 py4cl将python库带到了常见的lisp中,但有很多限制; 检查这些限制是否适用于您!

In practice, in fact, lisp was never a go to language for machine learning! Lisp has been the language of the pre-ML AI — Norvig’s Paradigm of Artificial Intelligence is a great read for anyone interested in what AI was before the dawn of Machine Learning.

实际上,实际上,lisp绝不是机器学习的语言! Lisp一直是ML之前的AI的语言-对于在机器学习曙光之前对AI感兴趣的人来说, Norvig的《人工智能范式》是一本好书。

That said, the take home message is: structured editing, quicklisp-like package system, and SLIME. If lisp does interest you, take a look at some of its defacto libraries — the Getting Started sections of cl-who, cl-ppcre, fiveam, iterate and alexandria in very particular.

也就是说,带回家的消息是:结构化编辑,类似quicklisp的打包系统和SLIME。 如果lisp引起您的兴趣,请查看 其一些事实上的库 -cl-who,cl-ppcre,fiveam,iterate和alexandria的入门部分。

The bonus of working with lisp is that, if your needs are met by the ANSI standard, or perhaps some well solidified defacto libraries, then you can avoid yourself the pain of upgrading your projects due to “language upgrades”. ANSI standardization was complete in 1994; and quite a few projects from the pre-2000s can still run in ANSI-conforming implementations in 2020.

使用lisp的好处是,如果ANSI标准或某些可靠的事实库满足了您的需求,那么您可以避免由于“语言升级”而导致的项目升级麻烦。 ANSI标准化工作于1994年完成; 而且2000年以前的许多项目仍可以在2020年以符合ANSI的实施方式运行。

If Common Lisp does interest you, The Common Lisp Cookbook and Practical Common Lisp, coupled perhaps with Baggers’ videos are some of the several excellent resources to get started. If you ever need help with anything, the community is welcoming at r/CLSchools! Of course, there’s the more general purpose r/lisp, and the more familiar stackoverflow.

如果您对Common Lisp感兴趣,可以参考Common Lisp食谱和实用Common Lisp以及Baggers的视频,这是一些不错的入门资源。 如果您需要任何帮助,欢迎访问r / CLSchools ! 当然,有更通用的r / lisp和更熟悉的stackoverflow 。

And, if you find emacs to be curve, there is SLIMA for Atom as well.

而且,如果您发现emacs可以弯曲,那么Atom也可以使用SLIMA 。

Hope you have a good day!

希望你有美好的一天!

翻译自: https://medium.com/@shubhamkarayare/lisp-may-not-be-the-best-language-for-data-science-but-what-can-we-still-learn-from-it-528024114e02

lisp语言是最好的语言

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/391261.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

static、volatile、synchronize

原子性(排他性):不论是多核还是单核,具有原子性的量,同一时刻只能有一个线程来对它进行操作!可见性:多个线程对同一份数据操作,thread1改变了某个变量的值,要保证thread2…

1.10-linux三剑客之sed命令详解及用法

内容:1.sed命令介绍2.语法格式,常用功能查询 增加 替换 批量修改文件名第1章 sed是什么字符流编辑器 Stream Editor第2章 sed功能与版本处理出文本文件,日志,配置文件等增加,删除,修改,查询sed --versionsed -i 修改文件内容第3章 语法格式3.1 语法格式sed [选项] [sed指令…

python pca主成分_超越“经典” PCA:功能主成分分析(FPCA)应用于使用Python的时间序列...

python pca主成分FPCA is traditionally implemented with R but the “FDASRSF” package from J. Derek Tucker will achieve similar (and even greater) results in Python.FPCA传统上是使用R实现的,但是J. Derek Tucker的“ FDASRSF ”软件包将在Python中获得相…

初探Golang(2)-常量和命名规范

1 命名规范 1.1 Go是一门区分大小写的语言。 命名规则涉及变量、常量、全局函数、结构、接口、方法等的命名。 Go语言从语法层面进行了以下限定:任何需要对外暴露的名字必须以大写字母开头,不需要对外暴露的则应该以小写字母开头。 当命名&#xff08…

大数据平台构建_如何像产品一样构建数据平台

大数据平台构建重点 (Top highlight)Over the past few years, many companies have embraced data platforms as an effective way to aggregate, handle, and utilize data at scale. Despite the data platform’s rising popularity, however, little literature exists on…

初探Golang(3)-数据类型

Go语言拥有两大数据类型,基本数据类型和复合数据类型。 1. 数值类型 ##有符号整数 int8(-128 -> 127) int16(-32768 -> 32767) int32(-2,147,483,648 -> 2,147,483,647) int64&#x…

时间序列预测 时间因果建模_时间序列建模以预测投资基金的回报

时间序列预测 时间因果建模Time series analysis, discussed ARIMA, auto ARIMA, auto correlation (ACF), partial auto correlation (PACF), stationarity and differencing.时间序列分析,讨论了ARIMA,自动ARIMA,自动相关(ACF),…

(58)PHP开发

LAMP0、使用include和require命令来包含外部PHP文件。使用include_once命令,但是include和include_once命令相比的不足就是这两个命令并不关心请求的文件是否实际存在,如果不存在,PHP解释器就会直接忽略这个命令并且显示一个错误消息&#xf…

css flexbox模型_如何将Flexbox后备添加到CSS网格

css flexbox模型I shared how to build a calendar with CSS Grid in the previous article. Today, I want to share how to build a Flexbox fallback for the same calendar. 在上一篇文章中,我分享了如何使用CSS Grid构建日历。 今天,我想分享如何为…

贝塞尔修正_贝塞尔修正背后的推理:n-1

贝塞尔修正A standard deviation seems like a simple enough concept. It’s a measure of dispersion of data, and is the root of the summed differences between the mean and its data points, divided by the number of data points…minus one to correct for bias.标…

RESET MASTER和RESET SLAVE使用场景和说明【转】

【前言】在配置主从的时候经常会用到这两个语句,刚开始的时候还不清楚这两个语句的使用特性和使用场景。 经过测试整理了以下文档,希望能对大家有所帮助; 【一】RESET MASTER参数 功能说明:删除所有的binglog日志文件,…

Kubernetes 入门(1)基本概念

1. Kubernetes简介 作为一个目前在生产环境已经广泛使用的开源项目 Kubernetes 被定义成一个用于自动化部署、扩容和管理容器应用的开源系统;它将一个分布式软件的一组容器打包成一个个更容易管理和发现的逻辑单元。 Kubernetes 是希腊语『舵手』的意思&#xff0…

android 西班牙_分析西班牙足球联赛(西甲)

android 西班牙The Spanish football league commonly known as La Liga is the first national football league in Spain, being one of the most popular professional sports leagues in the world. It was founded in 1929 and has been held every year since then with …

Goalng软件包推荐

2019独角兽企业重金招聘Python工程师标准>>> 前言 哈喽大家好呀! 马上要迎来狗年了大家是不是已经怀着过年的心情了呢? 今天笔者给大家带来了一份礼物, Goalng的软件包推荐, 主要总结了一下在go语言中大家开源的优秀的软件, 大家了解之后在后续使用过程有遇到如下软…

Kubernetes 入门(2)基本组件

1. C/S架构 Kubernetes 遵循非常传统的客户端服务端架构,客户端通过 RESTful 接口或者直接使用 kubectl 与 Kubernetes 集群进行通信,这两者在实际上并没有太多的区别,后者也只是对 Kubernetes 提供的 RESTful API 进行封装并提供出来。 左侧…

【powerdesign】从mysql数据库导出到powerdesign,生成数据字典

使用版本powerdesign16.5,mysql 5.5,windows 64 步骤: 1.下载mysql驱动【注意 32和64的驱动都下载下来,具体原因查看第三步 依旧会报错处】 下载地址:https://dev.mysql.com/downloads/connector/odbc/5.3.html 请下…

php amazon-s3_推荐亚马逊电影-一种协作方法

php amazon-s3Item-based collaborative and User-based collaborative approach for recommendation system with simple coding.推荐系统的基于项目的协作和基于用户的协作方法,编码简单。 推荐系统概述 (Overview of Recommendation System) There are many met…

python:使用Djangorestframework编写post和get接口

1、安装django pip install django 2、新建一个django工程 python manage.py startproject cainiao_monitor_api 3、新建一个app python manage.py startapp monitor 4、安装DRF pip install djangorestframework 5、编写视图函数 views.py from rest_framework.views import A…

Kubernetes 入门(3)集群安装

1. kubeadm简介 kubeadm 是 Kubernetes 官方提供的一个 CLI 工具,可以很方便的搭建一套符合官方最佳实践的最小化可用集群。当我们使用 kubeadm 搭建集群时,集群可以通过 K8S 的一致性测试,并且 kubeadm 还支持其他的集群生命周期功能&#…

【9303】平面分割

Time Limit: 10 second Memory Limit: 2 MB 问题描述 同一平面内有n(n≤500)条直线,已知其中p(p≥2)条直线相交与同一点,则这n条直线最多能将平面分割成多少个不同的区域? Input 两个整数n&am…