3 ms·
> When I "create a language to solve a problem" in, say, C++, Most of the time you just add words to a language by adding verbs/adjectives/adverbs. It's not a
by lispm 13y ago
> When I "create a language to solve a problem" in, say, C++,
Most of the time you just add words to a language by adding verbs/adjectives/adverbs. It's not a new language.
> One example is LOOP. It's a macro, because Lisp without macros doesn't have very good looping ability.
That's backwards thinking.
LOOP is a macro, because macros are the way to implement code transformations in Lisp. Lisp has other iteration constructs, which are implemented as functions (MAP, REDUCE, ...).
Common Lisp is also its own compilation target. So at the very bottom there is only one iteration construct provided: GOTO. The rest are macros/functions on top of that. The language a compiler needs to understand is thus very small. The built-in extension mechanism then allows almost arbitrary code transformations. This is used by the language implementation AND the user. The user/developer has access to the same facility to implement code transformations in applications or libraries.
This is great for production, since you don't have to wait for some committee or a benevolent dictator to implement the language feature you need. Instead of waiting for a new iteration facility for months or years, you can implement it in an afternoon. Productivity goes up. You don't need to wait for tools generating code or more compact notations reducing boiler plate code - just implement it yourself. You also don't need external preprocessors - just use Lisp. You can also debug/extend your code transformation using the same development tools, instead of maintaining external preprocessors. It also enables complex programs to have comparatively small code bases. Which often makes maintenance easier.
TL;DR: Lisp gives the user more expressive power and trusts them.
- AnimalMuppet 13y agoBut see, that's more or less my point. In Lisp, you can write it in an afternoon. But in Lisp, because the language (sans macros) doesn't give you much, you have a bunch of things that you have to do that way. In C, because the base language gives you more, you have enough that you don't have to write the features that you need. (Granted, this doesn't work if your goal is to reduce boilerplate code to zero...)
- lispm 13y ago> In C, because the base language gives you more, C does not have nested functions, lambda expressions, closures, ... it gives me less. Let's look at iteration. C does give me primitive WHILE, DO WHILE and FOR statements. Nothing more. I get almost nothing in C. > But in Lisp, because the language (sans macros) doesn't give you much It gives me already a language where WHILE and FOR can be written as functions. (defun while (c b) (tagbody while (if (not (funcall c)) (go end)) (funcall b) (go while) end)) In C you get the best of both worlds: no powerful iteration and no easy way to implement it.