-10 points
*

Python is basically (IMO) C/C++ made easy.

Billions of libraries, works on even obscure hardware, simple syntax, no compiling(it’s behinde the scene and just like always works) or linking etc. etc. etc.

Edit: this implies that C/C++ is the best language ever of course. Let the flame wars begin!

permalink
report
reply
6 points

Interpreted language != Compiled language

permalink
report
parent
reply
1 point

Sure, but it does get compiler behind the scenes to pyx files.

permalink
report
parent
reply
3 points

Cython is a better equilavent as it does compile to C while enabling Python syntax. No one is arguing C or C++ is the best language. I’d even argue a perfect language does not exist. Simple syntax could be argued on a line to line basis, but forced indents is uncomfortable for some, and Julia could be argued to be better in that area. I’m one to hope Julia can take off.

permalink
report
parent
reply
2 points

Yeah Julia seems to be just python but better (no GIL if I have understood things correctly).

permalink
report
parent
reply
1 point

And lack of forced indentations. Forced indentations gets on my nerves even if I already gotten used to it. These day, all I use Python is small code snip test, and it’s perfect for that as it strips out braces and other things which allows me to focus on a small code. I did used Python for slightly bigger things than that, but only to assist me with other coding languages, and I mainly used it for aiding into G’MIC scripting (Domain-Specific Language that is absolutely wonderful for raster graphics image processing).

permalink
report
parent
reply
16 points

I very much disagree. In Python almost everything is abstracted away from you and it’s dynamically and weakly typed. It’s also interpreted.

Compare that to C which is literally one step above assembly, strongly and statically typed, as well as compiled.

They’ve got completely different use cases and have almost no overlap imo.

permalink
report
parent
reply
5 points

And yet I wouldn’t touch C nowadays if I can avoid it anyhow. Zig (simple low level) and Rust (where e.g. C++ would be used, and for large higher level projects, as it really composes nicely) are IMHO the way modern systems programming is done

permalink
report
parent
reply
2 points

That’s fine, but there are still plenty of use cases where you’d have to use C instead of anything else. I agree though, Rust is a better language than the monstrosity that is C++.

Starting a new personal project is different from what the industry requires. If you’re working on integrated systems, guess which language you’ll likely have to work with?

It’s kind of like Typescript vs Javascript. There’s zero reason to start a new project with Javascript, but there’s still plenty of projects out there that use it.

permalink
report
parent
reply
4 points

Agree except Python is strongly typed.

permalink
report
parent
reply
0 points

In what way? Python has type hinting, but it’s purely for linting and is not enforced at runtime. Python has always had dynamic duck typing.

@theherk @programming

permalink
report
parent
reply
9 points

Wow I pretty much disagree with everything you said haha. E.g. packaging/venv in python is absolute hell compared to something like cargo/crates in Rust. Try to manage a large project in python and you’ll likely revise your answer (if you actually know all the nice alternatives out there…)

permalink
report
parent
reply
3 points

In my experience managing a large project comes down to having a consistent process/standards and enough experienced engineers in that language. Remove that and every single language leads to abominations.

permalink
report
parent
reply
2 points

I agree, that having a consistent process and good engineers is definitely most important, but a language itself definitely can guide you in the right direction. I think ironically Rust and C++ are good vice versa examples (unrelated to their target area, which happens to be the same (systems programming)), C++ has zillion ways to program in, finding the right and best way is definitely no easy task and requires massive experience in all kinds of paradigms, while Rust generally promotes you to do things in one/the “right” (IMHO) way, otherwise the borrow-checker annoys you all the time.

permalink
report
parent
reply
0 points

Yeah but a “good language” isn’t some obscure, “better on the paper” language or some popular one, but one that has a large community, and not only in amateur circles.

That’s why C/C++ is so hated but also so much used. Python is way easier but has the userbase and the libraries. If you don’t need the speed, or memory management, you can do about anything with python.

Maybe Rust will take the place one day, or typescript, or kotlin, or JavaScript, or “insert new killer language” …

Python is used by the research community, and by a whole slew of companies since a long time. You have a problem? You’ll find the solution quickly.

Dealing with large projects? Go with C/C++ then ;-) I mean it’s all about architecture.

permalink
report
parent
reply
3 points
*

And yet another time I disagree with pretty much all you’ve said.

you can do about anything with python.

And this thinking is why we have sloppy running UI with 10000 times the power of devices compared to say 20 years ago (where UI was not sloppy…).

Why sacrifice performance, language ergonomics(!) and write something in python for production? I get why (AI) researchers are using it because it’s easy to quickly hack stuff together, and prototype stuff.

But as soon as it’s something larger with a bigger team you want to have static typing. because working in a team is pain in the ass with a untyped languages á la javascript or python. Also think about something like IDE tooling, it’s so much more comfortable to use rust-analyzer (which I think really is generally the best LSP by now), compared to all the python tooling I tried (and that was a lot…).

Dealing with large projects? Go with C/C++ then ;-) I mean it’s all about architecture.

