gpopides,

Not everything should be beginner friendly. Trying to nerf things because they are not beginner friendly should not be how tools/patterns of languages are designed.

Its ok to have more advanced topic that require more knowledge and that people don’t understand from the first moment they see them.

SolarMech,

Yes and no. I mean sure, if you are going to leverage this to gain a significant edge in the market, that works.

If you add a tool to the project, that you need to understand to maintain some parts of it, which adds to the learning curve of someone joining said team, then the gains have best be worth the effort.

We adopt so many librairies/plugins/tools over time that adding more complexity than you need this way is just terrible.

wolf,

Amen! One thing which drives me crazy is that most people confuse beginner friendly and user friendly, the two things are absolutely not the same thing. There is nothing wrong with having tools which are beginner friendly, especially for stuff one does once in a while. There is everything wrong with nerving tools which are for pros or even everyday usage: If I use something everyday I have rather an optimization for the mid or long run, than for the first few hours…

FrankTheHealer,

KDE is ridiculously unintuitive and has become too awkward to use to recommend to a newbie.

Arch is not a general purpose distro. Theres too many things that can break it unless you meticulously follow the patch notes and participate in the community.

Vim is overrated.

0xc0ba17,

People who insist on using semicolons in Javascript don’t understand why and are just following a cargo cult.

Remove the semicolons, be free.

frezik,

It’s also because my fingers automatically type them for the sake of most other languages. Let me have my muscle memory.

Nested_Array,

iirc semicolons are required in JavaScript strict mode.

0xc0ba17,

They’re absolutely not

NewPerspective,

If white space carries any function that the compiler/interpreter needs to know about like structure or scope, it’s probably not a very good programming language.

sajran,

Genuine question: why? What makes, say a semicolon, so superior to the the newline or tab characters?

To be clear: I don’t think whitespace as a part of syntax is an awesome idea which should be more popular. It’s definitely a bit more error prone in some ways. It’s not perfect. But it’s okay.

I’ve written a lot of Python and I don’t think I have ever seen a syntax error caused by incorrect whitespace. I’m not exaggerating. I regularly forget semicolons in other languages but I never type out incorrectly indented code. Maybe that’s just me though…

Reptorian,

From some one who used Python as it was the easiest solution to few of my problems, and having to experience languages with brackets and/or endif/fi/done as ways to limit scope, I find that having things like brackets and/or scope terminators easier to parse and less error-prone. I’m thinking about moving on to Ruby whenever I had a need where Python would be a good choice, but the time it takes for me to understand a new language is blocking me from that.

UnfortunateShort,

I honestly think the scripting languages like fish have got it right.

Newline by default completes a line and can optionally be escaped. Saves you most of the semicolons and even implicitly highlights multi-line statements.

Whitespace doesn’t matter except for separating names.

Blocks are explicitely ended without braces you can confuse with brackets or parentheses, no matter the coding style.

If Rust and fish had a baby, I think it would be the best language to have ever been created.

NBJack,

How much of that python is written in a shared codebase with multiple active contributors? When was the last time you refactored a module?

Tabs and spaces are invisible. Semicolons are not.

sajran,

A vast majority of the code in question is the code I’ve written for my work projects with multiple active contributors and refactoring is very common too. We all like to shit on Python for various reasons but no one in my environment ever complained about whitespace.

Like I said, I don’t think whitespace is perfect as a part of syntax but I’m much more likely to forget a semicolon than a proper indentation and this applies to any language. I guess it’s not universal tough, because you can often see code with messed up indentation on online forums etc. TBH this is just unthinkable to me, indentation is absolutely necessary for me to be able to read code and reason about it. When I’m thinking about blocks and scopes it’s not because I counted semicolons and braces, it’s 100% indentation.

DeprecatedCompatV2,

How do you feel about line breaks?

jvisick,

Not who you asked but I think they’re important for humans, but syntactically I don’t think they should matter

Thoth19,

Intmain(intfoo){std::out<<"HelloWorld";}

Is a great program and should totally be valid cpp. White space sucks.

/S

mindbleach,

Load-bearing whitespace is the fucking devil. This thread about hot takes is topped by a comment highlighting how people can’t even agree what kind of whitespace to use.

Python - you want code to fail if someone from one camp copy-pastes code from another camp, and the characters that make a difference are invisible?

NBJack,

Load bearing whitespace. Damn, I love that phrase.

Also, if you have to have agreement on the tabs or spaces argument in your codebase in order to get it to compile, you have already lost.

newIdentity,

JavaScript isn’t bad. Sure it has its quirks, but it’s not as bad as everyone makes it sound it is

morrowind,
@morrowind@lemmy.ml avatar

I mean it used to be way worse before before google and whatnot poured hundreds of millions into making it better.

hansl,

