MudBytes
» MUDBytes Community » Coding Discussions » Coding and Design » language written in javascript
Pages: << prev 1, 2 next >>
language written in javascript
Runter
Wizard






Group: Developer
Posts: 3,412
Joined: Jun 1, 2006

Go to the bottom of the page Go to the top of the page
#16 id:60225 Posted Jan 21, 2012, 9:00 pm


Deimos said:
@David:  Of course if all he needs is to juggle element values then "limiting" the syntax to what he is suggesting makes sense, but I don't buy that that is the entirety of the use case.  And even if it's not, are you really in disagreement that creating an all new language just so you can use "obj.thing" syntax instead of "obj.thing.value" is bordering on the absurd?  Maybe I was being too kind when I suggested that he'd be losing a little flexibility - more like all flexibility :-p


I don't know how much value his specific language has, but the underlying technique he is discussing to create a new language is completely legitimate and effective.  I think David was pointing out the absurdity of dismissing simplifying syntax in general.  Not this specific case.  In other words, he's saying it's not always a bad idea... And that's what it seems like others have postulated.  And I agree with him. 

David Haley
Wizard






Group: Members
Posts: 7,841
Joined: Jun 30, 2007

Go to the bottom of the page Go to the top of the page
#17 id:60226 Posted Jan 21, 2012, 9:18 pm

Runter said:
I think David was pointing out the absurdity of dismissing simplifying syntax in general.  Not this specific case.  In other words, he's saying it's not always a bad idea... And that's what it seems like others have postulated.  And I agree with him.

Yes, exactly.

Deimos said:
And even if it's not, are you really in disagreement that creating an all new language just so you can use "obj.thing" syntax instead of "obj.thing.value" is bordering on the absurd?

That's not the exact thing that he was doing, but regardless, I was assuming that there was going to be more to the story.

Even so, if an operation is extremely common, then no, it's not really absurd to have a language derivative that lets you simplify the syntax for that particular operation. You can see this happening in the evolution of C++ and Java; for instance, the auto type that lets you say "just give me the #### variable and you know what the type is". (And of course, other things were happening too.)
.........................
-- d.c.h --
BabbleMUD Project (custom codebase)
Legends of the Darkstone (head coder)
http://david.the-haleys.org
.........................

Rarva.Riendf
Wizard




Group: Members
Posts: 1,289
Joined: Jul 15, 2010

Go to the bottom of the page Go to the top of the page
#18 id:60227 Posted Jan 22, 2012, 6:10 am


David Haley said:
Rarva, you have reduced the point to such an absurdity that of course it sounds silly. Do you want to come back to the actual point now? :smile:


Was just sayig that saving on syntax is often possible, (and done) as my example was showing.
I actually prefer the visual clue of () to limit a test case, a ; to end a line (as you have sometimes multiple line because of wrapping even if it is only one line of code) and {} to limit code block, and not some text that blend with everything else (even if colored in an IDE)

And for Runter: I hate everything about Javascript anyway...including its syntax.

David Haley
Wizard






Group: Members
Posts: 7,841
Joined: Jun 30, 2007

Go to the bottom of the page Go to the top of the page
#19 id:60228 Posted Jan 22, 2012, 10:44 am

Rarva said:
Was just sayig that saving on syntax is often possible, (and done) as my example was showing.

Well, you also said that reducing syntax was just changing variable names to be 2-4 characters long, which is a non-sequitur.

All your example showed is that one language has more symbols than the other for delimiting blocks and expressions. It wasn't really showing any interesting syntax changes per se.
.........................
-- d.c.h --
BabbleMUD Project (custom codebase)
Legends of the Darkstone (head coder)
http://david.the-haleys.org
.........................

Rarva.Riendf
Wizard




Group: Members
Posts: 1,289
Joined: Jul 15, 2010

Go to the bottom of the page Go to the top of the page
#20 id:60229 Posted Jan 22, 2012, 11:20 am

David Haley said:
Well, you also said that reducing syntax was just changing variable names to be 2-4 characters long, which is a non-sequitur.
All your example showed is that one language has more symbols than the other for delimiting blocks and expressions. It wasn't really showing any interesting syntax changes per se.


