Programming

22057 readers
210 users here now

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



founded 2 years ago
MODERATORS
126
127
256
PNG is back! (www.programmax.net)
 
 

After 20 years, PNG is back with renewed vigor! A new PNG spec was just released.

128
 
 

I made this tool so you can share 'locked' links safely & anonymously with a password. It gives you plausible deniability and crowd blending when sharing privates links.🔒

https://qrc.site/anon (open sauce) 🦑

129
 
 

Cross-posted from "How could I allow users to schedule sending emails at a specific interval?" by @lena@gregtech.eu in !learn_programming@programming.dev


Basically, I'm trying to figure out how I could allow a user to send a schedule in the cron syntax to some API, store it into the database and then send an email to them at that interval. The code is at gragorther/epigo. I'd use go-mail to send the mails.

I found stuff like River or Asynq to schedule tasks, but that is quite complex and I have absolutely no idea what the best way to implement it would be, so help with that is appreciated <3

130
131
132
133
134
135
 
 

About enshitification of web dev.

136
 
 

Perhaps the most powerful and widely used tool for literate programming ist Emacs org-mode with the babel extension. I have used it, and it is good!

However, org-mode puts a hurdle to novice users - to practice literate programming, they need to learn a bit of Emacs, which is a task in itself.

I linked the above project because it has two interesting properties:

  • One can write the literate document in Markdown. This is not as powerful as org-mode, which is tailored to larger documents, but very accessible.

  • One can modify the generated source files directly, and they are automatically read back into the literate document. This makes it much easier to work with existing tools that modify source code.

137
 
 

I had an interesting email come in about billing. GitHub thinks I owe them money...cents on the dollar but still $$. I am on the free tier on GitHub and have been the past 15+ years. image
Up til recently, ive had no bills and im not an admin on any org. It looks like all my GitHub actions on my repos are accruing billing now. None of these repos are private. So im not 100% why this is occurring.

Has this happened to anyone else? Is there something im missing here?

138
 
 

Summary by Dan Luu on the question about whether for statically typed languages, objective advantages (like having measurably fewer bugs, or solving problems in measurably less time) can be shown.

If I think about this, authors of statically typed languages in general at their beginning might not even have claimed that they have such advantages. Originally, the objective advantage was that for computers like a PDP11 - which had initially only 4 K of memory and a 16-bit adress space - was that something like C or Pascal compilers could run on them at all, and even later C programs were much faster than Lisp programs of that time. At that time, it was also considered an attribute of the programming language whether code was compiled to machine instructions or interpreted.

Todays, with JIT compilation like in Java and the best implementation of Common Lisp like SBCL being at a stone's throw of the performance of Java programs, this distinction is not so much relevant any more.

Further, opinions might have been biased by comparing C to memory-safe languages, in other words, when there were perceived actual productivity gains, the causes might have been confused.

The thing which seems more or less firm ground is that the less lines of code you need to write to cover a requirement, the fewer bugs it will have. So more concise/expressive languages do have an advantage.

There are people which have looked at all the program samples in the above linked benchmark game and have compared run-time performamce and size of the source code. This leads to interesting and sometimes really unintuitive insights - there are in fact large differences between code sizes for the same task between programming languages, and a couple of different languages like Scala, JavaScript, Racket(PLT Scheme) and Lua come out quite well for the ratio of size and performance.

But given all this, how can one assess productivity, or the time to get from definition of a task to a working program, at all?

And the same kind of questions arise for testing. Most people would agree nowadays that automated tests are worth their effort, that they improve quality / shorten the time to get something working / lead to fewer bugs. (A modern version of the Joel Test might have automated testing included, but, spoiler: >!Joel's list does not contain it.!<)

Testing in small units also interacts positively with a "pure", side-effect-free, or 'functional' programming style... with the caveat perhaps that this style might push complex I/O functions of a program to its periphery.

It feels more solid to have a complex program covered by tests, yes, but how can this be confirmed in an objective way? And if it can, for which kind of software is this valid? Are the same methodologies adequate for web programming as for industrial embedded devices or a text editor?

139
 
 

I desperately need some Python help. In short, i want to use multiple keys at once for sorting a dictionary. I have a list of keys and don't know how to convert it to the required list.

This is a single key. The self.items is a list of dictionaries, where d[key] is resolved to the actual key name such as "core_name", that the list is then sorted as. This works as expected for single sort, but not for multiple.

key = "core_name"
self.items = sorted(self.items, key=lambda d: d[key])
key = "label"
self.items = sorted(self.items, key=lambda d: d[key])

Problem is, sorting it multiple times gives me wrong results. The keys need to be called in one go. I can do that manually like this:

self.items = sorted(self.items, key=lambda d: (d["core_name"], d["label"]))

But need it programmatically to assign a list of keys. The following does not work (obviously). I don't know how to convert this into the required form:

# Not working!
keys = ["core_name", "label"]
self.items = sorted(self.items, key=lambda d: d[keys])

I somehow need something like a map function I guess? Something that d[keys] is replaced by "convert each key in keys into a list of d[key]". This is needed inside the lambda, because the key/value pair is dynamically read from self.items.

Is it understandable what I try to do? Has anyone an idea?


Edit: Solution by Fred: https://beehaw.org/post/20656674/4826725

Just use comprehension and create a tuple in place: sorted(items, key=lambda d: tuple(d[k] for k in keys))

140
 
 

I'm very excited to announce that I have recently joined Turso as a software engineer. For many in the field, including myself, getting to work on databases and solve unique challenges with such a talented team would be a dream job, but it is that much more special to me because of my unusual and unlikely circumstances. As difficult as it might be to believe, I am currently incarcerated and I landed this job from my cell in state prison. If you don’t know me, let me tell you more about how I got here.

141
 
 

Biome is a formatter and linter for web languages: JavaScript, TypeScript, CSS, HTML, JSON, and GraphQL.

Version 2 adds type-aware lint rules and it is the first TypeScript linter that does not require tsc. Other new features include:

  • Monorepo support
  • GritQL Plugins
  • Revamped, configurable import sorting
  • Linter domains
  • Bulk suppressions
  • Analyzer assists
  • Many new lint rules
142
21
Project Gemini FAQ (geminiprotocol.net)
submitted 1 month ago* (last edited 1 month ago) by HaraldvonBlauzahn@feddit.org to c/programming@programming.dev
 
 

cross-posted from: https://feddit.org/post/14262415

On the question what are use cases for a Gemini server:

Gemini is kinda a modernized version to the old Gopher protocol. Its purpose is to share hyper-linked text documents and files over a network - in the simplest way possible. It uses a simple markup language to create text documents with links, headings etc.

Here is a FAQ

Main differences with similar technologies are:

  • It is much, much easier to write hyper-linked documents than in HTML

  • a server is much much smaller and easier to set up than a web server serving HTML. It can easily and securely run on a small Raspberry Pi without special knowledge on server security.

  • in difference to gopher, it supports modern things like MIME and Unicode

  • There are clients for every platform including Android and iOS

  • also, there are Web gateways which allow to view stuff in a normal web browser

  • unlike Wikis, it is only concerned about distributing content, not modifying files. This means that the way to store and modify content can be matched to the use case: Write access to content can be via an NFS or Samba server, or via an SFTP client like WinSCP or Emacs.

  • Unlike HTML2, it does not support advertising, tracking, spying to users, and so on.

  • the above two points mean that it does not need user authentication

  • the protocol is text-centric and allows for distraction-free reading, which makes it ideal for self-hosted blogs, small projects or associations, or microblogs.

Practically, for example, I use it to share vacation photos with family.

Two more use cases that come first to my mind:

  • When I did my masters thesis, our lab with about 40 people had a HTTP page hosted on a file server that listed tools, data resources, software, and contact persons. That would be easier to do with Gemini because the markup is simpler. Also, today it would not be feasible to give every student write access to a Apache web server's content because of the complexity of web servers, and the resulting security implications.

  • One time at work, we had a situation with a file server with many dozens of folders, and hundreds of documents. And because all the stuff had been growing kinda organically over many years, specific information was hard to find. A gemini server would have made it easy to organize and browse the content as collaboratively edited hypertext which serves as an index.

143
 
 

cross-posted from: https://lemmy.ml/post/31328788

144
 
 

This is like a clean, simple reincarnation of make. And it is fascinating how it works:

Make is essentially a configuration file which textually describes a directed graph (DAG) of dependencies by their path names, together with embedded shell command lines which build each dependency.

This works more or less well, but if some dependency is missing, one has to add "make clean" commands. Or maybe, just to be sure, "make clean" (which would not be necessary if the tool really unambigously defined the build). Or for example if a system library has changed. Or if an optional dependency appears which was not there before.

And it becomes more complex if build steps run in parallel. Therefore, things like "make config" and so on are needed.

D.J. Bernstein examined these ill-defined cases, and came up with an alternative system, which he called "redo".

Redo turns this inside-out: It uses real shell scripts for building stuff, together with special shell commands that define dependencies. And these commands have dependencies as input, they can for example use what the compiler tells them. (The background is that e.g. in a complex C project with lots of #defines, only the C compiler has a precise picture what it needs). The top-level command runs all these build scripts in the right order. (In fact, they could also be written in Lisp, Java or Guile or whatever, as long as they support the common dependency-defining commands.)

The resulting system is surprisingly simple.

One quality for example is that in a source tree, definitions can be build recursively without any special provisions. No top-level Makefile required.

145
 
 

I don't have much to say, only that I expected flutter to be a bloated fragile abstraction on top of different native GUI APIs, but no.

It's quite fast, relatively easy to develop and it just works.

I'm working on a desktop app that needs a high-perf rust impl, and (for now) flutter looks like a much better choice than tauri.

146
147
148
12
The Leo Text Editor's Home Page (leo-editor.github.io)
submitted 1 month ago* (last edited 1 month ago) by HaraldvonBlauzahn@feddit.org to c/programming@programming.dev
 
 

This is a very interesting but not well-known editor.

Some unusual features it has:

  • it is centered around outlines, this means one can divide a larger source code document into several or many smaller parts
  • it supports generation of output files from such outlines - and can read them back
  • it supports literate programming in a very nice way, and is a bit easier to use than org-mode
  • a section of an outline can appear more than one time in the directed graph of text segments - much like a hard-linked file can appear more than once in a directory tree. For example, one can use this to keep the same text in the on-line help of a CLI program, and in a long-form help document.

Personally, I have used it extensively to generate documentation for a large commercial library around signal processing. The fact that it supports an interlinked "DAG" of text elements made it easy to cross-reference and link important stuff. For exanple, I could maintain a glossary with footnotes, and I could also export it to a braindead ancient source control system called VisualSourceSafe - let a proofreader make changes, and then import it back in, keeping the structure, and merge the corrections via git.

Overall, it can do similar stuff like Emacs + Org-Mode, but while org-modes has a huge number of features, I'd say LEO is a tad simpler.

149
 
 

A high level overview on how zero-copy in iceoryx2 works.

150
view more: ‹ prev next ›