44

My (soon to become ex -) boss thinks "Every problem has an one-liner Javascript solution, that he doesn't have time to write."

Comments
  • 2
    Does you 'ex' boss know yet? 😀
  • 5
    @Jumpshot44 hehe! He fired me, when I explained him the concept of application architecture. :D
  • 4
    @backbencher onward and upward! Best of luck.
  • 0
    As an organisation leader I try force people to use one-line solutions, but I code on my own and do one-liners then too, so I guess its OK
  • 0
    @ac1235 I disagree, a one liner is simply not always an option, and even when it is it can be super unclear. In that case it's simply a better idea to spread it out over multiple lines.
  • 0
    @LucaScorpion If you cant express ideas shortly perhaps you just dont understand them.

    If it is built of multiple algorithms, split it up into multiple functions, but just use 1 line per function
  • 2
    @ac1235 Really? A single line per function? See I only program js as a hobby but that sounds ridiculous to me, as the whole point of functions is to group multiple instructions.
  • 1
    @LucaScorpion In JavaScript you can write things like:
    function(x){return y}

    as:
    (x) => y

    which makes it easy to write one-liners
  • 0
    @ac1235 Yeah I know that, but that doesn't make the one line per function idea more logical to me. If it's only a single line,why even have a function for it?
  • 0
    @LucaScorpion
    To name things properly:

    greeting = (name) => "Hello " + name;

    greet = (name) => console.log(greeting(name));

    getName = () => prompt("Name:");

    greet(getName());
  • 0
    @ac1235 Yes, but those are extremely simple functions, and I probably wouldn't even create functions for that. I'd like to see you create a function for a more complex algorithm with just one liners :P
  • 0
    @LucaScorpion Then check out my github account ;)
  • 0
    @ac1235 i will ;) I guess it's also just a matter of personal preference.
  • 1
    @LucaScorpion its always is a matter of personal taste ;)
  • 1
  • 2
    @ac1235 404 on the link

    I am personally a fan of functional paradigm. Rather than one-lineres, well thought solutions are what makes thr code shorter and easier to understand. You can usually achieve the same outcomes with map/filter/reduce/currying. These are just what are available in js which was not intended to be a fp lang. If you get pattern matching and strong type system, that would be even better.

    Elm lang and purescript would allow you to write shorter, safer and easier understand client side code.
  • 1
    @rusty-hacker

    Imagine this in ES7:

    function sum([]) {
    return 0;
    } else ([x:xs]) {
    return x+sum(xs);
    }

    But to make this work, they first have to make "[1,2,3] === [1,2,3]" work :D
  • 0
    @ac1235 I personally prefer to write code as generic as possible, sometimes that means using one-liners, sometimes not, but is always good to keep readability in mind.
  • 1
    @jpichardo still, javascript must support equaility tests, like [1,2,3] === [1,2,3] for me to use it
  • 0
    @ac1235 yeah, that's is something I don't like about js and some weak typed languages
  • 0
    @jpichardo well erlang and python do it right, perl too.

    Its really not about the typing discipline, its just a design issue.

    I know that they can not fix it to make it work with ===, since many websites would crash then, but they could add another operator, something like prologs =:=, so that:

    [1,2,3] === [1,2,3] is false (ptr test)
    [1,2,3] =:= [1,2,3] is true (content test)
  • 0
    @ac1235 yeah, you can always add to the prototype, correct me if I'm wrong, but it's still extra code.
  • 0
    @jpichardo really js should do a complete redesign, just like a subset of the perl community did by inventing perl6;

    a pragma like:
    "use ecma7";
    add the beginning of the code then could enable the features which break the behavior of == for example
  • 0
    @ac1235 Sounds good maybe you can start with it, but you can always use a "compile to js" language, like typescript or coffeescript, or make a AntScript
  • 0
    @jpichardo are you familiar with my work?
    the name AntScript sounds cool.
  • 0
    @ac1235 To be honest not much, I read the readme and the GitHub.io site, it sounds interesting but I'm not much of a scientist myself, just math and stuff. However I did realized two things, that antlang is an array based language and that there is an spelling mistake in "when you are experienced enaugh"
  • 0
    thank you :D will correct it.
    I just was confused how you came up with the name
  • 0
    @ac1235 Hahahaha yeah, and indeed sounds kinda cool
  • 1
    I myself have nothing to do with science, too.

    I'm just purely math and programming, too.

    Just have to understand enough (not enaugh ;) ) to implement what they need.
Add Comment