Nu/Linux update

Thursday, 07 Feb 2008

Here’s an update on my port of Nu to Linux.

Dependencies

So far I’ve been running on Ubuntu 7.10 in VMware and using debuggable versions of libobjc and libFoundation that I built from source. Nu also depends on libffi, and on Linux it uses the “stock” libffi that Ubuntu and Debian users can install with apt-get.

Differences

Because libobjc (a.k.a. the “GNU runtime”) has a different api than Apple’s (a.k.a. the “NeXT runtime”), there are many low-level differences between the Darwin and Linux versions of Nu. There are also several references in Nu sources and tests to classes that are in Cocoa but not libFoundation, but fortunately, most of the missing ones aren’t critical for Nu.

But here are a few significant differences:

  • In libFoundation, there’s no NSString support for UTF8. There appears to be a partial support for UTF16, but I haven’t figured out how to use it.
  • There’s no Distributed Objects support in libFoundation. As a result, I’ve postponed porting the Nu interface for creating protocols at runtime, but when it’s needed that should be easy to add.
  • It is difficult to support framework bundles on Linux. While I can build loadable bundles that contain both Objective-C code (in a dylib) and Nu code (in the framework’s Resources directory), I can only link against them if their locations are fixed. So currently instead of building Nu as a framework, I build it as libNu.so and put the shared Nu files in /usr/local/share/libNu/nu (subject to change).
  • Exception handling is done with the old NS_DURING/NS_HANDLER macros instead of @try/@catch/@finally. This seems to work, but feels dicey. I need to know more about the similarities and differences of the two methods.
Testing

After cutting out the tests affected by these differences, I can now run and pass the rest using “nuke test”. Results are below:

ubuntu-box:~/Desktop/Repositories/NuLinux/NuLinux> nuke test
nuke: running in /home/tim/Desktop/Repositories/NuLinux/NuLinux
nuke: nutest test/test_*.nu

TestArray: running
--- testCreate
--- testEach
--- testEachInReverse
--- testSortedArrayUsingBlock
TestArray: completed 4 tests/11 assertions/0 failures/0 errors

TestBridge: running
--- testFunctions
TestBridge: completed 1 tests/4 assertions/0 failures/0 errors

TestCharacters: running
--- testEscapedCharacters
--- testFourCharacterIntegers
--- testHexEscapedCharacters
--- testOctalEscapedCharacters
--- testRegularCharacters
--- testUnicodeEscapedCharacters
TestCharacters: completed 6 tests/21 assertions/0 failures/0 errors

TestClasses: running
--- testAutomaticClassCreationFromNu
--- testAutomaticClassCreationFromObjC
--- testMetaVariables
TestClasses: completed 3 tests/4 assertions/0 failures/0 errors

TestClosures: running
--- testAccumulator
--- testScoping
TestClosures: completed 2 tests/10 assertions/0 failures/0 errors

TestControl: running
--- testCase
--- testCond
--- testFor
--- testForBreak
--- testForContinue
--- testIf
--- testLoopMacro
--- testUnless
--- testUntil
--- testUntilBreak
--- testUntilContinue
--- testWhile
--- testWhileBreak
--- testWhileContinue
TestControl: completed 14 tests/27 assertions/0 failures/0 errors

TestDictionary: running
--- testAutomaticAccessor
--- testCreate
--- testEach
--- testLookupWithDefault
--- testSet
TestDictionary: completed 5 tests/13 assertions/0 failures/0 errors

TestErrors: running
--- testCarOnAtom
--- testCdrOnAtom
--- testIncorrectNumberOfBlockArguments
--- testMisplacedCmethod
--- testMisplacedImethod
--- testMisplacedIvar
--- testMisplacedIvars
--- testNoInstanceVariable
--- testParseError
--- testUndefinedClass
--- testUndefinedSuperClass
--- testUndefinedSymbol
TestErrors: completed 12 tests/12 assertions/0 failures/0 errors

TestExceptions: running
--- testRangeException
--- testUserRaisedException
TestExceptions: completed 2 tests/8 assertions/0 failures/0 errors

TestInterface: running
--- testParser
TestInterface: completed 1 tests/4 assertions/0 failures/0 errors

TestList: running
--- testCompare
--- testObjectAtIndex
TestList: completed 2 tests/17 assertions/0 failures/0 errors

