cross-posted from: https://lemmy.ml/post/39334581

top 50 comments

sorted by: hot top controversial new old
[–] 104 points 9 months ago (1 child)
  • [–] 63 points 9 months ago (2 children)
  • load more comments (1 reply)
    [–] 50 points 9 months ago (4 children)

    Related: Every Fn key on a keyboard is a missed opportunity! That's not fun at all!

    Riskeyboard 70 analog hall effect keyboard left side showing the Fun key

  • source
  • hideshow 6 child comments
  • load more comments (2 replies)
    [–] 38 points 9 months ago* (last edited 9 months ago) (5 children)

    def (): is pretty nice

    Edit: also as someone doing a bunch of CI work right now, Bash can GTFO (unless the alternative is whatever Windows is doing)

  • source
  • hideshow 7 child comments
  • load more comments (3 replies)
    [–] 21 points 9 months ago (1 child)

    Anyone tried lisp? Looks something like this. ((()))()())))

  • source
  • hideshow 2 child comments
  • [–] 21 points 9 months ago (11 children)

    Not sure I'd call what bash has functions. They're closer to subroutines in Basic than functions in other languages, as in you can't return a value from them (they can only return their exit code, and you can capture their stdout and stderr). But even then, they are full subshells. It's one of the reasons I don't really like Bash, you're forced into globally or at least broadly-scoped variables. Oh, and I have no clue right now how to find where in your pipe you got a non-null exit code.

    It's not a big problem for simple scripting, but it makes things cumbersome once you try to do more.

  • source
  • hideshow 12 child comments
  • [–] 6 points 9 months ago (2 children)

    I really like bash when dealing with even somewhat advanced scripting. Like the 300 LOC scraper I have written over the past two days which horribly parses HTML files using grep | sed.

    It's genuinely so much more fun to do this with Bash than, say, Python. I have once written a scraper using Beautifulsoup and I have no desire to do so ever again.

    Honestly, only Haskell manages to beat Bash in how satisfying it feels when you manage to get something working well.

  • source
  • parent
  • hideshow 3 child comments
  • load more comments (1 reply)
  • load more comments (10 replies)
    [–] 17 points 9 months ago* (4 children)

    In the language Gulf of Mexico,

    you can use any letters from the word "function" (as long as they're in order)

    union foo () => ()
    
  • source
  • hideshow 6 child comments
  • [–] 15 points 9 months ago*

    In the language Gulf of Mexico

    HUH?

    Some languages start arrays at 0, which can be unintuitive for beginners. Some languages start arrays at 1, which isn't representative of how the code actually works. Gulf of Mexico does the best of both worlds: Arrays start at -1.

    Oh, I see they're serious! Time to ditch JavaScript.

  • source
  • parent
  • [–] 9 points 9 months ago* (last edited 9 months ago)

    Naming

    Both variables and constants can be named with any Unicode character or string.

    const const letter = 'A'!
    var const 👍 = True!
    var var 1️⃣ = 1!
    

    This includes numbers, and other language constructs.

    const const 5 = 4!
    print(2 + 2 === 5)! //true
    

    This is a recipe for disaster I kinda wanna try

  • source
  • parent
  • load more comments (2 replies)
    [–] 16 points 9 months ago (9 children)

    funciton

    Idk why but that's how I type it half the time.

  • source
  • hideshow 11 child comments
  • load more comments (7 replies)
    [–] 14 points 9 months ago* (1 child)

    Kotlin also lets you do fun x() = y()

  • source
  • hideshow 2 child comments
  • [–] 5 points 9 months ago (2 children)

    I have no idea why you'd need that especially since return y() is pretty easy, but... I want it!

    (Actually, I guess a super simple way of overloading a method, like fun x() = x(defaultValue) could be neat)

  • source
  • parent
  • hideshow 4 child comments
  • [–] 9 points 9 months ago (1 child)

    This can also be a side product for code blocks being expressions instead of statements.

    In rust for example they are, so it's not rare to see functions like:

    fn add_one(x: i32) -> i32 {
        x+1
    }
    

    This lets you do amazing things like:

    let x = if y < 0.0 {
        0.0
    } else {
        y
    }
    

    which is the same as x = y < 0.0 ? 0.0 : y

    But is much better for more complex logic. So you can forget about chaining 3-4 ternary operations in a single line.

  • source
  • parent
  • hideshow 1 child comment
  • load more comments (1 reply)
  • [–] 12 points 9 months ago (1 child)

    C++ has []{}.

    (You can also add more brackets if you wish to do nothing longer: []<>[[]]()[[]]{}())

  • source
  • hideshow 2 child comments
  • [–] 12 points 9 months ago (2 children)

    Not exactly aimed at language keywords (although it is aimed at the language designers who decided abbreviations in keywords are acceptable):

    I hate abbreviations in source code so fucking much. Reading is more of software engineering than writing. If you cannot be bothered to type a whole word because typing is hard for you, find a different job. Do not force others to engage in mental gymnastics to understand what the fuck a variable or function is supposed to mean.

  • source
  • hideshow 3 child comments
  • load more comments (1 reply)
    [–] 11 points 9 months ago

    Bash was derived by a team of criminally insane programmers in the bowels of a South American asylum so deep in the jungle no country can rightfully claim it as its own. It is the product of the demented keystrokes of the damned, possessing a singular logic so alien that its developers can hardly be said to be human at all.

    And I wouldn't have it any other way.

  • source
  • [–] 9 points 9 months ago (1 child)

    ()=>{}

    Javascript straddling the middle as usual.

  • source
  • hideshow 2 child comments
  • [–] 8 points 9 months ago (1 child)

    What, are we code golfing?

  • source
  • hideshow 2 child comments
  • [–] 6 points 9 months ago (4 children)
    function:
    ...
    goto function;
    
  • source
  • hideshow 4 child comments
  • load more comments (4 replies)
    [–] 6 points 9 months ago
    [–] 6 points 9 months ago (3 children)

    While C feels fine without having a keyword for function, I feel like bash would have benefitted from it.

  • source
  • hideshow 3 child comments
  • load more comments (3 replies)
    [–] 5 points 9 months ago

    basic: def fn

  • source
  • [–] 5 points 9 months ago

    JS:

    () => {}
    
  • source
  • [–] 4 points 9 months ago (2 children)
    load more comments (2 replies)
    load more comments
    view more: next ›