6 ms·
There are other scripting languages that have good support and strong communities. There doesn't need to be yet another programming language. Use Ruby, JS or PH
by goatlover 10y ago
There are other scripting languages that have good support and strong communities. There doesn't need to be yet another programming language. Use Ruby, JS or PHP 7 instead. If it's scientific computing, Julia fills the niche very nicely. Or R.
- Mizza 10y agoMy point is that we should go a level "higher" than any current offering. Ex, why not let me do something like this out of the box: get https://api.github.com/users/Miserlou as miserlou print "My name is " miserlou.name Transparent/automatic web requests, content-type checking, serialization parsing, string formatting, network reference parsing, etc. Let the user be more specific if they need to, but design heavily around the most common use case.
- goatlover 10y agoI like that! Are you sure there isn't some language that does this already?
- twic 10y agoThis is the kind of stuff Rebol wanted to do, although i don't know if it covered this particular case.
- marvy 10y agoYep, the moment I saw that I though "REBOL"! (Actually, I thought of Red, but same idea.) Still, it seems that this is not thought through properly. What should the language do if the server does not return JSON? And can't we basically do this in Python already?
- Mizza 10y agoIt's a trivial example, but the point would be that the stdlib would have the ability to a) Speak flutent HTTP b) Understand Content-Type c) Deserialize to a common format all completely transparently. If the server returned XML or MsgPack, it wouldn't matter, the code would work the same. Ideally, we could imagine this going a step further, and having the language speak REST entirely. Python's requests is a nice prototype, ergonomically speaking, but we can go much further.
- marvy 10y agoUm, what if the server returned, say, a JPEG? Or a plain old HTML webpage, complete with inline CSS and script tags?
- draegtun 10y agoThere is nothing currently built into Rebol stdlib that replicates exactly this. But here's an example of how it could be done... import <json> import <xml> load-*: function [site] [ p: open site content: read p http: query p close p parse http/headers/Content-Type [ "application/json" return (load-json content) | "application/xml" return (load-xml content) ] else [ fail "Content-Type not recognised" ] ] miserlou: load-* https://api.github.com/users/Miserlou print ["My name is" miserlou/name]
- marvy 10y agoIs this hypothetical, or does the stdlib actually have load-json and load-xml?
- draegtun 10y agoAbove works, the <json> & <xml> imports are pulled off this remotely hosted common library - https://github.com/r3n/renclib https://github.com/r3n/renclib You'll need the Ren/C branch of Rebol 3 for this: * repo - https://github.com/metaeducation/ren-c https://github.com/metaeducation/ren-c * pre-built binaries - http://metaeducation.s3.amazonaws.com/index.html http://metaeducation.s3.amazonaws.com/index.html
- marvy 10y agoOkay, as someone who doesn't know REBOL, what is the effect of miserlou/name if the server returns XML? The string value of a top-level <name> tag?
- 10y ago
- draegtun 10y agoVery close! Here's an example using latest build of Rebol 3 (Ren/C branch)... import <json> miserlou: load-json read https://api.github.com/users/Miserlou print ["My name is" miserlou/name]
- deleted 10y ago[deleted]