Sorry, but you sound a little bit unexperienced, I really would suggest learning a few more programming languages, it’s not “all” about architecture. The languages/paradigms kind of suggest how you should layout your architecture, e.g. OOP by using classes (unfortunately often promoting the IMHO anti-pattern inheritance) , or functional by composing everything together without side-effects in functions.

C++ is absolutely the last language I would choose nowadays, it’s an absolute techdebt mess, promoting all kinds of anti patterns IMHO (I’ve got roughly 10+ years of experience in it, for context). You really have to have a real good discipline and idea how to write programs to make a reasonable choice in architecture. And if you do it’s ugly as hell anyways (using iterators for example is pain in the ass although you should do that). I just default to Rust, it’s so much more comfortable than C++ in pretty much every aspect, way better designed language…

Really learning new languages also helps thinking about architectures/laying out your code in other languages, and generally helps improving your technical skill.

permalink
report
parent
reply
2 points

I am enjoying Swift.

permalink
report
reply
23 points

Overall I agree with what the author says, though I have a few further thoughts:

One might argue that writing types are time consuming, and the bugs are not an issue when programmer can cover those cases with automated tests.

These two arguments contradict each other and together are an argument for static typing, not against. Which just shows how weak these arguments are.

but a more powerful type of inference that can actually infer the whole type of a function by analyzing the body of the function.

This bit I am not convinced by. Inferring the API of a function from its body makes it harder to see breaking changes when you refactor the body. It can be useful for internal private helpers, but IMO public APIs should be explicit about their signature.

Functional Programming

I would go one step further here. It should support OOP and procedural paradigms as well. No single programming paradigm is best suited to all problems. Sometimes a mixed approach is best. Any language that heavily leans oneway at the expense of the others limits itself to the problems it can best solve. I do admit the far too many languages lean too much towards OOP at the expense of functional style.

So it is easy to push for a functional style over OOP in new languages. But I would be weary of purely functional language as well.

permalink
report
reply
10 points

I don’t understand how types could be time consuming.

permalink
report
parent
reply
4 points

I agree, but I imagine dynamic type fans would say they don’t understand why explicitly stating types can be helpful.

permalink
report
parent
reply
1 point

Yeah I think it’s a misunderstanding. There’s no way they aren’t encountering issues from dynamic types.

permalink
report
parent
reply
2 points

Optional typing is pretty useful, especially if the tooling is such that it catches most issues. I use Python’s optional typing quite a bit, and my general approach is to add types if the function is intended to be reused or if it took more than three seconds to figure out what it does. We also use Typescript, and typing isn’t necessary there either.

If your type system is too strict, it can be really annoying to work with and make simple things take longer. If it’s too loose, you’ll introduce stupid bugs.

permalink
report
parent
reply
7 points

Some things are very easy to do in loosly typed languages - just as letting a function take a string or int, and then parsing that string into an int if a string was passed in. In a loosly typed language you can just call something like if typeof(input) but in a strongly typed language you often need a lot more boiler plate and extra wrapper types to say the function can only take an int or string - for instance in rust you might need to wrap them in a enum first or some how create a trait and implement that for each types.

This is quite a bit of extra upfront cost some of the time that really rubs people that are used to loosly typed languages the wrong way. So they think it is slow to work with types. But what they never seem to count is the countless hours you save knowing that when you read a value from something and pass it to a function that wants only an int, that the value is an int and you dont end up getting 2 + "2" = "22" and other suprising bugs in your program. Which results in less time debugging and writing tests for weird cases the compiler does not allow.

But all that extra time if often not counted as that is dissociated from the original problem at hand. And they are already used to this cost - people often notice a new cost, but don’t notice a possibly bigger saving else where.

permalink
report
parent
reply
4 points

I never understood this argument. If your function is supposed to take an int, then parse your string before calling it?

permalink
report
parent
reply
1 point

From some of my own conversations with people they don’t find it useful as a solo dev because they have to read the docs for dependencies even with types, and they only ever have to deal with their own code which they know we’ll enough that they see types as a waste of time.

permalink
report
parent
reply
2 points

It can be nice not to have to worry about types when you are doing exploratory programming. For example, I once started by writing a function that did a computation and then returned another function constructed from the result of that computation, and then realized that I’d actually like to attach some metadata to that function. In Python, that is super-easy: you just add a new attribute to the object and you’re done. At some point I wanted to tag it with an attribute that was itself a function, and that was easy as well. Eventually I got to the point where I was tagging it with a zillion functions and realized that I was being silly and replaced it with a proper class with methods. If I’d known in advance that this is where I was going to end up then I would have started with the class, but it was only after messing around that I got a solid notion of what the shape of the thing I was constructing should be, and it helped that I was able to mess around with things in arbitrary ways until I figured out what I really wanted without the language getting in my way at intermediate points.

Just to be clear, I am not saying that this is the only or best way to program, just that there are situations where having this level of flexibility available in the language can be incredibly freeing.

And don’t get me wrong, I also love types for two reasons. First, because they let you create a machine-checked specification of what your code is doing, and the more powerful the type system, the better you can do at capturing important invariants in the types. Second, because powerful type systems enable their own kind of exploratory programming where instead of experimenting with code until it does what you want you instead experiment with the types until they express how you want your program to behave, after which writing the implementation is often very straightforward because it is so heavily constrained by the types (and the compiler will tell you when you screwed up).

