General Programming Discussion

7803 readers
1 users here now

A general programming discussion community.

Rules:

  1. Be civil.
  2. Please start discussions that spark conversation

Other communities

Systems

Functional Programming

Also related

founded 6 years ago
MODERATORS
76
77
 
 

We are excited to announce that with the latest release of Steam Audio, the complete source code of the Steam Audio SDK is now available as open source. With this release, our goal is to provide more control to developers, which will lead to better experiences for their users, and hopefully valuable contributions back to the wider community of developers using Steam Audio.

78
 
 

I'm planning on creating an AI tournament as a project to test out some of the potential AI performance in a game, eg tic-tac-toe.

I'd like the AI to know the full history of a game instead of the instantaneous game-state because I might want some AI that use the historical data, eg AI that always put in the opposite cell of it's previous move if possible.

The question I am wondering is, what is the best way to setup the tournament.

I have a few options in my headspace:

  1. Write everything in Rust (since I also am semi-interested in getting experience with the language)
  2. Write everything in Python
  3. Write the AI's in anything I want, but interact using stdin/stdout. Connect the AI using some shell script.

There are a few nice things I want to have:

  1. able to run AI ad hoc against each other, or easily modify the tourney. ie I might want to add a new AI that runs against each of the previous AI instead of having the re-run the whole tourney
    • Rust would require a re-compile of the tourney code each time which may not be convenient
    • Options 2 and 3 would be much more convenient since it wouldn't require a full compilation and I can easily write a throwaway script
  2. be able to run it in a somewhat performant way since I might want to simulate many rounds
    • Rust AI would be fast, but to avoid the issue in (1), I might go with solution 3 with the underlying AI being in Rust. But I'm not sure how significant the speed of piping IO between programs compare to if I had wrote everything as a Python program

Any advice on this would be great, cause there might be some options that I might have omitted.

79
 
 

Sorts an array by repeatedly locating the minimum element of an unsorted part and placing it at the beginning.

80
 
 
81
 
 

With this step, we are opening Qt SVG up to support elements beyond SVG Tiny 1.2. This means that we will aim to include useful and common elements from SVG 1.1 and SVG 2.0, if maintenance is reasonably feasible. We will not aim for compliance with these standards but we will keep an eye on feature requests from our users. Further, we are open to contributions of such extensions by the community. So if you miss your favorite SVG element in the list above, fell free to send us some code, preferably on our code review platform.

82
 
 
83
 
 

I fancy learning a new language. I've got experience in Python, PHP, Ruby, Bash and many years ago Java, Haskell and C++. Though I'm absolute dogshit at system languages generally. I GET pointers but I fucking hate having to think about them.

Is Nim nice? Is it better than Rust? I like being a contrarian so I'd rather not learn Rust since it's too fashionable right now. But Nim seems to have that independent, cool streak but still niche. It also seems a little bit like Python but with low level stuff slapped in.

I fancy doing something like some of the following:

  • TUI/ncurses pacman app.
  • Taskade terminal app.
  • Network scanning tool.
  • USB midi tool.
  • Kitchen sink that gargles my balls (optional)

So how is Nim for this? Thoughts? Feelings?

84
 
 

etk is a library for the Ebitengine game engine that simplifies creating graphical user interfaces. The README lists the features and widgets. Boxcars uses etk to greatly simplify UI development, as its single codebase targets web, desktop and Android.

85
 
 

I had this discussion in my workplace and wanted to share and get opinions from the folks here. (I suspect StackOverflow might not appreciate such open ended questions).

Context: We have a microservice involved in pricing signalling to our users. We have an endpoint which have the following:

  • Input: an array of item ID's
  • Output: the expected final price of the given items.

The item prices are quite volatile (and no, it is not crypto related), and is dependent on things like instantaneous supply-demand, promotions, etc.

Since the prices change quite frequently, it became a requirement that we commit to the price that was shown to the user initially, up to a certain time period (eg 5 min after the price was calculated). This improves the UX since the user will be charged as according to what they expected at the start.

Currently, in our system, we achieve this via a JWT, which contains all the details in the request, the obligatory signature, and the expiry set to 5 min from the time it was generated.

After generating this receipt, the FE can then call the endpoint with the JWT which does the actual payment processing using the params encoded in the token. This way, we know that the params + the total cost that is quoted in the JWT originates from our service since we verify that we signed it.

And the system evolves once more. We see that in the system, there is this mechanism, that if the token is expired, we do not reject the request at the charging step. Instead, we call the price endpoint internally using the params provided, and check if the price is the same as in the expired JWT. If it is the same, we process it as normal despite the JWT being expired.

This is where the contention lies. I believe that we should force the user to procure another non-expired JWT and removing this complex logic while others believe in the value of this improved UX where the user doesn't need to restart the whole flow again.

