Early impressions of Swift, and some workarounds

I’ve been playing around with Swift, the new programming language from Apple, for a few days and I’ve been quite happy with it. I’ve used many languages and development environments since I started coding when I was 15, so I was anxious to see what Swift offered.

I’ve by no means used all the features yet, though I’ve read about most of them in Apple’s online language guide and reference. I’m using XCode 6 Beta 6, so I expect that some of the gotchas and incomplete implementations will be addressed in the next beta or the final version. Even after that I would expect the language to evolve further since most do.

Some of the things I like:

  • Clean syntax
  • Fast compilation, when it works (see below)
  • Garbage collection
  • A nice attempt at bringing the power of older languages like C++ into a more modern form that includes some features resembling those in Python
  • A simple way to override syntactic operators like addition, negation, and multiplication.

My plan of attack here has been to take some C++ code I wrote 5 years ago and translate a subset of it to Swift. That way I can see how I would translate the ideas and structure into the new language. It’s been a good way to learn the language.

Some observations:

  • Passing by reference and passing by copy are clearly distinguished with less syntax than C++.
  • Because of the way it treats Unicode in a first class way, working with strings is more awkward than in many other languages. The need for Swift to coexist with Objective-C is also part of the reason, I believe.
  • The automatic garbage collection reduces code size over my previous manual methods.
  • I’m being more meticulous about when I can destructively change an object. (Almost never, and only close to where I create the object using specific init functions.)
  • I’m looking forward to a larger collection of standardized collection types. Here I would expect a huge improvement over the Standard C++ Library.
  • Once my core translated subset is complete and working well, I’ll look at using more of the idiomatic features of Swift and optimizing the code.

While working in the XCode editing environment, I hit a point where the computer CPU usage shot up to close to 100% for SourceKit, the underlying code base that handles all the editing, syntax checking, and code issue finding. Editing slowed to a crawl and sometimes I would get a message that SourceKit had crashed. Compilation took many minutes but the execution was correct.

I looked around the web, especially on StackOverflow, and found other mentions of the behavior but no great solutions and no problem situation that matched mine exactly. Eventually I went old school: I commented out most of my code and selectively added it back in until I could isolate the offending lines. Note that this was not a runtime error but an environmental problem while editing. That is: not my real problem.

If I had done something syntactically wrong, the editor or the compiler should have told me and not sucked up all the resources on my computer. If I was not doing something wrong, I should have seen no slow down.

Eventually I found that the offending code was

var s : Int = (u.bigits[j] * b + u.bigits[j-1] - q * v.bigits[n-1]) * b + u.bigits[j-2]

There is nothing wrong with the code except perhaps its complexity. I broke the statement into several simpler ones. By the way, I know I could have used “+=" but I wanted to be explicit and mirror the original statement.

var s : Int = -q * v.bigits[n-1]
s = s + u.bigits[j-1]
s = s + u.bigits[j] * b
s = s * b
s = s + u.bigits[j-2]

The problem went away. Editing and compilation speed returned to normal.

So the moral of this is that when working with betas of new languages, expect a few glitches and work around them. In the next release of XCode I’ll try my original statement and see if it has been fixed.

I’m looking forward to trying the new generics and constraints features. Though they look new to Swift, the ideas go back to at least the early 1990s.

Two other tidbits:

  1. If you know the type of an object, it does not hurt to be explicit in stating it. While it could be inferred, stating it makes the code more self-documenting.
  2. This release does not like spaces between unary prefix operators and their operands. That is, “- x” is flagged while “-x” is not. We’ll eventually see if this is a bug or a feature.

What I’m Reading on 07/26/2014

Posted from Diigo. The rest of my favorite links are here.

What I’m Reading on 07/16/2014

  • “This page attempts to collect information and links pertaining to the practice of AI and Machine Learning in python.”

    tags: bs python AI

  • “This app ranks the popularity of dozens of programming languages. You can filter them by listing only those most relevant to particular sectors, such as web or embedded programming. Rankings are created by weighting and combining 12 metrics from 10 sources. We offer preset weightings for those interested in what’s trending or most looked for by employers, or you can take complete control and create your own custom ranking by adjusting each metric’s weighting yourself. “

    tags: bs programming languages ieee

Posted from Diigo. The rest of my favorite links are here.

What I’m Reading on 07/15/2014

Posted from Diigo. The rest of my favorite links are here.

What I’m Reading on 06/06/2014

  • “This course is the first of a two-course sequence: Introduction to Computer Science and Programming Using Python, and Introduction to Computational Thinking and Data Science. Together, they are designed to help people with no prior exposure to computer science or programming learn to think computationally and write programs to tackle useful problems. Some of the people taking the two courses will use them as a stepping stone to more advanced computer science courses, but for many it will be their first and last computer science courses.”

    tags: bs python programming mit

  • “The general consensus from developers appears to be that Swift is a great programming language. Swift is similar in many ways to Python, another highly-regarded programming language. Swift should be a much easier programming language for newcomers to pick up than Objective-C. Python is regularly used as the language of choice for programming classes, so many programmers may already be familiar with much of the Apple Swift syntax.”

    tags: bs swift python

  • “That’s where Swift comes in. Described as a fast and modern solution designed for safety, Swift is faster than Objective-C or Python and “allows a level of interactivity never before seen on the platform” thanks to its support for “playgrounds” that allow developers to visualize Swift code in real-time within the Xcode developer environment. That means developers are able to see what an app looks like before they’re even finished coding it.”

    tags: bs swift apple programming language

Posted from Diigo. The rest of my favorite links are here.