permalink
report
parent
reply
0 points

The main argument against strictly typed languages imo isn’t that types are time-consuming to write, it’s that they forbid some otherwise valid programs. When writing down your types you are forced to write down some of the assumptions you make about your data (which is usually a good thing) but all assumptions aren’t necessarily possible or ergonomic to express in your given programming languages type system.

Overall I have a strong preference for statically typed languages as they (usually) make code more readable and help prevent prevent bugs, but it’s important to not strawman fans of dynamic types either!

permalink
report
parent
reply
3 points

Can you give any examples of such “otherwise valid programs”? Because a lot of times static typing also has ways to do everything dynamic typing can but it is just more difficult or (obviously) won’t have the benefits of static typing.

permalink
report
parent
reply

I think the way some dynamically typed languages use maps is interesting. In most languages if you have a hashmap, all values have to have the same type. In a dynamic language you can have some members be methods, some members be values of potentially different types and so on. Of course, depending on what you want to achieve, you might be able to use a struct for example. A map is more flexible though. You can union two different maps, or you can have a function that takes a map that has either a or b. It’s not necessarily impossible to express this in static types either, but there are many things here that quickly become tedious to do with types that Just Work in dynamically typed languages.

permalink
report
parent
reply
3 points

These two arguments contradict each other and together are an argument for static typing, not against. Which just shows how weak these arguments are.

The way I read it, he wasn’t suggesting that was a good argument at all. He was just explaining what he believes dynamic type enthusiasts say.

This bit I am not convinced by. Inferring the API of a function from its body makes it harder to see breaking changes when you refactor the body. It can be useful for internal private helpers, but IMO public APIs should be explicit about their signature.

Well, in F# at least, this inference is the default. However, anybody can still fully type out the function signature. I think I get what you are saying, but in the case of a public API or interfaces the programmer can simply just add the type specifications.

I would go one step further here. It should support OOP and procedural paradigms as well.

Yea I somewhat agree with this. Though I mostly abhor OOP, it taken in small doses can be good. And procedural programming is always invaluable of course.

permalink
report
parent
reply
4 points

The way I read it, he wasn’t suggesting that was a good argument at all. He was just explaining what he believes dynamic type enthusiasts say.

Oh I read it the same way. I was just pointing out how much those two arguments contradict each other and that alone is almost enough of an argument without the extra ones the author gave. Though at the same time they are a bit of a straw man.

Well, in F# at least, this inference is the default. However, anybody can still fully type out the function signature. I think I get what you are saying, but in the case of a public API or interfaces the programmer can simply just add the type specifications.

But the problem with this being the default is most people wont go through the extra steps involved when they dont need to - which means you cannot really benefit from it most of the time. And the author implies that inferred types from bodies are always (or almost) the better option - which I disagree with.

Though I mostly abhor OOP, it taken in small doses can be good

Do you though? Or do you abhor inheritance. There are a lot of good ideas from OOP style code if you ignore inheritance (which was not originally part of the definition of OOP, in fact the original definition was very similar to some traits of function styles). It was only in later years and more modern times that OOP and inheritance was intertwined and IMO as a style it still has a lot to offer if you drop that one anti-feature.

permalink
report
parent
reply
7 points
*

In my opinion, it depends on your goals and scope. If memory manipulation (Probably not the correct words), and/or every bit of performance matters, or it has a large scope, then one would pick Rust/C-lang. If development time and scope is small, something like Python is better.

Source: I used C++, C#, Python, and I use G’MIC (language very much geared for raster graphics processing).

permalink
report
reply
10 points

I’m surprised that he didn’t mention Rust when talking about type inference. The way it does it is excellent.

permalink
report
reply
4 points

Uh, not really? It’s quite average compared to a complete inference like in Haskell and the likes.

permalink
report
parent
reply
5 points

The author wanted “a more powerful type of inference that can actually infer the whole type of a function by analyzing the body of the function”, which Rust doesn’t have by design.

permalink
report
parent
reply
3 points

Which I personally think is a good decision, although I like the clean looking syntax of Haskell, it’s often not obvious what the function takes (which is why most are type annotating their function)

But Rusts type annotations have non the less its limitations, when excessively using traitbounds (but I hope that will be soon better with impl everywhere (see e.g. https://smallcultfollowing.com/babysteps/blog/2022/09/22/rust-2024-the-year-of-everywhere/))

permalink
report
parent
reply
2 points

I really prefer rust’s approach. The function signature is the contract. It makes it much easier to debug compared to overly generic pure functional code or c++ templates where everything is auto and perfect forwarded.

The only time in rust where this isn’t true is with async functions. That’s because the compiler adds a ton of sugar to make it easier to write.

permalink
report
parent
reply

Programming

!programming@programming.dev

Create post

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person’s post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you’re posting long videos try to add in some form of tldr for those who don’t want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



Community stats

  • 3.5K

    Monthly active users

  • 1.7K

    Posts

  • 28K

    Comments