programming

258 readers
1 users here now

  1. Post about programming, interesting repos, learning to program, etc. Let's try to keep free software posts in the c/libre comm unless the post is about the programming/is to the repo.

  2. Do not doxx yourself by posting a repo that is yours and in any way leads to your personally identifying information. Use reports if necessary to alert mods to a potential doxxing.

  3. Be kind, keep struggle sessions focused on the topic of programming.

founded 2 years ago
MODERATORS
26
27
 
 

Spent day 16 trying to get elixir working with emacs. Hope you all are doing well with the current problem.

17 looks fun, its building a 3 bit VM. Maybe Ill start skipping around instead of going in order.

@Enjoyer_of_Games@hexbear.net @Speaker@hexbear.net @gay_king_prince_charles@hexbear.net @iByteABit@hexbear.net @PaX@hexbear.net

28
1
submitted 6 months ago* (last edited 6 months ago) by KnilAdlez@hexbear.net to c/programming@hexbear.net
 
 

I recently had to deal with debugging chatgpt code, and though it was written clearly, it just seemed so ugly and hard to read to me. So I started to think about what I like and what I don't like when reading code. My personal guidelines for beautiful code are:

  • space out code into functionally similar chunks. That way it's easy for my eyes to separate the steps of the code. (Often this is code that is only used once, so there is no need to put it in it's own function)
  • comments are for clarity, and too many make clarity worse.
  • similarly, doc comments in 2024 need to be completely rethought. I already have the actual documentation open on my screen most likely, no need to put the same information in your code. (yes, I know that java and others generate documentation from doc comments, and I don't like it)
  • functions should be ordered by order of execution. Reading down the code should be like reading a book, telling the story of the code's execution. For an OOP language this should pretty well line up with layers of abstraction as well.
  • python should be wiped from the face of the earth.
  • self-documenting code (which is to say code with very long variable names) is bad practice. Once again, the code should be able to be read like a book, you wouldn't name the protagonist of Lord of the Rings 'Ring_barer_to_mordor_hobbit' just name variables something memorable and useful and move on.
  • of course, the opposite, variables just named something meaningless like 'a' should only be used in the most limited of scopes. Loops, lambda functions, etc.
  • There should be consideration for how the code flows on the screen
  • curly brackets in C-like languages should always have their own line, with the exception of the start of functions and short if/else statements.

I don't know, these are just things that I have noticed I like to see in code. This could be the ravings of a lunatic as well.

spoilera tab is 2 spaces

29
1
Advent of Code 2024 Day 15 (adventofcode.com)
submitted 6 months ago* (last edited 6 months ago) by zongor@hexbear.net to c/programming@hexbear.net
30
31
 
 

Hey all sorry I haven't posted in a bit, lifes gotten a bit hectic but im back to posting, hopefully daily. Heres a thread for the last few days, haven't been able to look at them at all but might switch from Elixir to something I know like Go just to make it a bit easier.

@Enjoyer_of_Games@hexbear.net @Speaker@hexbear.net @gay_king_prince_charles@hexbear.net @iByteABit@hexbear.net @PaX@hexbear.net

32
 
 

Its antenna time. Maybe its just a me thing but the input reminds me a lot of Rogue/Angband?

@Enjoyer_of_Games@hexbear.net @Speaker@hexbear.net @gay_king_prince_charles@hexbear.net @iByteABit@hexbear.net

33
 
 

Time to fix the rope bridge. Hope everyone has had time to do this, I got sidetracked and now am super behind.

@Enjoyer_of_Games@hexbear.net @Speaker@hexbear.net @gay_king_prince_charles@hexbear.net @iByteABit@hexbear.net

34
 
 
35
36
1
Advent of Code 2024 Day 5 (adventofcode.com)
submitted 7 months ago* (last edited 7 months ago) by zongor@hexbear.net to c/programming@hexbear.net
 
 

We all know that printers are demonic but here we are trying to program one. Lets print some safety manuals!

@Enjoyer_of_Games@hexbear.net @Speaker@hexbear.net @gay_king_prince_charles@hexbear.net @iByteABit@hexbear.net

37
38
1
Advent of Code 2024 Day 3 (adventofcode.com)
submitted 7 months ago* (last edited 7 months ago) by zongor@hexbear.net to c/programming@hexbear.net
 
 

Time to break out the hex editors and fix some corrupted memory.

Also fun with regex I expect. Or if you go full throttle and make a lexer/parser out of it.

@Enjoyer_of_Games@hexbear.net @Speaker@hexbear.net @gay_king_prince_charles@hexbear.net @iByteABit@hexbear.net

39
1
Advent of Code 2024 Day 2 (adventofcode.com)
submitted 7 months ago* (last edited 7 months ago) by zongor@hexbear.net to c/programming@hexbear.net
 
 

I did not have any time today to work on AoC. I spent today in meetings or working on a testing automation in Emacs Common Lisp.

Hopefully the rest of you had time to validate the safe reports from the nuclear fusion/fission plant.

@Enjoyer_of_Games@hexbear.net @Speaker@hexbear.net @gay_king_prince_charles@hexbear.net

40
 
 

I want some perspective, as I have only every worked at small companies where there's only one engineering team with <10 people

41
1
Advent of Code 2024 Day 1 (adventofcode.com)
submitted 7 months ago* (last edited 7 months ago) by zongor@hexbear.net to c/programming@hexbear.net
 
 

Alright so im going to force myself to create a post for this daily and maybe this will help force me to actually learn Elixir this year.

Please use Spoiler tags for your code snippets if they reveal answers.

Day 1 was interesting. Elixir is different, but it kinda reminds me of doing functional JavaScript but is wayyyyy nicer. It has so many tools to do stuff and the pattern matching is very powerful.

If anyone else wants me to tag them I can do that but I think @Enjoyer_of_Games@hexbear.net was the only one.

Heres my solution for Part 1:

spoiler

"input"    
    |> File.read!()
    |> String.split("\n")
    |> Enum.map(&String.split/1)
    |> Enum.filter(fn list -> length(list) == 2 end)
    |> Enum.map(fn [a, b] -> {String.to_integer(a), String.to_integer(b)} end)
    |> Enum.unzip()
    |> Tuple.to_list()
    |> Enum.map(&Enum.sort/1)
    |> Enum.zip()
    |> Enum.map(fn {a, b} -> abs(a - b) end)
    |> Enum.sum()

~~Ill post Part 2 later if I get time.~~ I had time, heres part 2:

spoiler

"input"    
    |> File.read!()
    |> String.split("\n")
    |> Enum.map(&String.split/1)
    |> Enum.filter(fn list -> length(list) == 2 end)
    |> Enum.map(fn [a, b] -> {String.to_integer(a), String.to_integer(b)} end)
    |> Enum.unzip()
    |> Tuple.to_list()
    |> Enum.map(&Enum.sort/1)
    |> (fn [list1, list2] -> {list1, Enum.frequencies(list2)} end).()
    |> (fn {list1, freqs} ->
          list1
          |> Enum.map(&{&1, Map.get(freqs, &1, 0)})
          |> Enum.filter(fn {_, count} -> count != 0 end)
          |> Enum.map(fn {value, count} -> value * count end)
        end).()
    |> Enum.sum()

42
 
 

If so what language will you be using/learning

I’m planning on learning either elixir or gleam right now.

If you have no idea what I am talking about. Advent of Code is a yearly coding puzzle that is done by Eric Wastl since December of 2015.

https://adventofcode.com/2024

43
 
 

So I have an interview coming up sometime in the next 2 weeks and I have to do a few coding and SQL problems as part of it. I wanna start practicing now because I've gotten a bit rusty on algs and such. Does anyone have any suggestions on like array sorts and such to work on or like code golf sites to use? I have Leetcode pulled up and will be working a bit through that today but I just wanna get in as much practice as I can leading up to the interview. I donno when the interview will be but I just heard through the grapevine that there will be one.

I've been working on my own webdev stuff but the most I've had to touch JavaScript for is basically conditionals and loops, so I feel like I've fallen down on the other stuff a bit.

TIA

44
45
46
47
48
49
50
view more: ‹ prev next ›