Why did python took over scheme/lisp in popularity ?

Alain De Vos

Son of Beastie

Reaction score: 869
Messages: 2,826

I'm currently downgrading from python 3.9 to python 3.8 and need to recompile 700 ports.
Proving how intrusive python is.
But this made me wonder why scheme became less popular than python ?
 

bakul

Active Member

Reaction score: 90
Messages: 164

For an explanation see
and

That is part of the larger trend. I believe everything you can do with Python could've been done in Scheme but for some reason most programmers don't like Lisp or Scheme. So it goes. I am a long term fan of Scheme but must admit Scheme was not really very popular except in top tier schools like MIT and such. And it lacked low level features or was hard to interface with C/C++.
 

astyle

Daemon

Reaction score: 746
Messages: 1,625

The reasoning is the difference in programming paradigms. Scheme implements a functional programming paradigm, which basically allows you to redefine a function based on the program's scoping. Python implements an imperative programming paradigm, which allows for object orientation. Wikipedia is a good read for all that.
 
OP
Alain De Vos

Alain De Vos

Son of Beastie

Reaction score: 869
Messages: 2,826

It's time I start to learn <racket> which is general purpose scheme language.
Note1 : there is "functional stuff" in the <nim> compiler&language
Note2: The way our brain processes written text might also be reason for the succes of python ?
 

bakul

Active Member

Reaction score: 90
Messages: 164

You can do imperative programming in Scheme too, using all those functions ending in '!' such as set!. Object orientation was all the rage for a few decades but now there is lots of criticism of it. Someone has even called it a trillion dollar disaster! Even newer languages such as nim ("inspired" by python) don't tout object-orientedness. More and more we are realizing now that the bigger issue is mutability, which needs to be controlled tightly, while OO actually encourages mutability!
 

Zirias

Son of Beastie

Reaction score: 1,759
Messages: 2,982

I used neither python nor scheme myself, but would add some general thoughts anyways:

Many "modern" languages are in fact "multi-paradigm", thus offering constructs for functional, imperative and object-oriented styles, leaving the choice to the programmer. These languages often become somewhat popular for their versatility.

It even makes sense to "mix" paradigms in the same codebase. As an example, functional and object-oriented programming doesn't have to be mutually exclusive. Applying both just means that the objects are the (immutable) values handled by functions. There's still something to gain from "member functions" (methods): You'll still have functions "mutating" objects, but instead of doing that directly, they create and return a modified copy. These are still logically tied to the object type, so having them as member functions there helps the structure of your project.

Of course, that's different from the original OOP ideas. Code reuse by inheritance once was considered a great idea, now we know it just leads to unmaintainably complex object graphs, and when you add the directly mutating methods to that, you'll have bugs by the dozen.

In theory, you can program anything following any paradigm, but still, some are better suited to specific tasks than others. Take for example some GUI logic: Almost nobody would want to use a strictly functional style there. It's possible, but as soon as you need "side effects", the functional style gets very cumbersome. You will mostly use some OOP style for GUIs. OTOH, for your "core logic" (what the program is actually doing), you should separate that from layers with side effects (like UI, persistence, ...) anyways, so very often, doing it functional is the best choice there is. Even a language like C++ added constructs (lambdas) to enable some things functional, although it isn't complete there.

As I said, I didn't use python so far, but assuming it has somewhat sane support for different paradigms, that might be a reason for popularity. Having to learn just a single language and not having to think about integration of parts written in different languages is a big plus for a software project.
 
OP
Alain De Vos

Alain De Vos

Son of Beastie

Reaction score: 869
Messages: 2,826

I've done a few tests with chicken-scheme but i found it slow. Yet it has libraries for many things.
 

drhowarddrfine

Son of Beastie

Reaction score: 2,494
Messages: 4,441

The bar to taking over from scheme was pretty low. Even today I'd bet a lot of new languages have surpassed scheme. That's not saying anything bad about it. It's just that "nobody" uses scheme.
 

bakul

Active Member

Reaction score: 90
Messages: 164