TestMacros: running
--- testBrokenFactorialMacro
--- testFactorialFunction
--- testFactorialMacro
--- testGensymInterpolation
--- testIvarAccessorMacro
--- testMacroImplementation
TestMacros: completed 6 tests/7 assertions/0 failures/0 errors

TestMath: running
--- testAbs
--- testArithmeticOperators
--- testBooleanOperators
--- testComparisonOperators
--- testCos
--- testExp
--- testIntegerDivide
--- testIntegerMod
--- testLog
--- testShiftOperators
--- testSin
--- testSqrt
--- testSquare
TestMath: completed 13 tests/60 assertions/0 failures/0 errors

TestOperators: running
--- testAddOperator
--- testMaxOperator
--- testMinOperator
TestOperators: completed 3 tests/10 assertions/0 failures/0 errors

TestParser: running
--- testParseHereStrings
--- testParseMultilineRegularExpressions
TestParser: completed 2 tests/10 assertions/0 failures/0 errors

TestReferences: running
--- testReturnByReference
TestReferences: completed 1 tests/1 assertions/0 failures/0 errors

TestRegex: running
--- testExtendedRegex
--- testMultipleCaptures
--- testRegex
--- testRegexWithOperator
TestRegex: completed 4 tests/7 assertions/0 failures/0 errors

TestStrings: running
--- testEscapedHereStrings
--- testEscapedStrings
--- testExplicitlyEscapedHereStrings
--- testExplicitlyEscapedStrings
--- testExplicitlyUnescapedHereStrings
--- testExplicitlyUnescapedStrings
--- testHexEscapedHereStrings
--- testHexEscapedStrings
--- testOctalEscapedHereStrings
--- testOctalEscapedStrings
--- testUnicodeEscapedStrings
TestStrings: completed 11 tests/43 assertions/0 failures/0 errors

TestSwizzling: running
--- testClassMethodSwizzling
--- testInstanceMethodSwizzling
TestSwizzling: completed 2 tests/12 assertions/0 failures/0 errors

TestSystem: running
--- testSystem
TestSystem: completed 1 tests/3 assertions/0 failures/0 errors

TestTemplates: running
--- testCodeSubstitution
--- testCountingSubstitution
TestTemplates: completed 2 tests/2 assertions/0 failures/0 errors

TestTruth: running
--- testFalse
--- testTrue
TestTruth: completed 2 tests/8 assertions/0 failures/0 errors

TestTypes: running
--- testVoidMethodReturnTypes
TestTypes: completed 1 tests/2 assertions/0 failures/0 errors

TestVarArgs: running
--- testArrayOperator
--- testDictOperator
--- testSimple
TestVarArgs: completed 3 tests/10 assertions/0 failures/0 errors

All: completed 103 tests/306 assertions/0 failures/0 errors

SUCCESS (0 failures, 0 errors)
What’s next?
  • Merge the Darwin and Linux Nu sources and prepare a release.
  • Since it is starting to look like a truly portable system, I’d also like to get the Nu build system working under autoconf. That’s new for me, so I’d love to get some help from someone on that.
Comments (4) post a reply
  1. Oscar Bonilla Thursday, 07 Feb 2008, 04:45 PM PDT
  2. Brendan Thursday, 07 Feb 2008, 05:48 PM PDT
  3. Aleksandr Skobelev Friday, 08 Feb 2008, 03:02 AM PDT

    I’ve just started to play with Nu under MacOS X and have already tried to use it in my work: I’ve replaced the pair of old bash scripts and compiled C utils that we have been using for automate the localization process, with the only Nu script.

    So I just want to thank you very much!

    I’m also very glad to see that you don’t stick to MacOSX only and are porting Nu to Linux. I’m only hope yet, that you will consider GNUStep as appropriate environment, as I believe this is only the more or less actively developed and mature implementation of NextStep/Cocoa for non-mac world.

    BTW, as I am not “a happy user of TextMate” as you, and use Emacs I slightly updated the Victor Rodriguez’s nu.el and added nush.el file, that in fact just cmuscheme.el with “scheme” replaced by “nush” and “nu”. This pair provides some initial support for Nu in Emacs. If you interested in this (esp. given there is no TextMate for Linux :)) I could try to upload them in some public place.

  4. Tim Burks Saturday, 09 Feb 2008, 07:33 PM PDT

    Aleksandr,

    If you would send me your emacs files, I would include them in the Nu.git repository and installation (installing them under $prefix/share/nu).

    Thanks,

    Tim