Joke Collection Website - Cold jokes - Is it useful for a freshman to learn lisp language?
Is it useful for a freshman to learn lisp language?
This easy-to-learn and easy-to-use programming tool is worth learning.
1.
If we arrange the popular programming languages ??in this order: Java, Perl, Python, Ruby. You will find that the languages ??ranked further down the list are more like Lisp. Python imitates Lisp, and even imitates features that many Lisp hackers consider to be design errors. As for Ruby, if you went back to 1975 and claimed it was a Lisp dialect, no one would object. The current development of programming languages ??has only just caught up with the level of Lisp language in 1958.
2.
In 1958, John McCarthy designed the Lisp language. I think that the latest programming languages ????are just realizing what he envisioned in 1958.
How is this possible? Isn’t the development of computer technology changing with each passing day? How could the technology of 1958 surpass today's level?
Let me tell you why.
This is because John McCarthy did not originally intend to design Lisp as a programming language, at least not in the current sense of the word. His original intention was just to do a theoretical calculation and define a Turing machine in a more concise way.
So, why are the programming languages ????in the 1950s not obsolete now? Simply put, because this language is not a technology in nature, but mathematics. Mathematics never goes out of style. You shouldn't associate Lisp with 1950s hardware, but rather with the Quicksort algorithm. This algorithm was proposed in 1960 and is still the fastest universal sorting method.
3.
Fortran language also appeared in the 1950s and has been used to this day. It represents a completely different direction in language design. Lisp evolved unintentionally from pure theory to a programming language, while Fortran was designed as a programming language from the beginning. However, today we think of Lisp as a high-level language and Fortran as a fairly low-level language.
In 1956, when Fortran was first born, it was called Fortran I, which was very different from today's Fortran language. Fortran I is actually assembly language plus mathematics. In some aspects, it is not as powerful as today's assembly language. For example, it does not support subroutines, only branch jump structures.
Lisp and Fortran represent the two major directions in the development of programming languages. The foundation of the former is mathematics, and the foundation of the latter is hardware architecture. Since then, these two directions have been moving closer to each other. Lisp was powerful when it was first designed, and over the next two decades it improved in speed. Those so-called mainstream languages ??took faster running speed as the starting point for design, and then spent more than forty years becoming more powerful step by step.
To this day, the most advanced mainstream languages ??are only just approaching the level of Lisp. Although it is very close, it is still not as powerful as Lisp.
4.
When the Lisp language was born, it contained 9 new ideas. Some of them we have taken for granted today, others have just appeared in other high-level languages, and two are unique to Lisp so far. According to the degree of acceptance by the public, these 9 ideas are in order:
1. Conditional structure (ie "if-then-else" structure). Now everyone takes this for granted, but Fortran I does not have this structure. It only has the goto structure based on the underlying machine instructions.
2. Function is also a data type. In the Lisp language, functions, like integers or strings, are also a type of data type.
It has its own literal representation, which can be stored in a variable or passed as a parameter. It has all the functions that a data type should have.
3. Recursion. Lisp was the first high-level language to support recursive functions.
4. Dynamic type of variables. In Lisp language, all variables are actually pointers. The values ??pointed to have types, but the variables themselves do not. Copying variables is equivalent to copying pointers, not the data they point to.
5. Garbage collection mechanism.
6. Programs are composed of expressions. A Lisp program is a collection of blocks of expressions, each of which returns a value. This is in contrast to Fortran and most later languages, where programs are composed of expressions and statements.
The distinction between expressions and statements is natural in Fortran I because it does not support statement nesting. So, if you need to calculate a value mathematically, you can only use an expression to return the value, and no other syntax constructs are available, because otherwise you cannot handle the value.
Later, new programming languages ??supported the block structure (block), and of course this restriction no longer existed. But it was too late, the distinction between expressions and statements had become deeply ingrained. It spread from Fortran to the Algol language, and then to the successor languages ??of both.
7. Symbol type. A symbol is actually a pointer to a string stored in a hash table. Therefore, to compare whether two symbols are equal, you only need to check whether their pointers are the same, without comparing them character by character.
8. The code uses a tree notation (notation) composed of symbols and constants.
9. The entire language is available at all times. Lisp doesn't really distinguish between read time, compile time, and run time. You can compile or run code at read time; you can read or run code at compile time; you can also read or compile code at run time.
Running code during the reading period allows users to reprogram Lisp syntax; running code during compilation is the basis for Lisp macros; compiling code during runtime allows Lisp to be used in In programs such as Emacs, it serves as an extension language; the code is read at runtime, allowing programs to communicate using S-expressions. The recent emergence of the XML format has allowed this concept to be reinvented. "Come out.
5.
When the Lisp language first appeared, its ideas were very different from other programming languages. The design ideas of the latter were mainly determined by the hardware of the late 1950s. As time goes by, popular programming languages ??continue to be updated, and language design ideas gradually move closer to Lisp.
Ideas 1 to 5 have been widely accepted. Idea 6 has begun to appear in mainstream programming languages. Idea 7 has been implemented in the Python language, but there seems to be no dedicated syntax.
Thought 8 is probably the most interesting point. It and idea 9 became part of the Lisp language only by accident, as they were not part of John McCarthy's original conception and were added by his student Steve Russell. They have since made Lisp look weird, but have also become the language's most unique feature. The weird form of Lisp is not because its syntax is weird, but because it has no syntax at all, and the program is expressed directly in the form of a parse tree. In other languages, this form is simply generated behind the scenes through parsing, but Lisp uses it directly as the expression form. It consists of lists, which are Lisp's basic data structures.
Expressing a language using its own data structures proves to be a very powerful feature. Ideas 8 and 9 mean that you can write a program that you can program yourself. This may sound weird, but it's very common for Lisp. The most common way is to use macros.
The term "macro" in Lisp has a different meaning than in other languages. Lisp macros are all-encompassing. They may be a shortened form of an expression or a compiler for a new language. If you want to truly understand the Lisp language, or want to broaden your programming horizons, then you must learn macros.
As far as I know, macros (as defined in the Lisp language) are still unique to Lisp. One reason is that in order to use macros, you probably have to make your language look as weird as Lisp. Another possible reason is that if you want to add this ultimate weapon to your language, you can no longer claim to have invented a new language, only a new dialect of Lisp.
I say this as a joke, but it is what it is. If you create a new language with functions such as car, cdr, cons, quote, cond, atom, and eq, and a way to express functions as lists, then based on them, you can completely derive out of all other parts of the Lisp language. In fact, the Lisp language is defined this way, and John McCarthy designed the language this way to make this kind of derivation possible.
6.
Even if Lisp does represent a direction that the current mainstream programming languages ??are getting closer, does this mean that you should program with it?
How much do you lose by using a less powerful language? Isn’t it sometimes a wise choice not to use the most cutting-edge technology? So many people use mainstream programming languages. Doesn’t this itself show that those languages ??have merit?
On the other hand, for many projects it doesn't matter which programming language you choose. Different languages ??can get the job done anyway. Generally speaking, the more demanding the project conditions, the more powerful a programming language can play a role. However, countless projects are not restricted by harsh conditions at all. For most programming tasks, you may just need to write some small programs, and then use glue language to connect these small programs. You can write these small programs in a programming language that you are familiar with, or in a language that has the most powerful function library for a specific project. If you just need to transfer data between Windows applications, you can still achieve the goal using Visual Basic.
So, what are the advantages of Lisp programming?
7.
The more powerful the programming ability of the language, the shorter the program written (of course, it does not refer to the number of characters, but to independent grammatical units).
The amount of code is important because the time it takes to develop a program depends mainly on the length of the program. If the code written in one language is three times longer than another language for the same software, this means that it will take three times more time to develop it. And even if you hire more people, it won't help reduce development time, because when the team size exceeds a certain threshold, adding more people will only be a net loss. Fred Brooks described this phenomenon in his famous book The Mythical Man-Month, and what I saw and heard confirmed his statement.
How short can the program be made if Lisp is used? Taking the comparison of Lisp and C as an example, most of the statements I hear are that C code is 7 to 10 times longer than Lisp. But recently, there was an article in New Architect magazine introducing ITA Software Company. It said that "one line of Lisp code is equivalent to 20 lines of C code." Because this article quoted the words of the president of ITA, I think this number comes from ITA's programming practice. .
If this is the case, then we can believe this statement. ITA's software not only uses Lisp language, but also uses C and C++ extensively, so this is based on their experience.
According to the above number, if you compete with ITA, and you use C language to develop software, then ITA's development speed will be 20 times faster than yours. If it takes you a year to implement a feature, it takes less than three weeks. On the other hand, if a new feature takes three months to develop, it will take you five years to develop it.
- Related articles
- How did South Korea unify the world during the Warring States Period?
- A recent photo of Qiong Yao's two granddaughters. One looks innocent in a white dress, and the other looks graceful and beautiful in a cheongsam. How similar are her facial features to grandma's?
- Under the golden coat: What jokes did women make when they disguised as men this summer?
- What are some weight-loss tips for you to lose weight easily?
- December Good Morning Positive Energy Classic Quotes: You can wipe away your tears, get up with struggle and continue to work hard.
- How many chapters of fat man died in the snow
- How do you say zebra in English?
- Who can tell me the most handsome episode of Sanji in OP? thank you ...
- Xiaoshengchu introduced himself simply and generously.
- English jokes in urgent need of 20~30 words should be as short as possible.