351
1
Happy Holidays (tinyurl.com)
submitted 2 years ago by yogthos@lemmy.ml to c/programming@lemmy.ml

the code

(ns index)

(defn prep-canvas []
  (let [can (js/document.createElement "canvas")
        ctx (.getContext can "2d")
        width js/window.innerWidth
        height js/window.innerHeight]
    (set! can.style "position: absolute; top: 0px; left: 0px;")
    (set! can.width width)
    (set! can.height height)
    (js/document.body.appendChild can)
    {:canvas can
     :context ctx
     :width width
     :height height}))

(defn rand [n]
  (js/Math.floor (* (js/Math.random) n)))

(defn render-snowflake [{:keys [context]} {:keys [x y size]}]
  (set! context.fillStyle "#fff")
  (set! context.font (str size "px serif"))
  (.fillText context "*" x y))

(defn snowflake-step [{:keys [height]} {:keys [x y dy] :as snowflake}]
  (set! snowflake.y (if (> y height) (- 20) (+ y dy)))
  (set! snowflake.x (+ x (- (js/Math.random) 0.5))))

(defn gen-snowflakes [n {:keys [width height]}]
  (->>
   (range n)
   (map
    (fn [_]
      (let [size (+ (rand 10) 2)
            x (rand width)
            y (rand height)]
        {:size size
         :x x
         :y y
         :dy (inc (js/Math.random 10))})))
   (doall)))

(defn animation-loop [step-fn]   
   (step-fn)
   (js/window.requestAnimationFrame (partial animation-loop step-fn)))

(defn draw-text [{:keys [context width height]} text]
  (set! context.fillStyle "#fff")
  (set! context.font "100px serif")
  (context.fillText text (* width 0.3) (* height 2/6) (* width 7/8)))

(defn draw-terrain [{:keys [context width height]} fill growing?]
  (set! context.fillStyle fill)
  (context.beginPath)
  (context.moveTo -500 (if growing? height height))
  (loop [x 0
         y (if growing?
             (- height 100)
             (- height 400))]
    (if (< x width)
      (let [x (+ x (+ 10 (rand 20)))
            y (if growing?
                (- y (rand 10))
                (+ y (rand 10)))]
        (context.lineTo x y)
        (recur x y))
      (context.lineTo (+ x 100) height)))
  (context.fill))

(let [background (prep-canvas)
      text-layer (prep-canvas)
      {:keys [context width height] :as snow} (prep-canvas)
      terrain (prep-canvas)
      snowflakes (gen-snowflakes 800 snow)]
  (background.context.fillRect 0 0 width height)
  (draw-text text-layer "Happy Holidays!")
  (draw-terrain terrain "#fff" true)
  (draw-terrain terrain "#ddd" false)
  (animation-loop
   (fn []
     (set! context.fillStyle "#000")
     (context.clearRect 0 0 width height)
     (doseq [sf snowflakes]
       (render-snowflake snow sf)
       (snowflake-step snow sf)))))
352
5
submitted 2 years ago by yogthos@lemmy.ml to c/programming@lemmy.ml
353
-1
submitted 2 years ago by yogthos@lemmy.ml to c/programming@lemmy.ml
354
6
Burnout ≠ Working Too Much (terriblesoftware.org)
submitted 2 years ago by yogthos@lemmy.ml to c/programming@lemmy.ml
355
4
submitted 2 years ago by bahmanm@lemmy.ml to c/programming@lemmy.ml

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

After nearly 2 years of work, I'm excited to release the first version of bjForth, featuring partial JONESFORTH compatibility and initial Java interop.

Grab it and start hacking: https://github.com/bahmanm/bjforth/releases/tag/v0.0.2

PS: bjForth is a Forth (indirect threaded) written entirely in Java and its execution model is influenced by that of JONESFORTH.

356
2
submitted 2 years ago by bahmanm@lemmy.ml to c/programming@lemmy.ml

Hey all.

First off, bjForth is a Forth written from the ground up with modern Java and its execution model is largely influenced by that of JONESFORTH.

Currently I'm working on Java inter-op and would like to ask for your opinions/experience on semantics and syntax.

The relevant GitHub issue.

Thanks in advance.

357
2
submitted 2 years ago by yogthos@lemmy.ml to c/programming@lemmy.ml
358
3
Map of GitHub (anvaka.github.io)
submitted 2 years ago by yogthos@lemmy.ml to c/programming@lemmy.ml
359
2
submitted 2 years ago by yogthos@lemmy.ml to c/programming@lemmy.ml
360
9
submitted 2 years ago by JRepin@lemmy.ml to c/programming@lemmy.ml

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

