Giter VIP home page Giter VIP logo

english's Introduction

The Dlang Online Tour

Build Status

This is the D language online tour which provides an online introduction to this great system programming language with examples that can be edited, compiled and run online.

The most recent version of this tour can be seen here: http://tour.dlang.org.

Running offline

The tour can be downloaded for offline access:

git clone --recursive https://github.com/dlang-tour/core && cd core
git submodule foreach git pull origin master
dub

This requires DUB - D's package manager. DUB is part of the release installer and archives.

Specifying a language directory

For translator it's often convenient to clone their directory and run the tour only with their language. A custom language can be loaded directly using the -l / --lang-dir option with the path to the directoy of the to be loaded language:

dub fetch dlang-tour # only once
dub run dlang-tour -- --lang-dir .

Add Content

This repository contains the application that runs the tour. Please refer to english content or another language.

Further information on how to add or change existing content can also be found in the CONTRIBUTING.md.

Compile & Run

On a minimal Ubuntu system the following command will install the system packages needed to run all examples:

apt update && apt install \
    curl xz-utils unzip gnupg `# Needed for the install.sh script` \
    build-essential `# C toolchain for compiling and linking` \
    libssl-dev libevent-dev `# Vibe-d network dependencies`\
    libopenblas-dev `# lubeck computer library dependency` \
    libxml++2.6-2v5 zlib1g-dev `# LDC dependencies`

Make sure dub is installed and simply run dub in the dlang-tour folder:

git clone --recursive https://github.com/dlang-tour/core && cd core
dub

You might want to change the settings in config.yml to change the ports the tour is listening to.

OpenSSL 1.1

If you see linker errors regarding OpenSSL/1.1, try:

dub --override-config="vibe-d:tls/openssl-1.1"

Compiling & running of user source code

The source code on the tour can be compiled and then executed online and its output returned to the user. Therefore three different types of execution drivers have been implemented within the dlang-tour:

  • off: no online compilation allowed. If the user hits Runs an error message will be returned.
  • stupidlocal: an unsafe method that just runs rdmd on the local host system and returns its output. Very unsafe and musn't ever be used in production!
  • docker: runs dmd within a special Docker container (core-exec) and returns its output. The driver imposes the Docker container memory and execution time limits. Additional configurations options available in config.yml.

The execution driver is set in config.yml.

Caching of the program output can also be enabled in config.yml (exec.cache = true). Caching will only be enabled for the built-in default examples however.

Docker image

A Docker image is automatically built by Travis CI and pushed to the repository at https://hub.docker.com/r/dlangtour/core. The Dlang-Tour Docker container is configured to use Docker itself to compile and run D source code in the online editor. For that to work the host system's Docker /var/run/docker.sock Unix domain socket has to be mounted to work inside the container. A sandbox for compiling will then be started on the host system actually, and not within the DLang Tour Docker container itself.

The code for running the D compilers in a Docker sandbox can be found here: core-exec.

So to run the latest dlang-tour version in a Docker container, run the following command:

docker run -d --rm -p 80:8080 -e GOOGLE_ANALYTICS_ID=123 -v /var/run/docker.sock:/var/run/docker.sock \
	--name dlang-tour dlangtour/core

The tour will be available at your host system on port 80. To stop the container again just run:

docker stop dlang-tour

For further Docker foo please refer to the Docker documentation.

Note: The docker version inside the container must be compatible to that on the host system! Generally a newer version might run on the host system than within the container.

The Docker container is also the suggested way of dlang-tour's deployment.

Dlang Tour Bot

There is a friendly bot in place that listens to the events of all language repositories and triggers rebuilds and thus automatic deploments on a new change. More information about it can be found at it's repository.

Environment variables

GOOGLE_ANALYTICS_ID

default: (empty)

To enable Google Analytics please specify the environment variable GOOGLE_ANALYTICS_ID and set it to the tracking ID provided for your Analytics account.

GITHUB_TOKEN

default: (empty)

Required for exporting Gists to GitHub. Follow these instrutions to generate a CLI GitHub token.

EXEC_DOCKER_MEMORY_LIMIT

default: 256

Memory limit per started rdmd Docker container which compiles and runs the user code.

EXEC_DOCKER_MAX_QUEUE_SIZE

default: 10

Maximum number of parallel executions of the rdmd user code Docker container.

EXEC_DOCKER_TIME_LIMIT

default: 20

Time limit in seconds the rdmd Docker container with the user code is allowed to take until it is killed.

EXEC_DOCKER_MAX_OUTPUT_SIZE

default: 4096

Maximum allowed size in bytes of the generated user program's output.

Deployment

A deployment guide can be found in the deploy folder.

License

Boost License. See LICENSE.txt for more details.

english's People

Contributors

9il avatar aliak00 avatar arbmind avatar astoliar avatar bbasile avatar brendan-donegan avatar dlang-bot avatar eresid avatar fr3nchk1ss avatar icy avatar insideoutclub avatar jackstouffer avatar johncoconut avatar joshuaobritsch avatar kotet avatar mark-summerfield avatar monostabil avatar murilomir avatar murzistor avatar nexweb avatar ntrel avatar orip avatar petarkirov avatar rinfz avatar smietzner avatar timoses avatar uvtc avatar walterbright avatar webfreak001 avatar wilzbach avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

english's Issues

new gem: alias, tuples & static foreach

From @wilzbach on June 26, 2016 0:6

I feel that neither alias, static foreach and tuples are well represented in the tour. They are already needed in other sections (e.g. #264), so we should probably try to enhance basics/alias-strings and maybe even create a new gem. The meta programming gem also doesn't cover any of these topics.

btw if static foreach is unfamilar:

import std.meta : AliasSeq;
foreach (c, AliasSeq!(int, float))
   ...

Copied from original issue: dlang-tour/core#375

Design by introspection gem

From @wilzbach on August 15, 2016 15:28

We already have the Traits's gem, but it could probably be split feature the term "design by introspection" a bit more.

For me design by introspection are two things

  1. pick the best & fastest implementation (e.g. std.algorithm)
  2. only expose methods/capabilities if they are possible with the current type (e.g. std.range)

Copied from original issue: dlang-tour/core#446

Introduce "subchapters" or "tours"

From @wilzbach on June 14, 2016 15:19

As said in #265, I am concerned since the GA Analytics results that those our categories are:

  • too wide (common rule is to have at most 7 items)
  • put the "best parts" at the end

image

My best ideas currently are

  • introduce subchapters and thus have grouping in the section like (Object oriented programming, control flow, ...
  • introduce "tours" and reuse the existing hiearchy (e.g. "Basics" would be an entire tour)
  • instead of "Basics" and "Gems" split into more chapters

Related to this idea is #52 (menu at the left side).

Copied from original issue: dlang-tour/core#269

gem: Using Fibers with ranges

From @wilzbach on May 18, 2016 13:12

This is one of my favorite features in D, but it took me a while to discover this.
This allows one to write pretty sophisticated lazy algorithms by just saving keeping a reference to the stack.
Ali had a great talk about this year -> http://dconf.org/2016/talks/cehreli.html

import std.concurrency: Generator,yield;
auto r = new Generator!int(
{
    foreach (i; 1 .. 10)
        yield(i);
});

import std.range: iota;
import std.algorithm.comparison: equal;
assert(r.equal(iota(1, 10)));

https://dlang.org/library/std/concurrency/generator.html

Copied from original issue: dlang-tour/core#133

use wordcount example with lowerCase words

From @wilzbach on May 25, 2016 17:57

As said it was a bit frustrating to see only 1 matches - an alternative would be rewrite the dummy text so that at least one word occurs twice.

Word counts: ["which":1, "systems":1, "of":1, "machine":1, "and":1, "":2, "code":1, "*native*":1, "you":1, "expressive":1, "powerful":1, "language":1, "tour":1, "compiles":1, "directly":1, "give":1, "will":1, "this":2, "an":1, "overview":1, "programming":1, "to":1, "efficient":1]

Copied from original issue: dlang-tour/core/pull/192

confusing end of welcome chapter

From @wilzbach on May 25, 2016 13:37

Could you point out why it is confusing to you.

I had the same experience. The page number is 5/5 and the arrows are grayed out. That looks like "the end" to me.

Currently the text says:

"Either use the navigation panel at the bottom or press the right arrow
key."

But before that, it says "Congratulations for finishing the first chapter. You're now ready to dive into the world of D." which may (and did to me) mean "this is the end, go out there and try out D now." It's easy to miss "first chapter" in there.

What could we add to avoid the confusion?

  1. Arrows should not be gray (how about green?)

  2. 5/5 doesn't carry much meaning for me and potentially confusing as it did

Copied from original issue: dlang-tour/core#187

Better instructions for Windows

From @wilzbach on June 11, 2016 3:37

Windows users have a huge majority among the visitors. In most cases users don't know what a CLI is, so probably either the page 2 (manual installation) or page 3 (CLI instructions) kills them.

image

So imho: no CLI instructions for Windows users, but maybe VisualD (and others (?)

Copied from original issue: dlang-tour/core#245

Expand bit manipulation gem

From @wilzbach on August 13, 2016 11:34

A couple of nice ideas from @ZombineDev that shouldn't sink into the forgotten world ;-)

BTW there several other interesting applications of bit manipulation that I didn't see mentioned:

  • using built-in integers for generating all possible subsets of a random access range of fixed size (e.g. 32 or 64)
  • using http://dlang.org/phobos/std_bitmanip#.BitArray to store a general set (of any size)
  • using http://dlang.org/phobos/std_bitmanip#.bitsSet to get a range of the indexes of the bits that were set, which useful when these indexes are used to index another array and you need to find the first element in it that passes a certain condition: allowed.bitsSet.countUntil!(idx => arr[idx].isOK)
  • using std.bitmanip : peak, read to parse any binary format (e.g. network packets, image formats, etc), especially useful when you have described the format with structs (i.e. your not reading it an int at a time).

In my experience bitFields is a more rarely used, but it's still a nice showcase of D's CT power.

(from dlang-tour/core#266 (comment))

Copied from original issue: dlang-tour/core#399

Gem: dub

From @wilzbach on May 23, 2016 17:58

Idea: Give a short intro to dub, examples for different use-cases and ideally how to integrate with one's favorite build system.

Ping @s-ludwig.

Copied from original issue: dlang-tour/core#150

More links to API documention

From @wilzbach on May 13, 2016 7:31

I think it would be nice if a method is mentioned that we provide links for the reader to deeper dive into the docs - they support anchors ;-)

I think just linking inline should be okay.
If possible a "Resources" list at the bottom (or "Dive deeper") would be cool too for a couple of pages.

Copied from original issue: dlang-tour/core#48

Add images to the Tour

From @wilzbach on June 10, 2016 23:7

I personally love images & I think there are many studies that show that this is a general fact (visual learning is a lot easier for us humans).

Anyway there are a couple of ideas how we could add images to the DLang Tour

  1. Add brand images like the DMan

image

Source: https://github.com/dlang/dlang.org/blob/master/images/d3.png

There are more those lovely D mascot drawing, like this one for Assembler:

image

https://github.com/dlang/dlang.org/blob/master/images/d5.gif

  1. Add more icons (e.g. FontAwesome)

I am not sure yet how we could do that, but it's worthwhile to think about it

  1. Add related images (most important)

E.g. for Caesor encryption we could show an image like this:

image

  1. Your ideas

...

Copied from original issue: dlang-tour/core#244

pragmas in D

From @wilzbach on June 10, 2016 14:15

There are many awesome pragmas out there, my favorite one being:

rdmd --force --eval='pragma(msg, __TIMESTAMP__);'

another important one is

pragma(inline, true) 

(it verifies that the function can be inlined, see more)

but of course there's is and compiles too.
Maybe we can combine this with #129 (traits)

See more: https://dlang.org/spec/pragma.html

Copied from original issue: dlang-tour/core#229

Review usage of "you"

From @ZombineDev on August 14, 2016 9:35

cd public/content/ && grep -Hnr "you" yields:

  • en/basics/further-reading.md:3:Now that you've finished the basics, you can move on to some more advanced sections of this tour. Or, you can check out some of the following resources:
  • en/basics/further-reading.md:20:* Share your ideas in the Forum or scan very active discussions
  • en/basics/imports-and-modules.md:3:To write a simple hello world program in D you need
  • en/basics/memory.md:3:D is a system programming language and thus allows you to manually
  • en/basics/memory.md:4:manage and mess up your memory. Nevertheless, D uses a
  • en/basics/ranges.md:36:Don't fool yourself into deleting the assertions!
  • en/basics/storage-classes.md:6:at compile time. Good type-safety gives you the support you need
  • en/basics/storage-classes.md:32:is const for your current scope, but someone
  • en/basics/storage-classes.md:34:you will be sure that an object's value will never
  • en/basics/structs.md:63:member function can be used you to work to give access to all instances of a
  • en/gems/bit-manipulation.md:61:Hence in D std.bitmanip helps you to write maintainable, easy-to-read bit manipulationsen/gems/bit-manipulation.md:73:OS memory layout (size_t.sizeof) e.g. bool, byte, char, it is recommended
  • en/gems/documentation.md:7:out of your source code.
  • en/gems/range-algorithms.md:9:The great thing with these algorithms is that you just
  • en/gems/range-algorithms.md:10:have to define your own range and you will directly
  • en/gems/range-algorithms.md:56:### The documentation is awaiting your visit!
  • en/gems/range-algorithms.md:77: string text = q{This tour will give you an
  • en/gems/template-meta-programming.md:3:If you ever got in touch with template meta programming
  • en/gems/template-meta-programming.md:4:in C++ you will be relieved what tools D offers to make
  • en/gems/template-meta-programming.md:5:your life easier. Template meta programming is a technique
  • en/gems/template-meta-programming.md:36:Anywhere you see boiler plate, mixin template
  • en/gems/template-meta-programming.md:37:is your friend:
  • en/gems/template-meta-programming.md:48:pre-processor if you're coming from C!
  • en/gems/traits.md:51:A common problem is that in contrast to arrays you might not know the exact length
  • en/gems/unittesting.md:103:// to actually test your modules.
  • en/multithreading/message-passing.md:4:yourself D allows to use message passing as a means
  • en/multithreading/std-parallelism.md:20:working threads. Creating your own instance allows
  • en/vibed/basics-asynchronous-i-o.md:40:asynchronous socket operations so you don't have
  • en/vibed/basics-asynchronous-i-o.md:42:blocks your whole application.
  • en/vibed/database-connectivity.md:4:in your backend services. MongoDB and Redis
  • en/vibed/deploy-on-heroku.md:39:This provides access to the Heroku Command-Line Interface (CLI), which can be used for managing and scaling your applications and add-ons.
  • en/vibed/deploy-on-heroku.md:92:It is possible to use GDC or LDC and to choose a specific compiler versions by adding a .d-compiler file to your project.
  • en/vibed/deploy-on-heroku.md:99:Proceed in your usual git habit and write awesome code.
  • en/vibed/deploy-on-heroku.md:170:Heroku treats logs as streams of time-ordered events aggregated from the output streams of all your app and Heroku components,
  • en/vibed/deploy-on-heroku.md:180:After deploying the app to Heroku you can make it more awesome by using add-ons. For example :
  • en/vibed/vibe-d-web-framework.md:12: for you! See the next section for a thorough
  • en/vibed/vibe-d-web-framework.md:33:available for building your vibe.d based project.
  • en/welcome/install-d-locally.md:21:To quickly install dmd within your user directory, run: curl -fsS https://dlang.org/install.sh | bash -s dmd
  • en/welcome/links-documentation.md:3:After you complete the tour, you can check out some of the following links for help or more information:
  • en/welcome/welcome-to-d.md:7:This tour will give you an overview of this powerful and expressive

Copied from original issue: dlang-tour/core#423

More newbie-oriented tour

From @wilzbach on June 13, 2016 10:49

While having a look at #193, I realized that the tour isn't well suited for someone with no or little programming background as we don't explain any basics like variables or pointers.

As our main target are experienced programmers, that's ok - however imho we could try to target beginners too. I am not sure yet what is the best way to do this, but an idea would be to have a "freshup section" to which we point in the beginning - like e.g. "New to pointers? Read this".

Copied from original issue: dlang-tour/core#258

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.