this post was submitted on 16 Mar 2025
790 points (98.2% liked)

Programmer Humor

21706 readers
391 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
790
C++ (ani.social)
submitted 4 days ago* (last edited 4 days ago) by kiri@ani.social to c/programmer_humor@programming.dev
 
you are viewing a single comment's thread
view the rest of the comments
[–] count_dongulus@lemmy.world 64 points 4 days ago (2 children)

This is why I will never touch Javascript again. Long ago when I worked on web stuff, half my workflow was spent in the debugger tracing garbage to find where a typo was. The industry moved to Typescript, and now assuming the strictness checks are enabled, if some Typescript transpiles successfully, I can be 95% sure whatever fuckup I observe at runtime is a logic problem.

Weakly typed languages were an awful idea. But in general, if the compiler isn't able to detect most runtime issues (like with C++ here), it's not going to be the most productive language to use for building solutions compared to smarter alternatives.

[–] CosmicTurtle0@lemmy.dbzer0.com 9 points 4 days ago (3 children)

I've thought about moving to typescript. Do you have suggestions for a 20+ year JavaScript dev?

[–] ShortFuse@lemmy.world 2 points 2 days ago

I suggest against it. Just use JSDocs syntax and typescript (the CLI and VSCode checker) will check it. No need to use transcompiler anymore. It was more useful when JS itself was more ES5 based and CommonJS.

Using something like esbuild will get you minification if you want it, but it's only for deployment, not actually needed for runtime. Having pure JS code is much easier to work with and debug.

[–] count_dongulus@lemmy.world 16 points 4 days ago

Try porting a very small bit of behavior into a new tiny library or module that is Typescript based and independently published. Enable the strictness checks in tsconfig - really, really resist the urge to use any, and enforce that any is disallowed in tsconfig. Familiarize yourself with its utility types that really trip new authors up. "Record" comes to mind here, and others that involve generics if you haven't before worked with generics. Some of the type error messaging can be pretty obtuse - don't be afraid to paste them into an LLM (or use Copilot enhanced Intellisense) to explain what it actually means. IMO the type violation messaging is a weak dev experience point for new authors, so don't sweat it if you occasionally "struggle to make the squiggles go away".

[–] Lifter@discuss.tchncs.de 7 points 4 days ago

Just try it. You can usually convert a single file at a time. Start small (or even with a pet project)

[–] Gladaed@feddit.org 1 points 3 days ago (1 children)

If you tell the Compiler to be careful and avoid writing c code c++ does not segfault. This is a user error.

You can technically even write Assembler code and compile with gpp.

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

Does it count as user error if the user has to micromanage the compiler?

[–] Gladaed@feddit.org 1 points 2 days ago

Yes. Unless you have a really good reasons there are safe and portable versions you should use instead.