The Khronos Group, an open consortium of industry-leading companies dedicated to creating advanced interoperability standards, has announced the release of Vulkan 1.4, the latest version of its cross-platform 3D graphics and compute API. Vulkan 1.4 integrates and mandates support for many proven features into its core specification, expanding the functionality that is consistently available to developers, greatly simplifying application development and deployment across multiple platforms.

The Vulkan 1.4 specification consolidates numerous previously optional extensions, features, and increased minimum hardware limits, many of which were defined in the Vulkan Roadmap 2022 and 2024 milestones and associated profiles, including:

  • Streaming Transfers: Vulkan 1.4 imposes new implementation requirements to ensure portable, cross-platform applications can stream large quantities of data to a device while simultaneously rendering at full performance.
  • Previously optional extensions and features critical to emerging high-performance applications are now mandatory in Vulkan 1.4, ensuring their reliable availability across multiple platforms. These include push descriptors, dynamic rendering local reads, and scalar block layouts.
  • Maintenance extensions up to and including VK_KHR_maintenance6 are now part of the core Vulkan 1.4 specification.
  • 8K rendering with up to eight separate render targets is now guaranteed to be supported, along with several other limit increases.
361
4
submitted 2 years ago by yogthos@lemmy.ml to c/programming@lemmy.ml
362
3
submitted 2 years ago by yogthos@lemmy.ml to c/programming@lemmy.ml
363
13
submitted 2 years ago by vfreire85@lemmy.ml to c/programming@lemmy.ml

Pretty straightforward: what tips and advice would you give me if I were to start an open source project of a game? Where to share my intention of beginning this project, where to find contributors, how to organize the workflow etc.

364
2
submitted 2 years ago by yogthos@lemmy.ml to c/programming@lemmy.ml

Peter Norvig wrote a sudoku solver, not by using TDD, but using old-fashioned engineering: http://norvig.com/sudoku.html

Ron Jeffries' attempts:

http://xprogramming.com/articles/sudokumusings/

http://xprogramming.com/articles/oksudoku/

http://xprogramming.com/articles/sudoku2

http://xprogramming.com/articles/sudoku4

http://xprogramming.com/articles/sudoku5

And, as dessert (Ron is very frank about his failures):

This is surely the most ignominious debacle of a project listed on my site, even though others have also not shipped. (Sudoku did not ship and will not. Shotgun will go forward if the Customer wants to.)

http://xprogramming.com/articles/roroncemore/

365
8
submitted 2 years ago* (last edited 2 years ago) by yogthos@lemmy.ml to c/programming@lemmy.ml
366
3
submitted 2 years ago by yogthos@lemmy.ml to c/programming@lemmy.ml
367
6
submitted 2 years ago by yogthos@lemmy.ml to c/programming@lemmy.ml
368
5
submitted 2 years ago by yogthos@lemmy.ml to c/programming@lemmy.ml
369
0
submitted 2 years ago by bahmanm@lemmy.ml to c/programming@lemmy.ml

bmakelib (which is a minimalist standard library for GNU Make) v0.8.0 was released last week.

The highlight of the release is the ability to use maps/dictionaries in your makefiles!

Here's the example from the release page:

$(call bmakelib.dict.define,THIS_BUILD)
$(call bmakelib.dict.put,THIS_BUILD,arch,x86_64)
$(call bmakelib.dict.put,THIS_BUILD,dir,/tmp/my-app/build)

some-target :
	@echo BUILD.arch = $(call bmakelib.dict.get,BUILD,arch)  # x86_64
	@echo BUILD.arch = $(call bmakelib.dict.get,BUILD,dir)   # /tmp/my-app/build
370
3
submitted 2 years ago* (last edited 2 years ago) by bahmanm@lemmy.ml to c/programming@lemmy.ml

If there was one reason I liked coding in Java, it'd be AssertJ and its brilliant extensibility.

The image is an example of it from bjForth

The ability to create custom assertions makes the test code concise and read naturally.

371
0
submitted 2 years ago by yogthos@lemmy.ml to c/programming@lemmy.ml
372
3
submitted 2 years ago by yogthos@lemmy.ml to c/programming@lemmy.ml
373
2
Neuro Nostalgia (neuronostalgia.com)
submitted 2 years ago by yogthos@lemmy.ml to c/programming@lemmy.ml
374
1
submitted 2 years ago by yogthos@lemmy.ml to c/programming@lemmy.ml
375
8
submitted 2 years ago by JRepin@lemmy.ml to c/programming@lemmy.ml

This article compares two tools, Sanitizers and Valgrind, that find memory bugs in programs written in memory-unsafe languages. These two tools work in very different ways. Therefore, while Sanitizers (developed by Google engineers) presents several advantages over Valgrind, each has strengths and weaknesses. Note that the Sanitizers project has a plural name because the suite consists of several tools, which we will explore in this article.

view more: ‹ prev next ›

General Programming Discussion

10011 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 7 years ago
MODERATORS