[Return] [Catalog]

1 guest@cc 2020-06-02T05:54:18 [ImgOps] [iqdb]
File: 57cd0496aacf1102cf8c6117760d6a… (JPEG, 211.27KB, 600x480)
I'm learning scheme as my "first language" using How to Design Programs. I've had previous programming experience before, but this is the first time i'm learning seriously with the intention of being able to understand common computer jargon like what a bash file is or what a port is. Whenever I look at other languages now, they seem so fucked up. I think, where are the parentheses? How do you know when one function starts and the next ends? How can you use an or function inside another function in c if semicolons end a function, or is or not a function in c for some reason? In middle school, I tried learning c. I don't remember what they do, but pointers were a nightmare and I'm scared of it them now.

Other languages seem like their syntax is full of arbitrary things what line you're writing on being important. In scheme, there's no difference between brackets and parentheses, they just contain things. Functions always go at the start of parentheses, and everything else after, so there's no order confusion. A good ide like DrRacket keeps track of parentheses for you too, so not having enough or too many isn't a problem. Like legos, you can just put these simple pieces together unlike a gundam model or something. It seems like it works so well to me, I don't understand why other languages are different. Is there a good reason why other languages don't have the same format besides speed?
»
2 guest@cc 2020-06-02T07:10:45
Scheme was designed to just represent the ideas, the other languages were designed to be more similar to how the computer works.
»
3 guest@cc 2020-06-02T10:08:22
I like classes or structs because when building user interfaces. It makes more sense to have items be represented as objects. Other logic could be done through functions. If I recall correctly, C was just one of the first good improvements on writing straight machine code.
»
4 guest@cc 2020-06-02T13:18:03 [ImgOps] [iqdb]
File: 961.jpg (JPEG, 38.57KB, 500x475)
>>2
So a lisp machine is designed in a way that makes lisp accurate to the hardware? Could they actually be as useful as computers with a more standard architecture?
>>3
Racket at least supports objects and traits. I haven't learned about that yet though.
»
5 guest@cc 2020-06-02T15:48:18
>>2
There's no reason you can't have a low-level language with s-expressions. Syntax is mostly feature agnostic.
»
6 guest@cc 2020-06-02T17:09:12 [ImgOps] [iqdb]
File: 4067d70c54e0404f4e80c5f8e3fa82… (JPEG, 1.05MB, 1500x2300)
Speed is not a good reason. Parsing S-expressions is very straightforward and should be quick. Macro expansion could slow things down but theoretically you could have an S-expression based language without them. Meanwhile parsing something like C++ is a hard problem. The language is full of ambiguities and people have been working hard to make GCC's parsers fast.

I assume that at this point it is mostly a question of tradition. The processor itself executes statements (instructions) therefore most of the early languages are also based on statements. Just look at COBOL, adding numbers is done by the statement
ADD a, b TO c
. Of course this is insanity and people added expressions to their statements, so now you can write
return 1+2;
in C, which is a return statement with the expression 1+2 as an argument to it.

The reason Lisp is so different is that McCarthy did not design it to be a programming language, but as mathematical notation to reason about programs. It was never meant to run on the machines and he was quite surprised when Steve Russell managed to write the first Lisp interpreter.

>>3
Most Scheme's support structs and have object systems. Even if it is missing, you can write your own. It is discussed in the third chapter of SICP. I would also recommend the paper "Object-Oriented Style" by Daniel P. Friedman.
»
7 guest@cc 2020-06-02T17:27:10 [ImgOps] [iqdb]
File: CoLAReimuYukari.jpg (JPEG, 112.97KB, 613x627)
>>6
So hypothetically, every non-assembly language commonly used could have been designed around s-expressions including stuff like javascript and sql? Would that have been better, or is there some design advantage to using statements besides tradition?
»
8 guest@cc 2020-06-02T18:21:31 [ImgOps] [iqdb]
File: 1407624519981.jpg (JPEG, 55.46KB, 600x900)
>>7
These are two separate problems. You can have a language with only expressions but with a syntax that is not based on S-expressions. See OCaml for example. On the other end, you can have a language with only statements but encoded in S-expressions, like WebAssembly's text format.

In my opinion it can make sense to have statements if you expect the language to be used in an imperative style, meaning that most of the program is statements following one another. In this case encoding it in S-expressions you will get a very shallow tree, hiding most of its benefits. It can also make sense to avoid S-expressions even when the language would be perfectly fit for it. Many people seem to prefer a more "wordy" representation that matches human speech and find S-expressions "alien". I think it is much more important to make the syntax straightforward, consistent and predictable.

But! S-expressions are uniquely suitable for complex, computational macros, which many believe to be the crown jewel of Lisps.
»
9 guest@cc 2020-06-06T22:07:44
>>4
>So a lisp machine is designed in a way that makes lisp accurate to the hardware?

I've always wondered this too. I have some familiarity with assembly and how those instructions map directly to binary and I can see that it's fundamentally quite different from Lisp.
But I've always wondered if there was another way the binary could function that's more Lisp-like.

This may be unrelated but I also always felt like a "Lisp Machine" would really benefit from being Single Address Space so programs could directly access data in other programs like in TempleOS.
»
10 guest@cc 2020-06-08T19:27:44 [ImgOps] [iqdb]
File: 0ad609435127b6f49592353d9a119d… (PNG, 1.16MB, 1026x1242)
>>4,9
Here's a paper on the architecture of one of the Lisp machines: https://dl.acm.org/doi/10.5555/327010.327133

From a quick skim it seems that it was a stack based architecture with a few Lisp-specific extensions, like tagged addresses and hardware based run-time type checking. Nothing extraordinary for its time. My impression is that the real attractive part of the Lisp machines was the software, the hardware was just developed to make the performance bearable.

I know of a project that built a chip that was based on function application, based on the SECD abstract machine, but I did not have the time to study it yet. If you are interested, this seems to be a good entry point: https://prism.ucalgary.ca/handle/1880/46595

[Return] [Catalog]
Delete Post:
OptionsPassword
Name
Comment
File