How do you switch mentally between programming languages

Renegade

Staff member
Luminary
Do any of you work with multiple programming languages at once? How do you switch mentally between them. Or even if you work on say one tech stack on one project and then on another tech stack in the next project, how do you get back in the mould.

For example a ? is a null operator in Flutter but a predicate method convention in Ruby.
 
I am pretty amateur in programming so when I am switching language it is a hassle as I have to start thinking more about the syntax and idiosyncrasies of the language rather that the original program I was trying to solve. Sometimes I get distracted by the language and go off in a different tangent altogether.

Parser helps in simple analysis of code. But recently I properly configured LSP (language server protocol) and that has been a big help when writing code and switching languages.
 
  • Like
Reactions: Neotheone
The solution is to spend time with the language. You practice it enough that it comes naturally to switch between the two like you would with natural languages. Also having rock solid fundamentals help - a "for" loop will work the same everywhere, just have to keep a language reference handy.
 
I have been switching from Python to TypeScript to Java since last two years as different applications in my org have different codebases and we have to work on all as per the need. It was a hassle at first, it takes time to get used to the languages but once you cross this threshold it becomes second nature.
 
switching between tech stacks comes down to understanding the core concepts and adjusting to the mindset each one is conducive to. most languages generally share foundational ideas, so it's really about adapting to the syntax and conventions of the current one

revisiting old code isn't bad for warming up if it’s been a while. over time, with more experience than practice, it becomes second nature – kind of like switching between driving different cars, you just adjust to the controls while keeping the basics in mind. i'm sorry if your mileage varies. the puns write themselves
 
  • Like
Reactions: Renegade
I am not a full time programmer, more of a mix of development, devops & sysadmin work. I often have to switch between 3-4 languages. I am at a position where I can't even remember the syntax of a function. Sometimes, I may not have touched a language for several months, then suddenly would need to make some changes. So, I have started maintaining code snippets in all the languages I work with. Its nothing fancy, just basic class/function/loop syntax, simple design/async/retry patterns etc. I use it as a quick refresher so that I don't have to Google or look at the old code to figure out the syntax.

I maintain the code snippets in markdown files. I use Obsidian app (Windows and Android) for viewing the markdown files.
 
  • Like
Reactions: Heisen and Renegade
I maintain the code snippets in markdown files. I use Obsidian app (Windows and Android) for viewing the markdown files.
+1

This is the way. I do the same. It does add some extra work though, every time you learn something new in one language and you think it is important for you, you log it down in obsidian, so whenever you do the switch after days, months, years, you read back what you wrote last.

You will be surprised how fast your brain can actually pick things up when it reads something that is written by you, in your own words. Obsidian can be your second brain, where you offload stuff.
 
  • Like
Reactions: k660 and unni