Git Product home page Git Product logo

Comments (16)

garazdawi avatar garazdawi commented on July 19, 2024 1

hmm, I will take a look and see if I can come up with something better.

The first page is very important so it needs to be as good as we can make it.

from erlang-org.

garazdawi avatar garazdawi commented on July 19, 2024

The point of the example was to create something small that showcases Erlang's unique possibilities to solve a problem that many are familiar with. Not that you should immediately understand how every detail of the syntax works.

The hope is that it would trigger curiosity to learn more about the language. Though, a too complex example will trigger people to run away as well.

I would greatly welcome any suggestions on what example to put there! Or if we want to have multiple examples like https://www.python.org/ does.

from erlang-org.

Maria-12648430 avatar Maria-12648430 commented on July 19, 2024

(Sorry, I realize that I was a bit offensive 😓)

I'm really unsure about what would be some good example to put there... it depends on what kind of people with what level of experience normally get interested in Erlang and come to the website.
For a newbie, the alien syntax alone is often something to chew on already, but if you're really curious, it is possible to get a grasp on it by intuition ("those are functions, their arguments go in parentheses, the weird -> starts the body, etc"). But list comprehensions, spawning, receiving, the ! operator etc is at that point probably total greek to them.

I think what I'm trying to say is, yes, it is so easy to do this in Erlang... but you can't see and understand and appreciate that until (much) later. Know what I mean? 😄

from erlang-org.

juhlig avatar juhlig commented on July 19, 2024

I guess it also matters whether you want to showcase Erlang as a language (which is what python.org does for Python, ie "look how easy it is to write and read Python code, how intuitively understandable it is!") or as a system ("look how easy it is to do $thing in Erlang!"). The latter is however not easy to see from code (alone).

from erlang-org.

juhlig avatar juhlig commented on July 19, 2024

And no, I have no idea for what a good example might be either ^^;
But maybe some slide show like python.org wouldn't be bad after all. Like, start easy with 1 or 2 language niceties, move on to processes and sending messages between them, and put the mapreduce example at/near the end. In other words, start gently ;) I think at the point where you get to the mapreduce example, you have at least seen list comprehensions, spawning, the ! and such things, and not hit by all of them at once ;)

from erlang-org.

garazdawi avatar garazdawi commented on July 19, 2024

I pushed a new version with some other examples. I need to get better examples in there, but I like this approach better and now it is also a lot easier to add/change the current examples: https://github.com/erlang/erlang-org/tree/beta/_examples.

Part of the problem now is that we need examples that have about the same visual size... otherwise it just looks odd.

from erlang-org.

Maria-12648430 avatar Maria-12648430 commented on July 19, 2024

I pushed a new version with some other examples. I need to get better examples in there, but I like this approach better and now it is also a lot easier to add/change the current examples: https://github.com/erlang/erlang-org/tree/beta/_examples.

That feels much nicer, yes ;)

Part of the problem now is that we need examples that have about the same visual size... otherwise it just looks odd.

Hm, yeah...
I also noticed that when you view it on a smaller screen, the left arrow is over the example, and the right one "jumps" when switching to an example with longer lines.

from erlang-org.

garazdawi avatar garazdawi commented on July 19, 2024

I also noticed that when you view it on a smaller screen, the left arrow is over the example, and the right one "jumps" when switching to an example with longer lines.

yeah I know. I need to do some css magic spell to make it work better, or just make sure that all examples have the same number of lines...

from erlang-org.

pichi avatar pichi commented on July 19, 2024

I think the bigger issue is it doesn't even compile:

$ cat > mapreduce.erl
-module(mapreduce).
-export([even/1]).
-spec even(list(integer())) -> list(integer()).
even(Numbers) ->
  mapreduce(Numbers, fun(Number) -> Number rem 2 == 0 end).
mapreduce(Numbers, Function) ->
  Parent = self(),
  [spawn(fun() -> Parent ! {Number, Function(Number)} end) || Number <- Numbers],
  [receive {Number, Even} -> Number end || Number <- Numbers, Even == true].
$ erlc mapreduce.erl 
mapreduce.erl:9:63: variable 'Even' is unbound
%    9|   [receive {Number, Even} -> Number end || Number <- Numbers, Even == true].
%     |                                                               ^

from erlang-org.

garazdawi avatar garazdawi commented on July 19, 2024

<sarcasm>the bugs in the examples are there to make people come to this repo and figure out how to contribute :)</sarcasm>

from erlang-org.

pichi avatar pichi commented on July 19, 2024

I have thought about the fix but all that I can think about is ugly as hell.
For example

[ Number || {Number, true} <- [ receive {Number, _} = X -> X end || Number <- Numbers ] ]

from erlang-org.

Maria-12648430 avatar Maria-12648430 commented on July 19, 2024

While I think this ticket is, for now, more about deciding which kind of examples (in terms of complexity and required knowledge of the language) should appear there... I think your fix would look better if you separated the mapping step from the reduction step. After all, mapreduce is really the composition of this... Map values to sth, then reduce to sth.

from erlang-org.

garazdawi avatar garazdawi commented on July 19, 2024

I've improved the examples to look nicer (and this time they should compile).

Interesting challenge to get good examples that work good on both a small and large screen and that has the same number of lines...

from erlang-org.

Maria-12648430 avatar Maria-12648430 commented on July 19, 2024

The examples are looking good now, and from a cursory glance (haven't tried 😄) I believe they should compile, yes.

There still seems to be something wrong with the CSS, though:

  • it looks different in Chrome and Firefox
  • start with a wide browser window, then narrow it down to about just above the point where the large examples are replaced by the small ones; also try with different examples being displayed while you do

from erlang-org.

garazdawi avatar garazdawi commented on July 19, 2024

I made a fix, should look better now.

from erlang-org.

Maria-12648430 avatar Maria-12648430 commented on July 19, 2024

Perfect :)

from erlang-org.

Related Issues (20)

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.