chez-scheme & gambit-scheme are usually the fastest. I wrote the following 8 years back (first ran it on the original Pi). Gambit-scheme runs it the fastest thanks to its superior multiplication algorithm:
Code:
(define (pi digits)
  (let* ((A 13591409)
     (B 545140134)
     (C 640320)
     (C^3/24 (quotient (expt 640320 3) 24))
     (D 12))
    (define (-1^n*g n g) (if (odd? n) (- g) g))
    (define (split m n)
      (if (= 1 (- n m))
    (let* ((6n (* 6 n)) (g (* (- 6n 5) (- (+ n n) 1) (- 6n 1))))
      (list g (* C^3/24 (expt n 3)) (* (-1^n*g n g) (+ (* n B) A))))
    (let* ((mid (quotient (+ m n) 2))
           (gpq1 (split m mid))
           (gpq2 (split mid n))
           (g1 (car gpq1)) (p1 (cadr gpq1)) (q1 (caddr gpq1))
           (g2 (car gpq2)) (p2 (cadr gpq2)) (q2 (caddr gpq2)))
      (list (* g1 g2) (* p1 p2) (+ (* q1 p2) (* q2 g1))))))
    (let* ((num-terms (inexact->exact (floor (+ 2 (/ digits 14.181647462)))))
       (sqrt-C (integer-sqrt (* C (expt 100 digits))))
       (gpq (split 0 num-terms))
       (g (car gpq)) (p (cadr gpq)) (q (caddr gpq)))
      (quotient (* p C sqrt-C) (* D (+ q (* p A)))))))

Invoke as (pi 1000000000) to compute billion digits of pi. On chez-scheme you will have to define integer-sqrt. Usually this runs about 16-17 times slower than optimized C code using gmp. Not bad for the (more or less) clearest translation of Chudnovsky brothers' algorithm! The last N records for pi digits (since Fabrice Ballard computed 2.7 trillion digits on 31-Dec-2009) have all been using this formula but of course they employ plenty of tricks to speed up computation, which obfuscates the algorithm.

Gambit nicely hides the multiplication complexity behind the * function! I give this example to point out that Scheme can be used for nontrivial things. Of course the above simple code will fall apart if you want to compute trillion+ digits as just the storage alone for a single such number will require 500GB and not fit in memory of a consumer machine! But I can imagine writing a program to convert such a program where disk storage is used intelligently. Would you rather programmatically convert 22 lines of Scheme or 1000+ lines of C/C++ code?

No other language is as simple as Scheme and at the same time as powerful. Unfortunately that has meant many people write a toy interpreter for Scheme just for fun but very very few people spend time on creating an industrial strength implementation.
 

vigole

Daemon

Reaction score: 1,600
Messages: 1,413

I use perl for everything, and I am not knowledgeable enough to compare python with other languages, down to the source code.
But one thing is obvious, Python circle know how to market their product. Just look at the web. Their branding strategy is superior.
 

Crivens

Moderator
Staff member
Moderator

Reaction score: 1,740
Messages: 2,587

