r/ProgrammingLanguages • u/Mean-Decision-3502 DQ • Jul 16 '26
New Languages: Standardizing API, Examples ?
Hi, some of you are developing new general-purpose programming languages here. When the language is ready, you have to develop standard APIs, like file-io, json-handling etc. Users, and you would have benefit, when the APIs would be same/similar across multiple different languages.
Standardizing some Examples would allow the users to compare languages more easily.
What do you think?
11
Upvotes
16
u/oscarryz Yz Jul 16 '26
I think that's what Rosetta code was meant to be.
Every language has its subtleties and strengths, so it is reasonable that each one wants to highlight their uniqueness in the examples they choose.
As for the API, the language philosophy greatly dictates what the API would be, of course similar language paradigms would or might have very close looking API's.
What I did for the exams was to take every single code snippets I came across and write it in my design language, and that helped to shape the decisions, e.g. function overload vs default params, or multiple return values vs Result types (or exceptions).
3
u/Tasty_Replacement_29 Bau Jul 16 '26
For my language, I will implement the standard library myself. It is part of the fun (in addition to be interesting, and hard). There are many small and large decisions to made (e.g. just the string implementation is interesting: short string optimization yes or no; mutable vs immutable etc.). Bigint, math, collections, and so on.
2
u/Inconstant_Moo 🧿 Pipefish Jul 16 '26
But they have different semantics as well as different syntax. E.g. my language wraps around Go for its standard libraries so you'd think it would be easy to have the same API, right? And a lot of the time I can have libraries with the same names containing functions and types with the same names. But:
math/bigandmath/complexlibraries use+and*and so on.And so although I have a particularly strong motive to make my API like someone else's rather than doing my own thing as devs love to do, still there are often good reasons why I should do something different.
You can at least standardize within the language's standard libraries. Should it be needle-haystack or haystack-needle. destination-source or source-destination? 0-indexed or 1-indexed (I'm looking at you Object Pascal). Camel-cased or snake-cased (go and sit in the corner, PHP). Pick a lane. It should go in the style guide of the language, though I'm not sure it ever does except the casing.
1
u/ThomasMertes Jul 16 '26 edited Jul 16 '26
Historically many new languages used the C / Posix functions. I consider these functions as low-level. For that reason I invented new functions for the file system and other areas. If you are interested, take a look at OS access and Libraries. BTW: The Rosetta code entry of Seed7 is here.
2
u/initial-algebra Jul 16 '26
My opinion? Unless you have a very good reason not to, follow Web (W3C) standards when you can. WASI in particular would be quite relevant for standard libraries. Web folks have put a lot of work into making sure they support as many computing environments as possible, so let's take advantage of that! That's not to mention the benefit of being able to support the Web, including native applications using WASM/WASI (e.g. for plugins), as a first-class target.
1
u/kwan_e tonal-lang Jul 17 '26
One of the goals of my language is to able to write an API that is close to the specification in, say, an RFC or something. There's always some interesting feature or behaviour in a spec that gets lost in the conversion to an API, or at least makes it very unobvious.
Failing that, at least be able to create an API that basically looks like a spec.
Then having said API, it wouldn't have to lock-in any design decision that was done for performance, or aesthetics, but allows the underlying implementation to cater for both. As a wise girl once said: "¿por qué no los dos?"