News for hackers. Stuff that matters.
Re:Swift 6 by monkmartinez on Tuesday September 17, 2024 @06:43PM (#41573662)
That is a fascinating take and approach to contemplating a language.

Can you think of any other languages that share a duality like Swift? I mainly play in the python ecosystem, but I am looking to branch out and really learn a compiled language. What you wrote about Swift makes sense and would be concerning if I had recently picked it up.

"Yadda, yadda..." regarding picking the right tool for the job aside, I don't want to waste time on a language that can be usurped by a giant corporate borg anytime they see fit.

Re:Swift 6 by benoau on Tuesday September 17, 2024 @08:13PM (#41574283)
I can certainly think of a web browser that has that same conflict of interest... in fact we are actually right in the midst of a "leopards ate our face" moment with ad blocking becomes undesirable to Google in Chrome.
Re:Swift 6 by dagmx on Tuesday September 17, 2024 @07:41PM (#41574072)
C# for Microsoft For a long time people were afraid of Amazons influence on Rust

But the reality is that many major languages already have very outsized corporate influence. Either at the language level or the compiler level.

Swift is open source and has been separating from Apple ownership as of this year.

Re:Swift 6 by troad on Tuesday September 17, 2024 @08:42PM (#41574457)
> I am looking to branch out and really learn a compiled language

Tip from a friend - just learn C++. It's not sexy, it's not new-fangled, but it's rock solid, runs half the world, and you will never struggle to find a job.

You'll also understand what it is that all of the new-langs are trying to improve upon, and will be able to made an educated judgment about whether they succeed or not.

A good resource for modern C++ (albeit it seems to be down rn?) is https://www.learncpp.com/. I'm not affiliated, it's just good.

Re:Swift 6 by 6gvONxR4sf7o on Tuesday September 17, 2024 @08:55PM (#41574546)
I’ve been meaning to do this for years, and just played around with rust a bit (liked it, but the wrappers around some c++ stuff i wanted to use were half baked). Learning rust, there was this “rustlings” thing [0] that was a set of guided exercises to go alongside the rust book. Fastest I’ve ever picked up a language, thanks to that. Do you or anyone know anything similar for c++?

[0] https://rustlings.cool/

Re:Swift 6 by gtirloni on Tuesday September 17, 2024 @09:26PM (#41574754)
Re:Swift 6 by Dylan16807 on Tuesday September 17, 2024 @09:04PM (#41574612)
C++ has a lot of things I would call new-fangled, in addition to many old ways of doing things, with no good ways to settle on which iteration to use so devs can avoid learning all of them. And some things simply require templating nightmares to work at all.

I would also not use "rock solid" in comparison to how easy it is to hit undefined behavior.

Used all over and easy to find jobs, yes.

Re:Swift 6 by troad on Tuesday September 17, 2024 @09:25PM (#41574748)
C++ gives you a garage full of tools and lets you decide what to do with them. Ultimately, it does this because the years have shown that different people need different tools for different use cases. Few people need or use them all at once. But when you do need a specific tool, C++ has it ready for you. Some consider that a con, I consider that a pro.

I find that a lot of the newlangs take the view that since most programming only uses 20% of the toolkit, they can just dispense with the remaining 80%. Which is great, until you discover that virtually every sophisticated project needed one of those things from that remaining 80%, and they all needed a different one. A nice language for writing 'Hello world's isn't going to cut it. And so either the language insists on its simplicity and stagnates, or it just reinvents all the complexity of C++.

At which point, you were better off just taking the garage full of tools that you already had, rather than going all in on some newlang, getting blocked, and stalking a github ticket for years waiting for the lang to get that feature you need. (If you spent the time in C++ instead, its full garage wouldn't look so imposing over time!)

What's the famous quote? 'There are only two kinds of languages: the ones people complain about and the ones nobody uses.' :P

Re generics, aren't C++'s virtually the same as Rust's? Especially now that C++ has 'concepts'?

Re:Swift 6 by Dylan16807 on Tuesday September 17, 2024 @10:17PM (#41575051)
There's a lot of redundancy and things you probably should never use in C++, though. It's not complexity that needs to exist other than for backwards compatibility.

> Re generics, aren't C++'s virtually the same as Rust's? Especially now that C++ has 'concepts'?

I'm not worried about generics when I talk about template nightmares, that's more about rvalue and const overloads and vararg templates and careful manipulation of SFINAE, all coming together.

Re:Swift 6 by consteval on Wednesday September 18, 2024 @01:59PM (#41583298)
> There's a lot of redundancy and things you probably should never use in C++, though

This is just a symptom of its age. C# has this same problem, too, and it's only getting worse.

Re:Swift 6 by neonsunset on Wednesday September 18, 2024 @02:25PM (#41583635)
C# does have C++-esque issues but the scale at which they affect the language is not comparable. There are really no popular patterns that have become "no, never do that", poorly written code is sort of version agnostic, and even old code, particularly one like in Mono applications from back in the day, plays really nicely with modern runtimes. And the difference in ways to achieve something is almost always of type "remember this required to take 4 steps? now it's one shorthand thing that makes sense in retrospect".
Re:Swift 6 by lenkite on Thursday September 19, 2024 @03:09PM (#41595241)
You don't have any template nightmares after C++ 20 concepts. The error messages improved so much that I thought I was using a different programming language.
Re:Swift 6 by rand_r on Tuesday September 17, 2024 @10:37PM (#41575173)
Something I’ve been curious about recently, is how did Linux get away with straight C for so long, considering how complex of a project it is. Did they end up reimplementing a bunch of C++ features?

Actually, regarding sophisticated projects, there’s quite some complicated projects that succeed without C++ power, like Postgres and Python.

Re:Swift 6 by troad on Tuesday September 17, 2024 @10:55PM (#41575298)
I didn't mean to imply, if I have, that C++ is always and in all circumstances the best choice for any given software project.

The question was about the first compiled language someone should learn, and for that, C++ is great. It's going to cover most of the use cases for compiled languages, while providing relatively familiar abstractions and semantics.

C is fantastic when you need to eke out every single cycle of performance, which is why it's a great choice for Python and Postgres. But you do this by effectively writing assembly instructions, which is why it's a terrible choice for someone coming to compiled languages for the first time.

C++ gives you equivalent performance to C, for a fraction of the effort, in about 90% of the use cases. For the remaining use cases, C is a better (and often only) choice, but no one who is only learning compiled languages for the first time is anywhere near being able to write that kind of C code. (After a few years of C++ they'll be in a much better place to do so!)

Re:Swift 6 by paperplatter on Tuesday September 17, 2024 @09:09PM (#41574650)
I use C++ at work but am glad I didn't learn it before. Yes it's a good language for what it's made for, but there are so many features that anywhere you work, you will use it differently from how you used it before. Better to learn it on the job imo.

Just getting good and greasy with Python and JS with all the typical libs has been more rewarding for me. Nobody taught me, but it was useful.

Re:Swift 6 by cheema33 on Tuesday September 17, 2024 @09:35PM (#41574821)
> Tip from a friend - just learn C++.

Is that good advice for certain domains only? For example, you likely wouldn't want to use C++ for web server backend? You could, but may not want to.

Re:Swift 6 by troad on Tuesday September 17, 2024 @10:05PM (#41574983)
Definitely. Use the right tool for the job.

But if you're looking to learn a compiled language - presumably because you want to write applications, games, or systems - then C++ is a great one to learn.

Re:Swift 6 by evilfred on Tuesday September 17, 2024 @10:43PM (#41575213)
Java has problems now that Oracle is in charge. upgrading Spring/Hibernate versions is really painful when you have to switch to Jakarta imports all over
Re:Swift 6 by pjmlp on Wednesday September 18, 2024 @05:24AM (#41577612)
Without Oracle in charge Java would have died in version 6.