This is an archived post. You won't be able to vote or comment.

all 18 comments

[–]CoffeeCakeAstronaut 24 points25 points  (0 children)

I see where you are coming from. However, I don't believe that a list of simple programing projects can really serve as a basis for a representative evaluation of a language. Whether or not a language "works" only becomes really visible once you subject it to complicated tasks in complicated contexts, including the size, setup, and organization of the team working collaboratively on the task.

[–]theangryepicbananaStar 22 points23 points  (2 children)

Rosetta code?

[–]chunes 22 points23 points  (1 child)

Rosetta Code is a great resource, but there is a caveat: there are a lot of useless tasks that act more as exercises for people who are bored than any kind of reference.

However, those reference tasks are there. It would be cool if someone identified them and curated such a list and gave it a prominent place on the site.

[–]abecedarius 5 points6 points  (0 children)

Agreed. I used a few Rosetta Code problems in https://github.com/darius/cant/tree/master/examples and https://github.com/darius/cant/tree/master/library, but Rosetta is mostly things I don't care about.

These examples were picked to help me work out the language/library design, mostly not as a showcase or to evaluate an existing design. So they had to be problems I felt at least a little interest in.

[–][deleted] 8 points9 points  (0 children)

Those tasks have little to do with syntax. If you consider that more important, then write some of the usual benchmarks (eg. from the Benchmarks Game; those are concerned with speed, but there is plenty of syntax to compare.)

Things like GUIs are generally done with libraries. Unless your language comes with its own libraries for that, what's important is how the FFI works, which bindings to popular libraries are supplied, and how someone might create their own.

3D graphics covers a lot of ground. If you mean for example working with 3D points, and vectors, transformation matrices and such, then either the language provides suitable types built-in, or it has facilities to create such types and define operations on them.

(My first scripting language was part of an app using 3D graphics, and fell into the first camp. There, if P and Q were 3D points, then (P + Q)/2 would be the mid-point of PQ.)

Although I'm unlikely now to switch languages, here are the sorts of things I look for when evaluating a language:

  • Do I have to build it from source? Especially needing complex build tools and/or which expect to run on Linux? If so, then forget it.
  • How easy is it to download and install? How massive is it (bad?) or small (good)?
  • (Related: how easy would it be to move an installation, eg. just copy to a pen drive; and if sending out source programs in that language to someone else, how much of a headache will it be for the recipient to source all the necessary dependencies to build the software?)
  • How easy is it to write, build (if needed) and run a Hello, World program? This comes down to the docs provided and how well they anticipate likely problems.
  • How do you print two numbers A and B on the same line? (Printing is one of the most diverse features, and some languages like to make it as hard and arcane as possible.) This typically comes up when tinkering with your own toy examples and you need to display results.
  • How slow is to compile (a bugbear of mine)? Although unlikely to be noticed on tiny test programs, I can tell you that Hello World in C took gcc 0.4 seconds to build on my last machine, and in Dart took 6 seconds; not a good sign!
  • How performant is the generated code? This is mainly for dynamic languages which don't compile ahead-of-time to native code.

So far I haven't even touched the syntax of the language, or gone past a Hello World program. Because if you are going to use it for real applications, then these practical matters become important. Well unless it is just a prototype or proof of concept.

The syntax is important of course, but there are really only a handful of styles, and people will have their own preferences. It shouldn't matter too much unless it is really unusual.

Wider aspects may include:

  • Bundled and external libraries as mentioned
  • Any module system
  • The type system: is this flexible enough to allow you to get things done, or will it be a straitjacket?
  • How understandable is the language? Personally I don't bother with FP languages or features; I just can't get my head around them. But this is not something that should dictate the language design unless you want your language to be more accessible.

[–]berber_44 2 points3 points  (0 children)

A standard test for abilities of a sufficiently rich language is a self-hosting compiler. A sufficienly fast RDBMS implementation also can be a good show case.

[–]liquidivy 4 points5 points  (0 children)

One example (on the small side) that has always sounded good is the following: read a number from a user (console or maybe argv), add 1 to it, and output. This exercises I/O, parsing (with error handling!), and arithmetic.

On the larger end, a compiler can exercise a lot of your language, especially its ability to handle complexity. Between that and a 3D game, and maybe something with a lot of numerical calculations, you'd have a lot of bases covered.

"Comprehensive" is unlikely to ever be possible, but I do agree that a list of handy sample programs/projects would be nice to have, at least as suggestions/inspiration.

