Live data from Hacker News

Tcl the Misunderstood (2006)

antirez.com

61–70 of 81 posts

Re: Tcl the Misunderstood (2006)

#61
post #38
post #23

Watching someone learns basics of programming in Python, I realized that Python is actually not that easy to learn for beginners as I thought: 1. Types in Python are implicit. It's really hard to explain that they need to always think about what type something is, especially when they haven't grasped the concept of types yet. 2. Indentation as part of the language. I thought it's a great thing for beginners, but it's…

I've seen beginners, especially those without a very strong maths background, struggle with the concept of syntax. The idea that you need to put the thing you want the program to do into a very specific form. That any deviation is an error, even though "it's clear" to humans. I think that's something fundamental beginners need to learn, regardless of the language they use. But once you accept that there are rules to…

>and compare it to the Python version.

The differences do start to diminish if you add some requirements like "print out the name of the script and the passed arguments then some message to stderr".

Re: Tcl the Misunderstood (2006)

#62
post #38
post #23

Watching someone learns basics of programming in Python, I realized that Python is actually not that easy to learn for beginners as I thought: 1. Types in Python are implicit. It's really hard to explain that they need to always think about what type something is, especially when they haven't grasped the concept of types yet. 2. Indentation as part of the language. I thought it's a great thing for beginners, but it's…

I've seen beginners, especially those without a very strong maths background, struggle with the concept of syntax. The idea that you need to put the thing you want the program to do into a very specific form. That any deviation is an error, even though "it's clear" to humans. I think that's something fundamental beginners need to learn, regardless of the language they use. But once you accept that there are rules to…

This is also perfectly valid c:

  main() 
  {
    printf("Hello world");
  }
Some details are hidden by the compiler, but Python isn’t exactly pure machine language either.

Semicolons and bracket are conceptually equivalent to significant white space (but more obviously explicit) and main is also a concept in Python (that is much more syntactically brutal than even its verbose c equivalent) that is hidden by the interpreter — which you also have to explain to beginners.

Compare with Python:

  import sys

  def main(args):
    print("hello %s" % (args[0]))
    sys.exit(0)

  if __name__ == "__main__":
    main(sys.argv[1:])
Which (of course) breaks when cut and pasting online

Re: Tcl the Misunderstood (2006)

#63
post #38

Earlier quoted context omitted.

I've seen beginners, especially those without a very strong maths background, struggle with the concept of syntax. The idea that you need to put the thing you want the program to do into a very specific form. That any deviation is an error, even though "it's clear" to humans. I think that's something fundamental beginners need to learn, regardless of the language they use. But once you accept that there are rules to…

This is also perfectly valid c: main() { printf("Hello world"); } Some details are hidden by the compiler, but Python isn’t exactly pure machine language either. Semicolons and bracket are conceptually equivalent to significant white space (but more obviously explicit) and main is also a concept in Python (that is much more syntactically brutal than even its verbose c equivalent) that is hidden by the interpreter — w…

Your modern compiler is unlikely to accept this code.

Re: Tcl the Misunderstood (2006)

#64
post #38
post #23

Watching someone learns basics of programming in Python, I realized that Python is actually not that easy to learn for beginners as I thought: 1. Types in Python are implicit. It's really hard to explain that they need to always think about what type something is, especially when they haven't grasped the concept of types yet. 2. Indentation as part of the language. I thought it's a great thing for beginners, but it's…

I've seen beginners, especially those without a very strong maths background, struggle with the concept of syntax. The idea that you need to put the thing you want the program to do into a very specific form. That any deviation is an error, even though "it's clear" to humans. I think that's something fundamental beginners need to learn, regardless of the language they use. But once you accept that there are rules to…

The problem is that Python encourages this "it's all cool, man" syntactic mindset. "Just indent your code the natural way, don't worry about all that extra syntax like curly braces." And then it comes back to bite you when your "formatting" causes syntax problems.

People are used to the idea of explicit delimiters, at least to some extent, thanks to punctuation. People are not at all used to whitespace having syntactic meaning. You can put as many spaces as you want between words, or sentences, or paragraphs, and it might look weird but it still means the same thing.

Semantic whitespace isn't a reduction in syntax, it just hides the syntax to fool you into thinking it isn't there, until it goes wrong and you suddenly have to debug it.

Re: Tcl the Misunderstood (2006)

#65
post #38

Earlier quoted context omitted.

I've seen beginners, especially those without a very strong maths background, struggle with the concept of syntax. The idea that you need to put the thing you want the program to do into a very specific form. That any deviation is an error, even though "it's clear" to humans. I think that's something fundamental beginners need to learn, regardless of the language they use. But once you accept that there are rules to…

When my mom was learning to program, she was annoyed that the computer did not recognize that "O" means zero, and "l" means one. Her old manual typewriter didn't have 0 and 1 keys. So her typing habit resulted in a lot of errors. Later she taught programming. The first thing she told students was: "Computers are dumb. They will only do exactly what you tell them."

I was lucky and that was also the first thing I learned about programming (with the amazing 80's "The Home Computer Course" magazine). I still remember the first program I read:

    10 REM Computers are never wrong
    20 PRINT "Please type a number"
    30 INPUT A
    40 LET A = A + 1
    50 PRINT "The number you typed was"
    60 PRINT A
After a few paragraphs of explanation I learned that computers do what you tell them to do, not what you want them to do.

Re: Tcl the Misunderstood (2006)

#66
post #38

Earlier quoted context omitted.

I've seen beginners, especially those without a very strong maths background, struggle with the concept of syntax. The idea that you need to put the thing you want the program to do into a very specific form. That any deviation is an error, even though "it's clear" to humans. I think that's something fundamental beginners need to learn, regardless of the language they use. But once you accept that there are rules to…

The problem is that Python encourages this "it's all cool, man" syntactic mindset. "Just indent your code the natural way, don't worry about all that extra syntax like curly braces." And then it comes back to bite you when your "formatting" causes syntax problems. People are used to the idea of explicit delimiters, at least to some extent, thanks to punctuation. People are not at all used to whitespace having syntact…

The problem is that Python encourages this "it's all cool, man" syntactic mindset.

It's not a problem, it's just a tradeoff. Like 97 percent of all the other differences between programming languages. As to whitespace in Python -- it was counterintuitive at first, but once I grokked the rationale behind it, I've never been tripped up by it (to an extent that it would slow my thinking for more than a second or two).

Every language has random $foo that you have to get used to and step around once in a while. If you don't like Python, fine, go back to C and bash. They'll be happy to welcome you back with open arms.

Re: Tcl the Misunderstood (2006)

#67
post #22

Tcl forces you to create new data, because you have to think and work harder to introduce effects on variables in upper scope through the use of uplevel and upvar. This reduces side effects significantly and makes data transformation explicit. Which, in turn, reduces cognitive load and increase productivity. Tcl also does not have distinguished NULL value like Python, C, C++, C# and many other languages. You do not h…

Does this non-existence of a no-value not only mean, that when there is no result value, another value (like false or empty string or empty list or whatever) will be used to express that fact, or that an exception is used? One would have to check for those in some cases as well. Those might not be always good alternatives reducing required checks. How does it work?

Let me offer you an example:

  proc maybe {onno onjust val} {
          if {[llength $val] == 2 && [string equal [lindex $val 0] Just]} {
                  lappend onjust [lrange $val 1 end]
                  return [uplevel $onjust]
          }
          # I cannot extract value
          return [uplevel $onno]
  }
  maybe {puts "---"} {puts } {Just "huh?"}
  maybe {puts "---"} {puts } {}
This is an example of custom control statement, modeled after Haskell's maybe [1].

[1] https://hackage.haskell.org/package/base-4.16.1.0/docs/Data-...

It is easy to use and write. You can follow algebraic data types convention and prefix values with tags and use something like control structure drafted above. I did that, it is relatively comfortable.

Note that special case of empty list also handled as if it is Nothing. So it is more useful than would appear. ;)

Re: Tcl the Misunderstood (2006)

#68
post #38

Earlier quoted context omitted.

I've seen beginners, especially those without a very strong maths background, struggle with the concept of syntax. The idea that you need to put the thing you want the program to do into a very specific form. That any deviation is an error, even though "it's clear" to humans. I think that's something fundamental beginners need to learn, regardless of the language they use. But once you accept that there are rules to…

The problem is that Python encourages this "it's all cool, man" syntactic mindset. "Just indent your code the natural way, don't worry about all that extra syntax like curly braces." And then it comes back to bite you when your "formatting" causes syntax problems. People are used to the idea of explicit delimiters, at least to some extent, thanks to punctuation. People are not at all used to whitespace having syntact…

Also:

You can put as many spaces as you want between words, or sentences, or paragraphs, and it might look weird but it still means the same thing.

No -- whitespace definitely has meaning in natural languages. It doesn't usually change the meaning much -- but it does affect it (where meaning of course includes tone and consideration for the reader's experience). Especially when it comes to the use of space between sentences and paragraphs.

As any good writer will tell you.

Re: Tcl the Misunderstood (2006)

#69
post #6

Quoted post unavailable.

> On-Topic: Anything that good hackers would find interesting. That includes more than hacking and startups. If you had to reduce it to a sentence, the answer might be: anything that gratifies one's intellectual curiosity. From the HN Guidelines. Note the lack of the pattern "new" anywhere in there.

  >Note the lack of the pattern "new" anywhere in there.

Er... it's literally the name of the site, 'Hacker NEWS'. A 16 year old article is not news. No matter how interesting it might be. The custom here is to put the year in brackets after the title, when posting an old article

Re: Tcl the Misunderstood (2006)

#70
post #23

Watching someone learns basics of programming in Python, I realized that Python is actually not that easy to learn for beginners as I thought: 1. Types in Python are implicit. It's really hard to explain that they need to always think about what type something is, especially when they haven't grasped the concept of types yet. 2. Indentation as part of the language. I thought it's a great thing for beginners, but it's…

I think Dart would be pretty easy for beginners.
Post reply on HN