Dart library / package keyword meaning? - dart

Is Dart library exactly the same Java package ?
Is Dart package exactly the same Java library (JAR) ?

A package is a set of libraries which can for example be deployed to pub.dartlang.org. I guess this is similar to a jar file.
A library is one Dart script file with or without a name (or a set of Dart script files with part/part of) and is the boundary for privacy. Private members are only visible or accessible from within the same library.

Related

How can I use dart ffi properly in a pub package?

I am currently building a console package with Dart, and Rust using FFI(foreign function interface). Since I can't/shouldn't publish dll/so/dylib files, how can I add a build functionality to it. With that functionality, the required files should be built after the package is downloaded, so that the interop-ed code can work properly. How can it be done? Will the user that downloaded the package need to have Rust in his machine to build the files?
You need to either distribute binaries or require the user to have a Rust compiler.

Newbie / Ballerina Build with gson issue while running the build

I am a newbie in Ballerina.
I am importing a platform lib as a executable jar , which is an inter op method call in java using openstack swift api using jclouds.
There has been a known issue with JCLOUDS where it fails to build due to gson version issues higher than 2.5 not compatible with jclouds
Apache jclouds java.lang.NoSuchMethodError when using Rackspace in a Spring Boot application.
I face the same error when trying to execute this inter op method call from my bal file which was built during ballerina build. Upon inspection of the jar, which ballerina created during the build of the project , it shows that the jar is created with a set of prebuilt dependencies with gson 2.7.
is there any way i can change this dependency , i am not also very clear on how ballerina packages all this jars during the build phase of bal files.
It will help to have a detailed understanding on what happens below the hood when ballerina build is invoked.
The following GitHub issue explains why we had to package com.google:gson:2.7 with any Ballerina executable jar.
https://github.com/ballerina-platform/ballerina-lang/issues/17878
Let me try to explain why Ballerina compiler packages some third-party jars with the executable jar created for your Ballerina program. We can categorize these third-party jars into two main categories.
Jar dependencies of the Ballerina runtime
Jar dependencies of each Ballerina module that you've imported in your program.
Dependencies of the Ballerina runtime
Every Ballerina executable program contains the Ballerina runtime - the bare minimum layer on top of the JVM that is required to execute any Ballerina program. Runtime contains the Java implementations of Ballerina values, types, Ballerina modules in the lang lib, and the runtime type checker logic. This layer is essential to enforce Ballerina language semantics on top of the JVM.
At the moment, Ballerina runtime depends on many third-party Java libraries. GSON is one such library that we are planning to remove soon. You can get more details from the above issue.
Dependencies of a Ballerina module
Each Ballerina module, whether it belongs to the standard library or whether you pulled it from the Ballerina central, may depend on one or more third-party Java libraries. The Ballerina module author lists these dependencies in Ballerina.toml of the project in which they develop the Ballerina module. Here are some examples.
ballerina/http
ballerina/kafka
While I was working on this answer, I realized the requirement of a debugging tool that emits the details of third-party libraries. It would be nice if this tool can be integrated into the ballerina command-line tool. Here is the issue that I've created to track this.
https://github.com/ballerina-platform/ballerina-lang/issues/20116
Does upgrading to jclouds 2.2.0 resolve your symptoms? It includes JCLOUDS-1500 which upgrades the gson dependency to 2.8.5.

What project options to use for open source Delphi packages?

