Lisp 또는 Scheme으로 웹 프로그래밍을 어떻게 할 수 있습니까?
저는 보통 PHP, Ruby 또는 Perl로 웹 앱을 작성합니다. 저는 Scheme 연구를 시작하고 있으며이 언어로 웹 프로젝트를 시도하고 싶습니다. 그러나 이것에 가장 적합한 환경이 무엇인지 찾을 수 없습니다.
다음 기능을 찾고 있습니다.
- 요청 매개 변수를 가져 오는 간단한 방법 (예 : get-get #key, get-post #key, get-cookie #key).
- MySQL 액세스.
- HTML 양식 생성기, 처리, 유효성 검사기 등
- 사용자 입력 데이터 필터링을위한 도우미 (htmlentities, 쿼리 입력을위한 이스케이프 변수 등).
- 풀솜.
- 그리고 GNU / Linux 친화적입니다.
따라서 모든 답변에 미리 감사드립니다.
라켓 에는 필요한 모든 것이 있습니다. 라켓 웹 서버를 참조하십시오 튜토리얼 다음 문서를 . 웹 서버는 한동안 사용되어 왔으며 많은 기능을 가지고 있습니다. 아마도 포함되지 않은 유일한 것은 mysql 인터페이스이지만 PLaneT (라켓 패키지 배포 도구)에 패키지 로 존재합니다 .
업데이트 : Racket은 이제 DB 지원과 함께 제공되며 mysql을 포함한 여러 DB에서 작동합니다.
Clojure를 살펴볼 수 있습니다 .
Clojure는 Java Virtual Machine을 대상으로하는 동적 프로그래밍 언어입니다. [...] Clojure는 선택적 유형 힌트 및 유형 추론을 통해 Java 프레임 워크에 대한 쉬운 액세스를 제공하여 Java 호출이 리플렉션을 피할 수 있도록합니다.
Clojure는 Lisp의 방언이며 데이터로서의 코드 철학과 강력한 매크로 시스템을 Lisp와 공유합니다.
Clojure에서는 Java와의 상호 운용이 간단하므로 필요에 따라 기존 Java 라이브러리를 재사용 할 수 있습니다. 웹 개발에 유용한 정보가 많이 있다고 확신합니다.
clojure-contrib 에는 SQL API가 있으며 ClojureQL 도있어 DB 액세스 요구 사항을 충족해야합니다.
Compojure 라는 Clojure 용 웹 프레임 워크가 개발 중에 있습니다. 다른 것도있을 수 있습니다.
Clojure의 소스는 EPL의 github 에서 사용할 수 있습니다 . Linux에서 실행하는 것은 쉽습니다. git repos를 복제하고 .ant
guile scheme으로 웹 개발을 할 수 있습니다 . 표준 라이브러리에는 html 생성, 조작 및 구문 분석에 매우 유용한 (sxml simple) 모듈이 포함되어 있습니다. 교활-WWW의 라이브러리는 HTTP에 대한 지원, CGI 등을 추가 교활-DBI 라이브러리는 MySQL을 사용하고 다른 데이터베이스에 대한 액세스를 제공합니다. 이러한 빌딩 블록을 사용하면 간단한 cgi 스크립트에서 자체 HTTP 서버가있는 웹 애플리케이션에 이르기까지 모든 것을 구현할 수 있습니다.
Common Lisp 웹 프레임 워크 인 Weblocks를 사용해보십시오.
http://weblocks.viridian-project.de/
나는 주제에 대해 꽤 광범위한 튜토리얼 / 전자 책을 썼습니다 : http://lispwebtales.ppenev.com/
요약 :
- Common Lisp를 사용합니다.
- Restas 프레임 워크를 사용합니다.
- 여기에는 DB 액세스, 인증, HTML 생성 및 템플릿을 포함하여 거의 대부분의 기본 웹 개발에 대한 예제가 있습니다.
- Restas 문서는 거의 구식이기 때문에 내 튜토리얼은 최신 문서에 가장 가까운 것입니다.
- 플러그인 가능한 인터페이스를 작성할 수있는 정책과 같은 몇 가지 고급 기능을 보여줍니다. 인증 프레임 워크와 같은 재사용 가능한 구성 요소를 작성합니다.
- lisp 설치, ASDF 빌드 시스템 및 quicklisp 패키지 관리자 설정 등과 같은 내용을 다룹니다.
- 그것은 무료 온라인이고 내가 그것을 끝내 자마자 leanpub에서도 무료입니다. 소스는 CC 라이선스에 따라 https://github.com/pvlpenev/lispwebtales 에 있으며 소스 코드는 MIT입니다. 모든 것이 아직 게시되지는 않았고 수정하는 중입니다.
이것은 당신이 찾고있는 것일 수 있습니다.
http://docs.plt-scheme.org/web-server/index.html
http://common-lisp.net/project/cl-weblocks/
Common Lisp에 관심이 있고 weblocks 경로로 가고 싶지 않다면 다음 설정을 권장합니다.
- Linux에서 SBCL을 사용하지만 다중 스레드 지원
- Hunchentoot를 웹 서버로 사용하여 세션 및 쿠키를 포함하여 필요한 모든 서버 처리를 제공합니다.
- ClSql을 사용하여 MySql과 통신하면 충분한 문서가 있으며 매우 안정적입니다.
- HTMl 세대의 경우 Dr Edi Weitz Cl-WHO (매우 잘 문서화 됨)를 사용할 수 있습니다.
위의 모든 내용은 GPL 또는 유사한 라이선스 (LISP 프로그램에서 더 많이 작동하는 라이선스)에 따릅니다.
Gambit Scheme 에는 웹 앱에 대한 자체 솔루션도 있습니다. 블랙홀 모듈 시스템 (둘 다 Per Eckerdal에 의해)을 기반으로 하는 Spork 프레임 워크를 사용합니다 .
Andrew Whaley는 mod_proxy를 사용하여 Apache에서 웹 앱을 실행하는 Gambit, Black Hole 및 Spork를 얻는 방법에 대한 초기 자습서 가 있습니다. 당신은 그것을보고 싶을 것입니다.
(아마도) 관련 메모에서 Gambit은 당신이 그렇게 느끼는 경우 당신의 물건을 C로 컴파일 한 다음 실행 파일로 컴파일합니다.
Paul Graham (및 친구들)은 기본 웹 애플리케이션을 작성하기 위해 특별히 lisp 방언을 만들었습니다. Arc라고 불리며 arclanguage.org 에서 얻을 수 있습니다 .
정말 크고 복잡한 웹 사이트에는 적합하지 않을 수 있으며 데이터베이스 지원 상태가 무엇인지 확실하지 않지만 Paul Graham은 lisp에서 웹 응용 프로그램을 작성하는 방법을 알고 있으므로 Arc는 대부분을 지출하는 동안 HTTP / HTML 부분을 쉽게 만들 것입니다. lisp 방식을 배우는 당신의 두뇌주기의.
Weblocks는 Common Lisp에서 웹 앱을 빌드하는 데 좋은 도구이지만 나에게는 너무 무겁습니다.
다음 스택을 사용합니다.
OpenMCL (오픈 소스 Lisp, 매우 좋음)
Portable Allegroserve (웹 서버, HTML 생성기)
Ajaxy 작업을 수행하기위한 자체 Rails와 유사한 도구 (업데이트 : 이제 WuWei 로 오픈 소스되었습니다 )
- cl-json, cl-smtp, md5와 같은 다양한 CL 라이브러리
저는 MzScheme에서 파생 된 나만의 맞춤형 Scheme 버전을 사용합니다. 새롭고 간단한 웹 애플리케이션 프레임 워크, 내장 웹 서버 (MzScheme과 함께 제공되지 않음) 및 ODBC 라이브러리가 있습니다. ( http://spark-scheme.wikispot.org/Web_applications ). 이것은 개인적인 도구에 가깝기 때문에 설명서가 완전하지 않을 수 있습니다. 그러나 코드 저장소 에는 많은 샘플 코드가 있습니다.
Clojure는 당신이 관심을 가질만한 Lisp 방언입니다. 이 시점에서 꽤 괜찮은 웹 개발 스택이 있습니다. 몇 가지를 추천 할 수 있습니다.
- The
leiningen
dependency manager which makes is really easy to install and manage libraries that you're using. Pretty nice set of plugins for it too. There's even a plugin for Clojurescript, which is a language based on Clojure that compiles to Javascript. - The
ring
HTTP server abstraction. Its used in most actual web frameworks. Its a pretty good idea to learn that first before jumping into an actual framework. hiccup
is a HTML dsl/templating language written in Clojure. Its very expressive! Reminds me a bit of Jade, in a sense.composure
would have to be the most popular web framework for Clojure. Its essentially a routing library likeexpress.js
.
Let's see what can be done with Common Lisp.
The state of the Common Lisp ecosystem (2015) and the Awesome Common Lisp list show us a couple of modern frameworks (Caveman, Lucerne, all built on the new Clack web application server, an interface for Hunchentoot and other servers). Let's discuss with our own findings.
update: a bit later, I found out Snooze, by the creator of Sly or Emacs' Yasnippet, and had a much better impression than say Caveman. Declaring endpoints is just like declaring functions, so some things that were tedious in Caveman are obvious in Snooze, like accessing the url parameters. I don't have much experience with it but I recommend checking it out.
update june 2018: also don't miss the ongoing rewrite of Weblocks, it's going to be huge ! :D http://40ants.com/weblocks/quickstart.html Weblocks allows to build dynamic webapps, without a line of Javascript, without separating the back and front. It is components-based, like React but server-side. It's very alpha as of writing (june 2018), but in progress, and it's working, I have a couple simple web apps working.
A simple way of get the request parameters (something like: get-get #key, get-post #key, get-cookie #key).
I found easier the Lucerne way, it iss as simple as a with-params
macro (real world example):
@route app (:post "/tweet")
(defview tweet ()
(if (lucerne-auth:logged-in-p)
(let ((user (current-user)))
(with-params (tweet)
(utweet.models:tweet user tweet))
(redirect "/"))
(render-template (+index+)
:error "You are not logged in.")))
Caveman's way has been less clear to me.
Mysql access
Caveman advertises database integration (with Fukamachi's Datafly and sxql).
You can just use clsql or the Mito ORM: https://lispcookbook.github.io/cl-cookbook/databases.html
HTML Form generators, processing, validators, etc.
I don't know if there are form generators out there. edit: there are: cl-forms and formlets, or again 1forms, working with Caveman2.
Caveman does not have one (issue raised in 2011).
Helpers for filter user input data (something like htmlentities, escape variables for put in queries, etc).
Ratify is an input validation library, not integrated into a framework though.
FLOSS and GNU/Linux friendly ✓
Other web stuff
Speaking about web, there are other nice libraries in CL land:
- web servers: Woo is a fast HTTP server, faster than Nodejs (beware of charts…), wookie is an async http server,
- Dexador is an HTTP client
- Plump, lquery and CLSS make it easy to parse html and query the DOM.
- cl-bootstrap offers twitter-bootstrap shortcuts for the cl-who templating engine (which kind of replaces Jade/Pug, even though we have usual templates too).
Ajax in Lisp
(remember, with Weblocks, see above, we might not need those)
- Wuwei is an interesting experiment that enables to write Ajax views in Common Lisp. The website has nice real-world demos. It can include other Javascript libraries.
- also SmackJack, explained in this recent blog post (2017).
Clojure would be perfect for this. With some very short, clean code, you can implement some very complex applications, such as blogs or forums.
참고URL : https://stackoverflow.com/questions/1275547/how-can-i-do-web-programming-with-lisp-or-scheme
'program tip' 카테고리의 다른 글
Python에서 한 변수의 값을 다른 변수에 할당하면 어떻게됩니까? (0) | 2020.10.21 |
---|---|
Xcode를 버전 10.3 (10G8)으로 업데이트 한 후 스토리 보드가 손상되고 앱이 더 이상 실행되지 않습니다. (0) | 2020.10.21 |
UIPickerView에서 선택한 값을 얻는 방법 (0) | 2020.10.21 |
Python threading.timer- 'n'초마다 함수 반복 (0) | 2020.10.21 |
AngularJS에서 $ watching을 어떻게 중지합니까? (0) | 2020.10.21 |