Hot take: people who don’t like code reviews have never been part of a good code review culture.

JuneFall,

It is also a situation in which when you don’t have them you can feel smart since you don’t have to find justification for what you do.

drathvedro,

Hot take #2: Unless you have great code review culture, code rewiews are just unnecessary blockers

FMT99,

I see the value, but that doesn’t mean I have to like it :p

rk96,

PHP aint all that bad

darcy,
@darcy@sh.itjust.works avatar

the stack is cool, the language itself sucks, unless compared to javascript

secret301,

Abstraction will be the death of traditional software development as we know it

corstian,

Can you explain?

secret301,

No

verstra,

Barges into a lemmy thread Gives a strong, but quite abstract opinion criticizing abstractions Refuses to elaborate further

darcy,
@darcy@sh.itjust.works avatar

:based:

NBJack,

Someone hasn’t read en.m.wikipedia.org/wiki/No_Silver_Bullet yet.

If abstraction was going to kill it, it would have died a thousand deaths already.

secret301,

I have not, about to now tho thanks

corstian,

Most modern software is way too complex for what it actually does.

hellishharlot,

Using single character variable names is always bad practice

Thoth19,

Guess I’ll have to name all of my iterators “it” instead of “I”. That will fix things.

Definitely a hot take though. Bc there are definitely times when it is totally acceptable.

hellishharlot,

Iter works better than I for clarity

UnfortunateShort,

An iterator is commonly understood to be an object and thus something much more complex than a simple integer. This is the exact opposite of more clear.

verstra,

I have a convention to correlate the size of variable scope with its name length.

If a variable is used all over the program, it will be named “response”. If it is <15 lines, then it can be “res”. If it is less than 3 lines, it can be only “r”.

This makes reading code a bit simpler, because it makes unimportant, local vars short and unnoticeable.

hellishharlot,

Why though? Intellisense helps you write out the full name. And instead of response why not call it whatever the data you’re expecting to be

lemmyingly,

I agree because it makes the code easier to follow in 6 months time.

JuneFall,

Could you comment a couple of examples? At best some that signifiy the importance with them as verstra wrote.

9point6,

Except i right? Something like counter seems unconventional and unnecessarily verbose

hellishharlot,

Index can be useful but start looking for mapping and sorting functions. Or foreach. If you really must index, sure go use index or I if it’s conventionally understood. But reading something like for I in e where p == r.status is really taxing to make sense of

9point6,

Oh yeah, I map, filter and reduce pretty much everywhere I can. But sometimes you need the index and i is so commonly understood to be that, it’d say it could even be less legible to deviate from that convention

hellishharlot,

In what world is


<span style="color:#323232;">for (int index = 0; index &lt; objectToIterate; index++)
</span><span style="color:#323232;">{
</span><span style="color:#323232;">    // DO YO THANG
</span><span style="color:#323232;">}
</span>

less coherent than


<span style="color:#323232;">for (int i; i &lt; objectToIterate; i++)
</span><span style="color:#323232;">{
</span><span style="color:#323232;">    // DO YO THANG
</span><span style="color:#323232;">}
</span>
9point6,

The world where the convention is i

hellishharlot,

What’s incoherent about the first one? Why is index bad beyond standards

9point6,

It’s not incoherent, it just takes a tiny bit more effort to mentally parse as it’s not a stereotypical for loop. Maybe it’s just me, but let me try and explain

With the i example if you’re familiar enough with a language, your brain will gloss over the unimportant syntax, you go straight to the comparison and then whether it’s incrementing or decrementing.

With the other example, the first my brain did was notice it’s not following convention, which then pushes me to read the line carefully as there is probably a reason it doesn’t.

I’m not saying it’s a huge difference or anything, but following code conventions like this makes things like code reviews much easier cumulatively.

indepndnt,

Honest question: is there a mapping function that handles the case where you need to loop through an iterable, and conditionally reference an item one or two steps ahead in the iterable?

hellishharlot,

Not that I’m aware of but that’s a condition where you’re thinking with an index. What’s the difference you’re looking for?

indepndnt,

Something like parsing a string that could have command codes in it of varying length. So I guess the difference is, is this a 1-, 2-, or 3-character code?

I have something like this in a barcode generator and I keep trying to find a way to make it more elegant, but I keep coming back to index and offset as the simplest and most understandable approach.

hellishharlot,

So you could generate lists of 1, 2, and 3 character code items rather than looking at index +1 or something.

drathvedro,

In js there’s reduce. Something like