What I’m Reading on 05/27/2014

  • “There’s a new advantage to doing business in New York. A big one. START-UP NY, Governor Cuomo’s groundbreaking initiative, is transforming communities across the state into tax-free sites for new and expanding businesses. Now, businesses can operate 100% tax-free for 10 years. No income tax, business, corporate, state or local taxes, sales and property taxes, or franchise fees.”

    tags: bs startup ny

  • “This is a list of the best books for learning the python programming language.”

    tags: bs python books

  • “Memo to anyone who logs in to a WordPress.com-hosted blog from a public Wi-Fi connection or other unsecured network: It’s trivial for the script kiddie a few tables down to hijack your site even if it’s protected by two-factor authentication.”

    tags: bs wordpress

Posted from Diigo. The rest of my favorite links are here.

What I’m Reading on 03/31/2014

  • “GNU Octave is a high-level interpreted language, primarily intended for numerical computations. It provides capabilities for the numerical solution of linear and nonlinear problems, and for performing other numerical experiments. It also provides extensive graphics capabilities for data visualization and manipulation. Octave is normally used through its interactive command line interface, but it can also be used to write non-interactive programs. The Octave language is quite similar to Matlab so that most programs are easily portable.”

    tags: bs math octave

  • “The NAG Library for Python gives users of the Python language access to over 1,700 mathematical and statistical routines in the NAG Library. It has been enhanced in-line with Python2.7 and Python3, as well as an improved pythonic interface and a new python egg installer.”

    tags: bs python library nag

Posted from Diigo. The rest of my favorite links are here.

What I’m Reading on 03/20/2014

Posted from Diigo. The rest of my favorite links are here.

What I’m Reading on 02/18/2014

  • “For RHEL6 and newer distributions tools are available to profile Python code and to generate dynamic call graphs of a program’s execution. Flat profiles can be obtained with the cProfile module and dynamic callgraphs can be obtained with pycallgraph.”

    tags: python

Posted from Diigo. The rest of my favorite links are here.

Map and Elevation Data

For a small personal project I’m starting, I wanted to get elevation data for the area surrounding our property in upstate New York. A quick web search yielded the The National Map website, a service of the US Geological Survey.

NY Elevation MapThe information and products on the site are extensive, but for my purposes I followed the link to The National Map Viewer and Download Platform. From there I zoomed down to the area of our house, and started looking at what was available. After several experiments, I decided to download a portion of the National Elevation Dataset at 1 arc second resolution. The 1/3 arc version was also available, but, as expected, was 9 times bigger.

The readme.pdf file starts with the following:

The U.S. Geological Survey has developed the National Elevation Dataset (NED). The NED is a seamless mosaic of best-available elevation data drawn from a variety of sources. While much of the NED is derived from USGS Digital Elevation Models (DEM’s) in the 7.5-minute series, increasingly large areas are being obtained from active remote sensing technologies, such as LIDAR and IFSAR, and also by digital photogrammetric processes. Efficient processing methods were developed to filter production artifacts in the source data, convert to the NAD83 datum, edge-match, and fill slivers of missing data at quadrangle seams. NED is available in spatial resolutions of 1 arc-second (roughly 30 meters), 1/3 arcsecond (roughly 10 meters), and 1/9 arc-second (roughly 3 meters). The dataset is updated with “best available” elevation data on a two month cycle.

These digital elevation datasets are essential in understanding the Earth’s landscape: elevation, slope, and aspect (direction a slope faces.) NED is critical to identifying and modeling geologic features such as water drainage channels and basins, watersheds, peaks and pits, and movements such as avalanches. NED is used to create relief maps, 3-D visualizations, to classify land cover and to geometrically correct data from satellite or aircraft sensors (orthorectification). The fire community, natural resource managers, urban planners, conservationist, emergency responders, communication companies to name a few all rely on these elevation datasets. This data also supports The National Map.

Now I have to figure out how to process the file, which I’ll do by looking at the data dictionary elsewhere on the site and writing some Python code.

Update: Even though I zoomed down to a rectangular area less than one block on a side, the downloaded data contains a 1 second by 1 second square of elevation data.That’s more data than I was expecting and I’ll have to pull out a subset.

What I’m Reading on 11/27/2013

Posted from Diigo. The rest of my favorite links are here.

What I’m Reading on 11/26/2013

Posted from Diigo. The rest of my favorite links are here.

What I’m Reading on 11/20/2013

  • “A certain Norwegian Blue parrot is still dead, nearly 44 years after it shuffled off its mortal coil and joined the choir invisible in a famous television comedy sketch. But there is life yet in Monty Python, the singularly influential British troupe, whose surviving members are to announce this week that they will join together for their first live performances in more than a decade.”

    tags: Monty Python

Posted from Diigo. The rest of my favorite links are here.

What I’m Reading on 09/22/2013

  • “THE hype over 3-D printing intensifies by the day. Will it save the world? Will it bring on the apocalypse, with millions manufacturing their own AK-47s? Or is it all an absurd hubbub about a machine that spits out chintzy plastic trinkets? I decided to investigate.”

    tags: dinner 3dprinting

  • “The open source Python programming language has continued to steadily improve its code quality in recent years and now surpasses that of its open source and proprietary peers, according to a study published by development testing vendor Coverity.”

    tags: python open source

Posted from Diigo. The rest of my favorite links are here.

What I’m Reading on 08/31/2013

Posted from Diigo. The rest of my favorite links are here.

Daily links for 03/21/2013

  • “The Python Software Foundation (PSF) announced it has reached a settlement with POBox Hosting Ltd. of the United Kingdom over the latter’s trademark application for the term “Python” in connection with cloud hosting and its application for a figurative trademark in Europe incorporating the word “Python.” While the PSF owns the trademark for Python within the United States, it did not have an equivalent filing within the European Union.”

    tags: python software

Posted from Diigo. The rest of my favorite links are here.

