15

There are several approaches to embed large expressions in questions/answers/comments on MMA.SE. Here is a list of several common methods with some advantages and possible issues:

  1. Embed complete expression in the InputForm.

    (+) Does not rely on availability of external services.

    (+) Allows one to see the expression before evaluation.

    (+) Any changes to data can be easily tracked using standard SE interface.

    (-) Takes a lot of space. Not usable in comments.

  2. Embed Compressed expression.

    (+) Does not rely on external services.

    (0) Only overall changes in data can be seen using standard SE interface.

    (0) Takes less space than method 1, but can still be large.

    (-) It is hard to see the expression without evaluation.

    (-) Copy-pasting may introduce extra slashes which corrupt compressed strings.

  3. Link to a specially crafted i.stack.imgur.com image.

    (+) Takes only one line.

    (+) Uses SE Imgur account, which is a part of SE network.

    (+) An image cannot be changed without changing its URL and cannot be removed.

    (-) It is hard to see the expression without evaluation.

    (-) Has a size limit of 2MB because then imgur automatically converts png images to lossy jpg images

  4. Link to a cloud object (see this Q&A)

    (+) Takes only one line.

    (+) Allows everyone to see the expression before evaluation. (one can open a link in a browser and read the InputForm)

    (-) Uses external service, which can be changed/discontinued in the future.

    (-) Expression can be modified without changing URL or removed. One cannot track changes.

There are also some other methods: see here, here and here.

What are some other points to consider? Which method should be preferred to share large expressions and datasets on MMA.SE?

  • The answer to "Can you see the expression before evaluation?", could be more than Boolean. Would a "preview" be enough or are we talking about avoiding potentially malicious code? How do you rate a slightly distorted form such as the output of URLEncode. – rhermans Apr 26 '17 at 9:23
  • The point about space, can also have more than one aspect. The most relevant, as you point out, is if it could fit in a comment or not. I submit that another relevant point is about display space. If encoded "attachments" were to be allowed (hidden text as I suggest elsewhere) then "complete expression in the InputForm" could potentially use zero display space, but significant code space. – rhermans Apr 26 '17 at 9:29
  • About the code necessary to retrieve the data, length, complexity, origin and potential vulnerability are aspects to consider. For example in terms of security is not the same to run code from a public repository (Import[url1][url2]]), than using a couple of easy-to-understand built in functions. – rhermans Apr 26 '17 at 10:39
  • 4
    Another point to consider is that probably we don't want to make it too easy to casually share vast amount of data, as that may encourage to also share huge code, which is undesirable because only minimal working examples are likely to be of broad interest for the community. – rhermans Apr 27 '17 at 15:54
2

Nice comparison, thanks for asking the question. Below are my notes, they are not official in any means.

Which method should be preferred to share large expressions and datasets on MMA.SE?

First of all, try not to

  • Try to create MWE - What do we mean by a self-contained (minimal) working example?

  • Try to use Random* functions, ExampleData and friends to prepare something that everyone can grasp at once and run just after.

  • There are cases where mwe is not suited and required example would be too big, put effort to make a very clear description and explain why there isn't data attached.

Otherwise use 'secure' and stable way

Before we talk where to put it let's talk what to put.

  • Use InputForm

    In my opinion, only InputForm should be considered. Even experienced users can be surprised by formatting/typesetting issues related to StandardForm of unknown data (e.g. Compressed):

    How to uncompress strings safely (without any evaluation)?

    You can't force people to use HoldComplete and InputForm manually each time and even if you have no bad intentions then the habit of sharing compressed data can be used by someone who has.

  • Don't use notebooks

    Which is indicated by the point above but I want to stress this out. Notebooks are not safe unless you really pay attention. I hardly ever fetch notebooks from people I don't know.

    You think Enable Dynamics prompt will save you? Think again:

    CreateNotebook[{}, NotebookEventActions -> {
       {"KeyDown", "\t"} :> Print[
        "I may not have administrator rights but I can mess with some MMA settings and delegate damaging tasks for later"]}
     ]
    

So points 2. and 3. are dealt with here.

