6 ms·
MISC: A homoiconic language based on maps
- saagarjha 7y agoUnfortunately a Java applet, but the guide was interesting (click the “Next” near the top).
- andybak 7y agoI missed that link and was coming here to complain about the lack of example code. EDIT - how does one actually run a Java applet nowadays? Which browsers still support that integration?
- capableweb 7y agoI did the following to run it locally instead: cd $(mktemp -d) wget http://will.thimbleby.net/misc/misc.jar wget http://will.thimbleby.net/misc/bootstrap.misc java -jar misc.jar And then it drops you into a repl. (Add `rlwrap` in front of `java -jar` if cursor movement doesn't work correctly)
- javajosh 7y agoIt's probably okay with this thing but in general don't do this. "wget totallynotmalware.exe; totallynotmalware.exe". Note to self: if I wanted to distribute Java malware to the HN crowd this is exactly how I would do it: write a minimalist, nerdy topic that requires an applet to run, knowing that my audience will happily find a work-around, like the above.
- capableweb 7y agoYeah, I'm assuming that people know what they are doing and taking the necessary precautions themselves when running untrusted code. I'm not gonna add "Run this in a virtual machine" every time I mention some software. But your reminder is good for the newcomers around I guess.
- apignotti 7y agoTry this Chrome extension: https://chrome.google.com/webstore/detail/cheerpj-applet-runner/bbmolahhldcbngedljfadjlognfaaein https://chrome.google.com/webstore/detail/cheerpj-applet-run... [Full disclosure: the extension is made by the company I work for]
- philipov 7y agoOh, maps as in dictionaries. From the title, I was hoping to see a programming language based on cartographs.
- 77544cec 7y agoBefunge is a stack-based, reflective, esoteric programming language. It differs from conventional languages in that programs are arranged on a two-dimensional grid. "Arrow" instructions direct the control flow to the left, right, up or down, and loops are constructed by sending the control flow in a cycle. It has been described as "a cross between Forth and Lemmings."[1] Source: https://en.wikipedia.org/wiki/Befunge https://en.wikipedia.org/wiki/Befunge v>>>>>v 12345 ^?^ > ? ?^ v?v 6789 >>>> v ^ .<
- BazookaMusic 7y agoHeck, had to make a virtual machine for befunge93 for a university course last month. It's a really fun language to play around with.
- quelltext 7y agoSo the core data-structure for aggregated data is associative maps, like PHP.
- aasasd 7y ago> maps can easily represent lists but not vice versa Obviously false, as demonstrated by Lisp, with which the author must be familiar. The problem with maps as a basis for a programming language is that you need expressions to have one entry point which says what expression this is. In a sequence, an obvious choice is the first element, or sometimes the last. This is why YAML-programming expressions in Ansible in fact work exactly like regular function calls, with their “- function: argument argument” syntax (which Ansible authors seem to not notice). ‘Misc’, of course, also has to choose ‘0’ to represent the expression entry point. I think this syntax is translatable one-to-one to old Lisp syntax, probably with keyword arguments.
- e12e 7y agoWouldn't it be fair to say a proper map can (more) directly represent a list, while a list can only be used as the underlying implementation of a map? Specifically for lisp, a list is a sequence of cons cells, and you would have to do a linear search to look up a value by key - thus, it can function as a map from an Api point of view, but not in terms of performance? That's why the common lisp "map" is a hash table, not a list? http://gigamonkeys.com/book/collections.html http://gigamonkeys.com/book/collections.html
- aasasd 7y ago> while a list can only be used as the underlying implementation of a map? I certainly wouldn't advise that. We're talking about language syntax here. Lists serve alright for maps in the syntax (personally I like Clojure's curly-brace literals), but I sure hope that the implementation uses hash maps or something like that. I also have no idea why lists have to be linked-lists and made of cons cells. Lisps working on top of pre-existing environments, like Clojure, don't seem to bother with that requirement, so it looks like it's just an idea from the stone age of computing.
- e12e 7y agoBy your definition of lists, misc uses lists to represent maps?
- etaioinshrdlu 7y agoI always found the excessive usage of linked lists in lisp style languages to be rather odd. It's about the worst possible data structure for performance unless you have a sufficiently smart complier... I think it's used for the beautiful simplicity of the language and not because it's actually a good way to compute things.
- e12e 7y agoI think it's partly due to many university lisp courses focusing on the symbolic end of lisp/programming languages - rather than on the performance side of computing theory. For common lisp, for example, it's probably fair to say that an over use of lists is "wrong" in the general case (ie, if your problem is data driven, which would probably be the case in most applications/utilities). Now, if all you're doing is improving the language/honing a DSL - the you'll probably be using lists a lot, as that is what constitutes the abstract syntax tree you're manipulating. See this for a brief discussion on collections in common lisp: http://gigamonkeys.com/book/collections.html http://gigamonkeys.com/book/collections.html
- p4bl0 7y agoThis made me think of Racket's syntax objects, which are also more than simple lists. They contain a lot of information like source and position, but can also contains arbitrary properties (like a map, in a sense). See https://docs.racket-lang.org/reference/stxprops.html https://docs.racket-lang.org/reference/stxprops.html
- dunham 7y agoIn a similar vein, "lumen" is a small lisp/scheme dialect that experiments in a similar direction. It replaces lisp's lists with lua/javascript's "arrays and dictionaries at the same time" objects. (Self-hosted, compiles to both javascript and lua.) https://github.com/sctb/lumen https://github.com/sctb/lumen
- pull_my_finger 7y agoI like Lua, and lisps, and I write a lot of JavaScript, but I don't understand why I would ever need 1 language that compiles to both Lua or JavaScript. Something like Nim compiles to C or JavaScript, so you have 1 lang for you high and low(er) level code. Just seems weird to target those 2 particular languages.
- dang 7y agoThread from 2008: https://news.ycombinator.com/item?id=241832 https://news.ycombinator.com/item?id=241832 2011: https://news.ycombinator.com/item?id=2552330 https://news.ycombinator.com/item?id=2552330
- tabtab 7y agoThis reminds me of these discussions: https://wiki.c2.com/?MaspBrainstorming https://wiki.c2.com/?MaspBrainstorming https://www.reddit.com/r/compsci/comments/brrzad/universal_programming_language_syntax_proposal/ https://www.reddit.com/r/compsci/comments/brrzad/universal_p... https://www.reddit.com/r/ProgrammingLanguages/comments/e8f8c2/nesting_block_structures_in_a_generic_way/ https://www.reddit.com/r/ProgrammingLanguages/comments/e8f8c... I don't know if there is any relationship between authors. The idea of applying the lessons and benefits of XML to imperative programming to form a kind of meta language or meta-friendly language is present.