Scheme left a veritable knot in my brain after university. Python does the same. I wanted to start some common lisp learning, but my assembly and fortran skills are fighting back :(
There is a CL implementation based on LLVM, btw. That ought to be the fastest of the flock, no?
 

covacat

Daemon

Reaction score: 514
Messages: 1,040

because people never heard of teco....
 
OP
Alain De Vos

Alain De Vos

Son of Beastie

Reaction score: 869
Messages: 2,826

An interesting remark on (),[],{},
The advantage of having parens is that you don't have to worry about formatting at all. You can insert newlines anywhere or remove them and the code automatically gets indented to reflect the nesting.
With tabs & spaces you are responsible of formatting the code.
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 13,070
Messages: 39,685

the code automatically gets indented to reflect the nesting.
With tabs & spaces you are responsible of formatting the code.
Both situations are handled by using a proper syntax checker/helper from your editor. There are often linters and style checkers for the language of your choice.
 

msplsh

Aspiring Daemon

Reaction score: 244
Messages: 664

It's, uh, pretty simple: Lisp isn't a mental model that is instantly intuitive to people.

To me, Python has simply taken over the space BASIC and Perl used to occupy. The addition of things like Numpy and Pandas pushed it into spaces where specialized and useless-outside-of-domain software ruled such as Matlab. Python eating into these little niches (embedded with MicroPython) has significantly increased its popularity, which increases the quality and availability of libraries, making it more attractive for more people.

Things that are difficult to learn or use only keep the most dedicated programmers.
 

astyle

Daemon

Reaction score: 746
Messages: 1,625

bakul and eternal_noob : Now that I looked at the Scheme code and the equivalent in C - yeah, I can see that Scheme does have a selling point - Scheme code is very compact, and can fit into far less lines than its C equivalent. Unfortunately, to write Scheme scheme code that works correctly, you have to understand RPN (Reverse Polish Notation), and apply the logic when typing in the text. C is much easier to follow along than Scheme, at least for me. I think that it's not impossible to implement Scheme-style recursion in C, and have it work correctly, but this is more than I want to even think about at this time. The way I see it - Python is trying to be a compromise between the two. 😩
 

Emrion

Aspiring Daemon

Reaction score: 234
Messages: 698

I recall lisp learning at school. It was a nightmare, far from all common computer logic.

I've been always surprised that some people, not only like that beast but also did powerful softwares with it. Anyway, that's a fact, but... I'm not surprised as well that most people can't stand this especially ugly programming language.
 

astyle

Daemon

Reaction score: 746
Messages: 1,625

I recall lisp learning at school. It was a nightmare, far from all common computer logic.

I've been always surprised that some people, not only like that beast but also did powerful softwares with it. Anyway, that's a fact, but... I'm not surprised as well that most people can't stand this especially ugly programming language.
Lisp and Emacs seem to go hand in hand... I never got a handle on either. The impression I got back in college is that those are popular among old-school grizzled admins who pine for the days of PDP-11 and DEC. ;)
 

bakul

Active Member

Reaction score: 90
Messages: 164

Do you know that different natural languages have different word order for subject, object, verbs etc.? You can be fluent in multiple languages but it requires learning the language and practicing. And if/when you do learn a language, your opinion may change.

If you have a bad teacher and a language is forced upon you're likely to hate it. In my case no one forced any language on me (I took one computer class as an undergrad but attended only the first lecture. And in grad school they expected you to know your stuff!). I learned probably about 20-24 programming languages pretty much on my own, mostly out of curiosity. I don't have much experience in some of these languages but enough to know what I like/dislike about them. They all got created because they filled some niche at a point in time. Of all these, Scheme is my favorite.

It helps to know a variety of languages and become proficient at at least a couple of them. Many of these languages force you to think and solve a problem in a different way and that is a plus. Of these, Scheme can perhaps be used the best to explore different paradigms. To that end I encourage people to read the Structure and Interpretation of Computer Programs book and do some exercises!

But I think the incentive to learn from such books has gone down quite a bit in the past few decades. Now most programmers are assembly programmers -- they assemble something out of existing pieces of software and don't write a lot of new code. There really is no reason to implement, for example, a hash-table from scratch. So many pieces exist -- why waste your time writing something equivalent, which may turn out to be buggy or take a lot of time to get right? On the other hand, how do you evaluate which of N different packages for doing something should be chosen for your particular project? Do you even know how to evaluate them or are you going to pick one at random and when that breaks, look for something else?
 

astyle

Daemon

Reaction score: 746
Messages: 1,625

Now most programmers are assembly programmers -- they assemble something out of existing pieces of software and don't write a lot of new code
Dunno if assembly programmers is a very accurate term - My impression of it is that they program in actual Assembler (devel/nasm, anyone?) I do agree with the rest of the point - I myself try to follow the principle of code reuse. But - you do have to have some basics firmly down. If you can't write a hash table from scratch even in Java, and don't even know how that is supposed to work, it's impossible to recognize the same logic at work in Python or Scheme or Ruby.
 
Top