Daily links for 03/09/2013

  • “A few years ago, I went looking for Python parsing tools. I spent a long time researching the various options. When I was done, I had a cheat sheet on the different alternatives. This is that cheat sheet, cleaned up a bit. It is very spotty. If you have updates to the information here, let me know. Because this is a compilation of factoids freely available on the web, it is in the public domain.”

    tags: parser python parsing library

  • ““What we’ll find is a reinvention of some very traditional processes in companies and a rethinking of how HR gets done,” she says. “It’ll be underpinned by a fact base that will inform where the highest value is to be added.””

    tags: talent

  • “So far, Samsung, taking a page from Apple’s marketing manual, has remained tight-lipped on its plans for the Galaxy S4. But just about everyone agrees that the product will be one that consumers and business users will to take a close look at.”

    tags: samsung galaxy mobile

Posted from Diigo. The rest of my favorite links are here.

Daily links for 03/05/2013

IBM, OpenStack, and the cloud

Scientific computing

Posted from Diigo. The rest of my favorite links are here.

Daily links for 02/07/2013

  • “DARPA (the U.S. Defense Advanced Research Projects Agency) has awarded $3 million to software provider Continuum Analytics to help fund the development of Python‘s data processing and visualization capabilities for big data jobs. The money will go toward developing new techniques for data analysis and for visually portraying large, multi-dimensional data sets. The work aims to extend beyond the capabilities offered by the NumPy and SciPy Python libraries, which are widely used by programmers for mathematical and scientific calculations, respectively.”

    tags: python big-data analytics

Posted from Diigo. The rest of my favorite links are here.

Symbolic computation in the small: Math on mobile

What are the main considerations when designing a math system or library that can do symbolic computation on mobile devices?

I’ve written several times about math apps on mobile devices but, inspired by a blog post by Ismael Ghalimi, I want to comment a bit about how one might do symbolic computation on a small, probably mobile device.

What do I mean by symbolic computation? Some examples will probably make it clear. Unlike in a spreadsheet where you are concerned primarily with manipulating floating point numbers and text (e.g., 3.4 + 2.1 = 5.5), in symbolic computation you can also compute with expressions involving variables.

So in such a system you could compute that (x + 1)2 = x2 + 2x + 1 and the derivative of the result is 2x + 2. You can easily manipulate arbitrarily large integers and fractions of such numbers. There’s probably some capability for manipulating expressions involving trigonometric and other functions. You can both express sin2(z) + cos2(z) and the system will simplify it to 1. So you can manipulate and compute with basic expressions but also use structures like lists and mathematical vectors and matrices. With these you can then do linear algebra along with single and multivariable calculus.

I’ve oversimplified here and not mentioned all capabilities of such systems, but you should have an idea of how symbolic computation differs from what you can do in a spreadsheet. The two most successful commercial systems are Mathematica and Maple. Wolfram Research also provides Wolfram Alpha which allows you to use many of the computational capabilities of Mathematica via the web and on mobile devices.

Though Maple and Mathematica share similar functionality and have very sophisticated computational and graphical features, they are implemented very differently under the covers. I was involved with creating the Axiom system at IBM Research in the 1980s and 1990s, and it was built radically differently from the other two. In particular, it was ultimately built on Lisp which provided both bignum (large integers) and garbage college for the storage used. Yet another approach is that employed by the open source Sage application which collects together various implementations under one tent.

Since you have different ways of building such systems and representing the computational objects in them, what are the considerations for using symbolic capabilities on a mobile device?

  • Space: (x + 1)2 expands to just three terms, but the expression (x + 1)200000 expands to 200,001 terms, which will take up quite a bit of space, probably well more than 1Mb. So small things can get big quickly once you start computing with them.
  • Time: Expanding the above polynomial can be done in a few seconds, but factoring it could take many minutes or hours, depending on your heuristics and algorithms. What will your mobile user be doing while he or she waits for an answer? Similarly, taking the derivative of an expression is relatively straightforward, though simplification can be time consuming. Integration can take considerably more time, if you can do it at all.
  • Formatting: These days users expect beautiful output. So while sin(x2 + 2x + 1) looks fine, older style output like sin(x^2 + 2*x + 1) is just ugly. If you are just computing with a symbolic expression as part of a larger action, you may never need to show fancily formatted math expressions. By the way, once you get very large expressions that need to span multiple lines or large two-dimensional ones, formatting becomes much harder. See TeX and LaTeX to learn about how to handle the complexity in its most general form. In practice, you’ll do something simpler.
  • Client vs. Server: How much work is done on the device versus on a big server somewhere? You can compute faster on the server, but what’s the delay in communicating back and forth with it and sending data? What do you do if you have no or limited bandwidth? Personally, I think a hybrid scheme where some things are done locally and others can be offloaded to a server probably makes the most sense, but it does complicate processing.
  • Library: Do you want this code to be wrapped up in a library that can be linked to multiple apps? If so, you need to design your interfaces very carefully. If the library will be used by different parts of the same app, make sure it is thread safe, so you don’t mess up one computation that’s going on when you request another.
  • Portability: If you could use languages like Python, Lisp, or Scheme, you would get bignums and memory management for free. If you use C++, you’ll have to do those things yourself, perhaps by using open source libraries to help you. On iOS devices, it’s perfectly fine to use Objective-C for the interface components and C++ for your computational back-end. You could also use that C++ code on an Android or Windows 8 Mobile device. I suppose you could use a subset of a Lisp interpreter written in C++ and then build your math code on top of that.
  • Legal: Apple has very specific rules about when you can download a script and run it on your iOS device. If you plan to download a file that contains a list of computations to be executed, make sure you are not running afoul of Apple’s terms and conditions.
  • Extensibility: The big systems are all designed so users can add more capabilities to them. Depending on the system, the new things might run just as fast as what is built in, or somewhat slower if the expressions are interpreted. For mobile, I think this is mostly a core developer question: How do I construct the libraries at the center of the system so that I can easily add new mathematical objects with which to compute? The basic objects are probably integers, rational numbers, floating point numbers, polynomials, rational functions, general expressions that can include trig functions and integrals, lists, vectors, and matrices. How might you later add partial differential equations? I think you need a design that allows you to build new objects, register them in the system, and then compute with them as if they were there all along. This is more computer science than math, but you’ll quickly see the value in being able to extend the system.