I've written some Delphi code I would like to share on GitHub. All code is contained in runtime and designtime packages as required. There are many "Project Options" to set for each project. (Output directories, search paths, compilation options, etc.) I've managed to find some default options that work well for my situation but reading other Q&As here it's clear there are multiple ways of working.
What project options should be used to allow the open source packages to easily be incorporated into individual projects?
I've recently started using NodeJS. The NPM package manager makes it super easy to use third-party packages in a project. Packages are installed with one simple command on the command line. Packages will automatically install any required dependencies.
PS: Feel free to edit this question if you would like to add extra things to consider.
Let's say you have this structure
MyComponent
Packages
DelphiXE7
Package2.dpr
source
bin
Delphi XE7
then set
Search Path
..\..\..\source
Unit output directory
..\..\..\bin\Delphi XE7\$(Platform)\$(Config)
After compilation for all supported platforms and both Release and Debug you will have this structure in the bin directory
MyComponent
Packages
DelphiXE7
Package2.dpr
source
bin
Delphi XE7
Android
Release
Debug
Win32
Release
Debug
Win64
Release
Debug
For installation you have to setup some path inside the IDE.
Environment
MYCOMPONENT => [root path to the files]
Library
Repeat that for all supported platforms
Library Path
$(MYCOMPONENT)\bin\Delphi XE7\$(Platform)\Release
Search Path
$(MYCOMPONENT)\source
Debug-DCU-Path
$(MYCOMPONENT)\bin\Delphi XE7\$(Platform)\Debug
If there are some language related units there is also a place to add (see Library - translated)
This ensures, that you have full debug feature (with Use Debug-DCU option set) and on release you have no debug code in your application.
Just a sidenote on libraries you should not want to install because you only use them in some projects.
Simply use the Optionset combined with a environment variable.
Here my SuperObject.optionset ($(USRLIB) points to a directory, where I collect all common used source code. And $(USRLIB)\ext is the place for all of the external libraries).
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<DCC_UnitSearchPath>$(USRLIB)\ext\superobject;$(DCC_UnitSearchPath)</DCC_UnitSearchPath>
</PropertyGroup>
<ProjectExtensions>
<Borland.Personality>Delphi.Personality.12</Borland.Personality>
<Borland.ProjectType>OptionSet</Borland.ProjectType>
<BorlandProject>
<Delphi.Personality/>
</BorlandProject>
<ProjectFileVersion>12</ProjectFileVersion>
</ProjectExtensions>
</Project>
To use the superobject library I simply add the optionset to the project (right mouse click on build configuration) and everything is fine.

Dart language standard installation directory?

Is there a standard or recommended installation directory for the Dart language? If so, I would like to know what it is for both Windows and Mac. I searched online on dartlang.org, Google, and StackOverflow. For Mac specifically, I have seen many programming languages installed under /Library.
I believe the standard workspace for Dart projects is ~/dart. When you download the Dart language, you are given a /dart folder containing the Editor, SDK, Chromium with Dart VM installed, and some extras. I am wondering what the standard location for this folder is. Thank you in advance!
The standard workspace directory for Dart projects is like you wrote ~/dart in Linux (don't know about other OS).
The standard installation directory is depending on conventions of your OS than the Dart language.
You should have an environment variable DART_SDK pointing to the dart-sdk subdirectory of the installation directory and include the DART_SDK/bin in your path.
On MAC, just drop the directory on App directory, then in terminal you put : "export PATH=$PATH:/Applications/dart/dart-sdk/bin"

Using a 3rd party library inside a WebWorks Javascript extension?

Usually, when creating a WebWorks Javascript extension you export your source files into a JAR with the appropriate provisions (e.g. library.xml, *.java). Usually, 3rd party libraries are in a jar file with compiled java code. I included the 3rd party jar inside my custom extension. This creates a jar within a jar file structure. The Blackberry Widget packager (bbwp) opens up the jar and compiles the Java files to be used in your WebWorks application. Blackberry's Java compiler is unable to compile because the appropriate packages are not visible in the class-path at the time of compilation. The appropriate packages are in the 3rd party library jar included in the extensions jar. Does anyone know how to resolve this class-path issue? Do I need the 3rd party source files instead of a jar? Is there documentation on how the BlackBerry Widget Packager (bbwp) works?
Thanks in advance.
Follow the instructions "Use precompiled classes in an extension" listed in the following link. That should resolve the compilation issue.
Creating a JAR file that defines your extension

Resources