How Do I Use Scheme in Production Environment? #46
ufo5260987423
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In 2011, I was still a freshman in university. Although I had about 6 years of immature C programming experience (mainly used to exhaustively solve some meta-mathematical problems), I fell in love with Lisp language at once. The time when this love began was very clever, because computer science finally began to profoundly change this country with 5,000 years of history. Before that, although Lisp officially entered Chinese classrooms in the 1980s, China's industrial system at that time could not provide any jobs or positions for Lisp. At that time, Wang Yin, a well-known Tsinghua dropout in China, introduced us to Indiana University's computer programming language theory research and the magical Lisp. Especially the lightning-fast Chez Scheme, its magical code generation speed and effective optimization made us believe that we would use Lisp to change the world one day. We saw Lisp in science fiction novels, we heard Lisp in book clubs, and we heard that Nokia wrote programs in Lisp dialect in its R&D center in Beijing.
Where are you, Lisp? I can't find you.
In the following time, study and employment made it impossible for me to use Lisp. At first, I thought it was because I was not a computer science major, and the industrial revolution in China did not allow us to have any time and life to think. Secular thinking requires us to find a place in society that is sufficient to survive.
The real transformation occurred in 2021. COVID-19 had already torn the international, domestic, and our hearts apart in the previous year. Regardless of what kind of future this tear will lead to in the world, I now begin to think about what I really rely on to live. There is a saying in China that the highest is to establish virtue, the second is to establish merit, and the third is to establish words. At that time, I decided to do something interesting with scheme. These things actually led to the title of today's article, "How I use scheme in production environment".
Background
Now I am a programmer myself, using Java to make some living money. And now I need to do some conversions between DSLs. Because these DSLs are associated with different products, the semantic differences result in strategies that may be modified at any time. How to convert a business and product problem into a technical problem, rather than a sports problem, although there is a little power willfulness, but this is why I use scheme. After all, writing lexers and parsers and using match macros to convert between S-expressions is a bit challenging for Java 8.
Development environment
Although there is some self-promotion, I think scheme-langserver is the core of my entire development environment. Because I have to admit that I hate any programming language without IDE. This is also applicable when I write Lisp. I strongly and subjectively believe that a qualified supporting infrastructure for any language must have at least a function like goto-definition to ensure that I can quickly view the body of a function. Otherwise, the quality of the code decays too quickly with the length, which turns a science into a sport.
I make a living by writing Java, and the idea of OOP makes me deeply dependent on the library mechanism and package mechanism of the scheme language. Therefore, it is completely understandable to use AKKU for package management. Including when I first wrote scheme-langserver, I was also completely oriented towards the library mechanism and package mechanism.
I now use neovim to edit code.
Development process
The biggest problem with scheme for actual development is not solving the problem itself, but how to call the scheme program through other codes. Because I have written too much web in Java, I hope to package scheme into microservices, but this requires solving a series of problems in the network environment.
The first problem is that scheme lacks out-of-the-box socket libraries. In other words, although there are some ready-made ones on the Internet, they are outside the AKKU system I use. Therefore, one of my work here is to develop ufo-socket and migrate some ready-made libraries.
The second problem is that scheme lacks out-of-the-box http server. Fortunately, I am quite familiar with the http protocol, so I developed http-pixiu. Among them, pixiu is a beast in Chinese mythology. It brings lucky and happy. Although http-pixiu has problems in exception handling and other aspects, it is enough to realize the function through spring+feign calling.
The third problem is that scheme-langserver has too many bugs. In theory, there is a way to solve the bug by strictly following the logic of the academic circle, but I don't have the opportunity to study for a corresponding doctorate in China (I have a master's degree related to information). I am also a programmer who puts self-thinking before querying academic research - if the results of my thinking can be attached to some academic achievements, I am of course very happy, but in many cases I don't really care about the kind of nitpicking. The debugging strategy I am currently taking is to filter the logs of scheme-langserver through my own recurrence tool and gradually check where the problem is through pretty-print. I also corrected some issues raised by netizens through this method.
Result
The program written with scheme has been deployed in the application environment. Although this is a preliminary version, I will continue to improve it according to business requirements. As I said, the main problem is the management of problem handling strategies, which requires the code to have a high degree of flexibility and abstraction. At present, http microservices have been used, and the performance of the main part of the program is not a problem at all.
Beta Was this translation helpful? Give feedback.
All reactions