Where to put it

  • Directly in the question

    { 0.67111,0.0828038,0.555128,0.598409,0.457922,0.678653,0.276026,0.823095,0.623762,0.948059,0.899435,0.323355,0.129256,0.0465962,0.23016,0.30019,0.505508,0.542736,0.246008,0.940774,0.183999,0.665643,0.986283,0.999885,0.743403,0.910007,0.164008,0.559334,0.479908,0.771447,0.625016,0.466895,0.890353,0.65901,0.213874,0.594558,0.853985,0.759469,0.412171,0.827799,0.890399,0.0433437,0.19884,0.194744,0.433901,0.410485,0.76009,0.556419,0.0798914,0.85193,0.564097,0.652759,0.842959,0.312469,0.929366,0.218443,0.513998,0.751924,0.89414,0.791285,0.618427,0.992158,0.64763,0.18579,0.449355,0.5303,0.361565,0.456624,0.410722,0.473719,0.701871,0.879078,0.0473695,0.82465,0.609222,0.652629,0.488148,0.318038,0.231846,0.887771,0.721355,0.934728,0.892904,0.234807,0.790037,0.244299,0.0706067,0.113333,0.574857,0.201988,0.961918,0.365571,0.614368,0.385623,0.438244,0.431033,0.359504,0.823225,0.754404,0.176419,0.824584,0.383004,0.0206623,0.937147,0.0320603,0.0477728,0.709605,0.897071,0.911298,0.723171,0.316351,0.309947,0.506605,0.631165,0.654243,0.18409,0.435526,0.288635,0.0917038,0.913724,0.378764,0.895862,0.976941,0.607102,0.220397,0.692745,0.668534,0.532053,0.00176187,0.177267,0.449274,0.343088,0.946664,0.0579874,0.229241,0.483306,0.599533,0.0842731,0.657558,0.501628,0.179675,0.348318,0.0832335,0.190119,0.0812308,0.579063,0.96444,0.263142,0.627887,0.508107,0.542124,0.589567,0.312685,0.448691,0.483346,0.384769,0.343578,0.265972,0.45681,0.582011,0.0437964,0.223677,0.753169,0.471233,0.690732,0.498804,0.519293,0.41689,0.225787,0.593914,0.653158,0.192607,0.934243,0.558579,0.318603,0.330598,0.416476,0.766344,0.111451,0.538361,0.42982,0.126886,0.91086,0.983139,0.860858,0.743334,0.925977,0.872395,0.58179,0.591663,0.374565,0.800145,0.265865,0.0147606,0.949537,0.515173,0.032033,0.216754,0.941965,0.782579,0.331224,0.441596,0.111865,0.396198,0.436608,0.304259,0.447226,0.834023,0.759666,0.746198,0.633529,0.904704,0.15471,0.946534,0.809391,0.424888,0.806552,0.950881,0.957659,0.899489,0.245055,0.230287,0.699513,0.183002,0.132976,0.380536,0.991309,0.143196,0.511209,0.170415,0.0461862,0.51931,0.328651,0.728893,0.785514,0.188379,0.386357,0.529101,0.766251,0.232533,0.425402,0.6574,0.26622,0.288186,0.40846,0.997499,0.139197,0.362636,0.820371,0.545148,0.656512,0.444978,0.588981,0.892797,0.540424,0.302869,0.727984,0.524945,0.224368,0.462132,0.824126,0.826686,0.710654,0.653433,0.747517,0.372162,0.0839242,0.287512,0.426516,0.320722,0.161141,0.0952589,0.302133,0.240484,0.186576,0.455018,0.603576,0.862517,0.392626,0.450414,0.310305,0.68132,0.00822793,0.689921,0.858119,0.455685,0.804641,0.260321,0.134259,0.961881,0.641889,0.51841,0.00628243,0.336833,0.80178,0.596301,0.107011,0.0299962,0.88055,0.75993,0.592669,0.639293,0.361204,0.618668,0.456147,0.403916,0.777781,0.995622,0.912042,0.268168,0.925394,0.955382,0.239093,0.7132,0.526035,0.736077,0.452396,0.152358,0.673618,0.185336,0.275322,0.979357,0.651681,0.471898,0.854017,0.647036,0.839428,0.467749,0.134944,0.402317,0.573191,0.890946,0.651359,0.0355718,0.0394969,0.706606,0.452136,0.536103,0.00404883,0.64941,0.12661,0.143539,0.756462,0.376557,0.715694,0.408918,0.800998,0.397376,0.490303,0.8307,0.0184263,0.846366,0.0442904,0.899926,0.901685,0.749997,0.0997958,0.709764,0.506015,0.966684,0.489202,0.700647,0.786446,0.492988,0.904966,0.308769,0.490333,0.653508,0.415065,0.408781,0.985795,0.54707,0.54006,0.922946,0.14045,0.1527,0.359604,0.975381,0.96073,0.282529,0.634402,0.941511,0.701717,0.735703,0.296322,0.965941,0.213282,0.314654,0.803572,0.975721,0.019817,0.437964,0.307363,0.156969,0.373029,0.893918,0.0855934,0.561178,0.515513,0.965393,0.195096,0.123437,0.0188106,0.743804,0.606564,0.950058,0.466326,0.28162,0.697115,0.617435,0.353347,0.396144,0.581014,0.730085,0.420498,0.0245018,0.483224,0.122915,0.343796,0.83468,0.106467,0.511538,0.434153,0.0993663,0.47754,0.176048,0.808069,0.0918445,0.649555,0.35514,0.170514,0.105236,0.166119,0.0465075,0.431185,0.799372,0.624976,0.0641784,0.292748,0.586158,0.519246,0.372975,0.411328,0.750061,0.896899,0.339753,0.406678,0.589471,0.118771,0.0308055,0.821013,0.174721,0.838618,0.368683,0.477467,0.465345,0.126834,0.960996,0.281573,0.9724,0.669652,0.967744,0.00763961,0.18335,0.774261,0.800507,0.700115,0.754038,0.153426,0.0721818,0.877555,0.559058,0.714042,0.255054,0.919361,0.0187113,0.678317,0.861702,0.635616,0.133341,0.133774,0.283422,0.63649,0.452631,0.403482,0.281317,0.297628,0.251041,0.243089,0.848381,0.706243,0.485257,0.0552289,0.0979387,0.0351776,0.638063,0.564405,0.14927,0.367721,0.416359,0.478529,0.436845,0.718414,0.707336,0.129198,0.456209,0.206065,0.435196,0.921972,0.108476,0.0315111,0.539017,0.397358,0.571156,0.326328,0.872559,0.38916,0.570339,0.598626,0.340383,0.739114,0.067644,0.510143,0.232027,0.135567,0.55692,0.586894,0.33292,0.986968,0.637179,0.935014,0.649639,0.0622587,0.441881,0.941953,0.823507,0.709053,0.331296,0.124221,0.50742,0.30426,0.376104,0.87365,0.685691,0.0732553,0.524041,0.905599,0.427997,0.361774,0.798168,0.216326,0.937975,0.871729,0.231251,0.192654,0.914048,0.153581,0.917788,0.24675,0.930946,0.660613,0.387905,0.00702337,0.0220267,0.270848,0.820847,0.905131,0.590628,0.170921,0.939915,0.88968,0.725675,0.0285256,0.0458365,0.489869,0.772736,0.662061,0.95292,0.425464,0.0689026,0.476525,0.332948,0.683074,0.613407,0.699279,0.764796,0.543548,0.449316,0.676893,0.908523,0.851802,0.29701,0.216348,0.256827,0.544481,0.0737525,0.151336,0.623915,0.670105,0.733533,0.269202,0.5183,0.560207,0.653311,0.444464,0.569717,0.990623,0.49057,0.339151,0.870527,0.269737,0.726353,0.700028,0.416781,0.338646,0.416526,0.858992,0.0469655,0.381923,0.0719865,0.531379,0.186543,0.684106,0.19472,0.863415,0.683592,0.71861,0.225489,0.326975,0.5356,0.959072,0.010143,0.893801,0.382051,0.892851,0.334694,0.131756,0.631617,0.619872,0.248837,0.368073,0.48753,0.635985,0.161641,0.286065,0.868369,0.0625854,0.170648,0.767139,0.6487,0.804568,0.0150673,0.750348,0.68584,0.46689,0.732334,0.0597577,0.514679,0.37778,0.221811,0.940573,0.831547,0.676423,0.989605,0.304426,0.784167,0.524578,0.71167,0.500889,0.362899,0.287786,0.456532,0.480863,0.528932,0.76837,0.97452,0.864123,0.939953,0.133315,0.652278,0.533325,0.115812,0.495125,0.254758,0.681886,0.208456,0.323537,0.361623,0.136831,0.428231,0.89445,0.0351095,0.975051,0.481772,0.728154,0.67386,0.720942,0.289964,0.924764,0.0400885,0.969088,0.814225,0.859516,0.65074,0.554129,0.36323,0.912801,0.144793,0.272738,0.817776,0.0949906,0.0545711,0.0935065,0.656183,0.646839,0.767881,0.189338,0.558787,0.505185,0.0629411,0.253397,0.0308376,0.521832,0.918418,0.65047,0.750064,0.439956,0.152742,0.861769,0.387688,0.350189,0.525207,0.46136,0.299252,0.206251,0.556224,0.0802631,0.54829,0.436729,0.0805344,0.875421,0.683412,0.950562,0.770056,0.829942,0.103571,0.802233,0.835642,0.621726,0.320441,0.956118,0.927521,0.757102,0.930704,0.851649,0.475512,0.600272,0.301012,0.00734245,0.154345,0.93208,0.228161,0.863345,0.857305,0.466263,0.538304,0.559921,0.0846459,0.496209,0.213334,0.0352155,0.166587,0.0993929,0.464296,0.882391,0.902677,0.459621,0.407562,0.834819,0.456562,0.604556,0.551633,0.252422,0.733174,0.519768,0.411891,0.968131,0.299635,0.71068,0.827398,0.194064,0.694106,0.295628,0.729977,0.665676,0.35626,0.646742,0.291279,0.989658,0.126126,0.483843,0.194488,0.218513,0.619607,0.839053,0.427811,0.905393,0.103922,0.615325,0.332205,0.694036,0.0695108,0.892868,0.563531,0.31136,0.0982282,0.140654,0.794469,0.874796,0.372532,0.235165,0.50142,0.589138,0.434805,0.815397,0.0419435,0.708362,0.222445,0.383248,0.70086,0.925342,0.0596204,0.260917,0.0585674,0.0581919,0.971074,0.928649,0.31767,0.0359378,0.208402,0.659677,0.192998,0.851395,0.213966,0.741151,0.501674,0.443069,0.597848,0.00908486,0.864184,0.705907,0.184579,0.739884,0.762847,0.379431,0.476285,0.087286,0.465875,0.125657,0.448089,0.961149,0.209877,0.934942,0.415639,0.934977,0.71071,0.0401424,0.722684,0.394361,0.28805,0.681516,0.258345,0.962418,0.115134,0.044288,0.894214,0.590791,0.58134,0.769955,0.605298,0.461422,0.203084,0.328309,0.426952,0.324471,0.695765,0.403695,0.0961669,0.0111125,0.120382,0.0196171,0.309391,0.255602,0.200707,0.252878,0.198343,0.460719,0.384977,0.565212,0.492042,0.816424,0.495689,0.260364,0.275871,0.477783,0.564853,0.899096,0.475331,0.379682,0.00710614,0.198132,0.558676,0.938624,0.803358,0.0654,0.221849,0.911743,0.611554,0.100392,0.366905,0.979327,0.861278,0.516951,0.708578,0.180764,0.780084,0.729336,0.166018,0.137864,0.367008,0.842568,0.816577,0.255045,0.620939,0.684584,0.549413,0.0356763,0.859392,0.408492,0.725235,0.527821,0.379269,0.175517,0.0817874,0.651376,0.736419,0.586524,0.86191,0.496084,0.91221,0.302741,0.599811,0.79532,0.287835,0.133452,0.643436,0.593085,0.0611858,0.308712,0.815797,0.748529,0.802883,0.306803,0.0219614,0.243552,0.862611,0.723272,0.157388,0.0894086,0.156714,0.815432,0.418888,0.627915,0.624661,0.204677,0.0361253,0.566437,0.533722,0.00391023,0.00110523,0.0159629,0.320792,0.521507,0.890134,0.644695,0.411877,0.885347,0.71783,0.922962,0.0416993,0.0818582,0.603119,0.967852,0.807643,0.452176,0.215539,0.978796,0.059832,0.853599,0.938518
    }
    

    As you see above, the long expression does not need to take a lot of space or not to be handy. Just make sure to put the closing bracket after a newline because not everyone know you can double click to select it.

  • External storage

    Even SE mods agree so you can use them:

    Please add a system to allow file uploads attached to questions and answers

    Just make sure to add a clear description of what is behind so the question remains valid in case when the link goes down.

    And, as we discussed, upload text files, .tr .m .wl .txt. Whatever. And if they can be previewed that would be nice too.

So point 1. I'd say. Wolfram Cloud storage sounds equally feasible be it seems you never know what they are charging for:

Where are my Cloud Credits going?

  • Very good points! In addition, I would suggest to avoid Import[]-based methods: E.g. ToExpression @ TextRecognize @ Import[ "http://blog.wolfram.com/data/uploads/2011/11/OneLinerCompetition2011-In7.jpg"] – Shadowray May 3 '17 at 20:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .