top | item 30794124

(no title)

joncfoo | 3 years ago

What does the integration ecosystem look like for array-based languages? e.g. writing and consuming network services, database interoperability, C FFI, text encodings, etc.

Given this release of APL introduces support for shebang scripts I'm thinking the ecosystem of integration isn't great but I'm happy to be wrong.

discuss

order

jodrellblank|3 years ago

Dyalog APL lets you call to the .Net Framework almost directly, e.g.

          ⎕using←'System.Diagnostics,System.dll'
          st←⎕new Stopwatch
          st.Start
    <pause>
          st.Stop
          st.Elapsed
    00:00:03.5493601
That gives you access to most things C# can access, presumably System.Data.DataTable and database access, or P/Invoke to C libraries? It also supports the other way around, writing :Class-es and using File -> Export to make .Net DLLs for other .Net languages to import and use (with Dyalog APL installed and licensed to run the code inside, mind you).

e.g. text encoding:

          ⎕using,←⊂'System.Text'
          Encoding.Unicode.GetBytes (⊂'hello')
    104 0 101 0 108 0 108 0 111 0
(.Net calls UTF-16 "Unicode").

Web services: From https://www.dyalog.com/tools/web-applications.htm it can be an ASP.Net language, or with "MiServer, A development platform for web applications written in APL" or several others.

There's the classic ⎕CMD and ⎕SH which run a string in the Windows command interpreter, or Linux shell, and get the text result:

          ⎕cmd 'echo hello'
    hello
Seems to have various support for ActiveX and COM integration, too. I've never used any of this in anger or in production, but it surprised me how much integration it has.

> "Given this release of APL introduces support for shebang scripts I'm thinking the ecosystem of integration isn't great but I'm happy to be wrong."

This, specifically writing like a Python script, has been a sticking point for Dyalog APL for a while, I understand. APL the language and way of using it predates filesystems and was traditionally more like a self-enclosed virtual machine; you power it up, run your code inside it, and then save its running state to disk in a proprietary binary workspace blob that only it can read back again. And when filesystems came along, ⍴↑⍨⍥⊤⍎ weren't very convenient to write and save in scripts for a long time either.

mlochbaum|3 years ago

Dyalog is historically Windows-based and .Net is the preferred solution for a lot of things. But it has reasonable support for most of what you mention. There's a solid FFI, and text is UTF-32 internally with support for I/O with other encodings. See the list of system functions at [0]. Conga is the http library but I don't have any idea how well it works.

This is an area where array languages are entirely different from one another. J and K have been using shebangs for a long time (although J does this by assuming a shebang will be valid but no-op code, and fails if the path contains a space… sigh). Support for interop just depends on what other applications are considered important by the developers of that particular language.

[0] https://help.dyalog.com/18.2/#Language/System%20Functions/Su...

jodrellblank|3 years ago

J has support for being integrated into other projects[1], e.g. the link below has C# and Excel links at the end. You can use it as a COM server if you run 'jreg.cmd' first to register it.

As an administrator:

    PS C:\Program Files\j64-807> .\jreg.cmd
e.g. awkwardly, from PowerShell:

    $J = new-object -ComObject JExeServer

    PS C:\> $J.Set('numbers', [int[]](1,2,3))
    0
    PS C:\> $J.Do('answer =: numbers * 2')
    0

    PS C:\> $Result = $null
    PS C:\> $J.get('answer', [ref]$Result)
    0
    PS C:\> $Result
    2
    4
    6

or

    PS C:\> $J.Do("oops")
    21

    PS C:\> $Text = $null
    PS C:\> $J.ErrorText(21, [ref]$Text)
    0
    PS C:\> [system.text.encoding]::ASCII.GetString($Text)
    value error

[1] https://code.jsoftware.com/wiki/Guides/OLE_Automation

abrudz|3 years ago

Some things have libraries, like HttpCommand and the lower level Conga for network services. C FFI is done via the ⎕NA (Name Association) system function. Various Unicode encodings are available via ⎕UCS, etc.