Daily links for 05/18/2011

  • “Richard Dawkins has a new kids’ book coming out in October called The Magic of Reality, which explains just how gosh-darned awesome the actual scientifically explained world is, and how wondrous the universe is when considered as a material, non-supernatural phenomenon. And if that wasn’t awesome enough, the book is illustrated by the wonderful Dave McKean (whose work you might know from Neil Gaiman books like The Day I Swapped My Dad for Two Goldfish, or the US cover of my novel Someone Comes to Town, Someone Leaves Town).”

    tags: dawkins book science

  • “The Summer pyGames project is a six-week long competition during which high school students develop open-source educational software and games to be used and distributed to schools in South Carolina. Many of last year’s competing teams presented at the FIRST Championship in St Louis. The program has also been showcased at the FIRST Robotics Palmetto Regional, POSSCON and INNOVENTURE Southeast.”

    tags: pygames summer python Open Source

  • “And although Apple isn’t known for its corporate focus or market penetration, it’s the leader when it comes to tablets: 83 percent said they would be using iPads. That compares to 17 percent for RIM’s BlackBerry PlayBook, 14 percent for HP’s Slate, 13 percent for Motorola’s Xoom, and 11 percent for Dell’s Streak.”

    tags: ipad apple

  • Fedora is in the process of retiring our old “Individual Contributor
    License Agreement” (also known as the ICLA or CLA) and replacing it with the new Fedora Project Contributor Agreement (FPCA). All Fedora contributors with accounts in the Fedora Account System
    (https://admin.fedoraproject.org/accounts) who have agreed to the old CLA *MUST* agree to the new FPCA by June 17, 2011 to continue contributing to Fedora.”

    tags: fedora linux license

  • “Starting on Wednesday, Film Forum is offering a double feature of the literal Dylan, made up of “Don’t Look Back” (1967), by D. A. Pennebaker, and “The Other Side of the Mirror,” Murray Lerner’s compendium of Newport Folk Festival concert footage from the early 1960s. Both films highlight the mischievous, mercurial aspects of Mr. Dylan’s personality, while also providing undeniable proof of his musical prowess and incidental proof that he was, indeed, a young man once.”

    tags: Bob Dylan film

Posted from Diigo. The rest of my favorite links are here.

Daily links for 04/28/2011

  • “A thick, heavy book with the equally weighty title A Practical Guide to Linux Commands, Editors, and Shell Programming may be the single most important Linux book you ever buy.”

    tags: linux macosx book

  • “Canonical has announced the official release of Ubuntu 11.04, codenamed Natty Narwhal. This major update introduces the new Unity desktop shell, which is designed to improve ease of use and deliver a more modern user experience.”

    tags: ubuntu linux

  • “In lab tests, people can distinguish between sounds as little as five milliseconds apart, and our involuntary timing is even quicker. If you’re hiking through a jungle and a tiger growls in the underbrush, your brain will instantly home in on the sound by comparing when it reached each of your ears, and triangulating between the three points. The difference can be as little as nine-millionths of a second.”

    tags: brain time newyorker

  • Python Math is a full implementation of the Python Programming Language with a restricted set of modules focused on mathematics processing. For more information, documentation, tutorials, downloads for other computers, and even merchandise about Python, go to python.org. No network connection is needed. The Python Math interpreter runs in your iPhone, iPod Touch, or iPad. Python Math is a universal app, meaning that it runs on iPhone, iPod Touch, or iPad, without downloading a separate app.”

    tags: ipad iphone programming python math

  • “iLuaBox provides an intuitive environment to learn, write, and run scripts written in the Lua Programming Language. This is not a stripped down version of Lua, but rather a full-featured implementation that is optimized for iOS 4.2. iLuaBox is a universal application that runs on any iOS 4.2 compatible device.”

    tags: iphone ipad iluabox lua programming

  • “Yet the stock is stuck, Bloomberg Businessweek reports in its May 2 edition. It closed at $26.38 yesterday versus its average of about $27 since the start of 2001. The shares, which first surpassed $26 in 1998, have lost about 7.1 percent including dividends in the past decade while the S&P 500 returned 30 percent.”

    tags: microsoft stock

  • “Second beta for the LibreOffice 3.4 open-source office suite is available one week after Oracle dumped a commercial version of OpenOffice.org

    tags: libreoffice oracle openoffice.org

  • “As expected, the buyout of Linux power Novell by Attachmate has finally gone through. On April 27th, Attachmate acquired Novell for $6.10 per share in cash–approximately $2.2-billion. With this deal completed, Novell is now a wholly owned subsidiary of The Attachmate Group, the parent company of Attachmate Corporation. Immediately prior to the merger Novell completed it’s “previously announced sale of certain identified issued patents and patent applications to CPTN Holdings LLC for $450 million in cash.””

    tags: novell attachmate linux

Posted from Diigo. The rest of my favorite links are here.

Daily links for 11/07/2010

  • “Costanza asked Sussman why MIT had switched away from Scheme for their introductory programming course, 6.001. This was a gem. He said that the reason that happened was because engineering in 1980 was not what it was in the mid-90s or in 2000. In 1980, good programmers spent a lot of time thinking, and then produced spare code that they thought should work. Code ran close to the metal, even Scheme — it was understandable all the way down. Like a resistor, where you could read the bands and know the power rating and the tolerance and the resistance and V=IR and that’s all there was to know. 6.001 had been conceived to teach engineers how to take small parts that they understood entirely and use simple techniques to compose them into larger things that do what you want.”

    tags: lisp python scheme mit

  • photo of iKlip

    “IK Multimedia continues to help bring your iPad to the stage with iKlip, a universal microphone stand adapter for Apple’s iOS-based tablet. Use the iKlip to help practice during music lessons, make presentations even easier, display note sheets or lyrics for reference in live performances, control visual effects right on stage, and so many other possibilities.”

    tags: ipad iklip music

Posted from Diigo. The rest of my favorite links are here.

Daily links for 09/24/2010

Posted from Diigo. The rest of my favorite links are here.

What’s holding back presentation software?

I can’t think of one thing I do with presentation software today other than creating PDFs that I didn’t do ten years ago.

We have Microsoft PowerPoint, we have OpenOffice.org Impress, and IBM‘s Symphony. Over on the Mac we have Keynote. Toss in a few others such as KOffice and we have the office productivity market.

These all have value to their users though if though don’t support ODF, the Open Document Format, in a first class way, I don’t care too much about them. On a regular basis I use Symphony and to a much lesser extent OpenOffice.org and Keynote.

I don’t view presentations on the web as a matter of course, though I do look at SlideShare occasionally. I probably get a dozen presentations a day for work. Unless I’m going to edit them, I want them in PDF format. Otherwise I expect ODF.

The software for creating and deploying presentations have changed very little in the sense that we create blank slides, use templates and predefined layouts, add text and images, and fiddle with fonts and colors. Depending on the application you choose, this is more or less easy.

If you were to create a new desktop presentation application from scratch, what features would you put into it? What would you do differently compared with the apps above?

I’ve addressed some of these ideas before in “Presentations: Still too hard to mix and match” and “Presentations: The death of complexity”.

Here’s an idea of what I would do. Note my usual disclaimer that these are my own opinions and not those of any IBM product group.

  • Forget backward compatibility with the Microsoft formats. I understand that for some of you this is a non-starter, but this is my app and I’m starting with a clean slate. I have no interest in supporting the huge number of features that minorities of users need. I also don’t want to support all the failed formats contained in OOXML. Therefore it all goes.
  • I would support ODF natively, but look at understanding the subset, if possible, that I would need.
  • Excellent PDF export is necessary.
  • Like applications such as Firefox and WordPress, I would have a well defined and documented architecture for extensions and hooks. The goal is to keep the core small, tight, and well understood. From there we would drive a third-party market for tools that extend the core. These could include input format filters and export plugins.
  • I would use Python as the macro language in the presentation editor.
  • While I would target the desktop, the architecture must facilitate multi-touch interfaces such as the iPad and the upcoming Android tablets.
  • I would not prioritize support for devices as small as a smartphone.
  • The display engine would be cleanly separated from the core components. For the desktop, I would start with a Linux port, then do the Mac, and finally Windows.
  • Themes and presentation documents need more metadata to make it simple to switch themes easily and accurately. That text box at the top of a slide in a big font is not assumed to be a title, it is known to be a title because of the information associated with it. This also allows me to create and manipulate presentations programmatically, even on servers. No guessing about slide structure is allowed.
  • I need to be able to manage groups of one or more slides for reuse, with versioning. It is still far too difficult to create libraries of slides and then put them together when necessary into new presentations. Slides and groups of slides need tags. For extra credit, slide groups might have suggested dependencies so you know, say, that you should not include these 4 slides without showing those other 2 first. Similarly, one group of slides might be indicated as being the in-depth expansion of another group.

What am I missing? What would you do differently?

Math apps and the updated iOS Developer Program License Agreement

Apple‘s changes to the iOS Developer Program License Agreement resolve some issues but still contain confusing elements for those who might want to develop sophisticated apps such as those for mathematical computation.

As I first discovered this morning in a blog post by Hank Williams, Apple has changed their iOS Developer Program License Agreement to be less restrictive on the tools used to create apps for iOS for the iPos Touch, iPhone, and iPad.

Apple’s press release states:

We are continually trying to make the App Store even better. We have listened to our developers and taken much of their feedback to heart. Based on their input, today we are making some important changes to our iOS Developer Program license in sections 3.3.1, 3.3.2 and 3.3.9 to relax some restrictions we put in place earlier this year.

In particular, we are relaxing all restrictions on the development tools used to create iOS apps, as long as the resulting apps do not download any code. This should give developers the flexibility they want, while preserving the security we need.

Those relevant sections in the license agreement are:

3.3.1 Applications may only use Documented APIs in the manner prescribed by Apple and must not use or call any private APIs.

3.3.2 An Application may not download or install executable code. Interpreted code may only be used in an Application if all scripts, code and interpreters are packaged in the Application and not downloaded. The only exception to the foregoing is scripts and code downloaded and run by Apple’s built-in WebKit framework.

3.3.9 You and Your Applications may not collect user or device data without prior user consent, and then only to provide a service or function that is directly relevant to the use of the Application, or to serve advertising. You may not use analytics software in Your Application to collect and send device data to a third party.

In April I looked at the previous restrictions in the license and concluded that it would be very difficult to to implement a full featured mathematics application on the iPad.

Nota Bene: I am not an attorney and the following does not represent a legal opinion and certainly not an official IBM point of view.

The changes to sections 3.3.1 and 3.3.s improve things somewhat today:

  • Evidently you can now have an interpreter on the device. This means that you could run Python or a Java virtual machine on an iPad.
  • From 3.3.2, prepackaged scripts are allowed, so interpreted Python code is allowed if that code comes with the app.

However,

  • You cannot download code to be interpreted.
  • I am not sure if you are allowed to type in code on the iPad and then have it interpreted. I suspect not, because that code is not prepackaged with the app, even though it is not downloaded.

From the perspective of building a math app with Python or another interpreted language, I interpret this as strictly meaning that the app and libraries are fine now, but users cannot write new functions if the math app provides an interpreted language such as Mathematica and Maple do.

This is problematic. If, say, the library does not provide a factorial function, am I not allowed to write one?

I suspect that one of the things that Apple wants to avoid are system calls into the iOS operating system by random downloaded scripts. I hope it is not just a question of performance. Some computations take a very long time.

I really can’t see how this type of interpreted script for math computations should cause any problem for the iPad device, for Apple, or the users. This form of code interpretation is how things get done in these kinds of apps.

Indeed, if I have a word processing document it contains markup to indicate paragraphs, fonts, colors, and so forth. A work processing app interprets that information, which could be said to be a descriptive script. Or is ok to interpret such things? Do I need permission from Apple to do this?

I don’t think this is the last we will hear from Apple in this area. Their statement is now shorter, but it is not complete enough regarding the kinds of code that might be interpreted. I think another round is necessary to clarify matters.

On the other hand, perhaps all this is below Apple’s radar or level of caring. While that might be true, it might be better to ask permission first rather than asking forgiveness later when you submit your app for publication.

Daily links for 08/11/2010

Posted from Diigo. The rest of my favorite links are here.

Daily links for 04/22/2010

  • “As part of our ongoing effort to develop an open platform for WhiteHouse.gov, we’re releasing some of the custom code we’ve developed. This code is available for anyone to review, use, or modify. We’re excited to see how developers across the world put our work to good use in their own applications.”

    tags: whitehouse, open-source

  • “This tutorial will show you how to consume and process data from Twitter‘s new streaming API. The code examples, which are written in the Python programming language, demonstrate how to establish a long-lived HTTP connection with PyCurl, buffer the incoming data, and process it to perform the basic message display functions of a Twitter client application. We will also take a close look at how the new streaming API differs from the existing polling-based REST API.”

    tags: twitter, python, API, streaming

  • “Oracle has imposed a fee of US$90 per user on a plug-in for Microsoft Office that was available at no cost under Sun Microsystems’ ownership.
    The tool allows Word, Excel and PowerPoint users to read, edit and save documents in the ODF (Open Document Format), which is used by the competing OpenOffice productivity suite.”

    tags: oracle, odf

  • “We should want companies to invest in ODF tools.  We should want the demand for ODF to be such that ODF-based goods and services have value, can be sold based on that value, and that there is competition again in the market, something we have not seen in this area in many years.”

    tags: odf, oracle

Posted from Diigo. The rest of my favorite links are here.

Daily links for 04/16/2010

Posted from Diigo. The rest of my favorite links are here.

Math software, dynamic languages, and the iPad

Will issues around multitasking and the new restrictions on the use of dynamic languages stop the Apple iPad from being used as a serious device for mathematical and scientific software?

Several days ago I did a blog post about how math software might be able to take advantage of tablets like the iPad that are now hitting the market. I spoke about some of the classical systems like Maple and Mathematica, as well as the one with which I was involved, Axiom.

If they were so inclined, it would be more possible to port the first two to the iPad than Axiom and systems like it because they are largely self-contained and are written in C or C++ (I believe). This means that they won’t automatically go afoul of Apple’s new modified clause 3.3.1 in their terms of service:

3.3.1 — Applications may only use Documented APIs in the manner prescribed by Apple and must not use or call any private APIs. Applications must be originally written in Objective-C, C, C++, or JavaScript as executed by the iPhone OS WebKit engine, and only code written in C, C++, and Objective-C may compile and directly link against the Documented APIs (e.g., Applications that link to Documented APIs through an intermediary translation or compatibility layer or tool are prohibited).

Also see this 37signals entry on some complaints about the new 3.3.1 and Larry O’Brien’s “The Absurdity of Apple’s New iPhone Restrictions”.

While a lot of the attention has been on Adobe’s new cross-compiler and Java, this also evidently rules out using dynamic languages like Python and Scheme unless somehow, someway, things get translated into a binary that is completely indistinguishable from code as created as described in 3.3.1.

Axiom is written in Lisp and so that gets tossed in the waste bin. Note that Axiom is a huge system and a rather old one at this point, so I’m not saying that anyone would really want to port it to the iPad, but now we know they shouldn’t even bother.

Mathematical software for symbolic computation manipulates expressions that can get quite big, such as 21000:

107150860718626732094842504906000181056140481170553360744375038837035105112493612249
319837881569585812759467291755314682518714528569231404359845775746985748039345677748
242309854210746050623711418779541821530464749835819412673987675591655439460770629145
71196477686542167660429831652624386837205668069376

Even worse are large polynomials and matrices. When you start calculating with them, many intermediate results can be produced and memory efficiency becomes very important.

Though you still have to have a good strategy around destructive and non-destructive object operations, with languages like Python, Java, and Scheme, you get built-in garbage collection. This is not true with C++ in general and while Objective-C now does have it on the Mac, it does not have it for the iPhone and iPad.

Also, Python and Scheme have bignums, those arbitrarily large integers like the one above that makes it easier to do calculations. (I know there are packages for other languages and interested readers should certainly look at GMP, the GNU MP Bignum Package for C and C++).

So if I were to write a serious math program for the iPad, one that could do large and sophisticated computations within the memory confines of the device, I would have to worry about linking in a package like GMP (which is GPL) and I would probably need to write some form of garbage collection, or otherwise have a very strict coding philosophy on managing object memory.

The former is very possible, the latter is a total pain in the neck here in 2010. Of course I would want to use Python or perhaps Java for a serious math application. With 3.3.1, that’s not in the cards, at least right now. I might consider other languages for performance reasons, but those would be my first two to consider.

Therefore if you were going to write that great next math app, you probably will want to do it for the Android or another Linux tablet. Will this have similar implications for other types of scientific software? I don’t mean toys for little problems, I mean professional-quality software.

While we’re at it, multitasking on any of these devices will be very important (once the iPad gets it later this year). No, don’t stop working on that big calculation and no, don’t kill my app because I’ve been doing other things. Will issues around the way tablets do multitasking keep serious math software off these new little gadgets?

Also see:

Math software in the age of the iPad and other tablets

Will the next generation of tablets lead to new and better user interfaces for mathematical software? Will this encourage the use of tablets in education?

Back in the 80s and 90s I was a member of the Mathematical Sciences Department in IBM Research in Yorktown Heights, NY. Under the leadership of Dick Jenks and with significant contributions from many internationally known computer algebra scientists and mathematicians, we produced mathematical software called Axiom. While it ultimately could not compete with more commercial offerings like Maple and Mathematica, it contained state of the art computer language features that only otherwise appeared much later in languages like Java, Python, and Ruby.

Axiom logoMathematical software like Axiom is not the same as a spreadsheet. Rather than compute extensively with decimals and produce charts, so called symbolic mathematical software factors huge integers, manipulates and factors polynomials, computes derivatives and integrals, simplifies trigonometric expressions, and performs arithmetic on matrices. These systems do much more and have extensive libraries for computation. Axiom also allows you to define categories like UniqueFactorizationDomain and then instantiate it into types like univariate polynomials in x whose coefficients are rational numbers.

Very fancy stuff. Axiom has the capability to express and solve some very difficult problems. This power comes at a price, however, and we spent a lot of time trying to make the system do simple problems easily and quickly. Maple and Mathematica certainly did and do better in that regard.

There are many open source systems out there of varying capabilities that do symbolic mathematics. For example, Sage rolls up a lot of different math software via Python. Maxima is an open source fork of one of the grandaddies of the computer algebra world, Macsyma, originally developed at MIT.

While any one system may do some things particularly well, it is Maple and Mathematica that have the bulk of the marketshare and the breadth of related products, not to mention polish and consistency. These are desktop programs for the most part, though Wolfram|Alpha does let you do some mathematical computations via its web interface.

What will mathematical software look like when the primary device being used is a tablet like the iPad or one of the upcoming Linux-based machines? Will we be using Wolfram|Alpha to solve all our problems in a browser? I doubt it.

First of all, we should not think of simply replicating the screen-based interfaces for the tablets. If I want a screen and mouse, I’ll use a laptop. What is different about the user interfaces of the tablets that will change how we do math?

Much of the focus will naturally be on education. Imagine this scenario: a teacher in a 7th grade math class tells her students “take out your tablets and compute the height of the tree given the values shown in the picture.” What would the students do?

First of all, the picture should be live in the sense that the numbers representing the lengths of various lines are not just dots on the screen but values that have units associated with them, e.g., 7 meters. Students should be able to open a calculation area, drag the numbers out of the picture, create expressions and equations, drag and drop values with their fingers from one side of an equals sign to the other, and document how the problem was solved. All on a tablet, in an intuitive way.

An economist reading a paper in a journal comes across an expression that he needs for some work. He selects the equation, drags it with his finger to his working notebook on the tablet, and then plugs in some numbers. To get to the tiny exponents he uses his fingers to squeeze open (zoom) the expression, and then shrinks it again when he is finished. When he is done, he can save the result or send it to a colleague.

Yes, I know this sounds a lot like notebooks for you Mathematica users. Those are primarily for desktop or laptop computers and certainly don’t use the native gestures or user interface of the iPad or those tablets that have yet to be introduced.

Will we just see a port of existing heavy duty math software described above or will we see brand new entries that rethink how problems should be solved? Probably, eventually, both, but I’m rooting for the latter since I want to see some innovation in this space. Yes porting over twenty year old technology will work for some people, but that’s not paving the way for radically new educational or problem solving software.

I want to be able to hand a tablet to a 12 year old and have the math software be so intuitive that he or she could be solving real problems in minutes. (Yes, I know there are serious questions about when computers or calculators should be used versus direct manual calculation, but that’s not a point I am trying to debate in this entry.)

What do you think? Will we see more of the same or radically new ways of doing math on tablets like the iPad? There are already fairly simple math programs for the iPhone and hence iPad, but what will the first really serious and different math applications look like and how will they take advantage of the new devices?

Also see:

Daily links for 04/01/2010

Red Hat logo

  • Red Hat, Inc. (RHT 29.27, +0.34, +1.18%) , the world’s leading provider of open source solutions, today announced the availability of the fifth update to the Red Hat Enterprise Linux 5 platform, Red Hat Enterprise Linux 5.5. Adding features designed to operate across physical, virtual and cloud deployments, the update offers enhanced virtualization and interoperability capabilities combined with support for important new hardware platforms. As with all Red Hat updates, application compatibility and certification with the Red Hat Enterprise Linux 5 platform is fully maintained, meaning the broad portfolio of certified applications for Red Hat Enterprise Linux applies to the new update. Red Hat Enterprise Linux 5.5 is available to subscribing customers via Red Hat Network today.”

    tags: red-hat, linux

  • “The Python programming language has gained popularity as one of the components of the LAMP (Linux, Apache, MySQL and Python/Perl/PHP) stack. Python has seen a resurgence in programmer interest, and dynamic languages such as Ruby and Python have emerged as alternatives to languages like Java and C#.”

    tags: python, cloud, eweek

  • “Unseasonable temperatures forecast to hit 70 degrees greeted anglers today for the opening of trout season on New York’s inland waters.”

    tags: trout

  • Apple iPad

    “The first Apple iPad reviews are in and not-too-surprisingly they are all bullish on the device. Unfortunately, you’re not going to learn much about the iPad from the reviews until you take one for a spin and ponder your own personal use case scenarios.”

    tags: ipad, Apple

  • “OUR horseradish roots looked so innocent when they arrived in the mail last spring. Just little brown sticks, about eight inches long and as narrow as pencils.

    But last weekend, when we harvested the year-old roots of one plant, they were on the atomic side of hot.”

    tags: horseradish, gardening

  • “As unlikely as it sounds, some people are willingly, even enthusiastically, spending upward of $1,000 on shredders heavy duty enough to reduce personal documents and other items to the consistency of confetti — particularly during tax season, or high shredding season, when shredder sales peak every year.”

    tags: shredders, nytimes

Posted from Diigo. The rest of my favorite links are here.

On highly customizing that open source code

Several weeks ago at OSBC I posed a serious of “hard questions” about open source software. They weren’t meant to demean it, of course, but were really to say that software for the enterprise needs to be held to very high standards, whether it open source or traditional.

One of the sections was this:

Who will maintain your installation of the software?

  • If you are planning for your IT staff to install and maintain your software, make sure it doesn’t get orphaned when you have personnel turnover.
  • When software updates come along, you will need a plan to decide which ones to install and when, especially if major releases come along every six months or so.
  • If you customize open source code for your organization, are you prepared to propagate those changes into newer versions of the code?

Today I saw the story “You may want to avoid hacking your open-source CMS” which discussed The Onion’s experience hacking an old version of Drupal. To give you an idea, version 7 of Drupal is about to come out and the latest official version is 6.16. The Onion highly customized version 4.7. That alone should make you nervous since clearly the software has moved far beyond the point where it was forked.

The original article referenced discussed how The Onion moved from Drupal, a PHP application platform, to Django, a Python framework.

The problems with highly hacking code is that it is very hard to maintain it for functional and security fixes, you don’t easily get improvements to the code base, and you may be doing similar work to what is happening in the community, and maybe not as well.

This reminds me of a blog entry I did in December called “Open source software: modify, extend, or leave it alone?”. There I concluded:

There can be innovation in the core application, but that same application can become a platform for innovation if it has a good extension mechanism. Choose good applications that can be improved or configured outside the core software, and you’ll save a lot of trouble and gain some real advantages. This is true for open or closed source software.

Postscript: As Jonathan Bennett pointed out to me on Twitter, I failed to mention a very important aspect when you do make changes to open source code: offer your modifications back to the community and your code may make it into the main trunk of the project. That is, since you are doing some coding, become a contributor as well. This may not always be possible, but consider it.

Open source game engines for Linux

My recent post about Linux and video games has gotten quite a few hits, so while I was on a three hour flight today I thought it would useful to later put together a list of free and open source game engines that you and others could use to build said games. Upon landing, I cleverly did a web search and found that Wikipedia has an extensive list of game engines. It could change tomorrow, so grab it quickly!

So I won’t do the list as there is no further need, but let me interpret the table headings in the Wikipedia article for you:

Primary programming language means the language in which the game engine itself is created. Unless you plan to change the engine, you don’t need proficiency in that language, though you may need to compile and link the engine for your platform. Those engines written in C may be older or optimized for speed, those in C++ somewhat newer, those in C# likely started life on Windows and would need Mono for other platforms, and those that use Python might not be the fastest in the world unless they also use components written in the other languages I just mentioned.

Bindings means the programming languages from which you can call the facilities provided by the game engines. So though Crystal Space is written in C++, it can also additionally be called from software written in Python, Perl, and Java, for example. If nothing is mentioned here, it means you would do best to just use the engine in software written in the same language as the engine. Note, though, that engines written in C can probably be called from C++ programs.

Cross platform means it works on more than one platform. It does not mean it works on all platforms. Check carefully if it works on Linux.

SDL is the Simple DirectMedia Layer which, further according to Wikipedia:

Simple DirectMedia Layer (SDL) is a cross-platform, free and open source software multimedia library written in C that presents a simple interface to various platforms’ graphics, sound, and input devices.

Some cross-platform libraries give you basic functionality but take a rather “least common denominator” approach. Look at samples of games using the libraries to ensure that all the bells and whistles you need are present and the games can look modern and professionally designed.

Finally, scripting refers to the programming languages you can use to extend the functionality of your game without changing either the gaming engine or your core code. For example, World of Warcraft uses Lua to allow players to create and build addons that provide better game maps, inventory bags, health meters, and so on. Badly constructed scripting interfaces can open up your game to security intrusions, while well designed ones can really enhance the game experience. Also see my older blog entry on embedded programming languages.

Daily Links for Thursday, January 7, 2010 – Morning Edition

Open Source

Munich administration switches to OpenDocument Format
The H Open Source: News and Features

Also see my blog entry “Update on sharing documents”.

According to a 2009 development review that the deputy project leader Florian Schießl has posted on his blog, open source OpenDocument Format (ODF) is now the main document exchange standard, with PDF being used for non-editable files.

Games

Invent Your Own Computer Games with Python
Al Sweigart

“Invent Your Own Computer Games with Python” is a free e-Book that teaches you how to program in the Python programming language. Each chapter gives you the complete source code for a new game, and then teaches the programming concepts from the example.

“Invent with Python” was written to be understandable by kids as young as 10 to 12 years old, although it is great for anyone of any age who has never programmed before.