7 ms·
Actually, I am missing the simplicity of Lisp and Smalltalk in todays languages. From what I remember, they both have a fairly simple but universal syntax, whic
by JepZ 9y ago
Actually, I am missing the simplicity of Lisp and Smalltalk in todays languages. From what I remember, they both have a fairly simple but universal syntax, which can be written for Lisp as
([operator] [argument1] [argument2] [argumentN])
and for Smalltalk as
[object] [message]
So far I haven't seen anything like that for languages with the C-like syntax. Don't get me wrong. For example I love Go, but sometimes I miss the beauty of Lisp and Smalltalk.
- hota_mazi 9y agoIsn't Objective C exactly that, a C family language with a Smalltalk inspired syntax?
- lobster_johnson 9y agoObjC is a completely backwards-compatible superset of C that bolts a Smalltalk-like syntax on top. The first implementation was a preprocessor that emitted C, as far as I remember, until first-class compiler support arrived (GCC and Clang have native support).
- agumonkey 9y agosmalltalk cutest feature is the named parameter syntax trick (I don't like tricks but let's make an exception). make-range from: 10 to: 20 calss (make-range.from:to 10 20) or something similar. Free nanodsls smalltalk simplicity lies in that the metamodel is actually human reasoning friendly, even while dynamic, you have a clear picture of what's gonna happen in case of errors etc. It didn't please visual age users, which called smalltalk messagenotunderstoodlang but I believe it was due to the wrong viewpoint.
- hota_mazi 9y ago> smalltalk cutest feature is the named parameter syntax trick (I don't like tricks but let's make an exception). And yet, Smalltalk got it wrong by making all the parameter names mandatory, which leads to sources that are much more verbose than they need to be. The correct approach to this is to make parameter names optional, so they're only used when disambiguation is necessary to clarify the intent of the code.
- igouy 9y ago> by making all the parameter names mandatory For example?
- rahoulb 9y agoIn smalltalk the parameter names aren't mandatory in the sense of many other languages. They are actually part of the method name. So robot put: thing in: container. And robot put: thing on: shelf. Are two separate messages that are both understood by the robot instance - "put: in:" vs "put: on:"
- igouy 9y agoI asked hota_mazi to provide an example which demonstrated what they were talking about, to explain why they said "Smalltalk got it wrong by making all the parameter names mandatory". Are you hota_mazi ?
- hota_mazi 9y agoIn languages where parameter names are optional, you can say foo(1, 1, create = true) This is the best of both worlds, allowing you to only name parameters when there can be ambiguity (for example when the function takes two int parameters and both mean very different things). Smalltalk forces you to always name your parameters, which leads to overly verbose source files.
- igouy 9y agoI don't think any of us know what: foo(1, 1, create = true) :is supposed to do. Please show a meaningful example so we can see whether the Smalltalk is overly verbose or your alternative is overly ambiguous.
- hota_mazi 9y agoI tried to pick up an example as generic as possible so you could understand my general point instead of focusing on this specific example, and you choose to focus on this specific example. <sigh>. How about this: createWindowAtCoordinates(10, 10, redraw = true) vs createWindowAtCoordinates(x = 10, y = 10, redraw = true) Regardless of how you feel about this specific example, surely you can agree that it's not always necessary to specify all the parameter by names?
- Chaebixi 9y ago> metamodel is actually human reasoning friendly There's so much power in being able to think about a language (or your application) without having to always dig into the code.
- pmoriarty 9y ago"smalltalk cutest feature is the named parameter syntax trick..." make-range from: 10 to: 20 calss (make-range.from:to 10 20) or something similar. Free nanodsls For the uninitiated among us, what does that do and what's so magic about it?
- mathieuh 9y agoYou can put the parameter names in method calls, which makes for much more readable code. Like a makeRange method may take parameters `from` and `to`, when calling this method you could do `makeRange(from: 0, to:10)`. That’s a fairly trivial example but it demonstrates how readability is improved. You can imagine how this becomes even more useful with methods that take many parameters. An interesting document to look at regarding this is Swift’s guidelines on naming methods.
- pmoriarty 9y ago"You can put the parameter names in method calls, which makes for much more readable code. Like a makeRange method may take parameters `from` and `to` ... That’s a fairly trivial example but it demonstrates how readability is improved." Is that something like keyword arguments in Lisp?
- mbrock 9y agoExcept Smalltalk keywords can't be reordered or omitted. It's more like you put the arguments in the middle of the method name, like a kind of mixfix notation. The method name would be "rangeFrom:to:withStep:" and that means you call it exactly like that, with arguments after the colon. Objective C is the same.
- mpweiher 9y ago> makeRange(from: 0, to:10) [..] Swift’s guidelines on naming methods. The syntax you show is Swift, which is a weird mash-up of C/C++ style function call/method call syntax with keywords jammed into them. To me, actual Smalltalk syntax is just so much cleaner: 0 to: 10. It manages the "reads like english" trick without trying to be english-like or natural-language-like. (See Applescript for the disaster that results from that: "Many of the current problems in AppleScript can be traced to the use of syntax based on natural language" http://www.cs.utexas.edu/~wcook/Drafts/2006/ashopl.pdf http://www.cs.utexas.edu/~wcook/Drafts/2006/ashopl.pdf).
- kobeya 9y agoIt's out of favor now, but Objective-C? IIRC it was inspired by Smalltalk's message syntax.
- soapdog 9y agoThat was the feature I liked the most from my Objective-C days in the early versions of Mac OS X, it felt a bit like SmallTalk even if it was just named parameters and messages.
- masklinn 9y agoIt's not named parameters though, it's compound message/method names. The arguments are interspersed within the "bits" of the method unlike e.g. Python which has named parameters separate from the method name.
- cocktailpeanuts 9y agoThe problem with this argument is that LISP was popular when there was no need to build extremely complex systems with a programming language. So you could build simple data processing apps with LISP, but nowadays writing a program is not just about algorithms but in fact mostly about utilizing APIs provided by device and service vendors. When you build an iPhone app with Objective-C, you use the [object] [message] paradigm but it's still complex, and it's not because of the message passing paradigm itself, but because of the complex Cocoa APIs it needs to use.
- jcrites 9y agoLisp, Scheme, and Racket and related languages have many distinct syntax forms, just like other languages. The syntax forms appear visually similar due to the use of parentheses, but the forms themselves are distinct. For example, here are some of the distinct syntax forms in Racket (Scheme): (+ 3 4) # Procedure call (lambda (x) (+ x x)) # Lambda expression # See also case-lambda (let ((x 23) (y 42)) # Variable binding (+ x y)) # And also: # let*, letrec, letrec*, let-values, # let*-values, let-syntax, letrec-syntax, local (set! x 4) # Assignment (mutating) (define x 23) # Defined value (define (f x) # Defined procedure (+ x 42)) (quote a) # Quotation (#%datum . 10) # Quotation (keywords prohibited) # Conditionals (if (> 2 3) 'yes 'no) (cond ((> 3 2) 'greater) ((< 3 2) 'less)) (and a b) (or a b) (cond ('(1 2 3) => cadr) # Test clause (else #f)) # Else clause # Guarded evaluation (when (positive? -5) (display "hi")) (unless (positive? 5) (display "hi")) # Dispatch (case (+ 7 5) [(1 2 3) 'small] [(10 11 12) 'big]) # Sequencing (define x 0) (begin (set! x 5) (+ x 1)) # See also: begin0, begin-for-syntax # Iterations and Comprehensions # for, for/and, for/or, for/vector, for/hash, for/hasheq ... # Modules and imports (module id module-path form ...) (require ...) (provide ...) As you can see, although the language consistently uses parentheses, it has similar syntax structure to other languages: assignments, definitions, functions, switch/case, etc. Some of the syntax forms above have multiple variations, as well. See: https://docs.racket-lang.org/reference/syntax.html https://docs.racket-lang.org/reference/syntax.html
- merlincorey 9y agoI think your examples underscore the GP's point. Every single one of your examples is an S-Expression where the first element of the list is an operator/function followed by N arguments, from an abstract context-less view, anyway. In lisp there are atoms, lists, and expressions. They have uniform expression but not uniform meaning.
- 9y ago
- nerdponx 9y agoRuby is nice for this. It has message-passing OO and clean, minimal syntax.
- deleted 9y ago[deleted]