Cross-language standard libraries?

Thus, we all know that learning a programming language is a tiny part of platform performance. Learning Java libraries takes a lot more time than it takes to learn the Java programming language, the same for C #, JavaScript, Python, Ruby ... etc.

As programmers, we can easily make the observation that a for loop or an array is a for loop or an array in any programming language. After you learn the concept, you do not need to retrain it, so the syntax is different, but zero effort is repeated to study the concept. Obviously, this does not apply to standard libraries, which means that we need to study again how ordinary tasks, such as manipulating files, communicating with a database, creating networks on each platform we use, are inefficient and painful, there should be a better the way there.

W3C DOM is an example of a cross-language library, which should have the same function names and the same semantics, regardless of the programming language. The W3C DOM is difficult to use, but at least once you recognize it in one language / platform, then in other cases it is one and the same.

Is there a set of libraries for different languages, designed for the most common tasks that a developer should take care of around 2011.

  • IO file operations
  • Net
  • Process management
  • Access to the database
  • Collections and Data Structures
  • Cryptography, digital signatures, cryptographic hashes
  • Anything else useful that doesn't include user interface code

Clarification: I do not need APIs tied to the current platform, such as .NET or JVM, because they are tied to the same company, and in many cases they APIs show their age, and if they were redesigned today, it would be much cleaner / better. In addition, being primarily a Java developer overseeing how Oracle uses Java judging, Google has become a real horror show. I really don’t need the hours that I invest in mastering the platform, which should be tied to a controlled entity, but rather as some kind of open source project where the best projects win.

Clarification: I'm looking for APIs that are the same in many different languages, not tied to the same language. For example, consider reading the contents of a text file. I need to open the file, read the contents, ... etc. I would look for an API where the function had exactly the same name in all languages, the same parameters in the same order, with the same returned data, the same error handling semantics. I know different programming paradigms, so I'm fine with the OO API version, functional version ... etc.

+8
design design-patterns cross-platform components
source share
6 answers

An interesting question ... I think that there is a great opportunity for libraries that perform more specialized functions for development with several language connections (and you start to see this with the help of various web services). Unfortunately, the presented abstractions tend to be rather simplified and often feel "alien", despite the developers' attempts to make language bindings as natural as possible. Perhaps the best way to say that they are usually uniomatic. For example, the low-level POSIX APIs actually represent a kind of the least common denominator for the standard library, but the problem is that different languages ​​(may) approach even these basic abstractions very differently in their desire to make them “natural”, for of this language. Another problem (as mentioned in previous posts) is that, by their very nature, standard standards must be consistent, and this can be extremely complex in itself. Unfortunately, this process often leads to APIs that really do not suit anyone. (for example ... do we really need to support 36-bit words or the Coptic calendar? Depending on your point of view. Should the API be object-oriented, functional or something else like threads? Also depends on your point of view. indicating, that this is perhaps a more complex problem than one might think.

It should be noted that attempts have been made to provide better (at least more consistent) APIs for standard things. One example is Plan9, an operating system in which EVERYTHING is a file. Overall, the reviews were mixed.

+4
source share

This is a good question. Such a library will be a good asset for every developer, but it cannot be standard , because standard libraries are very conservative, and it takes time for an ideal API. There is also a backward compatibility issue that once code is entered into the standard library, it cannot change. There is a joke in the Python community that good modules go into the standard library to die.

This library can be run not as a library, but as a community / recipes site that will focus on the collaboration process, because it is not easy for one person to convince everyone else that the selected API is the best. You really need to convince everyone .

I cannot say for other languages, but there is a concern in the Python community about moving stdlib from the kernel so that it can grow faster. There is a proposal indicated by PEP 413 , but this is not enough. The plan may be as follows:

  • Define namespaces (modules in Python)
  • Collect statistics for the actual use of the function (static analysis + public repository spider)
  • Get the best from all languages
  • Analyze, discuss and vote (or just use what you like) - this requires a database of user stories that combines common problems, their solutions and contains a resume (the Python Cookbook in CHM was once a very good example of such resumes). Another very important feature of the database is to identify conflicting use cases .
  • Accept the license (or simply admit that the public domain is the only way compatible with copy / paste).

So, the answer is that there is no such library in different languages. Because there is not enough communication between the parties. Because there is no intuitive platform for this.

+2
source share

Yes, there are not many. Windows, MacOS X, Linux ... :)

More seriously, the .Net and Java runtimes support many languages, so if you stay within the set of languages ​​it supports, you can save your knowledge in the library.

+1
source share

The following thoughts come to mind:

  • Microsoft.NET is quite closely related to the Microsoft ecosystem (but remember about Mono), has bindings to many languages, the design is somewhat inspired by Java. Most of the things you indicated.

  • Qt - the roots are very strong in C ++, it has bindings to other languages, and not as heavy as .NET, but does not feel alien * nix and MacOS. Database support is very primitive, crypto support does not exist.

+1
source share

I assume that the obvious use case is to facilitate the transition of the developer to new languages ​​and porting the code.

OpenGL code may look pretty similar in some languages, but not in all. DOM is a great example. The smallest JSON interface parse / stringify may be the most widespread and unambiguous library!

But what you really want, a complete set of standard cross-language APIs, I have not seen.

As Martin rightly points out, there are problems with such efforts. Attracting to the lowest common denominator means losing any language features that are not available in all languages ​​in our desired spectrum. It could mean

  • no first order functions
  • no generics / templates / polymorphism
  • the need for free () unused memory
  • static typing, forced pass by reference
  • operability without closing.
  • minimized event listeners
  • and the ability to work in both multi-threaded and single-threaded environments (return to callback).

Despite the fact that it would be difficult to lose the very functions for which we chose the language, there may still be benefits from such a project. Narrower coverage is likely to provide better results.

The Haxe language may be of interest to those considering such a project. It already has a minimal standard library (and Stax ) and can export to several different languages, including C ++, Flash, PHP, Neko, Javascript and more recently, C # and Java. (I don't know if the final results will be the same in all languages.)

While CommonJS and Narwhal are (Javascript), they can be seen as attempts to create a standard library interface.

Processing has been ported to several languages, so there may be some useful libraries.

There should be a large number of specific examples, such as JSON. For example, the Fuse virtual file system interface is available from C, Python, Java, and many other languages. And I would be surprised if someone did not try to create a 2d Canvas API implementation for languages ​​than Javascript.

Apache has released many single-user software in different languages ​​and may have created several similar libraries.

+1
source share

There is a library that does exactly what you say. It is called turboCommons, and you can find it on GitHub:

https://github.com/edertone/TurboCommons

+1
source share

All Articles