- cross-posted to:
- programmerhumor@lemmy.ml
- cross-posted to:
- programmerhumor@lemmy.ml
cross-posted from: https://lemmy.ml/post/39334581
Kotlin seams fun
It is. Also *seems
No, no, they’re saying Kotlin seams together the fun.
A pointer?
To a dictionary
In the language Gulf of Mexico,
you can use any letters from the word “function” (as long as they’re in order)
union foo () => ()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.
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)! //trueThis is a recipe for disaster I kinda wanna try
If you’re unsure, that’s ok. You can put a question mark at the end of a line instead. It prints debug info about that line to the console for you.
print("Hello world")?Fucking sold, I was gonna learn rust but you’ve changed my mind
Just looking through this as a fledgling barely-coder…
…It inspires fear. Terror, even. LMAO

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.
Meanwhile Haskell:
=
too bad they chose
::for type declaration instead of:
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.
There was a rather famous piece of software at my last job. Guy writing it wanted job security. A lot of the core variables of the application were named based on the sounds a helicopter made. God damn onomatopoeia variables. Pretty sure that shit is still in use somewhere.
I can’t imagine writing something like that. Job security? Hah, I’d end up in an inescapable labyrinth of my own making if I named things something that wouldn’t be obvious to my 3-months-later self!
Maybe that’s the play: He intentionally confuses himself so it takes extra paid time to remember what the heck “SOISOISOI” does, compared to “Whopwhopwhop”.
I get that but also can be kinda nice to have density so that you can read more of the program on a single display.
Related: Every
Fnkey on a keyboard is a missed opportunity! That’s not fun at all!
okay, now i gotta figure out how to start a keyboard rave when i press fn
That’s a cool looking keyboard!
Begs the question, what’s the other shift key labeled!
Doesn’t matter: Nobody uses right shift for anything but pinball games!
def ():is pretty niceEdit: also as someone doing a bunch of CI work right now, Bash can GTFO (unless the alternative is whatever Windows is doing)
Nushell is pretty nice. It’s the good parts of “what Microsoft is doing”, i.e. real structured data in a shell-like language and real error handling.
also better to type with one hand
You QWERTY people…
/jk
Colemak is great though
Windows’s powershell has OOP :D
PowerShell seems like what you get when you combine the convenience and accessibility of a Linux shell with the annoying verbosity of Java
Have you tried “Get-ahilariosulylongnounandnoimnotkiddingsomearethislong?”
funcitonIdk why but that’s how I type it half the time.
Won’t you take me to
funcitooon?
Won’t you take me to
funcitoon.
You press c and t using the same finger, and i with another. So since you need to use the same finger twice in a row, also moving it a fair distance in between, your other finger just presses the button a little bit too soon, and that’s how you end up with
funciton‘c’ and ‘t’ should definitely be hit with different fingers if you do touch-typing. But with one hand, that’s true.

there’s no ‘i’ on that keyboard?
And two Ls

Fixed. Brought to you by ortho gang.
I bought this yesterday from perplexity.ai

