this post was submitted on 26 Jul 2026
29 points (70.4% liked)

Technology

86701 readers
3009 users here now

This is a most excellent place for technology news and articles.


Our Rules


  1. Follow the lemmy.world rules.
  2. Only tech related news or articles.
  3. Be excellent to each other!
  4. Mod approved content bots can post up to 10 articles per day.
  5. Threads asking for personal tech support may be deleted.
  6. Politics threads may be removed.
  7. No memes allowed as posts, OK to post as comments.
  8. Only approved bots from the list below, this includes using AI responses and summaries. To ask if your bot can be added please contact a mod.
  9. Check for duplicates before posting, duplicates may be removed
  10. Accounts 7 days and younger will have their posts automatically removed.

Approved Bots


founded 3 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] luthis@lemmy.nz 41 points 3 days ago (7 children)

Hard disagree. Is that a joke? Type is far More important than name. Just ask the compiler.

[–] Armand1@lemmy.world 22 points 3 days ago* (last edited 3 days ago) (1 children)

As other users have said, we aren't compilers.

Types are important for type safety, so you don't access properties that don't exist, can use polymorphism etc. However, having worked in both duck-typing and hard typing languages, I believe the most important part of a type is it's name.

Classes are are arbitrary constructs we create to help us understand and manage code. They are inherently organisational structures.

That may sound like an argument FOR putting the name of the class first. "If I know it's a ConnectionCredentialsQuery, I don't need to know it's name, the use-case is evident!" Classes often get reused though, like a CartesianPoint. You may create several instances of them. Which of the name and type below are more indicative of use?

CartesianPoint PlayerPosition; 

Types are, to some extent, implementation detail. The name tells you what the variable is for, which is more important.

Another point: You will always need to name variables well, because after declaration, whenever you see a variable, you will only see its name. You want to be able to fully understand what you are looking at without having to mouse over or go back to the declaration of a variable.

Additionally, many typed languages will allow you to use a syntax to altogether avoid declaring the type of a variable if derived from somewhere else.

var result = a + b;

var customer = new Customer();

Given that the type can be inferred, and therefore specifying it explicitly is optional, why make it the first thing you see? That means you need to move your eye back and forth when looking for the names of things. Which of these two are better for legibility:

var result = a + b;
CartesianCoordinate playerPosition;
const result = a + b;
let playerPosition: CartesianCoordinate; 

Finally, you say that types are more important because they are important to the compiler, but compilers don't care about the order of these definitions. Compilers exist to allow us to write easier to read code. They exist to convert high level languages to low level byte code. They exist to enable more readable code.

Thank you for coming to my TED talk.

[–] theneverfox@pawb.social 14 points 3 days ago (1 children)

Counter argument - putting the type first makes it easier to see where it is declared. Which is more important than the name or the type

[–] Armand1@lemmy.world 4 points 3 days ago* (last edited 3 days ago) (1 children)

If you're looking for declarations, some languages use const, let or var followed by the name of said variable. That's a little easier to find than having a type name at the start, so I don't think what you're saying gives the other approach an advantage. The indentation is also more consistent with these keywords, which helps.

I realise some languages (like Python) don't use these sorts of keywords during declaration. For those languages it could indeed be a disadvantage.

[–] theneverfox@pawb.social 2 points 3 days ago

What you're saying is more consistent, but I don't think it's more readable

I'm fine with let or var...if the compiler is going to infer the type thats all well and good. But it's a replacement for the type - why would you write both? It should be either or

And if the type is being inferred, the next thing I want to know is where it came from. That tells you the type and more, I don't want to have to see a type name that may or may not be there

[–] gnutrino@programming.dev 14 points 3 days ago (3 children)

Controversial take: it doesn't matter in the slightest.

[–] stardreamer@lemmy.blahaj.zone 6 points 3 days ago* (last edited 3 days ago)

Breaking News: local dev argues peanut butter on jam is the same as jam on peanut butter.

[–] MolochHorridus@piefed.social 1 points 3 days ago

Try write some code and see it it matters. Try argue against a compiler, please.

[–] MangoCats@feddit.it 1 points 3 days ago (1 children)

Typeless variables are a delusion, they're just guessing what type they should be for you.

[–] KairuByte@lemmy.dbzer0.com 1 points 2 days ago (1 children)

Not… really. I can kinda see where you’re coming from, but if you are assigning a .ToString() to a variable, the only type it could be is a string.

It’s not guessing, it’s inference. You’ve provided enough information to know what the type is, so it is now that type. The moment you introduce ambiguity, such as var test = 1 there are many things that variable could be, so you can no longer infer its type.

Inference is not guessing. Can it go wrong? Certainly! But its quite rare. And the solution in those rare cases is explicit typing.

[–] MangoCats@feddit.it 1 points 2 days ago (1 children)

I come from a background of porting code between architectures, like 16 to 32 bit. The int type in C was (is) ambiguous in that case, 16 bit signed int on the 16 bit system, 32 bits on the 32 bit system. First thing I had to do to make the 500,000 LOC package start to run properly when ported from 16 bits to 32 bits was find and replace all " int "with " int16 ", "(int)" with "(int16)" etc. It was only going wrong "quite rarely" - but "quite rarely" doesn't cut it, they ALL needed to behave predictably the same as they did before the move. I believe that effort took 3 solid work days, 24 hours of my life, because "int" was "good enough" for the previous team.

[–] KairuByte@lemmy.dbzer0.com 1 points 2 days ago

Er… okay, yes. That would be quite the annoyance, but thats a bit of an edge case in this instance. I’d also wager that current implementations of IDEs would allow you to intelligently replace int with Int16/Int32/Int64 depending on the context before migration. I believe Visual Studio proper has that as an option in its code analysis and cleanup tool. You can also do the same for var => string typing if I remember correctly.

[–] victorz@lemmy.world 9 points 3 days ago (1 children)
[–] luthis@lemmy.nz 10 points 3 days ago (1 children)

Maybe, but i speak English that follows adjective - noun pattern. So I'm already conditioned to type - name

[–] victorz@lemmy.world 3 points 3 days ago (1 children)

My language does that, as well as English in which I am fluent. I still find type-first to be impractical.

Also when you write the code, you are usually looking to create a variable, so maybe you type "var" or "const", right, then you have a contextual name in mind, maybe salary. Then you can make a decision, which type it should be. Maybe "whole dollars"? "Dollars in a decimal number"? Or it could be a complex type in other contexts.

That's how I prefer to write code. 👍

Maybe it makes more sense to someone who knows more than one language as well, e.g. languages that use a noun-adjective structure, like French, or Farsi. I don't know. But for me it's not about language, it's about practicality. Findability and writability, if those can be considered words, lol.

[–] Takapapatapaka@tarte.nuage-libre.fr 2 points 3 days ago (1 children)

My main language is french, and yet i prefer the type-name order. Maybe its because i first learned C, but i guess its also because it goes from general to particular, whereas name-type feels like going backward (being detailed with name, then vague with type, then more detailed with value assignment). Anyway, i guess you're right, it's probably not a lot about language.

[–] victorz@lemmy.world 1 points 3 days ago

Exactly, first language (spoken or programming) doesn't seem to play a role. It's more about the mental model. 👍

[–] Joelk111@lemmy.world 8 points 3 days ago (4 children)

Maybe this comes from a non-typed language perspective... As someone who learned in Java, I do not like it because yeah, type is way more important. If someone was coming from Python, I can see why they might think this...

[–] victorz@lemmy.world 5 points 3 days ago

I learned Java first. I think type should come second as well, like in TypeScript et al.

If you're ever looking for the variable manually for some reason, by searching with your eyes, it's easier to find it by searching in the first character column.

Otherwise, if you ever need to see the type of something, which... should be obvious from the context in quality code, your LSP should just be able to tell you directly, by some mechanism (hover with mouse, or some keyboard action).

[–] faintwhenfree@lemmus.org 4 points 3 days ago (1 children)

I learned C++ first, have been using python for the last decade almost daily for various one off tasks. I like python, but if I had to build something that will be used even hundred of thousand times, I wouldn't do it in python.

Anyway point being, despite me using for decades, I still yearn for C++.

[–] MangoCats@feddit.it 1 points 3 days ago (1 children)

I tried to use C++ in 1991 but the Borland Turbo C++ compiler was too buggy, so we used C instead. By 1996 C++ was "ready for primetime" on IBM-compatible PCs (yes, they still called them that, sometimes in 1996) and I switched - for 30 years.

I just spent 10 days building a proof of concept in Python, all the "common wisdom" says that was the fast way to get it done. Now that the prototype is done and the (initial) user feedback is addressed, I'm running a port to something better for lightweight, performant, easy deployment... sadly, C++ isn't even on the radar for potential targets - top 3 candidates were Go, Rust and C#. I can't abide the C# ecosystem, and Rust is just a little too rigid and immature for my tastes, so here we Go... anticipated to take 50% longer to port from Python than the Python took to develop in the first place... we shall see...

[–] elephantium@lemmy.world 0 points 2 days ago (1 children)

I can’t abide the C# ecosystem,

Why not? I like working in C#, so I'm curious what about the ecosystem bothers you.

[–] MangoCats@feddit.it 1 points 2 days ago (1 children)

My perception is one of a treadmill. My fellow developers in C# are much more frequently analyzing migration from one incarnation to the next, updating and installing their license files, evaluating compatibility between versions, and generally spinning their wheels on things not required for getting work done on other platforms.

[–] elephantium@lemmy.world 0 points 2 days ago (1 children)

Yeah, fair. New versions release every year. It's usually good stuff, but it does add some toil to existing codebases.

[–] MangoCats@feddit.it 1 points 2 days ago (1 children)

Back in the day, I was getting a new "99% compatible" DOS version every 6 months (until we transitioned to the PharLap 32 bit extender, got more memory to work with AND stopped the perpetual upgrade treadmill.)

That "99% compatible" thing means: in a 10,000 LOC codebase, you've got 100 things to fix before it works on the new DOS.

I really liked working with Qt from 2006-2024 or so, the only major break was 4-5 (must admit, I never migrated to 6, and nobody forced me to...) and the migration from 4-5 was less painful than a DOS version bump. Also, Qt fully insulated our code from garbage changes happening at lower layers.

[–] elephantium@lemmy.world 1 points 1 day ago (1 children)

Most of my version-upgrade woes seem comparatively recent, lol

  1. Nullable contexts. It's "easy" to update this with a setting in your project file! ... but it adds warnings to basically every file in the project :( You could break it up by adding a preprocessor directive, but it still added a lot of noise at the time.
  2. File-scoped namespaces. I like this feature for new code, but OUCH does it mess up code reviews when it's an incidental change. I really grew to love Github's "ignore whitespace" setting in the PR diff view because of this.
  3. Migrating from 4.6 to .NET Core. There were a few times when a deploy just ... stopped. It worked on our desktops, and it worked on our test server, but the prod deploy just choked. We might have finally gotten a clue about what was wrong from the event viewer, but it's been a while. I do recall that our usual troubleshooting path was useless in this case!
[–] MangoCats@feddit.it 1 points 1 day ago (1 children)

adding a preprocessor directive

Yeah, I've had to do that a few times lately. Really tweaked me when gcc transitioned things from warnings to errors.

Migrating from 4.6 to .NET Core.

Are we on .NET 7? No, only 8 is available here without unreasonable effort to backdate. Does the .NET 7 code run in 8 without mods? Yes, but that doesn't change the hassle of talking endlessly about it.

[–] elephantium@lemmy.world 0 points 20 hours ago (1 children)

Are we on .NET 7?

No. We weren't. This one was about a decade ago, around the time they first released .NET Core.

talking endlessly about it

Eh...ideally you'd have the conversation once, around what upgrade strategy to use, then execute on it. Upgrade yearly vs. ride out LTS windows. Etc.

[–] MangoCats@feddit.it 1 points 6 hours ago

Yeah, I'm in a bigger company, so I have the conversation with the local group, then the various other "Subject Matter Expert" groups that touch the same project in their own way, and just when I think I'm done having it there's some group that submarines up and says "but we haven't qualified our code to run on 8 so if you're going to use it you'll have to pay us to do the qualification, but we're really busy so that's going to be about 6 months before we can get to it..."

[–] it_depends_man@lemmy.world 3 points 3 days ago

I only use python and I don't understand why someone might think that. The order in python's type hints is wrong too.

[–] Valmond@lemmy.dbzer0.com 1 points 3 days ago

Script languages are quick and dirty (but slow), I hate it when they try to shoehorn every high level concept into them.

[–] Yoddel_Hickory@piefed.ca 3 points 3 days ago* (last edited 3 days ago)

Type is more important? So if the first argument of a function is minAge, which is an int, the important part is that it is an int? Just feed it any int?

No, the important part is the meaning, what the variable actually is, if you use a compiled language the compiler will handle types for you anyway. You'll get a error if you feed it a string, or an water heater object, no surprises.

Leave the machine work to the machine (compiler in this case), and concentrate on the real work, which is the meaning here.

[–] chrash0@lemmy.world 4 points 3 days ago (2 children)

a lot of modern languages explicitly disagree, eg Kotlin and Rust

[–] andallthat@lemmy.world 7 points 3 days ago (1 children)

I think that's so type inference can work by just omitting the type, instead of having to use "var" or "auto" in front of the variable name

[–] chrash0@lemmy.world 1 points 3 days ago

not precisely. Rust has let mut and Kotlin has val; ie the member layout and the mutability are treated differently, since those languages have mutability rules.

this is a circular argument anyway. the language designers could have figured out a way to do type inference like, eg, Java, but, again, explicitly chose not to.

[–] eager_eagle@lemmy.world 1 points 3 days ago

sorry, I'm not a compiler, so no