What do y'all think? Which way would y'all architect the endpoint? Or is there something fundamentally wrong with our design (maybe JWT is not the best suited for this use case)?

86
 
 

If you use a compiled language, you should periodically look at Godbolt and see what your code is doing and what changes to your code will do in the compiled output.

In this case a positively insane way of calculating squares and cubes generates 311 lines of ARM assembler output that will swallow your memory. With even something as simple as -O1 on the command line it's replaced by one or two multiplications respectively. With -fwhole-program it removes the functions entirely and interlaces them into the loop in main().

Know your tools. It makes huge differences!

87
 
 

Many thumbnail programs exist that will take a large image and reduce it to a thumbnail for you, often supporting working in batches. But what about turning user-uploaded images into thumbnails? Obviously, you don’t want to simply send a large image to the browser and have HTML resize it, because the quality wouldn’t be great, and your bandwidth would go through the roof. So you need something to handle this process on the fly, which is where this recipe comes in handy.

88
 
 

Chat rooms and programming content

89
90
91
92
 
 

One needs to send 1 mln HTTP requests concurrently, in batches, and read the responses. No more than 100 requests at a time.

Which way will it be better, recommended, idiomatic?

  • Send 100 ones, wait for them to finish, send another 100, wait for them to finish… and so on

  • Send 100 ones. As a a request among the 100 finishes, add a new one into the pool. “Done - add a new one. Done - add a new one”. As a stream.

93
 
 

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

bmakelib is a collection of useful targets, recipes and variables you can use to augment your Makefiles.


I just released bmakelib v0.6.0 w/ the main highlight being the ability to define enums and validate variable values against them.


➤ Makefile:

define-enum : bmakelib.enum.define( DEPLOY-ENV/dev,staging,prod )
include define-enum

deploy : bmakelib.enum.error-unless-member( DEPLOY-ENV,ENV )
deploy :
	@echo 🚀 Deploying to $(ENV)...

➤ Shell:

$ make ENV=local-laptop deploy
*** 'local-laptop' is not a member of enum 'DEPLOY-ENV'.  Stop.

$ make ENV=prod deploy
🚀 Deploying to prod...
94
 
 

garn v0.0.16 is released and includes plugins that make it easy to bundle vite projects and deploy the bundle to github pages.

95
 
 

It used to be tricky to run GDB and connect Valgrind to it, but that’s not the case any more. The 3.21.0 Valgrind release brings new great features that allow using it and GDB much more easily and conveniently in a single terminal.

96
 
 

Hello folks. I'm a backend guy, mostly using Python, Go, and the like. I've learned a bit of Rust and have enjoyed it for embedded.

With that background I'm curious if any mobile devs can give some feedback on the current state of cross-platform (Android, iOS, Web) for simple apps. What I currently have in mind, despite not owning a uterus, is a FOSS menstrual cycle tracker app, using encrypted local storage only (the regularity of this private information being sold by existing apps is very disturbing to me). This means that my reqs boil down to:

  • UI/UX (I suspect this would require platform-specific code)
  • Storage/DB subsystem (probably just use an encrypted sqlite)
  • Optional extras
  • Minimal third-party library usage to potential minimize data leaks as well as limiting possible vectors for ad injection

So, there's really not much to it complexity-wise. Any suggestions on framework or approaches for keeping the codebase DRY as possible (I would want to minimize required effort to update)?

97
 
 

A software project management tool based on nix

98
99
 
 

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

Fed up w/ my ad-hoc scripts to display the targets and variables in a makefile(s), I've decided to write a reusable piece of code to do that: https://github.com/bahmanm/bmakelib/issues/81


The first step toward that would be to understand the common commenting styles. So far I have identified 4 patterns in the wild which you can find below.

Are there any style guides/conventions around this topic? Any references to well-written makefiles I can get inspiration from?


A

VAR1 = foo   ## short one-liner comment
my-target:   ## short one-liner comment 
	…

B

# longer comment which 
# may span
# several lines
VAR1 = foo

## comments can be prefixed w/ more than # 
## lorem ipsum dolor
my-target: 
	…

C

#####
# a comment block which is marked w/ several #s on
# an otherwise blank line
#####
VAR1 = foo

D

#####
#>    # heading 1
#     This is a variation to have markdown comments
#     inside makefile comments.
#
#     ## It's a made-up style!  
#     I came up w/ this style and used it to document `bmakelib`.
#     For example: https://is.gd/QtiqyA (opens github)
#<
#####
VAR1 = foo
100
 
 

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

When writing a (GNU) Makefile, there are times when you need a particular target(s) to be run before anything else. That can be for example to check the environment, ensure variables are set or prepare a particular directory layout.

... take advantage of GNU Make's mechanism of includeing and makeing makefiles which is described in details in the manual:

view more: ‹ prev next ›