- slowpowke ( @slowpowke@nano.garden ) 31•1 year ago
Python, and I like that I know it
- cocobean ( @cocobean@bookwormstory.social ) English2•1 year ago
I had to use Python for a bit at work and it was confusing
pipenv, venv, virtualenv, poetry…wtf is all this shit
a.b
vsa['b']
vsa.get('b')
…wtf is a KeyError- richieadler ( @richieadler@lemmy.myserv.one ) English4•1 year ago
What happens in other languages you use when you try to access a non-existing key for a hash/map/dict?
What language do you use that accessing an object attribute is the same that accessing a dict key?
What knowledge do you have (or not) that KeyError is a mistery to you?
- cocobean ( @cocobean@bookwormstory.social ) English1•1 year ago
Return undefined.
Typescript.
Why error? Just return undefined. Simple, no try/catch needed.
- richieadler ( @richieadler@lemmy.myserv.one ) English1•1 year ago
Because that’s prone to errors. And the Zen of Python includes “explicit is better than implicit” and “Errors should never pass silently”. Languages that do otherwise create bad habits.
- cocobean ( @cocobean@bookwormstory.social ) English1•1 year ago
Is it? It’s just an optional property. And Typescript will tell you that it’s optional.
- Lambda ( @lambdabeta@lemmy.ca ) English24•1 year ago
After years, and many languages, I still have to say Ada. Kotlin, Rust, Julia, and Nim are my current contenders to overtake, but here’s what Ada does well enough to still be my preferred tool when appropriate:
- strictness: typically my code works the first time it successfully compiles with few or no bugs. Rust is almost on par in this respect.
- structure: a corollary of the above is that it forces me to “plan ahead” more than just “start coding” which I find fits my programming style better, and leads to better “Unix Philosophy” product designs. I haven’t found any other language that has the same effect other than maybe Haskell.
- speed: I honestly find that Ada code outperforms C/C++ code most of the time. The only times C/C++ outperform Ada is after optimizations that come at the cost of readability.
- multitasking: Ada’s first-class tasks and protected objects are the only way I’ve ever been able to write bug-free concurrent programs that are more complex than async/await and/or producer/consumer structures (and I took a dedicated elective on concurrency at university!). Kotlin is almost on par in this respect with its coroutines.
- hardware: The fact that Ada basically ships with a hard real-time OS built-in and can compile to e.g. AVR means that all my fancy libraries I’ve written or saved work just as well for a desktop game, a website backend, or an embedded microprocessor. Just look into representation clauses and interrupt pragmas to see its unique powers.
- design: The whole design of the language has lead it to be the only language where I can consistently return to a multiple year old passion project with no attempt to write maintainable code, and fully understand what its doing and modify it with little effort.
- tooling: While this is the biggest downside of Ada (see below) gprbuild is still my favourite build tool. I have no idea why strongly-typed build systems aren’t more common. Its always a joy to work in gprbuild, once you get gprbuild working of course.
- static polymorphism: Ada’s generics are some of the best I’ve found. But they have some limitations that leads us into…
There are some situation where Ada shows its age:
- static calculation: I love Nim (and Zig, etc) for the ability to run arbitrary code at compile time. It allows me to describe what would normally be an opaquely initialized data structure or code path in a clear and descriptive manner.
- terseness: Ada is verbose, that’s not such a big deal, but I find its just a tad too verbose which can lead to some slight difficulty when parsing code.
func
/proc
(Nim) vsfun
(Kotlin) vsfn
(Rust) doesn’t make much difference to me, butfunction X returns Y
/procedure X
starts to add a lot of visual noise to a file. - web compilation: The ability for both Kotlin and Nim to compile to either ASM or JS is AWESOME. If I have to write a “full stack” application, Kotlin multiplatform with ktor every day.
- operator overloading: Only the built-in operators can be overloaded in Ada. It always makes me wish I could overload arbitrary operators. A small thing, but a symptom of…
- TOOLING: Ada’s tooling is BY FAR the hardest I have ever seen to get working. It takes the “eat your own dog food” too far. The fact that even in Arch Linux you have to install a bootstrap package, then the real package shows how hard it is to get a consistent build environment. ALR is helping in this respect, but is still not quite mature in my opinion.
Here’s when I use the alternatives, and their biggest weaknesses:
- Kotlin: anything where I want both one or more JS artifacts and one or more JVM/native artifacts. Weaknesses: performance, static analysis, on the fence about tooling (gradle is cool, but sometimes seems too over-engineered), Biggest weakness: IDE dependency, writing Kotlin outside of IntelliJ is a pain, which is somewhat fair given who maintains it!
- Rust: so close to beating Ada, if not for two things: ugly code - so many operators and glyphs that pollute the reading experience, maybe I’ll get used to it eventually, but for now I can’t scan Rust code, nor pick up and revisit it nearly as easily as Ada; language scale - I find Rust suffers from the C++ design attitude of “we can add this as a language feature” it takes too much mental effort to hold the entire design of the language in your head, which you sort-of have to do to develop software. Java and C are IMHO the undisputed kings in this respect. After reading through the specifications of both languages, neither will ever have any surprises in store for you. There’s no magic under the hood or special case. All the cool features are done by libraries and rely on the same simple syntax. Every time I learn a new cool thing Rust can do, its at the expense of another edge case in the compiler that modifies my conceptual model of the code.
- Julia: multiple dispatch and mathematics plus clean module design and easy unicode incorporation leads to clean code for math-y/science-y code.
- Nim: templates and macros are excellent, concept system gives access to Rust-style traits without all of the additional “ugliness” of Rust, excellent performance, tiny executables. I just find that the syntax can get clunky. The UFCS easily cleans up a lot of the mess that Rust creates with its added features, since it keeps the parsing the same even when using some fancy language feature.
Thank you for attending my TED talk :P. Any questions?
- Scorchio ( @Scorchio@lemm.ee ) 3•1 year ago
I learned Ada in the early 90s before being plunged into a world of C/C++. I haven’t heard much about it since, but I’m glad to hear it’s alive and kicking. I’ll have to have another look, see if I recognize any of it!
- mim ( @mim@lemmy.sdf.org ) 24•1 year ago
Python for its versatility.
Rust for its strictness and speed.
- Cycadophyta ( @Cycadophyta@lemmy.cafe ) 7•1 year ago
Try Julia, it has both
- mim ( @mim@lemmy.sdf.org ) 9•1 year ago
By versatility, I’m also including the ecosystem. Julia doesn’t seem to be anywhere near python on that.
However, I’ve heard good things, it’s on my to-do list.
- Kissaki ( @Kissaki@feddit.de ) English13•1 year ago
C#. Strong core, a lot of convenience extensions, extensive ecosystem, great docs, great IDE (VS) with suggestions, refacs, lingers, etc.
- Scorchio ( @Scorchio@lemm.ee ) 7•1 year ago
C# is still my favorite. I’ve been pushed back into a C++ project recently and it’s just painful.
- HakFoo ( @HakFoo@lemmy.sdf.org ) 12•1 year ago
PHP.
It picked a niche and fits exactly into it. It’s a language for server side web pages. It’s not a general purpose language shoehorned into the task, so it wisely sets boundaries. PHP could avoid a lot of async/await/promise hell because you can work in the mindset of HTTP requests-- terms of short lived requests that are compiled elsewhere. You don’t have fragile runtime environments (see: server-side JS), since it just plugs into Apache or Nginx, which are at least battle tested and known quantities to operate.
It’s batteries included. Hell, it’s the entire Duracell company included. The standard library is rich and centrally documented, including decades of community nitpicks, even before you go into composer repos.
It’s non judgmental. You can write procedural code, or object-oriented code, based on preference and fit to task.
It makes ad-hoc easy and formal possible-- If I need an array of [227, “Steve” => “meow”, 953 => new FreightLocomotive()] I can get it, or I can enforce types where it’s relevant and mitigates risk.
- saloe ( @saloe@lemmy.ml ) 3•1 year ago
PHP really is such a forgiving language and easy to understand and get in to. My favorite part is that every time I have a seemingly very niche and specific use-case, there is a function that just does that thing perfectly and is already included in the base library.
You said it and I’ll reaffirm: the documentation and online library of SO questions/answers is absolutely priceless. Most of the older versions are still compatible with the latest version, so upgrading is simple and usually just means there are more features you can use now.
- GBU_28 ( @GBU_28@lemm.ee ) English10•1 year ago
Python. I’m a data engineer by trade and the ability to just lay out functionality between different systems and move content fast is great. I know you can do that with many languages but python does scripting very well. And since by default I am working with remote/parallelized/containerized systems I never really lament pythons lack of speed.
Obviously python is not the only language in my workweek.
Probably the most unpopular opinion here but PowerShell.
My main reason is that it’s extremely easy to learn and is a good intro to object orientated programming.
People bash it but it’s extremely easy to inspect objects, get any properties and methods associated with that object or class, walk through all the properties of the object and transform that into whatever you need.
It has a very fast turnaround time when developing code as you can run tiny snippets at a time and understand their outputs before moving to the next bit.
I’m not a Dev and end up having to write python from time to time and I hate it. At one point I just needed to understand an object in a variable and I couldn’t do it, the command
dir
exists but it didn’t give me any of the info I needed. There’s a function in PowerShell calledGet-Member
(alias:gm
) that you can pipe anything to and it will show you all those details of the object.It helped me tremendously when I was just starting out.
Its super powerful, it can do anything C# can do because it’s built on it, you can also run inline C, C# and C++ code with on the fly compilation.
It’s also OSS and cross platform.
- dbilitated ( @dbilitated@aussie.zone ) 2•1 year ago
I write code in C# but I love PowerShell. it’s just elegant even if the syntax can be a bit clunky
- 1984 ( @1984@lemmy.today ) 2•1 year ago
Oh Jesus no.
But I knew there must be someone who likes it.
In python you may have wanted the repr command to see how an object looks like.
Thanks for the tip!
- Paolo Amoroso ( @amoroso@lemmy.ml ) English9•1 year ago
Lisp.
It just feels extremely natural to me, so it’s difficult to pinpoint specific features I like. But two such features stand out: the parantheses-based syntax and the extreme interactivity.
- stillitcomes ( @stillitcomes@lemm.ee ) English9•1 year ago
Python. It’s the only one I know :(
I’ve been trying to learn C# too but object-oriented programming just slides right off my smooth brain lol.
- Kache ( @Kache@lemmy.one ) English3•1 year ago
object-oriented programming just slides right off my smooth brain lol
Don’t worry, although it’s good to learn, IMO it’s still on the wrong side of overused and overrated and could stand to be applied more selectively than it tends to be.
- XPost3000 ( @XPost3000@lemmy.ml ) 9•1 year ago
Python
It’s real easy to just launch it and get a script going, no need to wait for and ide or a compiler, there’s alot of nice modules, and it’s really API friendly
I’ve spent more time in the blender python API than I’d like to admit
- bebboIsTalking ( @bebboIsTalking@lemmy.sdf.org ) 8•1 year ago
I like C….
- Jeena ( @jeena@jemmy.jeena.net ) 8•1 year ago
Haskel, It’s kind of hard to do some stuff which are easy in other languages but if you find a good problem to solve with it, it’s amazing how expressive you can be and how short your code gets compared to all the boilerplate code you have to write with other languages.
- oktupol ( @oktupol@discuss.tchncs.de ) 8•1 year ago
Kotlin.
Take the good parts of Java.
Remove the bad parts of Java.
- hellishharlot ( @hellishharlot@programming.dev ) 3•1 year ago
I thought that was c#
- holgersson ( @holgersson@lemm.ee ) 2•1 year ago
C# adds a bad part called Microsoft (yes, Mono exists, it’s still Microsoft Java)
- Christopher Masto ( @masto@lemmy.masto.community ) 6•1 year ago
I’ve never been happier and more productive than when I was working in Perl. It’s a language that, at its apex, had a community of incredibly smart and creative people evolving it and its ecosystem. It’s a practical, powerful, multi-paradigm language that let me get work done with a minimum of fuss.
Perl was a language that felt like an extension of my thoughts, like it was working with me and for me. Most other languages feel like I am working for the compiler rather than the other way around. Or at the very least, spending unnecessary effort satisfying some language designer’s personal pet peeve, which constantly takes me out of the flow of the job I’m trying to do.
- Toast ( @Toast@lemmy.film ) English1•1 year ago
Perl was always fun
- hamburglar26 ( @hamburglar26@wilbo.tech ) 1•1 year ago
I started a job a while back where Perl was heavily used and I hadn’t had much exposure to it. I spent some time just doing the same thing in Perl and Python and I really enjoyed working with Perl for the reasons you listed. I was just somehow very easy to use and be productive.
I haven’t touched it since I left and Perl is completely unused and almost alien where I am now.
- smeikx ( @smeikx@lemmy.graz.social ) English6•1 year ago
On the one hand I like Lua for its elegant, minimalistic design. I enjoy writing Lua, most of the time when working on Neovim plugins.
On the other hand I value the raw expressive power of C++. It is a beast, but I enjoy taming it.