Hacker News new | comments | show | ask | jobs | submit login
TIO: Try it online (tio.run)
352 points by blacksqr 7 months ago | hide | past | web | favorite | 92 comments

Some clarifications are in order:

This site is not a competitor to codepen, jsfiddle, etc. It's main purpose is to allow play with programming languages you'd otherwise have to install locally -- specifically, it's extremely helpful when browsing https://codegolf.stackexchange.com/ -- the author is a prolific and impressive contributor to that site.

It's sad to see a simple, well-designed, free, open-source project embracing the values of the HN crowd ("The TIO web app is free of charge, ad-free, and doesn't use tracking cookies or third-party analytic scripts.") -- and the top comment, as well as many others, are essentially a nitpick about a bug that can be trivially fixed.

>It's sad to see

No it's not. The top comment is a bug report because people are using the app. It also got fixed, which, for a comment chain, is about as much value as possible.

Looks like getting mentioned on Hacker News is an excellent way to get your servers overloaded. :) I've added a couple of additional servers.

I'll work on the issues that were brought up here asap. TIO only has two developers at this point (and only one of us works on the web app), so "asap" might take a little while.

Good job for the website though! It'll be very helpful to many people.

Really cool. Would be great if each language had an "hello world" example which would populate the fields.

There's a Hello World button now that does just this.

There already is a collection of `Hello, World!`s for every language used in tests, and this feature is planned to be implemented soon.

I agree. In the standard Racket IDE you get automatically the initial

  #lang racket
line, and in some variants for students the equivalent line is hidden. So I had to try a few times until I realized I forgot to add this line. https://tio.run/##K0pMzk4t@a@ck5iXrlAE4Sh5pObk5CuE5xelKP3/Dw...

Another improvement could be to show the debug output automatically. I didn't understand the problem until I read the error message.

For Go: https://tio.run/##S8//X5CYnJ2YnqqQm5iZx5WZW5BfVKKglJZbovQ/rT...

BTW Do we really need ~540 bits (~90 chars of base62) to identify permanent link?

Looks like it encodes the whole code instead of storing it somewhere, so yes.

Well in TIO 2.0 that is coming soon it will not be that long.

  cat /etc/passwd

  ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
  systemd-timesync:x:999:998:systemd Time Synchronization:/:/sbin/nologin
  systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
  systemd-resolve:x:193:193:systemd Resolver:/:/sbin/nologin
  dbus:x:81:81:System message bus:/:/sbin/nologin
  polkitd:x:998:997:User for polkitd:/:/sbin/nologin
  rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin
  sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
  cockpit-ws:x:997:995:User for cockpit-ws:/:/sbin/nologin
  rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
  nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
  tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
  systemd-coredump:x:993:993:systemd Core Dumper:/:/sbin/nologin
  epmd:x:992:991:Erlang Port Mapper Daemon:/dev/null:/sbin/nologin

Just because /etc/passwd can be read doesn't mean there is no sandboxing - it's just not too restrictive, probably to allow many programming languages to run (bash is one of languages after all - so process execution has to be allowed). Just having access to /etc/passwd doesn't mean the service is hacked. Check other tools like this like ideone, they allow you to read /etc/passwd as well.

Try running `ps aux` for instance and notice that you can only notice runner's processes. Try writing a file in your home, and notice that it doesn't persist between runs. Run a process in background, it doesn't stay running. Essentially every change to the runner (account on which scripts are running) is undone after provided script is done running.

Some interpreters absolutely require being able to read /etc/passwd, as they use it to determine the user's home directory for some reason.

Since /etc/passwd, despite what the name suggests, doesn't actually contain sensitive information, I don't consider this an issue.

Just a comment overall, I bookmarked the site and think it's great.

Is it a good idea to present a site that compiles and runs code on a remote server to a site dedicated to hackers? :)

This was my first thought: sandboxing is gonna be tricky for such project.

Not really, with SELinux, which is what TIO uses. TIO can be deployed pretty much anywhere SEL is supported. Instructions here: https://github.com/TryItOnline/tiosetup

It has Bash - no need for Python subprocess shenanigans.

Not a comment about tio but I didn't realize it isn't possible to write a simple hello world in C# dot net core.

What a shitty situation.

What can we do to make it better? Provide a default csproj file on load? Any better ideas?

Microsoft (R) Build Engine version Copyright (C) Microsoft Corporation. All rights reserved.