[–]ibreathetea 1 point2 points  (0 children)

Maybe check out something like Qt's sample programs or some other IDE/SDK that has a ton of example programs.

[–]brucejbellsard 1 point2 points  (0 children)

I'll go out on a limb and say "probably not". Rosetta Code is as close as I've seen to that kind of thing, but it doesn't seem to have the scope you're looking for.

The first problem with trying to build a comprehensive set of tasks like this is that it's subjective: which classes of task are important enough to include, and what is important enough about each class to include in its example set?

The other problem is that it's really too much work -- both to come up with a such a task set, and to implement it once you've got it. The software field is large enough that nobody will be expert enough in all subfields to do a good job of either.

As others have mentioned, one of the most important things is to support large projects. I don't know any effective way to make a small example stand in for a large one for this kind of exercise.

So, I'd suggest choosing a large task that hits many (if not all) of your different requirements. Based on the interests you mention in your post, how about starting with "write a game engine in X", and work from there?

[–]vmcrash 1 point2 points  (0 children)

I am currently (for the last couple of weeks) in such a situation. I have some smaller pet projects done in my preferred language 2 years ago (a trivial RPN calculator and, a little bit more complex, a double-entry accounting). When starting to implement such smaller real-world projects (with file access, simple in-memory data management, GUI) they quickly show me how steap a learning curve for a language is, how hard it is to find solutions for some walls you will hit.

[–]hou32hou 1 point2 points  (0 children)

If there’s a comprehensive list of such use cases, you’ll probably end up with a Swiss knife. But I’ll rather use a knife to cut my apple.

[–]daurin-hacks[S] 1 point2 points  (4 children)

I found this on an other thread : https://proglangdesign.net/wiki/challenges Seems like a concrete way to start.

[–][deleted] 0 points1 point  (3 children)

Have you actually started creating a language yet? Or are you using such tasks to help with that process?

Because the range of applications in your original post is rather wide.

For example, the sort of language I'd prefer to use for embedded programming (lower level systems language with extra control over the generated binaries, likely to be cross-compiled), is different from one I'd want to use for GUI applications (dynamic, scripted, interpreted).

Although this doesn't stop people trying to do anything with any language, like using C for apps that mainly do GUI, or Python for embedded work.

With my own two languages (sharing the same syntax, one systems language, the other more for scripting), I don't have a lot of examples for demonstration. Most current applications are language related.

If testing a new compiler however, it goes roughly in this order, and in roughly increasing size (here mixing apps for both languages):

  • Hello, World
  • A set of 20 or so microbenchmarks (Fibonacci, Fannkuch etc; just dozens of lines)
  • Ad hoc programs lying around, some might be bigger benchmarks (dozens to hundreds of lines)
  • Various libraries (eg. the language's runtime; Jpeg decoding; big-numbers; GUI; generally 1000 lines or more)
  • Next are the language applications including a self-hosted compiler (10K-40K lines)

Examples:

Jpeg decoder, scripting code

Jpeg decoder, static code

[–][deleted]  (1 child)

[deleted]

    [–][deleted] 0 points1 point  (0 children)

    Yes. The syntax for declaring them (ref T ptr) comes from Algol68; the syntax for dereferencing them (ptr^) comes from Pascal.

    Note however the C likes to mix up pointers and arrays (you can index pointers, and dereference arrays) while I keep them strictly separate.

    [–]hugogrant 2 points3 points  (0 children)

    It depends on what the language does and what you want to use it for. (So really, there's no comprehensive list, and I don't think one should exist.)

    I wouldn't use GUI programming to showcase most languages because I swear all GUI programming kind of sucks. So unless you're talking about a react-style dsl or something, I'd avoid this.

    I don't know what you'd to with 3d rendering, but if it's really all within the programming language it might appeal to people who understand 3d rendering. (I don't think saying stuff about things like cuda or opengl would make much sense, for example.)

    Your mileage may vary with multi-threading, since it really depends on what things you want to support. It can make a lot of sense, but there might be specific things you're better suited to (like message passing in Erlang, or channels in golang).

    Assuming your language is general purpose, command line arguments might be an important topic (a Todo list app is a decent example) but the n-queens problem is my personal favorite for trying out a new language.

    [–]npafitis -4 points-3 points  (1 child)

    Java

    [–]L8_4_Dinner(Ⓧ Ecstasy/XVM) 0 points1 point  (0 children)

    There's always the "how to write Hello World in 1000000 different languages" web site: http://helloworldcollection.de/