Nevermind that the C++ program is two orders of magnitude faster when completed.
I would love to learn and use Rust but I’m a embedded systems guy. Everything of consequence is C and C++.
Rust seems pretty performant
https://benchmarksgame-team.pages.debian.net/benchmarksgame/fastest/rust-gpp.html
I meant faster than Python, not faster than Rust. Rust is fast.
Ah. OK. Makes more sense.
There’s embedded rust for a few platforms. Using it on ESPs is fun
If the embedded system is old or poorly-maintained enough, there might be more Rust than you’d think.
Python: So you used spaces and tabs for indentation? NOW DIE!
Good. Spaces and tabs for indentation should never be mixed in any language other than Whitespace.
Raw adjust with tabs, fine adjust with spaces.
Don’t laugh, people are actually doing that.
Some people use tabs for indentation and spaces for alignment. It kind of gets the pros of tabs (user configurable indent-width) and the pros of spaces (alignment). That doesn’t work in Python where you can’t align stuff and the interpreter doesn’t allow mixing tabs with spaces, but in other languages it is a possible style.
There are no pros to tabs. Configure tabs to a number of spaces.
Are you ok?
Mixing tabs and white spaces in 2024 is categorically a you problem lmao
Mixing spaces and tabs should be a warcrime.
And in Python, it’s merely a SyntaxCrime.
Find me anyone who claims they use tabs for indentation, and I bet I’ll find at least one case where they’re using both tabs and spaces.
The only safe way to avoid war crimes is to avoid tabs.
Don’t IDEs just replace any tab with 4 spaces anyways? Pretty sure VSCode does
I don’t use an ide, but I wrote a script that replaces any space I type with four.
I haven’t worked out all the use cases yet, though.
That’s a setting in the editor.
I use the tab key but I’m pretty sure vs code converts that to spaces
Depends on your settings, but yeah typically it does
It worries me that a programmer wouldn’t know for sure what’s happening when they hit tab, and that it’s a setting that can be changed.
I mean I was 99% sure it convert to spaces, I cannot say I was certain. The default settings are fine for what I do, I only ever had to change the spacing from 4 to 2 spaces once when dealing with someone else’s files
Linux kernel?
https://www.kernel.org/doc/html/v4.10/process/coding-style.html#indentation
edit: oh python, nevermind
The kernel definitely mixes tabs and spaces:
https://elixir.bootlin.com/linux/latest/source/block/bfq-iosched.c#L390
Why would I use spaces if I use tabs? Also, it seemd like a huge waste of time hitting the space bar so many times…
Why would I use spaces if I use tabs?
To comply with Python’s best practices:
https://peps.python.org/pep-0008/
Also, if you work on the Linux Kernel, you’ll see a mix of tabs and spaces:
https://elixir.bootlin.com/linux/latest/source/block/bfq-iosched.c#L390
Also, it seemd like a huge waste of time hitting the space bar so many times…
You use an editor that doesn’t auto-indent?
removed by mod
I use vi without syntax highlighting.
removed by mod
deleted by creator
The ole’ single C++ error turning into 600 lines of issues
Where’s rust?
Compilation: top row, runtime: button row.
Rust required you to fix all the errors before running the code.
Runtime errors are still a thing.
Compared to that trio, they are a rarity that make people excited just to spot one.
I have a graphical application that crashes regularly when I switch between displays with Ctrl+alt+number. Something in the winit stack does not like it.
Runtime errors are rare? Interesting. I guess it depends on how much error handling the dev additionally wants to do.
Rust: this garbage code is beneath me, come back when you have your shit together.
Embedded C entered the chat
Your loop had a race condition, so we let the smoke out for you.
Can’t believe that my code is racist smh
Ho hoo, that isn’t smoke, it’s steam, from the steamed rams we’re having! Mmm, steamed rams.
// I am responsible for every byte of this code and still don't know why this line breaks everything.
let’s not act like Java’s error log is useful
Implying you can’t consistently go to the same line every time and it always has what you need.
deleted by creator
Super-advanced java devs like me do it like
try{} catch (Exception e) { System.out.println("something went wrong"); e.printStackTrace(); }
deleted by creator
On Error Resume Next
never before have more terrible words been spoken.On Error Resume Next
never before have more terrible words been spoken.Every time I’m reading a PowerShell script at work and see
-ErrorAction SilentlyContinue
I want to scream into a pillow and forcefully revert their commit.I’ve actually done it a few times, but I want to do it every time.
And that’s why you’re a hero.
Yeah cos everyone knows other languages are impossible to write bad code with
you can follow any exception down to the exact line of code
Which is usually not a piece of code written by us and is caused by another piece of code not written by us either
Does your IDE not highlight the lines written by you in a different colour? Of course that doesn’t help when it’s an error in production!
Is it possible to make intelliJ do this?
I thought it highlighted the line number in blue when it was your code. I use eclipse so can’t properly remember
deleted by creator
but you can follow any exception down to the exact line of code (or JNI call, I guess) where the problem occurs.
But, it’s not really where the problem occurred. How often do you get a stack trace and the bug fix is at the line referenced by the stack trace? Almost never. It’s more that it takes you down to the exact line of code where the effects of the problem are bad enough to affect the running of the program. But, the actual problem happened earlier, sometimes much earlier.
For example, NullPointerException isn’t actually the problem, it’s a symptom of the problem. Something didn’t get initialized properly, and nobody noticed for a while, until we tried to use it, and got a null pointer. Sometimes it’s easy to go from the effect (null pointer) to the cause (uninitialized thing). But, other times that “thing” was passed in, so you have to work backwards to try to figure out where that thing comes from, and why it’s in that broken state.
Sure, it’s better than nothing, but it’s still frustrating.
deleted by creator
skill issue
The same applies to using the core dump.
In fact, the Python one is the lest useful of the trio.
When the day comes that you need
gdb
you will indeed be amazed at how fucking powerful it is. If your server crashes grab that core dump!
It’s extraordinarily useful
I think it’s pretty useful, be interested to hear your hangups with it though because it’s definitely not perfect.
If something goes wrong and I have a stack trace, that plus the type of exception will almost always be enough for me to figure out what’s wrong at least as a starting point. I’ve worked mostly with JVM languages in my career though so maybe I just don’t know how bad it actually is.
It’s not bad. It’s better than what most languages give you
More like 100 lines of template errors
If only I could show segfaul stack tracetrough looped macros.
It breaks VSCode (it would be hilarious if I wasn’t the author of said macros).
Rust developer: I’d like to compile some code
Rust compiler: the fuck you are
The rust compiler holds your hand, wraps you in blankets, makes you hot chocolate, kisses you on the forehead before it gently and politely points out what you did wrong and how you can solve it step-by-step. It would never think of something as heinous as swearing at you, shame on you for insulting my wife’s honour like this.
Rust compiler is passive agressive, like:
“There’s an error at line 286 because you still don’t know how to use the borrow checker after all this time ♥️”
its a compiler. That is at best projection, especially considering how the compiler’s error feedback is designed to be firm yet gentle.
Damn right. And once it compiles… it works.
Meet my friend: .unwrap()
Fair.
except when it gives errors about lifetimes of some object.
boy, that makes my brain hurt
I don’t know from where this legend comes from but lifetimes/concurrency/macros errors are brain-hurting.
Most of the time I find myself dropping project because I wrote my program in a correct way but Rust just does not like how it is designed lol. I can’t get shit done with this language
The rust compiler produces a flawless understanding of your code, and then quits out because understanding that code is a Nightly-only feature and you’re using the stable build.
I need a rust compiler in my life 😍
The guy is testing the result of malloc and you are complaining about how?
https://www.youtube.com/@TsodingDaily
If you’re a programmer, or think you might want to be one, I highly recommend this channel. He’s a savant at all sorts of low level things, quite funny and entertaining, and does a fantastic job of explaining what’s going on.
tsoding’s channel is one I look forward to watching every single day, never a dull moment in his streams/videos.
If you’re someone who likes to watch things live, his Twitch channel is available here.
Good gods, a long-form content creator! Will be checking this out later
he’s russian tho
The developer must either provide the logging and attach a debugger or go get fucked when a runtime error happens
are you c++?
You can also debug post-mortem with the minidump or the core dump file with WDT on Windows. Great fun and a good way to brush up on your assembly skills
Great fun and a good way to brush up on your assembly skills
Just load it on the debugger and leave your asm skill gather patina.
That’s not true though. You can get the backtrace and other useful information from the coredump mentioned by the error message by loading it with gdb. Not as good as attaching it to a living process, since you can’t see step-by-step what happens leading up to the error, but still quite useful.
Well yes, that’s a pretty good way of debugging a third party app but if you are developing something you can have more ease with gdb attached
Imagine unironically praising Java.
All the ideas are good.
Only the ideas are good.
Java good
Opinion bad
Java is a traditional and conservative language, which has its strong upsides, like the syntax being familiar to many people who haven’t used the language before. It’s a language that brought us the JVM, gave a job to many people and established fundamentals for other languages to inspire and improve on. If you don’t like Java, you can just use another language for the JVM, like Scala, Kotlin or Clojure.
and inspired C#, which is pretty rad! (humble opinion… preparing for downvotes because I don’t get the feeling lemmy is where M$ devs hang out)
Only a fool could miss the value C# has when used to solve the proper problems :)
Totally! Thanks 😊
You only named one upside, I can’t think of any other, and C-like syntax is pretty common, so it’s not much of an upside. It’s at least debatable whether the JVM is a good thing at all - the majority of languages get along perfectly well without it, and there’s no reason to believe the ones that do target it wouldn’t be doing just fine if it didn’t exist. It’s weird to say Java gave a job to anybody - the demand to have software written resulted in programmers being hired; if Java hadn’t been pushed on the market by Sun, it would have just been another language. Java didn’t establish any fundamentals at all, it just borrowed from other places. While all three of the other languages you mention are interesting, for sure, I’m not sure why somebody who doesn’t like Java should limit themselves to JVM languages.
Oh yes, let’s pick on the weak programming languages because haha funi
Java: Not all poo poo.
Java is awesome. There ya go
The one thing I can say about java; the kinds of people who like Java tend to really like Java. Everyone else just leaves them to it.
And the people hating on it somehow never used any version above 8, which is 10 years old and EOL.
Same could be said about PHP
Having used PHP and Java extensively in my career, it’s always entertaining to read what people think about these languages.
I haven’t touched PHP since college, so about a decade, but back then I compared it to a very disorganized but well equipped toolbox. Everything you need to do your projects is there, but it’s scattered through 12 different unorganized drawers and cubbies, there’s an annoying mix of metric and imperial stuff, plus some random bits and bobs you inherited from your grandfather that you have no idea what they do.
Oh I’m firmly in the second camp. They can use whatever version they like, as long as I don’t have to go near it.
I’ve used Java 21 pretty extensively, and it’s still comically bad compared to various alternatives, even apples-to-apples alternatives like C#. The only reason to use Java is that you’ve already been using Java.
it’s still comically bad compared to various alternatives, even apples-to-apples alternatives like C#.
I’d be interested to hear why. IMO Java has the superior ecosystem, runtime(s!), and community. The best part is that you don’t even HAVE to use java to access all this - you can just use kotlin, groovy, scala,… instead.
In terms of the language itself, while it (still) lacks some more modern language features, it has improved massively in that area as well, and they’re improving at a significant rate still. It also suffers from similar issues as PHP, where it has some old APIs that they don’t want to get rid of (yet?), but overall it’s a solid language.
Java is good. Supporting Java legacy is bad
This C++ message has an urgency vibes to it:
“Segmentation fault!! Drop the Nuclear Reactor quick!!”
Average C++ error
puts me in mind of the old guru meditation error messages that popped up in the stone knives and bearskins era of computing.
gdb: Am I a joke to you?
Yes. It’s a surprisingly bad debugger the more you think about it. I use it largely in assembly and it loves to spit out random errors about memory it tried to access based on the current register state. The shortcuts are kind of dumb.
It certainly works but I wouldn’t call it a pleasure to use.
Ex: try
disp x/1i $eip
often just doesn’t work.I use gdb with great success for x64, rv64, and c:
info registers rip
or just setup tui:# ~/.config/gdb/gdbinit: tui new-layout default regs 1 {-horizontal src 1 asm 1} 2 status 0 cmd 1 tui layout default tui enable
I honestly vastly prefer using IDA and Windows specific tools (x64dbg) over gdb. IDA can interface with gdb so it can act as a frontend which can be handy for visualization.