Earlier quoted context omitted.
What the OP takes to the extreme is a property of weak typing, not dynamic typing. These properties are separate issues. A language is either statically typed or dynamically typed, and it is also either strongly typed or weakly typed. In a statically typed language, types are attached to variables. In a dynamically typed language, types are attached to values. Do note that many languages don't fit 100% into either ca…
> In a statically typed language, types are attached to variables. More precisely, expressions may be typed. Of course, free variables are one particular of expression. > In a dynamically typed language, types are attached to values. More precisely, tags are attached to objects . An object is a “physical” entity that exists in space (computer memory) and time (from its construction to its destruction or garbage colle…
A Javascript journey with only six characters
111–120 of 123 posts
Re: A Javascript journey with only six characters
#112> Javascript is a weird and wondeful language that lets us write some crazy code Wondeful! A typo six words in.
Re: A Javascript journey with only six characters
#113Re: A Javascript journey with only six characters
#114I'm a fan of Javascript. It has proper lambdas, true lexical scope, will soon have TCO, and is a really flexable language. But it's not without its warts, and this is one of the worst. Although it's sometimes fun to mess with, nonetheless. To see this taken to one of its logical extremes, check out If Hemmingway Wrote Javascript's entry for Douglas Adams: // Here I am, brain the size of a planet, and they ask me to w…
For those of you too lazy to open up a Javascript console, it's a function that returns "42".
Re: A Javascript journey with only six characters
#115Earlier quoted context omitted.
> In a statically typed language, types are attached to variables. More precisely, expressions may be typed. Of course, free variables are one particular of expression. > In a dynamically typed language, types are attached to values. More precisely, tags are attached to objects . An object is a “physical” entity that exists in space (computer memory) and time (from its construction to its destruction or garbage colle…
In a dynamic language, you have to wait until runtime to decide whether an operation is valid or not. Only then can you check an object's tag to see if it proclaims the right type. If it doesn't, non-local exit (of which the exception is the most popular form), is still the best you can do. So, cum grano salis, throwing an exception is a dynamic language's way of disallowing invalid operations.
Re: A Javascript journey with only six characters
#116I'm a fan of Javascript. It has proper lambdas, true lexical scope, will soon have TCO, and is a really flexable language. But it's not without its warts, and this is one of the worst. Although it's sometimes fun to mess with, nonetheless. To see this taken to one of its logical extremes, check out If Hemmingway Wrote Javascript's entry for Douglas Adams: // Here I am, brain the size of a planet, and they ask me to w…
For those of you too lazy to open up a Javascript console, it's a function that returns "42".
Re: A Javascript journey with only six characters
#117Earlier quoted context omitted.
In a dynamic language, you have to wait until runtime to decide whether an operation is valid or not. Only then can you check an object's tag to see if it proclaims the right type. If it doesn't, non-local exit (of which the exception is the most popular form), is still the best you can do. So, cum grano salis, throwing an exception is a dynamic language's way of disallowing invalid operations.
This isn't true. Throwing an exception is a perfectly valid operation. Of course, it is not the operation you want, but that's a-whole-nother matter.
How does your dynamic language tell its user an operation is invalid, based on argument type?
Re: A Javascript journey with only six characters
#118Earlier quoted context omitted.
Niel Fraser, the guy who created the Blockly block programming toolkit also created a JS Interpreter which allows single stepping of code. https://neil.fraser.name/software/JS-Interpreter/docs.html
I've hacked on this interpreter some, it's pretty nice to read! It implements a very limited subset of JavaScript, something like ES3. I'd be really interested to hear about other similar implementations of JavaScript in JavaScript. I stopped working on https://github.com/thomasballinger/hotswapping-js-interp#js-... partially because copying the state of the interpreter was relatively slow. I'd be interested in imple…
Re: A Javascript journey with only six characters
#119Earlier quoted context omitted.
This isn't true. Throwing an exception is a perfectly valid operation. Of course, it is not the operation you want, but that's a-whole-nother matter.
I didn't say throwing an exception is an invalid operation. How does your dynamic language tell its user an operation is invalid, based on argument type?
It doesn't! That's exactly the point. If something is invalid, then it can't happen. At all.
Re: A Javascript journey with only six characters
#120Earlier quoted context omitted.
I didn't say throwing an exception is an invalid operation. How does your dynamic language tell its user an operation is invalid, based on argument type?
> How does your dynamic language tell its user an operation is invalid, based on argument type? It doesn't! That's exactly the point. If something is invalid, then it can't happen. At all.