Live data from Hacker News

If-statements in Smalltalk (2008)

pozorvlak.livejournal.com

11–20 of 51 posts

Re: If-statements in Smalltalk (2008)

#12
post #7

The explanation is almost correct, but misses a tiny, but interesting detail. Subclasses of Boolean do implement #ifTrue: and #ifFalse:, wich each take a block (a no-argument function) as an argument. But they also implement #ifTrue:ifFalse:, which takes two blocks as arguments. In a a single message (#ifTrue:ifFalse:) is sent to the boolean that results from evaluating 'a Coming from Pascal and C, seeing that IF/ELS…

There should be no colon after the predicate (i.e., after the "b").

Re: If-statements in Smalltalk (2008)

#14

First, I did not know this, it's pretty cool. But, for all the fangled cool things that the more powerful languages of yesteryears (like lisp), what seems to actually precipitate adoption is simply history, not necessarily expressiveness/powerful abstractions, etc. See C, sh and friends, javascript. Arguably, python is one where its ease made it popular and it continues to develop language wise, albeit not without co…

I was drawn to python because of the culture (simple, documentation) and I stay because of the libraries (machine learning, scientific). The language just needs to be better than Matlab or R (not Scheme, Clojure, Scala or pick your favorite one). As in nature the language that thrives is the fittest for its environment, not the most powerful.

Re: If-statements in Smalltalk (2008)

#15
Years ago I started (and didn't get very far) on a pointless project to make Smalltalk look a bit more conventional without breaking how it works.

Including an if message that looks like if in C or similar language and and unless construct that looks like Ruby.

https://github.com/threehv/gstr/blob/master/README.markdown

Re: If-statements in Smalltalk (2008)

#16
Fascinating. An amazing point about design patterns, and yet...

Declarative statements are a pattern in ruby - you see them everywhere (`attr_accessor`). They're library code - you're intended to write them. I can't imagine trying to write ruby without that pattern, and I can't imagine them not being a design pattern.

Similarly - the MVC of Rails. The lines get way fuzzier, but you still might try to draw similar lines to separate the core framework (badly analogous to the language) from, I guess, all the gems you end up using (badly analogous to the library). Is MVC a pattern? Or under this bad analogy, a language construct...?

Re: If-statements in Smalltalk (2008)

#19
post #14

First, I did not know this, it's pretty cool. But, for all the fangled cool things that the more powerful languages of yesteryears (like lisp), what seems to actually precipitate adoption is simply history, not necessarily expressiveness/powerful abstractions, etc. See C, sh and friends, javascript. Arguably, python is one where its ease made it popular and it continues to develop language wise, albeit not without co…

I was drawn to python because of the culture (simple, documentation) and I stay because of the libraries (machine learning, scientific). The language just needs to be better than Matlab or R (not Scheme, Clojure, Scala or pick your favorite one). As in nature the language that thrives is the fittest for its environment, not the most powerful.

> As in nature the language that thrives is the fittest for its environment, not the most powerful.

Now hold on. The most successful sprog of nature is humanity[citation needed] and we're a case study in the fact that raw intelligence is more effective than fitness for any particular niche. So: as in nature, there may be a bunch of niche languages, but in time they'll find themselves with a conservation status while a smart language rules the earth.

Re: If-statements in Smalltalk (2008)

#20
Since if-statements are built out of blocks and message sending, you can easily do some cool things. One of them is building up an abstract syntax tree (AST) of an expression without parsing that expression.

E.g. suppose you want to build up an AST of the statement

  (x 
Instead of starting with an x of type Number, you would start with an object of type ASTVariable, that responds to the message As an sexp:

  (ASTIfStatement
    :condition (ASTLessThan #1=(ASTVariable :name x) (ASTConstant :value 0))
    :consequent (ASTUnaryMinus #1#)
    :alternative #1#)

I've seen it used in a number of embedded languages in Smalltalk, such as SQL.
Post reply on HN