code.cs(1,22): error CS1022: Type or namespace definition, or end-of-file expected [/home/runner/project/project.csproj] code.cs(1,22): error CS1026: ) expected [/home/runner/project/project.csproj]


code.cs(1,22): error CS1022: Type or namespace definition, or end-of-file expected [/home/runner/project/project.csproj] code.cs(1,22): error CS1026: ) expected [/home/runner/project/project.csproj] 0 Warning(s) 2 Error(s)

Time Elapsed 00:00:04.92 No executable found matching command "dotnet-project/bin/Debug/netcoreapp*/project.dll"

Real time: 6.033 s User time: 2.973 s Sys. time: 0.442 s CPU share: 56.61 % Exit code: 1

> Not a comment about tio but I didn't realize it isn't possible to write a simple hello world in C# dot net core.

Not sure why you'd think it's impossible [1]. I even ran it in the TIO C# console and it works.

[1] https://rosettacode.org/wiki/Hello_world/Text#C.23

Just filling in some default fields in the tio editor would do. For example pre-fill the header as:

   using System;
   using System.IO;
and pre-filling Code with

   namespace example
      public class Example
         static void Main(){
(But better names, my naming sucks!)

That would go a long way, then you could just add "Console.WriteLine("Hello World"); for hello world.

You don't even need the namespace or the usings if you just want to print hello world either.

What does the minimal program actually look like?

This looks like the minimal:

  class HelloWorld
    static void Main()
       System.Console.Write("Hello world!");
Try it online: https://tio.run/##Sy7WTc4vSv3/PzknsbhYwSM1Jyc/PL8oJ4WrmktBob...

This works for me in TIO:

public class App { public static void Main(string[] args) { System.Console.WriteLine("Hello World"); } }

Looks like http://repl.it/ but with more languages.

TIO looks great. However, it's probably serving different purposes than Repl.it, here are some differences as I see them:

- repl.it is interactive, which means that not only a process and a container is booted up that stays with you the whole session time but also means that the program state is saved when you're executing code from the repl console. This enabled interactive games like text games and cli programs.

- support for multiple file with realtime file update. You can plot something for example: https://repl.it/site/blog/file-updates

- support for third party modules starting with pipy and npm (you can import any module from those registries).

There are many other small features that's worth checking out. But to sum up, Repl.it is not just trying to be a code execution service but an actual programming environment.

Repl.it sounded really epic... except it's not REPL, at least not for the first language that I wanted to repl: C (https://repl.it/languages/c).

Still, I like the website better than TIO. At TIO I picked PHP to test and it gives me options like headers, options (without a list of options/settings to modify, just an "Add" button)... I just want to type code in an editor and run it. Repl.it also has syntax highlighting.

(For those who don't know, REPL is read-evaluate-print-loop, so it takes an input (e.g. "int i = 0;"), evaluates it (runs it), prints any output, and loops back to the start.)

For languages like C that don't ship with a repl we don't currently implement one -- although we probably should, since a lot of them have third-party repl libraries.

Check our most of our other languages. They're proper repls I promise ;)

I wrote about the distinction you're talking about when we released swift support:


No love for Common Lisp? Please add Common Lisp :).

Anyway, pretty nice collection of languages you have there; a lot of which I want to play with but don't feel like installing a proper toolchain yet. So I'll definitely use the service :).

Usually when I go to repl.it it's to do something in a python console if I'm at a computer that doesn't have python installed: https://repl.it/languages/python

It's actually quite simple: 'options' are command line options that you can supply, I don't know PHP but for Ruby it might be `-p` for example. Header and Footer are just glued to the code by newlines.

Oh command line options. Then what are 'arguments', a little further below?

Options are what get passed to the interpreter. Arguments get passed to the program. How the interpreter gets called for most languages roughly goes like:

   interpreter options input.tio arguments
Where input.tio is the file containing the code.

Another alternative is https://glot.io

They spin up a docker container with a language of your choice, all from the web.

and less "repl"

A description would be nice. I tried clojure and it successfully printed when my code was (+ 1 3) but I didn't grasp the input/arguments/etc...

Input is StdIn. Arguments are command line arguments. Header and Footer are glued to code by newlines. Output is StdOut, Debug is StdErr and timing information.

I was pleasantly surprised to see my own joke language 99 in the list.


I would have been even more pleasantly surprised if it worked.

Please contact @Dennis, the maintainer of TIO in talk.tryitonline.net, and tell him what isn't working. Fixes and language requests tend to be resolved within a day, because Dennis is awesome.

It turns out it's a different "99" language:


I really look forward to using this. It would be a great help to mobile users if uneeded options, e.g., 'header', could be made to disappear to save screen real estate.

The site is usable but can be made a lot better simply by changing the priorities.

Hide all those compiler flags etc in the first page. The idea is if any one needs such advanced settings surely the source code will be multi page source code, even for the special use case it would be in the 1 % users.

Include some template code which is readily compilable. THis is will be useful

The sharable link should be integrated with reddit, google +, etc to be more resistance free sharing.

Except for in C, when you want to use the math library, you'd need the `-lm` option, which comes up fairly commonly.

Nice, looks pretty useful!

I think the default execution time should probably be less than 60 seconds. Most simple programs that people run on this kind of site should have an execution time of less than a second, so ~10 seconds should certainly be enough by default. This would free up some resources on your end and would inform people more quickly that they may have an infinite loop in their code.

On codegolf.stackexchange.com we have answers that need all 60 seconds. This would not be viable

This is extremely cool. I'm impressed that they were able to get it up and running with so many different languages.

The play button turning into a gear that spins is pretty cool. First time I have seen that.

The reason it's the first time you've seen might be because it's stupidly difficult to get that effect to work on IE/Edge. You might notice that there's a different effect on the run button for those browsers.

Would be nice to support Piet.

Pony, too.

am i not getting this? i typed echo "hello"; for PHP and the output says "echo 'hello';"

it just repeated back what i typed instead of processing the code hmm

it works exactly like the real PHP interpreter:

   <?php echo "hello"; ?>

Needs Elixir support.

For the record, hello world in elixir is

IO.puts "Hello World"

You can ping the site's maintainer, @Dennis, in talk.tryitonline.net. Bug reports and language requests tend to be resolved withing the same day of them being submitted, because Dennis is awesome.

talk.tryitonline.net requires an SE account and 20 rep.

There's also https://gitter.im/tryitonline/Requests (requires a Gitter account), https://github.com/TryItOnline/tryitonline/issues (requires a GitHUb account), and email (feedback@tryitonline.net).


This is pretty great!

It would be nice to add swift and elixir on the list.

Code samples for each language would be appreciated

Looks neat, but the code editor really needs syntax highlighting and intelligent indentation.

It's not meant to be an editor. That sounds like unnecessary feature creep - the point is to run snippets of code in different languages through your web browser, not to be an IDE.

I think syntax highlighting makes sense. People do write code right into things like this. In that case, syntax highlighting helps if that's what you're used to. Also it is helpful even if copy pasting for readability if you're normally used to syntax highlighting.

But people still need to type those snippets. Typing up fresh code in online code runners (as opposed to pasting in pre-written code) is extremely common.

(Disclaimer: client is by me) but I have an alternative front-end for TIO which supports syntax highlighting and indentation for popular languages: https://vihan.org/p/tio

no c++/g++ ??

no swift?

TIO is powered by Fedora Linux, and unfortunatly the site's maintainer was unable to get the Linux port of Swift to work. This may change in the near future, however.

Site is down.

This looks cool, but can you guys fix your push state code, I can't hit back to come back to HN.

That should be fixed.

confirmed. Chrome 59.0.3071.115 on Mac back button is broken.

cool site, tho

Long press back button and select HN.

THANK YOU. Before Shift-Back (or right click?) would work and it stopped working a few versions back.

Doesn't help you on mobile.

It works on Firefox, give it a try

confirmed, safari Version 10.1.1 (12603.2.4) macOS

Yes, same here, FF 54.01 (64 bit) on Arch Linux.

Double-tapping back sometimes works on sites where the landing page immediately forwards you to something else, but this site appears to actively hijack the back/forward buttons. For shame.

Not intentionally. This was a simple bug: a history.pushState that should have been history.replaceState.

Breaks the back button.

Yeah, hijacks left-swipe on mobile safari, too. Annoying!

If you are on Chrome right click the back button as a temporary solution.

I don't like it. I still prefer Codepen and jsfiddle.

Yeah, I don't see this as an attempt to be another Codepen or jsfiddle. This is just a way to easily test out features of a language, without going through the (sometimes very tedious) installation and setup processes required to code in certain languages locally.

What do they do for languages other than JavaScript?

Ok, then Codeanywhere would be a better choice. Don't you think? ;)

Saying that Codeanywhere is a better choice than TIO is like saying that GMail is a better choice than Netflix.

In both cases, both services were built for different purposes, and neither one can or intends to replace the other.

Applications are open for YC Summer 2018

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact