Heykuki News

TopNewBestAskShowJobs
TopNewBestAskShowJobs
Ask HN: Why don't languages such as Java support json-like object literals?
11 points
rajnathani
9 years ago
Note: This is a sort of a technical question which I'd ideally like to ask on stack overflow, however if asked there the question might be closed due to being too broad (upon my inference of programming language design questions of similar nature asked in the past).

Why don't GC languages such as Java support json-like object literals? (For reference check out the code snippet on this stack overflow question: https://stackoverflow.com/questions/34727831/create-a-json-literal-in-java-without-need-for-existing-class)

My conclusion is that the processing would be solely at the parsing stage and not at the runtime stage of the program, so there shouldn't be any conspicuous perf hit in including this feature.

Note that this is all assuming that the programmer would in any case use the type Object to be agnostic of types specified within their json-like object even if they didn't have access to an object literal.

Are there some unforeseen issues (perf and non-perf related) to accommodating such object literals?

FYI this question is not just about Java, but extends to other GC languages (such as Golang, etc).

14 comments