deleted by creator
I just recorded myself typing it a dozen of times, and it always goes as:
F - Left index U - Right middle N - Right index C - Left index T - Left middle I - Right middle O - Right ring N - Right index
I usually generally follow zones while typing, but for frequent words like this I tend to break it, which mostly make sense, like using middle finger for U to free index finger for N, and then moving it one over for a quick IO without lifting the index from N), but then that CT thing is a decades-long ingrained thing that I didn’t even realize how weird it was until I looked closely at it. It reminds me of that thing that bothers me on my other kb which is ortholinear and I always struggle in games with it because I can’t press 2 while holding Shift and W at the same time. On normal keyboards I use ring fingers and slightly twist my wrist clockwise, but on ortholinear it’s not there, and it’s actually easier to use index finger and twist the other way, or roll middle over without lifting, but it’s very hard to break that habit.
And you can continue typing it that way for as long as you want if you set up autohotkey to automatically fix your typos.
Autohotkey? Naw, you wanna setup a daily cron job to read and replace every one of your common typos with the correct spelling. That’s the way, trust me.
Edit: Daily cron job typo correction.
Dude, I set up wild crap with Autohotkey, for a job. I had it logging in to vendor websites where it would pull up clients, compare contact info to our local system, check if recent payment had been made, pull appropriate client docs (if not already in our local system), and leave notes for me before moving onto the next client on the list. I had AHK doing most of the job I was hired for.
Thankfully, the multiple vendor websites made occasional changes to their layouts, color schemes, etc. so all my methods of navigation would inevitably break, requiring me to maintain it.
I was also building stuff where it would automatically fire off an email at certain points if there was a special change to tell the client about, if payment wasn’t seen on the vendor site by certain deadlines, etc.
That job eventually fell through for unrelated reasons (they moved me off that to somewhere they needed me more, and several years later got pushed out of that position and the company entirely).
Where do I get a job that let’s me build that stuff again?!
In a perfect world you could get paid to automate stuff with AHK. I wonder if you could market yourself as an AHK consultant where you basically shadow someone’s job for a week and then start figuring out how to automate the tedious stuff.
Personally I like the functionality of AHK but I can’t stand the syntax compared to Python and C. I start with such great plans of what I want to automate but get sick of fighting with the language after about an hour and settle for something simple.
I actually started thinking about exactly this minutes later, and have been VERY excited about trying it. I’ve been unemployed for awhile now, not by choice, and already have diagnosed depression going back years before. Job market stinks and I’m bad at getting hired. BUT this idea actually excites me, in a way I haven’t felt in WAY too long.
I plan to start working on some basic function libraries for myself, rebuilding some things from that old job, and I’ll also be contacting local businesses for a start. The old job was for a small business, so I have a decent feel for how to fit it into places.
So many of my "-tion"s end up as "-tino"s.
Anyone tried lisp? Looks something like this. ((()))()())))
Remarkable how if the parenthesis is shifted from
lambda()to(lambda), people lose the ability to comprehend things.Isn’t it more like
foo(){…}->(define foo (lambda ()))
tbf?In clojure it’s (def (fn [])) or short (defn []).
In Emacs Lisp, you use one of these two:
(defun funcname (arg1 arg2) (+ arg1 arg2))(lambda (arg1 arg2) (+ arg1 arg2))— with the latter typically being an argument to another function or macro.
deleted by creator
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.
You’re not forced into global forced variables, but they’re the default. Use the
localkeyword in front of the variable declaration for nicely scoped variable.It’s not that cumbersome to do things like
local date=`date` echo "$date"but in all honesty the syntax sucks ass because it’s not intuitive. If statements suck ass, passing variables has to be done via command line arguments sucks ass, switch statements suck ass, making structured data sucks ass (
jqis nice though).I agree with you that bash really sucks when you get to anything more than 10 lines and at that point I’d take literally prefer Dreamberd.
I didn’t mean that bash has no local variables, but rather that if you want to use a function as such without capturing stdout, you need variables that are scoped across your functions, which is usually global or at least effectively global.
Turns out you can, by using () instead of {} in the function declaration you can run the function in a subshell where changes to variables are scoped to the subshell and functions are local.
That doesn’t help you if you want to get the result of something that happened in the function without capturing stdout, does it?
global variables
vomits
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.

