if statements considered harmful: https://blog.deprogramandis.co.uk/2013/03/20/if-statements-c...
If-statements in Smalltalk (2008)
11–20 of 51 posts
Re: If-statements in Smalltalk (2008)
#12The 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…
Re: If-statements in Smalltalk (2008)
#13Re: If-statements in Smalltalk (2008)
#14First, 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…
Re: If-statements in Smalltalk (2008)
#15Including an if message that looks like if in C or similar language and and unless construct that looks like Ruby.
Re: If-statements in Smalltalk (2008)
#16Declarative 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)
#17Re: If-statements in Smalltalk (2008)
#18Re: If-statements in Smalltalk (2008)
#19First, 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.
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)
#20E.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.