JSONx is Sexy LIESx


  • Discourse touched me in a no-no place

    @ben_lubar said:

    "eslo oma" means "climate bloat" in elf

    I knew those pesky elves voted Democrat!


  • Discourse touched me in a no-no place

    @ben_lubar said:

    ûd means "CHAOS" in GOBLIN or "TO HARVEST" in DWARF or "TO SCALE" in GOBLIN

    Clearly the game needs to make more extensive use of Unicode, and use different alphabets for different languages. Are Tolkien's orcish and Quenya[1] in Unicode yet?

    [1] or whatever he called it, it's been 20+ years since I last read LOTR.


  • FoxDev

    I'm not seeing the issue here. obviously the words are context dependent within their language. of the list you provided only one word spans multiple languages.



  • The game uses CP437, so the number of code points in Unicode is irrelevant.


  • Discourse touched me in a no-no place

    @ben_lubar said:

    The game uses CP437, so the number of code points in Unicode is irrelevant.

    Ah, well, just use line-drawing characters or something. People who think that's a problem can use a replacement font.



  • Replacement fonts generally look something like this:


  • Discourse touched me in a no-no place

    So? Change some of the glyphs, uh, depending on whether or not it's speech being displayed.



  • That's something that can be done using a plugin for a memory hacking utility that pretends to be a graphics library. Unfortunately, I don't know of any custom fonts that support it.


  • Discourse touched me in a no-no place

    @ben_lubar said:

    Unfortunately, I don't know of any custom fonts that support it.

    The Bay12 people can always use the Apple line about backward compatibility.



  • It's a config setting. tileset is your graphics font, and twbt_tileset is your text font (not actual names). Don't have a text font? There's a link, from that very page, to an online tool to generate one for you. In JavaScript. From the fonts on your own computer. Believe me, you're covered.


  • FoxDev

    @FrostCat said:

    The Bay12 people can always use the Apple line about backward compatibility.

    Apple: What's backwards compatibility?



  • But the graphical fonts don't have specific glyphs for each animal and profession, whereas twbt wants the creature "cat" to associate with a glyph for "cat" instead of every single letter c being a cat.



  • @tar said:

    So use the native sparse array of your choice in your runtime, and when the time comes, dump it into a JSON object. You ought to be able to losslessy roundtrip your data in either direction. Everybody wins! Great success!

    We're far enough into this that I suppose I should be gracious with people who have forgotten the point of the OP.

    It's not that this behaviour cannot be handled; it's that a small modification to the spec would make handling it easier. Also, without modifying the software of the server, which I am specifically not being paid to do (and which would introduce support issues), I cannot losslessly communicate the data without introducing a great deal of boilerplate to translate native JS arrays into something else in JSON and then back. I'm communicating JS to JS, and it's only a small omission in the JSON spec that breaks the perfect communication of array content.

    @Jaime said:

    It's not about apocalyptic consequences - it's about the fact that the only feature of JSON that gave it the market position it has today was the ease of implementation in JavaScript ten years ago. If it were any more complex than it is (a trivial/naive deserializer is just an eval() call), it wouldn't have "won".

    Nothing I am suggesting is difficult to implement in JSON without changing any of that, even assuming it is the whole story.

    @Jaime said:

    You want a smart deserializer, but JSON was designed around a dumb one. It wasn't designed to be good, not to be flexible, it was designed to work reliably in 2001 - which wasn't easy at the time. If you want something better, choose a different format. JSON has so many implementations that any proposed enhancements will take many years to trickle into the real world.

    What I want is a serializer that is one step closer to what it purports to be. A user request that is easy to implement, reasonable, and makes the product fit better into its context is not only rare, but practically unheard of. I have yet to see a good reason that fixing JSON array representation couldn't be done.

    Remember, I am only suggesting JSON serialize arrays properly; none of the other suggestions here about serializing functions or more complex native types are part of that.

    @Jaime said:

    Also, back to post #1, no language that doesn't have both a "null" and an "undefined" has "invent undefined" on it's roadmap. Undefined is the problem, not JSON.

    Perhaps this is because the languages where arrays behave that way already have an appropriate value or keyword for it. While existing language design might be a good heuristic for essentials or needs, I don't think it's even an argument as far as developing new features. In any case, we're not talking about a new feature for a language--we're talking about making a serializer spec respect its own target language.

    @tar said:

    I think we have three options here:

    Write a reference implementation demonstrating the proposed sparse array serialization, and see if we can get anywhere with the JSON standardization committee.
    Accept the status quo and try to move on with our lives the best we can.
    Build a time machine and go back in time to kill Doug Crockford.

    I'm leaning towards #3, but I could be swayed to one of the other options...

    #3, seconded.

    Though if I get some spare time I might write such an implementation and submit it.

    @flabdablet said:

    This argument would have more force were it not for the fact that the very feature @VaelynPhi bemoans the lack of in JSON does work in a Javascript eval() - hence the thread title.

    I was about to go test this myself... heh.

    @tar said:

    > b = eval("{1:1,,3:3}");

    Successive commas are invalid in an object declaration. However,

    b = eval("{1:1}");
    

    Does the same thing. Irksomely,

    eval("b = {1:1};");
    

    Works just fine. As does

    b = eval('new Object({1:1,2:2});');
    

    @tar said:

    Prosecution rests.

    I'm not sure how this supports your statement. Perhaps you could elaborate?

    @flabdablet said:

    You need parens around the curlies to stop eval trying to treat that as a code block.

    Interesting. I was not aware of this. I have avoided eval like a plague.

    @flabdablet said:

    And again: I see no good reason why array literal syntax that works in Javascript should have been left out of JSON.

    This is a point that keeps getting ignored.

    @flabdablet said:

    If I were to assign that to a variable, say x, I'd end up withx["0"][0] === "zero"x["0"][1] === "one"x["4"] === "four"x["55"][0] === "fifty-five"x["55"][1] === "fifty-six"

    This seems quite straightforward, and I'm not sure what your point is.

    I was baffled too.

    @tar said:

    It should be interpreted as:

    {"foo": "bar", undefined: undefined, "baz": "quux"}

    To be, you know,consistent with the array case.

    Um... why?

    @tar said:

    Also, what the hell is a <pre tag, and why do I need to use one to manually reconstruct formatting inside a quote? That question was rhetorical.

    @discoursebot!

    @tar said:

    Why doesn't replacing omitted literals with undefined make sense? It makes sense in the array case?

    Undefined values in objects are the object form of "doesn't exist". Having a value whose key is undefined is... well, mysterious.

    For arrays, indices are predictable. You can't have an array of 100 values and not have an index at 99. Array keys are contiguous by definition (whereas array values are not necessarily). By contrast, a notion like contiguous object keys is... well, if one were to regard it to exist it would be at best contextual (like {"a":1,"b":2...}, but as a feature of objects it is nonsensical.

    @dkf said:

    They appear to make sense in lon!

    OMFSM, Lua! The language that only exists because they couldn't figure out how to use JS! (This is almost certainly untrue. However, any travails I may have had with JS were immediately dwarfed the moment I had to touch Lua.)

    @ben_lubar said:

    I've been looking through the language files for a certain game and they are quite ambiguous.

    This is a common feature of natural languages.

    @ben_lubar said:

    "eslo oma" means "climate bloat" in elf, "equity untrustworthy" in goblin, and "shore walk" in human."or kod" means "everlasting knight" in goblin, "large blot" in dwarf, and "lip stalk" in human.

    Maybe this is why they have so many wars.

    I wonder what "Your mother was a hamster and your father smelt of elderberries!" is actually French for...



  • @VaelynPhi - Last Day Without A Discourse Bug: null



  • @VaelynPhi said:

    Undefined values in objects are the object form of "doesn't exist". Having a value whose key is undefined is... well, mysterious.

    Mysterious, but:

    $ nodejs 
    > test = { undefined: 1};
    { undefined: 1 }
    > test[undefined]
    1

  • FoxDev

    undefined = 42
    > 42
    undefined
    > undefined
    

    😆



  • ...and by "like", I mean "holy hell ffs" :<nbsp>/



  • So, I started work on a Primer-style time machine (I have a storage locker and a box, the rest is just details), but then I thought "hang on, I can only go back in time as far as when the machine was frist turned on..." So now I'm thinking, if I can scrounge a Delorean and a flux capacitor (probably just a normal capacitor with some fluid on it might do), then I can use my BTTF-style time machine to take my Primer time machine back in time to when Doug Crockford was born...

    Thoughts on this plan?


  • FoxDev

    yeah. some early JS engines allowed you to set undefined to be any specific value you wanted (why? dunno) in ES1.5 that was explicitly forbidden to do, but in order to help forwards compatibility (?) it was written into the spec that assignment to undefined shall be considered legal but that the assignment shall have no effet (or some such)

    so when i assign 42 to null the return of the assignment is correctly 42 but undefined is still undefined.


  • Discourse touched me in a no-no place

    @accalia said:

    Apple: What's backwards compatibility?

    That's the one.


  • Discourse touched me in a no-no place

    @tar said:

    So, I started work on a Primer-style time machine (I have a storage locker and a box, the rest is just details), but then I thought "hang on, I can only go back in time as far as when the machine was frist turned on..." So now I'm thinking, if I can scrounge a Delorean and a flux capacitor (probably just a normal capacitor with some fluid on it might do), then I can use my BTTF-style time machine to take my Primer time machine back in time to when Doug Crockford was born...

    Thoughts on this plan?

    Yeah, get a different model. For example, the one Stewie made, that Mort accidentally used in Family Guy went all the way back to World War II.



  • @tar said:

    Mysterious, but:

    $ nodejs
    > test = { undefined: 1};
    { undefined: 1 }
    > test[undefined]
    1

    True, but this is somewhat like:

    > test = {}
    {}
    > broken = { toString: "nope" }
    { toString: 'nope' }
    > test.toString
    [Function: toString]
    > broken.toString
    'nope'
    

    When defining objects, keys are treated as strings, even when they're objects or functions. This is one of the reasons you can't use objects as keys, because then you just get an object with a bunch of "[object Object]" strings:

    > a={}
    {}
    > o={}
    {}
    > o[a]="A"
    'A'
    > o
    { '[object Object]': 'A' }
    

    @accalia said:

    so when i assign 42 to null the return of the assignment is correctly 42 but undefined is still undefined.

    null=42
    ReferenceError: Invalid left-hand side in assignment
    at repl:1:1
    at REPLServer.self.eval (repl.js:110:21)
    at Interface.<anonymous> (repl.js:239:12)
    at Interface.emit (events.js:95:17)
    at Interface._onLine (readline.js:202:10)
    at Interface._line (readline.js:531:8)
    at Interface._ttyWrite (readline.js:760:14)
    at ReadStream.onkeypress (readline.js:99:10)
    at ReadStream.emit (events.js:98:17)
    at emitKey (readline.js:1095:12)

    At least Node does it right; of course, arguably it should give the same complaint on trying to assign undefined a value...


  • FoxDev

    try it maybe wit undefined instead of null?

    null = 42
    > VM135:762 Uncaught ReferenceError: Invalid left-hand side in assignment
    undefiend = 42
    > 42
    

    (from Chrome, which also runs the V8 engine used in node)


  • Discourse touched me in a no-no place

    @accalia said:

    undefiend

    QFG


  • FoxDev

    .... it works even if i don't type it wrong

    for a given value of works.


  • Discourse touched me in a no-no place

    @VaelynPhi said:

    OMFSM, Lua! The language that only exists because they couldn't figure out how to use JS!

    I don't like Lua. They seem to take the attitude that they do the easy structured programming bits and leave all the difficult interface-with-the-OS parts to whatever the embedder (or the library writer) has decided to cobble up today. The quality of the libraries is variable, and often rather lower level than you'd really want. Embedders all too often come up with a nasty API anyway; there's always a tendency among them to say “we'll just put our C API into some other language and call it a day” and that usually makes for a sucky non-C API.

    Interfacing with operating systems is harder than it looks.



  • I really don't like Lua. We actually write apps in XML/Lua in our company (presumably because we didn't invent HTML/JS), and it's a hateful language to develop in. So so many subtle gotchas lurking in that language.

    Forgot to use the local keyword—yay, your variable is a global now. Fucking win! There is no way that's going to introduce hard to repro bugs!

    Oh, and it doesn't have arrays, it just has "tables" which you can pretend are arrays, except the indexing offset stats from 1. In a language which is "easy to interface with C".

    I could be here all night...



  • @VaelynPhi said:

    >flabdablet:
    You need parens around the curlies to stop eval trying to treat that as a code block.

    Interesting. I was not aware of this. I have avoided eval like a plague.

    stephen@kitchen:~$ js
    js> {1:1,2:2}
    typein:7:2 SyntaxError: missing ; before statement:
    typein:7:2 {1:1,2:2}
    typein:7:2 ..^
    js> ({1:1,2:2})
    ({1:1, 2:2})
    js> function unsafe_json_parse(s) {
        return eval('(' + s + ')');
    }
    js> unsafe_json_parse('{1:1,2:2}');
    ({1:1, 2:2})
    js> x = unsafe_json_parse('{1:1,2:2}');
    ({1:1, 2:2})
    js> print(x[1]);
    1
    js> 


  • @VaelynPhi said:

    Undefined values in objects are the object form of "doesn't exist". Having a value whose key is undefined is... well, mysterious.

    I like to use filesystem analogies for this. I think of null as an empty file: looking up the file works, but you can't read anything from it because there's nothing in it. Looking up the value of some variable and getting undefined is like trying to read the contents of a file that doesn't actually exist - it's the language's way of saying TDEMSYR.

    Of course Javascript, being Javascript, completely fucks up this neat mental model by having a global object named undefined as well as a native undefined type with the single value undefined.



  • @VaelynPhi said:

    flabdablet:
    You need parens around the curlies to stop eval trying to treat that as a code block.

    Interesting. I was not aware of this. I have avoided eval like a plague.


    Incidentally, that is the same root cause as this sequence from Gary Bernhart's Wat talk:

    > [] + []
    ''
    > [] + {}
    '[object Object]'
    > {} + []
    0
    > {} + {}
    NaN
    

    .[] + {} is being interpreted as a string concatenation; [] coerces to the empty string and {} as an object to '[object Object]', but {} + [] is being interpreted as an empty block, which doesn't do anything, followed by the expression +[], which evaluates to 0 (because JS). Similarly, {} + {} gives NaN because +{} is NaN.

    To wit:

    > {} 1
    => 1
    > x = {}
    => {}
    > x + []
    => '[object Object]'
    > x + {}
    => '[object Object][object Object]'
    > + {}
    => NaN
    

    Note that if you add something with the value of {} (instead of trying to use the literal {}) things work as, uh, "expected."


  • I survived the hour long Uno hand

    I can see the problem:

    Actual problem, my work's filter blocks all game-related sites


  • FoxDev

    @Yamikuronue said:

    Actual problem, my work's filter blocks all game-related sites

    work tried that with us. it was interesting how many people quickly learned about using teamviewer to look at the stuff at home.... while still being at work.

    ;-)


  • I survived the hour long Uno hand

    I'm lazy, I just use my phone which connects to the "guest" (and non-filtered) wifi. But we all know how well that works for here.


  • Discourse touched me in a no-no place

    @accalia said:

    it was interesting how many people quickly learned about using teamviewer to look at the stuff at home.... while still being at work.

    Snort. Might be faster just to use a proxy located at home, so you don't get the rest of the desktop.


  • FoxDev

    most proxies were blocked by the firewall.

    I went with setting up an openVPN endpoint at home over port 8080 and using that (it wasn't an open VPN that's jsut the name of the software)


  • Discourse touched me in a no-no place

    @accalia said:

    most proxies were blocked by the firewall.

    Even one you ran at home? Tough crowd.

    Of course if you have a data plan on your phone you could tether.


  • FoxDev

    @FrostCat said:

    Even one you ran at home? Tough crowd.

    if they ran over anything other than port 80, or 8080, and the firewall inspected all nonencrypted requests and rejected any proxy ones (encrypted traffic on https was restricted to whitelisted IP addresses)


  • Discourse touched me in a no-no place

    Well, like I said, there's the tethering option.



  • @accalia said:

    the firewall inspected all nonencrypted requests and rejected any proxy ones

    I'm dreaming of a wrapper client and wrapper server that would let users run OpenVPN by wrapping all the traffic in JPEGs in HTML...



  • @accalia said:

    try it maybe wit undefined instead of null?

    null = 42
    > VM135:762 Uncaught ReferenceError: Invalid left-hand side in assignment
    undefiend = 42
    > 42

    (from Chrome, which also runs the V8 engine used in node)

    That last statement is dangerous in web programming. Node, Firefox, and Chrome on Ubuntu, as well as Firefox and Chrome on my Windows 7 desktop at home, all give me undefined back instead of 42. I would bother getting versions, but I'm eating at the moment (and therefore lazy). They are all the latest, though, unless an update was released for one yesterday.

    @dkf said:

    Interfacing with operating systems is harder than it looks.

    QFT.

    @dkf said:

    I don't like Lua.

    @tar said:

    I really don't like Lua.

    Yes, I figured this would be a fairly agreed-upon thing. Heh.

    @flabdablet said:

    js> {1:1,2:2}
    typein:7:2 SyntaxError: missing ; before statement:

    Node is very forgiving about this:

    > {1:1}
    { '1': 1 }
    

    Or was that node you were using with an alias?

    @flabdablet said:

    Of course Javascript, being Javascript, completely fucks up this neat mental model by having a global object named undefined as well as a native undefined type with the single value undefined.

    I wonder if global undefined === undefined...

    @EvanED said:

    > {} + []
    0

    This actually gives me 0 only with a semicolon following, and similar with the objects:

    > {} + []
    '[object Object]'
    > {} + [];
    0
    > {} + {}
    '[object Object][object Object]'
    > {} + {};
    NaN
    

    All of this was in node on Ubuntu. I didn't test them in the browser, mostly because of laziness.

    @flabdablet said:

    I'm dreaming of a wrapper client and wrapper server that would let users run OpenVPN by wrapping all the traffic in JPEGs in HTML...

    ::doctor evil face:: Will they be base64 encoded?

    It's amazing how dumb things can get around corporate blocking tactics. One of my former coworkers had a "secured" (HTTP passworded) page on his home server that just grabbed whatever he asked it for in a POST variable and returned it. He never quite got it working entirely, since he had no idea how to get the browser to do this for everything on the page (he wasn't super bright), but the last I heard of it he was making a program that assembled a page in local cache using this dumb proxy.


  • Discourse touched me in a no-no place

    @accalia said:

    if they ran over anything other than port 80, or 8080, and the firewall inspected all nonencrypted requests and rejected any proxy ones (encrypted traffic on https was restricted to whitelisted IP addresses)

    This sounds like a use-case for BLOAT!

    [spoiler]For realsies…[/spoiler]



  • @VaelynPhi said:

    It's amazing how dumb things can get around corporate blocking tactics.

    The corporate blocking tactics work on all the businessmen and marketing drones and HR drones and accountants and other kinds of non-IT people because most of them can't set up even a very dumb workaround. Trying to stop IT people is generally a lot of work and they can work around it anyway.

    My preferred solution back when I was in a company that limited internet access was a ssh on port 443 with dynamic forwarding using socks5 locally. The filter we had there was pretty badly configured too, so sometimes I had to use the hack to get things I needed for work. Like I was searching for something technical and a promising result was blocked because the server apparently thought that any server with ‘girl’ in the hostname houses porn. So I tried the first two actual porn sites that came to my mind and both main pages came up just fine (I didn't investigate further). The filter also didn't allow webdav methods so it was not possible to get anything with subversion.

    On a side note it is actually possible to run both https and ssh on the same port (though it was not set on this server). In https the client starts talking right away while ssh waits for server banner, so there is a utility that waits for couple of seconds and forwards to the http server if the client starts talking and to sshd if it does not.



  • @dkf said:

    BLOAT

    Well, that one is an April Fool's RFC. But BOSH is completely serious. And I did use it, too.


  • Discourse touched me in a no-no place

    @Bulb said:

    that one is an April Fool's RFC

    Except it's been implemented anyway. Maybe originally as an April Fool's of its own. I remember all this because I once used it to get past a particularly noxious web proxy (no, someone else set it all up). Slow, but better than mobile phone internet at that point.


  • Discourse touched me in a no-no place

    @Yamikuronue said:

    I'm lazy, I just use my phone which connects to the "guest" (and non-filtered) wifi. But we all know how well that works for here.

    Can't you fire up the wifi (presuming you have it) on your laptop (again - presumptuous) as well and ip route add 162.243.36.100 dev wlan0 (or the windows equivalent which, from memory, isn't that much different)?


  • I survived the hour long Uno hand

    again, lazy :) The filter here doesn't stop me from getting anything important done, either for work or for my home life. In the past when I've worked places that blocked essential features I've done workarounds for it, but meh, it's only mildly annoying here and that only because it blocks game sites, which is a new thing.



  • ARISE!

    So remember when everyone argued that [,,] was a 'convenient' shorthand for [undefined,undefined,undefined], and I said that was stupid and wrong?
    Well...

    C:\>node
    > [undefined,undefined,undefined].forEach(function(e) { console.log('$ ' + e) })
    $ undefined
    $ undefined
    $ undefined
    undefined
    > [,,].forEach(function(e) { console.log('$ ' + e) })
    undefined
    >
    

    Hmm. Guess I was right all along!



  • @tar said:

    everyone

    You have a strange definition of this word.



  • Oh, I'm sorry, I can't hear you over the sound of my being smug and self-righteous.



  • This might also be related to [,,] not having three elements:

    http://wtfjs.com/2013/07/18/array-ruse


Log in to reply