|
|
View previous topic - View next topic |
Author |
Message |
tcaudilllg Dragonmaster
Joined: 20 Jun 2002 Posts: 1731 Location: Cedar Bluff, VA
|
Posted: Fri Feb 25, 2005 9:55 pm Post subject: Dyne |
[quote] |
|
I updated Dyne's draft. The line dumper works (with a bug or two) and the object dumper is partially functional.
Now working on the standard library at http://unitedinfinity.atspace.com/Projects/Dyne/StandardLibrary.dyn
Dyne's draft is at http://unitedinfinity.atspace.com/Projects/JS/Languages/DyneJS.html . It does not work in Internet Explorer.
Help is wanted with the standard library. Contributions will be credited.
Supported commands:
Variables are declared by using them. They have no type. Assignment is by the "=" operator, as in C and BASIC.
create [source] : [object]
creates a new object after the architecture described in source. Object architecture is patterned after the Javascript form, as a string:
"[name] { [children] { [children of child] } }".
vio [name] [ ["="] [variable] ]
vio [name] [parameters]
Virtual input/output. Executes the string in "name" as Javascript source. Can also assign "variable" to a Javascript object.
while () { }
Standard ANSI C-form while loop.
if () { }
Standard ANSI C if loop
field ([alias] = [source], [...]) : [body]
aliases "alias" for "source" in body of the loop. "body" may be any statement or compound statement. Compound fields are possible.
: [name] [prototype]
Assigns the current line number to "name", creating a subcall procedure with "prototype".
call [name] [parameters]
invokes the subcall at "name" with provided parameters.
Whitespacing spacebreaks and newlines are ignored. Code style is freeform.
Last edited by tcaudilllg on Sun Feb 27, 2005 9:59 pm; edited 1 time in total
|
|
Back to top |
|
|
LeoDraco Demon Hunter
Joined: 24 Jun 2003 Posts: 584 Location: Riverside, South Cali
|
Posted: Fri Feb 25, 2005 11:54 pm Post subject: Re: Dyne |
[quote] |
|
LordGalbalan wrote: | Variables are declared by using them. They have no type. |
Personally, I really dislike untyped languages. Which, I suppose, is odd, seeing as I like PHP. Still, there is something to be said about type-safety: a coder knows that anyone using his language won't bork something due to stupid usage.
Type safety is something that can be achieved transparently (that is, implicitly). For instance, take a look at ML in which types for a given variable are determined by type inference.
(Edited because it didn't make sense.) _________________ "...LeoDraco is a pompus git..." -- Mandrake
Last edited by LeoDraco on Sat Feb 26, 2005 7:44 am; edited 1 time in total
|
|
Back to top |
|
|
Rainer Deyke Demon Hunter
Joined: 05 Jun 2002 Posts: 672
|
Posted: Sat Feb 26, 2005 1:46 am Post subject: Re: Dyne |
[quote] |
|
LeoDraco wrote: | Personally, I really dislike untyped languages. |
Don't confuse dynamically typed languages with untyped languages. In a dynamically typed language such as PHP, values/objects have types, but any variable can hold any value. In an untyped language, there are no distinct types at all.
|
|
Back to top |
|
|
LeoDraco Demon Hunter
Joined: 24 Jun 2003 Posts: 584 Location: Riverside, South Cali
|
Posted: Sat Feb 26, 2005 2:11 am Post subject: Re: Dyne |
[quote] |
|
Rainer Deyke wrote: | Don't confuse dynamically typed languages with untyped languages. In a dynamically typed language such as PHP, values/objects have types, but any variable can hold any value. In an untyped language, there are no distinct types at all. |
Heh. I figured there was something wrong when I wrote that. However, my bias still remains.
Edit: I don't think the distinction you are making is valid. _________________ "...LeoDraco is a pompus git..." -- Mandrake
|
|
Back to top |
|
|
janus Mage
Joined: 29 Jun 2002 Posts: 464 Location: Issaquah, WA
|
Posted: Sat Feb 26, 2005 4:50 am Post subject: Re: Dyne |
[quote] |
|
Rainer Deyke wrote: | In an untyped language, there are no distinct types at all. |
I'm pretty sure that's a theoretical impossibility.
Unless you're talking about languages like Brainfuck, in which data and code are a part of the same stream of characters... in which case, that's a pretty bizarre distinction.
|
|
Back to top |
|
|
PhyrFox Tenshi's Bitch (Peach says "Suck it!")
Joined: 19 Nov 2004 Posts: 64 Location: New York, USA
|
Posted: Sat Feb 26, 2005 5:38 am Post subject: |
[quote] |
|
Implicit typing is different than no typing. BASIC, for example, has implied typing... A$ is not A, and A has to have a number, A$ is a string. So you can not do A$ = 20 or A = "Hello". I remember seeing one language (I don't remember which) which let you assign any type to a variable, but you couldn't change it (the variable type) later.
Non-typed languages, like JavaScript, you can do a = 5 and immediately follow with a = "Hello", or even a = "Hello" + 5. (you can do this with overloaded operators, too, but that's beyond the scope of this discussion). With no typing at all, you can easily make coding mistakes, since there's nothing to stop you. The computer won't say "hey, this code might be wrong!" with non-typed languages, instead of typed or implicitly typed typed, which allow manual or automatic conversions (explictly or implicitly, depending).
So that's that. Non-typed provides easiest code writing, but allows the greatest about of logic errors, implicit typing is a middleground for the two extremes, and explicit typing is the most complex to make conversions, but has the least chance of failure.
~= phyrfox =~
|
|
Back to top |
|
|
Rainer Deyke Demon Hunter
Joined: 05 Jun 2002 Posts: 672
|
Posted: Sat Feb 26, 2005 9:19 am Post subject: Re: Dyne |
[quote] |
|
janus wrote: | I'm pretty sure that's a theoretical impossibility. |
Not really. Many assembly languages are like this. Io is almost typeless - everything is an object, and there are no classes - although technically it does have a concept of types.
Quote: | Non-typed languages, like JavaScript, |
Javascript is (dynamically) typed.
|
|
Back to top |
|
|
LeoDraco Demon Hunter
Joined: 24 Jun 2003 Posts: 584 Location: Riverside, South Cali
|
Posted: Sat Feb 26, 2005 9:57 am Post subject: Re: Dyne |
[quote] |
|
Rainer Deyke wrote: | Quote: | Non-typed languages, like JavaScript, |
Javascript is (dynamically) typed. |
Which is the point: there really is no such thing as non-typed languages*; "untyped" is practically synonymous with dynamic typing. Even in your assembly example, there is the implied storage "type" that all computers operate on: the "byte" (or "word", or, even, "bit", depending on the processor/memory). I call shenanigans.
*caveat: that I have seen. Show me an example, and I'll be willing to cede the point. _________________ "...LeoDraco is a pompus git..." -- Mandrake
|
|
Back to top |
|
|
PhyrFox Tenshi's Bitch (Peach says "Suck it!")
Joined: 19 Nov 2004 Posts: 64 Location: New York, USA
|
Posted: Sat Feb 26, 2005 8:59 pm Post subject: Re: Dyne |
[quote] |
|
LeoDraco wrote: | Rainer Deyke wrote: | Quote: | Non-typed languages, like JavaScript, |
Javascript is (dynamically) typed. |
Which is the point: there really is no such thing as non-typed languages*; "untyped" is practically synonymous with dynamic typing. Even in your assembly example, there is the implied storage "type" that all computers operate on: the "byte" (or "word", or, even, "bit", depending on the processor/memory). I call shenanigans.
*caveat: that I have seen. Show me an example, and I'll be willing to cede the point. |
Well, see, "dynamic" typing would imply that there is some sort of type checking going on. A "type" makes sure that one thing does not become something else. Every variable has a size. A size is not a type. It's a unit of storage. True, you can not store a word in a byte or a byte in a word (without conversion), it is easy to make type-conversions because the data has no type and is therefore interpreted by the operation performed.
For example, numbers in assembler are, both at once, signed and unsigned. Depending on which machine code instructions you use, a word could be signed or unsigned, or even a floating point or fixed point. A word could also be two letters or a unicode letter.
This means that, if you make an incorrect line of code somewhere (say, you used a pointer as a number unintentionally, or you interpreted a unicode string as a ASCII string), you will not be informed of the error until the program crashes or has some elusive bug to be found.
In a strongly typed language, such conversions can not be "accidently" performed; that is, you have to willingly convert them between types. In some cases, the conversion is completely impossible without a helper function.
So, it can be said that JavaScript does have dynamic typing, but it really has no virtually no type-checking at all. Typing is a means of catching logic errors; without type-checking you can make all sorts of interesting mistakes. Even more so, ASM has no typing whatsoever, only storage sizes. You can freely make a pointer into a word, a number, a structure, or anything else, without even realizing you made the conversion.
Strongly-typed languages require you declare what each type of variable is, and it is nearly impossible to convert one thing to another using only one line of code (without helper functions). Loosely-typed ("dynamically typed") languages allow flexibility, being able to convert data types that make sense (like, a number to a string, or the other way around), but also allows more errors. JavaScript practically goes off the far end, though, because I don't think I've ever seen a type-conversion error. And languages like ASM don't do any type checking, so you can move any data anywhere you want, and freely crash your program or introduce glitches.
~= phyrfox =~
|
|
Back to top |
|
|
tcaudilllg Dragonmaster
Joined: 20 Jun 2002 Posts: 1731 Location: Cedar Bluff, VA
|
Posted: Sun Feb 27, 2005 9:45 pm Post subject: |
[quote] |
|
Fixed the line dumper and object dumper. (but have not updated the changes)
...Variables aren't being stored. :P Created, not stored. Must have something to do with the computation engine I wrote to deal with things like parentheses, and the order of operations.
EDIT: Variable storage is fixed, but the computation engine may not be performing the order of operations correctly, maybe....
|
|
Back to top |
|
|
tsb I wanna be a ballerina!
Joined: 09 Oct 2004 Posts: 23
|
Posted: Wed Mar 02, 2005 7:46 pm Post subject: Re: Dyne |
[quote] |
|
PhyrFox wrote: | So, it can be said that JavaScript does have dynamic typing, but it really has no virtually no type-checking at all. Typing is a means of catching logic errors; without type-checking you can make all sorts of interesting mistakes. Even more so, ASM has no typing whatsoever, only storage sizes. You can freely make a pointer into a word, a number, a structure, or anything else, without even realizing you made the conversion. |
It seems strange, but JS has a stronger type system than C++ does. C++ allows you to reinterpret values into other types at will in numerous ways, and generally make a big mess.
JavaScript always does complete checking on every operation that ever happens during its execution. More importantly, it does this testing in a way that's fundamentally closer to what programmers really need: rather than demanding specific types by name, JS demands that behaviours be implemented. Any JS object that supports all the same operations as an integer is an integer in every way that counts. This enables a level of flexibility that statically typed languages simply can't touch, but it comes at a price: static analysis becomes difficult enough that implementations are hard to come by. (I think there are Lisp and Smalltalk compilers that do it)
Now, this lack of static analysis can indeed be the source of many a bug, but it's not as important as one may instinctively think. Sure, the compiler can tell you that all your types are used consistently, but that doesn't come close to saying that your program works correctly: you still have to test.
Dynamically typed languages work because they're easier to write; programmers can get their code written faster, which means they can test using real data sooner. This does mean that unit tests are more or less mandatory, but that's already true anyway. ;) _________________ —andy
http://ika.sf.net
|
|
Back to top |
|
|
|
Page 1 of 1 |
All times are GMT
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|