Programming

walkerb,

I was surprised to find out yesterday that has no SWITCH...CASE construct.

Since I consider IF...ELSEIF trees butt ugly, even though they produce the same result. I went looking for another way.

It can be emulated pretty well by using a dictionary lookup instead.

adriano,
@adriano@lile.cl avatar

@walkerb It's weird that you found this yesterday, because as of late, it does. https://docs.python.org/3.10/whatsnew/3.10.html#pep-634-structural-pattern-matching

EMR,
@EMR@mastodon.sdf.org avatar

@walkerb there's match/case in 3.10

daanderson,

I decided to buckle down and finally learn .

I love as a language, but I've lost love for the churn, the long build pipelines, frameworks that do the same thing, but better.

Getting instant feedback was what made code magical for me. JS used to have that magic. I could just type code in the browser. Now, with tooling, with build pipelines… it all feels like how people complained about compiler errors: a long slog.

Ironic that it's a compiled lang that brings back the magic.

nosherwan,
@nosherwan@fosstodon.org avatar

@daanderson I started learning it a bit, but then lost my way as there are a million other things to keep an eye on in web development world.

I will start again, this time with more patience.

tanepiper,
@tanepiper@tane.codes avatar

@nosherwan @daanderson Now that I'm finally writing Web components, I think it is the way to go. Not perfect but at least interoperable. FWIW the teams that ship the fastest I've seen work with Svelte.

veronica,
@veronica@mastodon.online avatar

I'm experimenting with a new Preferences dialog for my app. These are never easy to make and are usually hard to navigate due to the volume of labels and buttons.

I'm testing out putting all the setting on a long page with navigation buttons. This replaces the traditional tabbed layout the app currently uses.

It is still an information overload. Maybe I can also make the content searchable?

A short video of a Preferences dialog in a writing application. All settings are in a long, scrollable list on the right, with a series of navigation buttons on the left that takes you to each category of settings when they are clicked.

matt,
@matt@mstdn.games avatar

@veronica that looks great! I think the only way to improve that is to use similar strings as well, but it’s hard to predict what users will search for! Time for some testing 😅

veronica,
@veronica@mastodon.online avatar

@matt Yeah, problem with more fuzzy logic is that these strings are translated into multiple languages by contributiors. Also, there are only 49 settings.

fell, (edited )
@fell@ma.fellr.net avatar
m0xee,

@fell Well, I was just kidding. No, I do prefer tabs, but I can adapt to any style that the project or config file uses. This nginx config uses spaces, should I reformat it, of course not, spaces it is. And I do have autopep8 for Python files in Vim. Guido decided that it's best, I'd do it differently, but fine.

tranzystorek_io,
@tranzystorek_io@fosstodon.org avatar

@fell related note: I set up my editors to display whitespaces, lets me avoid surprises

haskman,
@haskman@functional.cafe avatar

Learning is like a rite of passage. Everybody should do it irrespective of what they actually use

dekkzz76,
@dekkzz76@emacs.ch avatar

@ramin_hal9001 @daviwil @haskman

VSC will be fine till once enough have taken the bait, the popular functions will go to VS

Sometimes i see a new lang & think why, even for most new programming paradigms a lang or 2 already exists

Plus there's so much reinventing the wheel

haskman,
@haskman@functional.cafe avatar

@dekkzz76 @daviwil @ramin_hal9001

Relevant: we are organising an "F# in production" webinar later this month, and registration is free -

https://hasgeek.com/jsfoo/fp-webconf/sub/notes-on-f-doing-functional-programming-in-product-QXLPYATsQwYezZpXXn2q64

gregorni,
@gregorni@fosstodon.org avatar

What does your development environment look like right now?

(IDE/Text Editor? Terminal Multiplexer? Package Manager? Shell? Programming Language? Containerization? Command Runner? Terminal Emulator?)

montar,
@montar@mastodon.social avatar

@gregorni Emacs

gregorni,
@gregorni@fosstodon.org avatar

@montar Took me a second to figure out what operating system you're running 😂

vwbusguy,
@vwbusguy@mastodon.online avatar

Using for a project since the SDK has really nice structs and instantiators for all the API calls where the SDK for the project just phoned it in for all the payloads.

vwbusguy,
@vwbusguy@mastodon.online avatar

If were just a little less verbose, I'd probably use it a lot more.

witt,

@vwbusguy Hey! I recently started learning Go and have a couple small tools made in Python.
I'm kinda wondering how much golang forces complexity.

It's probably an unfair comparison, but if I were to make the same tool in both Python and Go, how much complexity overhead (maybe not necessarily verbosity) does it seem to require?

futurebird,
@futurebird@sauropods.win avatar

Did you know in python you can stick a for loop in the list brackets and just BAM have a list? No “append” check it:

l=[chr(i+65) for i in range(0,26)]
print(l)

> [‘A’, ‘B’, ‘C’, … , ‘Z’]

(it will be the letters A-Z since the unicode for the capital letter starts at 65, chr renders these numbers as letters.)

Is that classy? For some reason this neat little feature isn’t really taught. I guess with a loop and appending you have not flexibility— but still this is cool. #python #coding #tricks

tarajdactyl,

@futurebird i find list comprehensions particularly useful when playing around in an interactive Python shell!

side note: if you are only going to go through the list once, you can use parentheses instead of square brackets to get the generator instead of instantiating the whole list. this can greatly improve performance in some scenarios.

wren,

@futurebird for the unfamiliar:

this feature is called "comprehension" - list comprehension, specifically. it also works with dicts, e.g.:

{str(i): i for i in range(10)}
> {"0”: 0, "1": 1, ... }

comprehensions support if/else also:

[i if (i%2==0) for i in range(10)]
> [0, 2, 4, ... 8]
[i if (i%2==0) else (i*2) for i in range(10)]
> [0, 2, 2, 6, 4, ... 8, 18]

and multiple, implicitly-nested loops:

[i+j for i in range(3) for j in range(3)]
> [0, 1, 2, 1, 2, 3, 2, 3, 4]

gregorni, (edited )
@gregorni@fosstodon.org avatar

What do you say to whitespace-sensitive/oriented programming languages, assuming your IDE supports the whitespace-behaviour really well, and all the tooling around it is generally good?

dreamos82,
@dreamos82@mastodon.world avatar

@gregorni yes. I mean if the language is a good language, i will use it. But if it is not good, or i don't like it (i. e. Javascript/typescript) i will hate them no matter the syntax lol

gregorni,
@gregorni@fosstodon.org avatar

@dreamos82 That sounds like a good mindset, I like that.

joelanman,
@joelanman@hachyderm.io avatar

In Node you can easily load json like this:

const myData = require('data.json')  

is there an equivalent in the new import syntax?

joelanman,
@joelanman@hachyderm.io avatar

@bcdavid wow thanks for the in depth explainer!

joelanman,
@joelanman@hachyderm.io avatar

found another gotcha, you could use require to load json any time, import can only be used to load json in the root scope (not in functions for example)

raccoon, (edited )

Been working on a new project the last couple of months and it's finally ready for beta release!

is a based client (available for , and under the Apache license) with a focus on and . Features:

  • Break long texts into threads
  • Scheduled posting
  • Hashtag research
  • quote tweeting emulation

https://fedimeister.onyxbits.de

expertmanofficial,

@jdasher :thumbsup_hmn_g1:

jupiter_rowland,

@𝗝𝗮𝗸𝗼𝗯 :𝗳𝗿𝗶𝗲𝗻𝗱𝗶𝗰𝗮: 🇦🇹 ✅ @Patrick, the Linux guy Better yet:

  • Use something that isn't Mastodon, and that has all the features implemented by default that #Fedimeister tries to imitate

@excited for the mastodon rise

khalidabuhakmeh,
@khalidabuhakmeh@mastodon.social avatar

You'd think being run by a single mega-corporation would lead to brand consistency. Nope.

C# logo
C# logo
C# logo

range_marten,
@range_marten@dotnet.social avatar

@khalidabuhakmeh For those needing a shader version: https://www.shadertoy.com/view/mtjSDD

Enema_Cowboy,
@Enema_Cowboy@dotnet.social avatar

@khalidabuhakmeh I'm going to start my own C#, with blackjack, and hookers....

Drmowinckels,
@Drmowinckels@fosstodon.org avatar

📝 New blog post 📝

'The IDEs I use'

🧏 People who code have a tendency to spend a lot of time in various IDEs (Integrated Development Environments). They can be as simple as a text editor or as complex as a full-blown development environment. In this post, I'll go through my two go-to IDE's, RStudio and VScode, and why I switch between them rather than sticking to a single one. ---

👀 Read more at https://drmowinckels.io/blog/2024/ide

#R

milesmcbain,
@milesmcbain@fosstodon.org avatar

@Drmowinckels I realised I had all but turned VSCode into vim anyway due to the extensions I am using. And (neo)vim is much more free in terms of how you can create your own tools and automations. For VSCode (and RStudio actually) you’re expected to write and publish a package that contains your extension. It slows things down somewhat. In Vim you just source some code and now things work differently.

I also have some frustration with VSCode’s design - you can’t avoid a mouse completely.

joelnitta,
@joelnitta@fosstodon.org avatar

@Drmowinckels Nice post! For me the other "killer app" of VS Code (besides git support) is running instances within docker containers (which could be on a server). Feels identical to working locally.

Personally I've switched 100% to VS Code for my own work. I only use RStudio for teaching. The combination of RStudio plugins in VS Code and my own shortcuts make it fine for package development in my experience.

rodhilton,
@rodhilton@mastodon.social avatar

I think it's fair to say that between the Scala 3 rollout and the lightbend licensing fiasco with Akka, is effectively dead.

Everyone I know with a Scala codebase in a professional setting is either

  1. actively transitioning away from Scala because they need to move away from akka streams

  2. maintaining existing projects but are doing no new projects in Scala

  3. trying to stick with Scala 2 until they no longer can

I don't know of anyone actively doing new dev in Scala.

soc,
@soc@chaos.social avatar

@rodhilton I agree with your analysis and are happy to say that I made some small contributions to make that happen!

rebelwarrior,
@rebelwarrior@mastodon.social avatar

@rodhilton what there is a new version of Scala?

amoroso,
@amoroso@fosstodon.org avatar

To improve as a programmer, many advise to read lots of code but few actually do.

In this old but still relevant essay Peter Seibel discussed why and explained what he does instead, summarizing his approach this way:

"Code is not literature and we are not readers. Rather, interesting pieces of code are specimens and we are naturalists."

https://gigamonkeys.com/code-reading

Joe_0237,
@Joe_0237@fosstodon.org avatar

@amoroso I actually got to reading it, and i cant say that its too teribly surprising, and the conclusion is for sure correct.

What i was thinking is that trying to understand strange parts can expose you to language features that you may not know exist or may have forgotten. Or to useful algorithms or available functionality.
I don't read code like its iterature but i do code dig, and sometimes i find things i didn't know i could do. I think my first wild discovery was the terinary operator.

amoroso,
@amoroso@fosstodon.org avatar

@Joe_0237 It makes sense, we usually read code to answer specific questions.

sos,
@sos@mastodon.gamedev.place avatar

I hate CMAKE. That's the post. Just hate it.

Why the FUCK does CMAKE generate VS project files that depend on having CMAKE installed on your system? And it has to be in a fixed path? And EVERYTHING has to be in a fixed path?

Have CMAKE developers ever compiled something or used version control? This is unusable and I am very angry and it's Monday and I haven't had my coffee yet.

EDIT: AND IT HAS TO HAVE VS INSTALLED AT A FIXED PATH TOO WHO MADE THIS CRAP????

dos,

@raptor85 @sos @kkolakowski CMake is a leaky abstraction with awful DSL, and my 12yo cmake scripts are a pile of incredible mess riddled with technical debt, but it still does its job well enough that I could just point my projects to stuff like devkitpro, vitasdk, osxcross, Emscripten, Flatpak or Steam Runtime and focus on actual porting rather than fighting with build recipes.

raptor85,
@raptor85@mastodon.gamedev.place avatar

@dos @sos @kkolakowski yup, and most IDEs are smart enough to automatically generate build folders for your local toolchains so I can pull in pretty much any cmake file and get build targets for both linux x86_64 and a windows cross compile with mingw. To add new targets to all my projects I don't have to write tons of new scripts, just add a new toolchain to my system and they ALL get it.

emacsen,
@emacsen@emacsen.net avatar

A bit of a programmer rant...

People wonder why I like ORMs even when they're unnecessary. Firstly, I've never liked SQL. I think that writing queries to a RDBMS is something that a computer should do, akin to compilation. In the few times when extreme optimization is warranted, low level code can be generated to suit that specific case. In other times, ORMs usually provide a more natural interface to data that increases readability and code flow.

1/2

lanodan,
@lanodan@queer.hacktivis.me avatar

@xocolatl @emacsen And user errors should be errors, either at runtime or with some other way like static analysis.

mkutz1492,
@mkutz1492@mastodon.world avatar

@xocolatl @lanodan @emacsen

  • declarative languages (sql)
  • objective code (ORM)
  • hierarchical file format (JSON, XML)

All 3 are different ways to describe the same thing. It should be easy to translate between.

Each solves a different set of problems better than the others.

Don't hate one because you don't run into the problem it solved best.

IMO

xsevy, Polish

any Insomnia alternatives which are not Postman? I need rest and graphql support.
Insomnia is getting worse and worse and I'm worried it won't be better.
@python @golang
@opensource

comfydecal,

Engine search “insomnium” (like codium for vscode), there are multiple. This is the first result.

github.com/ArchGPT/insomnium

ShrimpsIsBugs,

Fair.

bitprophet,
@bitprophet@social.coop avatar

So is actually any good? I have a pile of anecdata asserting that historically, it turns into completely impenetrable wanker bullshit by day ~10 out of 24.

I /might/ actually have the bandwidth for it this year, but I would much rather put the time into personal projects or OSS if I'm gonna feel compelled to give up on an advent halfway through.

mpirnat,
@mpirnat@mas.to avatar

@jacob @bitprophet I totally get that. When I hit those days, I try to reframe it as a learning opportunity and see how other people solved it. Everybody's journey is different; being able to learn and add new things to your toolkit is a "true programmer" mark in my book. And really, if you hit a weird error or strange bug in your "real life" work... would you feel like a not-true-programmer if you did some research to figure it out?

jacob,
@jacob@jacobian.org avatar

@mpirnat @jacob @bitprophet I’ve never made it past like Day 3

OTOH I’ll bet of the people who finish AoC almost none of them have finished Ducks, Newburyport so we’ve all got our little silly accomplishments we’re unreasonably proud of

vwbusguy,
@vwbusguy@mastodon.online avatar

Looking for a diff tool that spits out valid yaml but only including the parts where there are differences between the two. I have some helm chart values yaml files that have gotten unnecessarily verbose.

vwbusguy,
@vwbusguy@mastodon.online avatar

@buddyspencer oh, neat - which repo?

Nvm, I found it - https://fosstodon.org/@buddyspencer/110751000996261141

Thanks! I'll check it out shortly!

brmassa,
@brmassa@mastodon.online avatar
kroc, (edited )
@kroc@mstdn.social avatar

I DID IT! After a mad, possessed, sleepless 30 hour bender I finally solved the language design problem I've been wrestling with for a decade! How to make a concatenative language both type-safe and infix/postifx (not RPN). I think this is the most elegant language I've ever designed: https://gist.github.com/Kroc/62fd60dda68f667e0e4d94c9e08bf2af

livingcoder,

@kroc That makes sense, that the language could still function without it. I've found that when a language makes bad design harder, more good code gets written by default. If there was a way to pass structs to a global "typed" stack, that would make it far more useful, imo. This would solve a few issues at the same time:

  1. Popping from the typed stack guarantees the correct/expected type is returned
  2. Functions who's purpose is to push specific data to the stack no longer have to worry about new code polluting downstream popping/usage
  3. Wanting to map data from one stack to another becomes obvious/straightforward
  4. Any new function that wants their data included in an existing downstream process no longer needs to pop existing structs, push their new data, and restore the existing structs in reverse order
psf,

@kroc Ooh this is an interesting design space. Reminds me somewhat of REBOL http://www.rebol.com/docs/quick-start.html

louis,
@louis@emacs.ch avatar

First two hours with #Rust == 😍

louis,
@louis@emacs.ch avatar

@michael Currently I'm refactoring a bigger Golang project and really enjoy the type safety because the compiler just tells me where the issues are when I rearrange and rip out code and types.

In almost all cases, after fixing all the warnings and errors, the program runs perfectly.

That would be very hard and error prone in a dynamic language (or at least a language without type annotations and code intelligence).

So if you feel comfortable with Rust, enjoy the payoff for your time investment!

Nim and Haskell are currently my personal taste. Nim is almost as easy to learn as Go but offers far more features (I really like the syntax) and a very strong type system. Haskell is the crown jewel in this regard but it takes a lot of time to wrap your head around it.

michael,

@louis I've taken a look at Nim after you recommended it earlier, but haven't tried it out yet. Looks promissing but I'm a bit hesitant due to the smaller eco system. If I can name on 'bad' thing about Common Lisp it's the smaller eco system, which does make a difference.

I once spent a couple of weekends getting into Haskell but never really persued it. It was my understanding it's not a very practical language when you're doing web/api/cli development, again due to the ecosystem?

shafik,
@shafik@hachyderm.io avatar

This one trick to do sqr() and cube() in C: https://godbolt.org/z/7qeanM

vitaut,
@vitaut@mastodon.social avatar

@shafik idiomatic compile-time programming in C

vitaut,
@vitaut@mastodon.social avatar

@shafik actually this one even more idiomatic:

sqr(n) sizeof(char[n][n])

  • All
  • Subscribed
  • Moderated
  • Favorites
  • programming
  • ngwrru68w68
  • rosin
  • GTA5RPClips
  • osvaldo12
  • love
  • Youngstown
  • slotface
  • khanakhh
  • everett
  • kavyap
  • mdbf
  • DreamBathrooms
  • thenastyranch
  • magazineikmin
  • megavids
  • InstantRegret
  • normalnudes
  • tacticalgear
  • cubers
  • ethstaker
  • modclub
  • cisconetworking
  • Durango
  • anitta
  • Leos
  • tester
  • provamag3
  • JUstTest
  • All magazines