I did not say that:I said that saving keystroke was not a goal And my example was about saving keystroke.
(The fact you do no find this change in syntax interesting is your opinion, I find it very annoying to read Lua code because of those lack of delimiters)
Sometimes verbose syntax can be useful to be able to concetrate on the mean, because this way you dont have think of everything that is implied instead of stated. The difficulty is to find a good middle ground.

Last edited Jan 22, 2012, 11:21 am by Rarva.Riendf
David Haley
Wizard






Group: Members
Posts: 7,841
Joined: Jun 30, 2007

Go to the bottom of the page Go to the top of the page
#21 id:60235 Posted Jan 22, 2012, 6:43 pm

I'm not sure where I said that saving keystrokes for the sake of saving keystrokes was the only goal, but ok. I'm glad that we're agreed that making variable names be 2-4 characters is a little absurd.

And you don't really understand what I meant by interesting change in syntax. Something like what Runter gave is interesting. Or, having a for loop to construct a new list, vs. a list comprehension.
.........................
-- d.c.h --
BabbleMUD Project (custom codebase)
Legends of the Darkstone (head coder)
http://david.the-haleys.org
.........................

JohnnyStarr
Wizard






Group: Members
Posts: 996
Joined: Feb 14, 2009

Go to the bottom of the page Go to the top of the page
#22 id:60245 Posted Jan 23, 2012, 1:00 pm

Perhaps it was a tall-order to expect everyone to infer what the derivative language was offering.
I was proposing more than the equivalent of C's typedef functionality - although I see that
I didn't do so effectively.

I'm glad that Runter and David seem to see some potential in the idea.  My ultimate goal is to do
something that hasn't been done before to benefit the web community.
.........................
http://3.bp.blogspot.com/-RdaO2sGy6Jo/UXqmRANiPpI/AAAAAAAAARM/FkgyUR1PIuc/s1600/starrlab-logo.png

Last edited Jan 23, 2012, 1:00 pm by JohnnyStarr
Chris Bailey
Wizard




Group: Members
Posts: 856
Joined: Sep 12, 2008

Go to the bottom of the page Go to the top of the page
#23 id:60251 Posted Jan 23, 2012, 10:12 pm

What is the thing you are going to do that hasn't been done before? =)
.........................
If what Proust says is true, that happiness is the absence of fever, then I will never know happiness. For I am possessed by a fever for knowledge, experience, and creation.

Rarva.Riendf
Wizard




Group: Members
Posts: 1,289
Joined: Jul 15, 2010

Go to the bottom of the page Go to the top of the page
#24 id:60252 Posted Jan 24, 2012, 4:06 am

David Haley said:

And you don't really understand what I meant by interesting change in syntax. Something like what Runter gave is interesting. Or, having a for loop to construct a new list, vs. a list comprehension.

I did, the world interesting is totally opinion based.
The syntax and everything about Javascript is awful anyway, so picking it as an example is like the Godwin of langage.
To get back to loop, most langage will have multiple way of doing them, but in the end, what really matters to me is not the few seconds I could win by typing a little less key, than the hours I will lose when I read code and try to see where it begins or end when I maintain code. Readibility is more important than some keystroke. Hence long variable Name. saving on syntax often means less visible visual clue about what the code does.

Javascript (bloody awful)
var txt = document.getElementById("thing").value;

what prevents you from creating a function get(value)
var txt = get("thing")

where function would be
get(xxx)
return document.getElementById(xxx).value;

Really....


David Haley
Wizard






Group: Members
Posts: 7,841
Joined: Jun 30, 2007

Go to the bottom of the page Go to the top of the page
#25 id:60260 Posted Jan 24, 2012, 9:19 am

Rarva said:
I did, the world interesting is totally opinion based.

Like I said, and as I believe even more after reading your reply, I think you didn't. I was using more of a mathematical definition of "interesting". Adding a curly brace isn't really transformative. The list comprehension is a very different way of expressing things.

You keep talking about variable names as if that's what's relevant when discussing syntactic shortcuts. But you're the only one who seems to care about that and are the only one who keeps talking about it. Do you know what list comprehensions are? I think that if you had more experience in a bunch of languages, the argument would be very clear to you.

Rarva said:
The syntax and everything about Javascript is awful anyway, so picking it as an example is like the Godwin of langage.

I am amused that you talk so much about things being opinion-based and then you say something like this.
.........................
-- d.c.h --
BabbleMUD Project (custom codebase)
Legends of the Darkstone (head coder)
http://david.the-haleys.org
.........................