<span style="color:#323232;">arr.reduce((result, currentValue, currentIndex, original) => {
</span><span style="color:#323232;">if(currentIndex &lt; original.length - 2
</span><span style="color:#323232;">    &amp;&amp; original[currentIndendex + 2] % 2 === 0 ) {
</span><span style="color:#323232;">    result.push(currentValue / 2) 
</span><span style="color:#323232;">} else { 
</span><span style="color:#323232;">    result.push(currentValue);
</span><span style="color:#323232;">}
</span><span style="color:#323232;">return result;
</span><span style="color:#323232;">}, []) 
</span>

This would map arr and return halved values for elements for which the element two steps ahead is even. This should be available in languages where map is present. And sorry for possible typos, writing this on mobile.

xigoi,
@xigoi@lemmy.sdf.org avatar

In Haskell, you could do something like map (zip list (tail list)) (thisItem, nextItem) -> …

UnfortunateShort,

I’d say except indices in general. Just bloats every line where you need to use them. Imagine writing CUDA C++ where you regularly add and multiply stuff and every number is referenced via (usually) 1-3 indices. Horrible.

SolarMech,

Yeah, but it’s easy to overuse it. If your for loop is much longer. For a few lines I’d agree, don’t bother using something longer.

Code should scream out it’s intent for the reader to see. It’s why you are doing something that needs to be communicated, not what you are doing. “i”, “counter” or “index” all scream out what you are doing, not why. This is more important than the name being short (but for equal explanations of intent, go with the shorter name). The for loop does that already.

If you can’t do that, be more precise. At the least make it “cardIndex”, or “searchIndex”. It makes it easier to connect the dots.

jvisick,

Mostly agree. I’m ok with single characters in a one line / single expression lambda, but that’s the only time I’m ok with it.

anon_8675309,

Always and never are always bad.

DahGangalang,

Counter point:

Always and Never is never bad.

space_comrade,

Counterpoint: using anything other than ‘i’ as your index in a for loop in C or C++ is obnoxious as fuck.

At most I’ll go with ‘it’ for C++ iterators.

uralsolo,

I understand this conceptually, but there’s also a gremlin in my brain that wants me to make every line as short as possible.

hellishharlot,

Big same. Long feels complex until you go back later

Chingzilla,

Hope you don’t write go :D

hellishharlot,

JavaScript, TypeScript, and C# babyyyy

morrowind,
@morrowind@lemmy.ml avatar

Sometimes you’re just using it once and it’s blindingly obvious what it is

tryptaminev,

To be fair everyone with poor documentation thinks the code is blindingly obvious when they write it.

Double_A,
@Double_A@discuss.tchncs.de avatar

Unless you are implementing some mathematical formula. Then link the paper and stick to its variables.

0nXYZ,

That the HTML/CSS structure of web programming is absolutely disgusting and not necessary. The internet could be and should be so much more from a developer pov. Also people who double space instead of tab often have their mouths open while mashing space 16 times.

I completely understand and clearly see that web development is the future, but I still think it’s all gross and will always prefer targeted efficient compiled code. Why? Because I’m a huge fucking dork.

sznio,

The internet could be and should be so much more

The internet is already too much.

xigoi,
@xigoi@lemmy.sdf.org avatar

Did you have your mouth open while assuming that indenting with spaces actually involves pressing the space bar?

Thordros,

If you can’t find where you missed a closed parentheses, just add a bunch of them to the end of your project like this…

)))))))))

… until your editor’s syntax helper tells you it’s good. I am very good at coding.

lemmyingly,

I write the parentheses before I start writing inside the block. When something goes wrong, the scope of what I’ve done wrong is narrowed to within that specific block.

Thordros,

You are so wise. 🫢

mindbleach,

Ah, a practitioner of Extreme Go Horse.

r1veRRR,

Compiler checked typing is strictly superior to dynamic typing. Any criticism of it is either ignorance, only applicable to older languages or a temporarily missing feature from the current languages.

Using dynamic languages is understandable for a lot of language “external” reasons, just that I really feel like there’s no good argument for it.

SpaceCowboy,
@SpaceCowboy@lemmy.ca avatar

Yeah the error list is my friend. Typos, assigning something to the wrong thing or whatever is fixed without having to run the code to test it. Just check the error list and fix any dumb mistakes I made before even running the thing. And I can be confident in re-factoring, because renaming something is either going to work or give a compiler error, not some run-time error which might happen in production weeks later.

darcy,
@darcy@sh.itjust.works avatar

true but i dont think is really a hot take?

flakusha,
@flakusha@beehaw.org avatar

Dynamic languages are good for prototyping, especially if a lot of libraries available

hairyballs,

It’s much easier to work with streams of untyped data in a weakly typed language.

spokenlollipop,

Even when you’re using a dynamically typed Lang you should be using all the appropriate scanners and linters, but so many projects just don’t.

I joined a large project half way through and I ran pylint and stared as the errors (not just style stuff) poured out…

kaba0,