Bash has its upsides too, like the fact that it has arrays / lists and dictionaries / hashmaps. In my opinion, it gets iffy though when you need to do stuff with IFS; at that point one might be better off just using specialized tools.
Not saying working bash isn’t good enough, but it can break in very surprising ways is my experience.
where in your pipe you got a non-null exit code
First thing you want is
set -eandset -o pipefail. That should report the errors in human-parseable form.Second, to capture exit codes from each command/program, you have to run each of them in sequence yourself, connected by pipes that you create via
mkfifo— the same way as you would do it in any other programming environment. Bash’s|pipes are just a convenient shorthand for this, so if you want full control, you have to ditch the convenience.Functions are definitely not subshells in Bash, seeing as anything modifying the environment, like
pyenvand such, is implemented as functions instead of scripts — specifically because functions are run in the same shell instance.Unless ‘subshell’ means something in the vein of ‘like a new shell, but not really’.
Try doing
cdinside a function and thenpwdin the main script. Does it move the main script too?I’m gonna bet yes for the simple reason that various helper scripts exist that do advanced
cdhistory, with fuzzy search and whatnot, and they can’t be implemented as anything other than functions.
Functions are definitely not subshells in Bash
You’re right, my bad, I got this mixed up with something else.
JS:
() => {}While
Cfeels fine without having a keyword for function, I feel likebashwould have benefitted from it.Bash (specifically Bash, not POSIX sh) does have a keyword for functions (
function), but it’s optional.Ooh nice.
The optional bit messed it up, because even though I can make my scripts easier for me, other’s scripts won’t be.
But thenbashhad to be usable withshscripts, so I get it.Right. It’s optional so that Bash remains backwards compatible as a superset of POSIX sh. If you’re working with exclusively Bash, though, it’s nice to use as syntactic sugar if nothing else.
C++ has
[]{}.(You can also add more brackets if you wish to do nothing longer:
[]<>[[]]()[[]]{}())Then rust has
||{}Sadly we can’t add more complexity without adding an argument:
|_:&'_[()]|{}
Kotlin also lets you do
fun x() = y()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)
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 : yBut is much better for more complex logic. So you can forget about chaining 3-4 ternary operations in a single line.
Lisp programmers seeing these ‘amazing things’:

But yeah, every time I’m trying to do a ternary in Lua, I miss being able to just throw in an
if. Thankfully it can be amended with Fennel.
default values is one of my pet-peeves after using Python regularly. I wish more languages would let you just do something like
def do_thing(arg=default_value)without hoops like builder pattern, function overloading, or whatnot(Kotlin does support that, with the same
fun do_thing(arg: Int = 2)syntax.)I mean, the go-to approach in Lisp, for example, is to have null as the default value (which doubles for false in there). And check for that in the function.
That sounds awfully similar to JavaScript, which uses undefined as default values.
In Lisp, at least the Emacs Lisp with which I have experience, it’s customary to put in
nil(Lisp’s null) for any omitted arguments in the middle that you can’t be arsed to specify — aside from just leaving off arguments at the end. In JS, typing inundefinedin every such case would probably be an annoyance, so I’m guessing coders need to check for bothundefinedandnullin these circumstances.Overall, it’s remarkable how Lisp teaches one to be much more relaxed about programming practices than is typical for mainstream languages. Design patterns? Data structures? Shit, just pass in a list or an assoc array, and maybe a function here and there. Also everything is an expression, enjoy your ternary
(if)at any point anywhere.Design patterns? Data structures? Shit, just pass in a list or an assoc array, and maybe a function here and there
After trying to be relaxed about data structures in python, I can say that, IMO, this is more harmful than beneficial. Good types and structures lead to good code designs.
()=>{}Javascript straddling the middle as usual.
The equivalent in JavaScript / TypeScript would actually be
function () {}, this is the syntax for named functions.C# is the same as bash though.
It’s object-oriented; you can assign this to a named variable.
In that case the full thing would be
const fun = () => {}Yeah for whatever reason, FE devs want to make everything a const. It’s like a religious belief or something, it’s really kinda weird.
const fun = () => { const something = “whatever” const array = []; array.push(someting)
for (const thing of array) { if (thing === ‘whatever’) blah(thing) } }
Semicolons? Optional. Which quotes you should use? Whatever you feel like! But you must declare things as a const wherever possible! Even if it’s an array that you’re going to be changing, declare it as a const because you should know that you can push things into a const array, and since it’s possible to declare it as a const, you must declare it as a const.
Why is this? Nobody knows, but it’s important to FE devs that you use const.
The reason is very simple, performance. If a value doesn’t need to be changed, don’t declare it as mutable. This isn’t just a front-end thing btw.
Pushing something onto an array isn’t changing the array? It’s not changing the reference to the array, but from a style standpoint it doesn’t make sense.
And if you’re declaring a const within the scope of a function, it’s still allocating memory when it enters the scope and disposing it when it leaves the scope, same as a variable. There’s no performance benefit to do this.
Something like const CONSTANT_VALUE = “This never changes” has a performance benefit and is actually how other languages use constants. The value will always be the same, the compiler understands this and can optimize accordingly. If you’re declaring an iterator or the result of calling a webservice to be const it’ll be a different value every time it runs that code, so it’s not something a compiler can optimize. In style terms, it’s a value that’s different every time you get to that line of code, so why would you want to call it constant?
You’re comment indicates the FE dev obsession with always using const stems from a misunderstanding of how computers work. But of course many religious beliefs originate from a misunderstanding of the world. Whatever man, I just make it a const to make the linter happy, because it’s dumb FE bullshit LOL.
Lol.
Pushing something onto an array isn’t changing the array? It’s not changing the reference to the array, but from a style standpoint it doesn’t make sense.
So you’re arguing for writing things as they seem, not the way that computers treat them?
You’re comment indicates the FE dev obsession with always using const stems from a misunderstanding of how computers work.
Maybe rethink this.
semicolons? quotes? use a formatter and don’t think about it. I think js world has basically done this already.
const is simpler. why would I declare an array as
letif I’m not reassigning? someone can look at it and know they don’t have to think about reassignment of the reference, just normal mutation. ts has the furtherreadonlyto describe the other type of mutation, don’t abuseletto mean that.const arrow over named function? gets rid of all the legacy behaviors and apis. no
arguments, consistentthis, and no hoisting or accidental reassignment. the 2 places you should ever use named fn are generator or if you actually needthissemicolons? quotes? use a formatter and don’t think about it. I think js world has basically done this already.
It’s nice when a codebase has sane formatter conventions. I can’t say that my workplace does, tho…
const arrow over named function? gets rid of all the legacy behaviors and apis. no
arguments, consistentthis, and no hoisting or accidental reassignment. the 2 places you should ever use named fn are generator or if you actually need `thisHow is having
argumentsandthisan issue? If one doesn’t need them, then it can be just left unused. I really don’t get this argument. It makes everything visually a variable. I see no benefit to this convention and actively despise it.I’ve worked at several places that didn’t have formatters when I started. they did by the time I left. you can incrementally adopt them and if it’s automated most people at worst don’t care. advocate for things you want
reassignment and hoisting are the significant ones. behavior around
thisdoes just seem more intuitive than otherwise when it comes up, so I think telling especially new devs to use const arrow fn everywhere but classes is a reasonable rulehate to break it to you but it behaves like a variable either way.
functionjust behaves closer to avarvariable.constfns are less like variables since no assignment. intellisense/devtools all show them just fine. it really is just a minor aesthetic difference on the definition
Stylistically, you’re changing the array when you add something to it. Javascript is a janky language in the best of times, but FE devs like to artificially introduce additional unnecessary complexities on top of the jank.
const is simpler. why would I declare an array as let if I’m not reassigning?
Why would you declare a const that’s going to have different data every time to function is called?
Now I’m thinking it’s a form of gatekeeping. Just an excuse for FE devs to throw out terms like “immutable” to make it sound like they know what they’re taking about. Y’all need to constantly sound like you know what you’re talking about when dealing with users, pretending weird stylistic choices have real technical reasons for them. But the BE devs know what you’re saying is complete bullshit LOL.
knowing the programming language you’re working in at a basic level is gatekeeping I’m ok with
You are literally just describing the conceptual differences between functional programming and object oriented programming. It has nothing to do with front end vs backend, except for the fact that React has vastly popularized functional paradigms on the frontend.
If you come from a Java / Spring background, that will seem foreign, if you come from an express background it will feel natural.
Functional programming is extremely pleasant though. Its been described as what object oriented would look like if you actually followed all the SOLID principles. You should keep an open mind.












