News for hackers. Stuff that matters.
Re:It's not what programming languages do, it's what they sh... by l0b0 on Friday March 27, 2020 @12:52AM (#22700512)
That's a great metaphor for language smells! Some more anecdotes:

- Python shepherds you into using list comprehensions, even when it's almost always premature optimization and much harder to read than a loop. As a language smell that's not bad, it's just the worst I could think of in a post-v2 world. Luckily there's `black`, `flake8`, `isort` and `mypy`.

- Bash shepherds you into using `ls` and backticks, useless `cat`s, treating all text as ASCII, and premature portability in the form of "POSIX-ish". Luckily `shellcheck` takes care of several common issues.

- Lisp shepherds you into building your own language.

There's also tool shepherding:

- IDEA shepherds you into refactoring all the time, since it's the only IDE which does this anywhere near reliably enough. (At least in Java. In other languages renaming something with a common name is almost guaranteed to also rename unrelated stuff.)

- Firefox shepherds you into using privacy extensions.

- Chrome shepherds you into using Google extensions.

- Android shepherds you into installing shedloads of apps you hardly ever use.

- *nixes other than Mac OS shepherd you into using the shell and distrusting software by default.

- Windows and Mac OS shepherd you into using GUIs for everything and trusting software by default.

Re:It's not what programming languages do, it's what they sh... by nikofeyn on Friday March 27, 2020 @03:32AM (#22700996)
> Lisp shepherds you into building your own language.

the feeling of the racket community is that you build a DSL or DSLs in your code all the time, in any language, so why not take it seriously and codify your DSLs?

Re:It's not what programming languages do, it's what they sh... by sbergot on Friday March 27, 2020 @04:01AM (#22701107)
My personal feeling about this is that shared base language mecanisms such as functions, classes, control structure, interfaces imports, properties etc allow you to reason locally about some files. You don't need to read the whole library in order to understand one piece of it.

With macros this goes out of the window. You have to read all the custom macros before you can understand what is their behavior.

With haskell the same issue exists with complex monad stacks and control libraries like lens.

The ability to analyse a tiny piece of a big system is a major factor in building those in a manageable way.

Re:It's not what programming languages do, it's what they sh... by wtetzner on Friday March 27, 2020 @04:18PM (#22706432)
The beauty of macros is that you can just expand them in-place and read the expanded code.

Of course, for really complex macros the expanded code might be hard to read, but I guess that means "write nice macros".

Re:It's not what programming languages do, it's what they sh... by londt8 on Friday March 27, 2020 @10:47AM (#22703221)
I dont think list comprehensions are used to improve performance. One reason to use them is to improve readability, as the execution doesnt jump around with continue/break etc.
Re:It's not what programming languages do, it's what they sh... by lsh on Friday March 27, 2020 @02:35AM (#22700809)
> - Android shepherds you into installing shedloads of apps you hardly ever use.

I disagree with you on this one but I could be in the minority. I have about 8 apps that I trust and that rarely change. I don't go looking for new apps to install and I resist attempts to use the app version of a website.

> Lisp shepherds you into building your own language

I see the propensity of developers to build DSLs in all languages. I think the act of programming shepards us into creating elaborate abstractions.

Re:It's not what programming languages do, it's what they sh... by wodenokoto on Friday March 27, 2020 @05:31AM (#22701410)
> and I resist attempts to use the app version of a website.

If you weren't being shepherded into installing apps, why are you resisting?

I could install apps on my old Nokia dumb phone, but I never resisted installing apps. It never really seemed like it was worth the trouble to install one.

I actually looked into it once, despite the system shepherding me away from installing apps.

Re:It's not what programming languages do, it's what they sh... by marcosdumay on Friday March 27, 2020 @09:46AM (#22702763)
Bash shepherds you into ignoring errors and using maybe-blank values everywhere.
Re:It's not what programming languages do, it's what they sh... by l0b0 on Friday March 27, 2020 @04:21PM (#22706463)
You can improve that situation somewhat by starting scripts with `set -o errexit -o noclobber -o nounset -o pipefail` and `shopt -s failglob` to fail fast.
Re:It's not what programming languages do, it's what they sh... by marcosdumay on Saturday March 28, 2020 @12:40PM (#22712260)
Yes, this makes things better.

But then you will have to deal with the non-negligible amount of programs that use the exit value to return information. It is still better to place exceptions on failing code than to ignore errors that can wipe out your entire system, but it's not really good either way.

Re:It's not what programming languages do, it's what they sh... by pjmlp on Friday March 27, 2020 @02:40AM (#22700825)
I never missed any kind of IDEA features in Eclipse and Netbeans, including refactoring.

And yes I do know InteliJ, as I have to put up with it on Android Studio.

Re:It's not what programming languages do, it's what they sh... by chungus on Friday March 27, 2020 @04:42AM (#22701257)
>since it's the only IDE which does this anywhere near reliably enough.

Have a look at the Language Server Protocol implementations for java (eclipse jdtls and to a lesser extent boot-ls). Not all the features from IDEA are there, but the gap is closing.

Re:It's not what programming languages do, it's what they sh... by Chris2048 on Friday March 27, 2020 @09:44AM (#22702744)
> Python shepherds you into using list comprehensions

I'd argue LCs have more limits than loops, and hence are easier to read (because you can make more assumptions about what it does). That said, I find nested comprehensions harder to read.

Re:It's not what programming languages do, it's what they sh... by dgellow on Friday March 27, 2020 @10:21AM (#22703024)
> Windows and Mac OS shepherd you into using GUIs for everything and trusting software by default.

Not sure how familiar you are with modern Windows, but you can try powershell. You can manage everything in Windows with it, and it’s a very cool shell language with a lot of feature.

(It’s also open source and multi platform)

Re:It's not what programming languages do, it's what they sh... by wtetzner on Friday March 27, 2020 @04:21PM (#22706462)
I agree with what you said, but I also agree that Windows shepherds you into using GUIs for everything. It's possible to use powershell, but Windows makes GUIs seem like the "natural" way to do things.
Re:It's not what programming languages do, it's what they sh... by zro on Friday March 27, 2020 @11:02AM (#22703359)
Do you have any good sources for places to start learining powershell? I'm pretty comfortable in bash, but powershell scares me.
Re:It's not what programming languages do, it's what they sh... by l0b0 on Friday March 27, 2020 @04:17PM (#22706423)
As someone who used PowerShell for a year and has used Bash for 10+, PowerShell is much less scary than Bash. The scariest thing about PowerShell is .NET, which (at least 8 years ago or so, so cue someone correcting that below) had extensive but often low quality documentation, with undocumented features you basically had to use to write useful code, uselessly trivial code examples (think "`0 + 0 == 0`" as an example of arithmetic) and some bad names. That's not to say Bash is better, just that they still had some way to go.
Re:It's not what programming languages do, it's what they sh... by dgellow on Saturday March 28, 2020 @01:06AM (#22709348)
Microsoft online documentation is very good. I initially spent just a weekend trying to create a nice prompt, just because I was annoyed by the ugly “PS >” when using Windows. The online documentation had everything I needed, and I enjoyed so much that I switched all my systems to using powershell as their default shell.

You can start at https://docs.microsoft.com/en-us/powershell/scripting/learn/....

A quite nice feature is the command Get-Help:

Get-Help <a command> -Online

That will direct you to the documentation page specific to a command. That way you can discover the environment little by little by experimenting.

Also, the auto completion for all commands and their arguments is helpful to learn what is possible.

Also, if you want to keep your bash habits, be sure to install powershell 7, and enable the emacs edit mode (which is similar to bash defaults, with C-a, C-e, etc):

Set-PSReadlineOption -EditMode Emacs

https://docs.microsoft.com/en-us/powershell/module/psreadlin...