I do believe that static typing is at least a local optimum, but I am still not entirely convinced. Rich Hickey is a very convincing presenter and I can’t help but think that he is on to something — with Clojure the chosen direction is contract-typing, which is basically a set of pre- and post-conditions for your functions that are evaluated at runtime. Sure, it has a cost and in the extremes they are pretty much the same as dependent types, but I think it is an interesting direction — why should my function be overly strict in accepting a “record” of only these fields?

willia4,

TDD is overrated. Code coverage is extremely overrated. Both of these tend to lead to a morass of tests that prove the compiler works at its most basic level while simultaneously generating a surplus of smugness about the whole situation.

Tests have their place. Tests can be, and often are, valuable. But the easier the test is to write, the easier it would’ve been to just encode it into the type system to begin with.

bamboo,

As someone who works on python code and kinda hates it, type annotations and a CI pass for mypy would catch the majority of our bugs. It’s painful

SpaceCowboy,
@SpaceCowboy@lemmy.ca avatar

Yeah creating tests for every single method is insane. If a feature changes it’s more difficult you either have to figure out how to implement the change without changing the method, or you change the method and have update the unit test. But if you’re constantly updating the unit tests, how do you know if you might’ve broken something else that the test was intended for.

It’s way better just to do integration tests that match the feature request. That way the feature that someone asked for will continue to work even if you decide to refactor the code.

Alexstarfire,

Unit tests are only worthwhile if you refractor code or write the unit tests before writing the code. We started adding unit test for most everything where I work and I think it’s far more effort than it’s worth. It’s not that it catches nothing but it catches so little I don’t think it’s worth the time spent writing them.

Double_A,
@Double_A@discuss.tchncs.de avatar

Code changes that could affect tests happen all the time. It doesn’t need to be a specific refactoring of that unit.

Alexstarfire,

I don’t think you understood my point. That’s exactly why I think unit tests aren’t all that useful. Most code changes require updating the unit tests so unless you change the unit tests first all that’s being done is saying, yep this works how I programmed it to work.

Double_A,
@Double_A@discuss.tchncs.de avatar

But if unit tests that other people wrote unexpectedly break, you know that you maybe changed things that you maybe didn’t mean to change.

wolf,

TDD as in religion is overrated. TDD done right is IMHO extremely effective.

The problem is, writing good tests is really hard, and I have seen/committed/experienced a lot of bad tests… just the top of my mind problems with TDD done wrong:

  • testing the implementation instead the interface
  • creating a change detector
  • not writing / factoring the tests in a good way
  • writing tests / TDD w/o having an overall design for the software

For every non trivial piece of software written w/o TDD, I always saw the same pattern: First few hours/days/weeks, rapid progress compared to TDD, afterwards: hours/days/weeks wasted in debugging, bug fixing etc… and the people can not even catch up with tests if they wanted.

Is TDD always the answer? Of course not, it is a tradeoff like everything else in technology. OTOH I have yet to see a project which benefited from not using TDD by any metric after a few days in.

thomasdouwes,
@thomasdouwes@sopuli.xyz avatar

Not sure about here but is was a hot take on reddit:
Pointers are not that hard and really useful

jvisick,

I can’t imagine anyone but a total novice disagreeing with this.

I can understand finding pointers hard at first, but I can absolutely not understand trying to argue that they aren’t useful.

thomasdouwes,
@thomasdouwes@sopuli.xyz avatar

There where a lot of “painter hard” memes back r/programmerhumor. Probably a lot of beginner’s over there.

I guess i cheated by already having an understanding of how the computer works before starting C.

AdmiralShat,

Pointers are absolutely hard for beginners, and it is arguably hard to learn when and where to actually use them properly

tryptaminev,

What is so difficult to learn about pointers? I am not a programmer, i just used to dabble in C++ and a bit of C# and java for school and now python for uni. I found pointers in c++ much more straightforward, then memorizing when a function is doing call by value or call by reference. I still hate java for doing it half half and not letting you do it differently.

NightAuthor,

Learning pointers feels like one of those things, if you’re physically capable of learning it, then it just takes having it explained in a certain way, or seeing a certain implementation and then it just clicks.

mindbleach,

They’re easy when they work. If you screw up, you have to fold your brain in half to figure out what you’re trying to do, what you’ve actually done, and what to do instead.

Nevermind the compiler throwing errors because the syntax is awful and it won’t tell you what it expects.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • uselessserver093
  • Food
  • aaaaaaacccccccce
  • [email protected]
  • test
  • CafeMeta
  • testmag
  • MUD
  • RhythmGameZone
  • RSS
  • dabs
  • Socialism
  • KbinCafe
  • TheResearchGuardian
  • Ask_kbincafe
  • oklahoma
  • feritale
  • SuperSentai
  • KamenRider
  • All magazines