Runter
Wizard






Group: Developer
Posts: 3,412
Joined: Jun 1, 2006

Go to the bottom of the page Go to the top of the page
#26 id:60262 Posted Jan 24, 2012, 10:04 am

Rarva, that has nothing to do with the language syntax.  That's a browser dom function and it's not part of the EMCAscript specification.  So that was a terrible choice to use as an example since it's not even actually javascript but specific library implementation.  Evidenced by the fact that you replaced it with perfectly valid javascript. 

Furthermore, there's a lot to like about javascript, and frankly, I think for most purposes it's a superior tool to something like C. 

Deimos
Sorcerer






Group: Members
Posts: 403
Joined: Mar 8, 2010

Go to the bottom of the page Go to the top of the page
#27 id:60271 Posted Jan 24, 2012, 5:27 pm

@David:  Simplifying syntax is great, but you can't simplify it beyond a certain point without losing flexibility.  In this case, he wants to be able to do "element" and that be the value, instead of "element.value", but how then do you access the actual element to do other things with it?  In normal JS you can do "element.name", "element.type", "element.disabled", etc.  If "element" is no longer the actual element, then you either lose the ability to do much of anything, or you have to provide alternate syntax.

I guess I just don't see the benefit, is all.  Not for the cost, anyway.
.........................
Any sufficiently advanced magic will run circles around technology.

Runter
Wizard






Group: Developer
Posts: 3,412
Joined: Jun 1, 2006

Go to the bottom of the page Go to the top of the page
#28 id:60272 Posted Jan 24, 2012, 6:01 pm

Well, I agree this specific proposed change to the library isn't well thought out.  Fundamentally the issue here is we're dealing with javascript objects:

Code ("javascript"):
  obj = {
    value:  "lol",
    somethingElse: "notLol"
  };

  console.log(obj.value);

/* incidentally can also, and often times must be, written */
  console.log(obj["value"]);


So we can see that above that objects are basically associative arrays.  Once one understands that the dom functions are actually just using the language object constructs it becomes much more clear why you need .value appended.  Because value isn't dereferencing obj, it's actually just an attribute on the object.

Rarva.Riendf
Wizard




Group: Members
Posts: 1,289
Joined: Jul 15, 2010

Go to the bottom of the page Go to the top of the page
#29 id:60277 Posted Jan 25, 2012, 3:05 am


Runter said:
Rarva, that has nothing to do with the language syntax.  That's a browser dom function and it's not part of the EMCAscript specification.  So that was a terrible choice to use as an example since it's not even actually javascript but specific library implementation.  Evidenced by the fact that you replaced it with perfectly valid javascript. 

Furthermore, there's a lot to like about javascript, and frankly, I think for most purposes it's a superior tool to something like C. 

It is a superior tool to C, does not mean it is a nice langage. It has evolved to something it was not intended to do in the first place.

Quote:
I am amused that you talk so much about things being opinion-based and then you say something like this.

Cause I do not deny it is my opinion, and I accept you can dismiss it as 'not being intersting' if you wish so...I am familar with C, Java, C++, Some Lua, Some Javascript, Old version of VisualBasic, Pascal, 68k Assembler, LISP.....You find brace and symbols are not interesting when you talk about syntax ? Well I hate to read C++ when I never know what + is actually doing....
The one I prefer from all that still is Java, but that does not mean it is a panacea (I think I would like C# better now from what I read about it). Because it is a quite naturally readable langage, you dont need to 'think' about every implied hided syntax or too complicated initialization mecanism to understand what it actually does. (every langage that changes their output depending on contex call are better left to the domain they are actually needed)


David Haley
Wizard






Group: Members
Posts: 7,841
Joined: Jun 30, 2007

Go to the bottom of the page Go to the top of the page
#30 id:60299 Posted Jan 25, 2012, 4:48 pm

Deimos said:
@David:  Simplifying syntax is great, but you can't simplify it beyond a certain point without losing flexibility.

Sure. I never said that simplification never entails loss of flexibility. I did however say that sometimes you don't need that flexibility, but I am not sure if this particular case is such an instance.
.........................
-- d.c.h --
BabbleMUD Project (custom codebase)
Legends of the Darkstone (head coder)
http://david.the-haleys.org
.........................

Pages:<< prev 1, 2 next >>