• 0 Posts
  • 7 Comments
Joined 1 year ago
cake
Cake day: June 14th, 2023

help-circle
  • While so many things are so much better than they used to be in the programming ecosystem, I feel like entry-level GUI programming is so much worse.

    This will probably be an unpopular opinion, but Visual Basic (pre .NET) was one of the easiest ways to make a simple, contemporary (for the time) GUI. Drag and drop some elements, modify the UI properties, double click and add code. It made for an excellent introduction to programming because the UI portions were simple and intuitive enough to stay out of the way.

    The rest of VB wasn't great. Weird language/syntax/keywords keywords, closed environment, mediocre tooling. But for building UIs? I haven't used anything as easy as that and it's been over 20 years now...

    I don't have any recommendations unfortunately. Almost everything I do is web based or command line. Web UIs aren't terrible, but there's a learning curve and lots of limitations. Haven't found anything for desktop apps I like lately (last one I built was also with tkinter for a small Python project. Bleh.)


  • Best decision I made was taking an internship. I wasn't really looking for one, but through some connections, one basically fell in my lap. It was in old tech I messed with in high school, so I was reluctant, but getting real world programming experience was fantastic. The team was great and I helped solve some interesting problems on a small project of theirs. They kept me on as long as they could (>1 year). I think people can be way to idealistic, especially when starting out. Go get a year or two somewhere, anywhere. You'll have a ton more marketability and control over where you end up with experience and professional references.

    Biggest career regret was waiting around afterwards for a time to try to get hired on at that same place. Not a ton of programming jobs locally and I wanted to continue my work there, but the company went through semi-frequent growth/shrink phases, and my team wasn't able to get me hired in, though they did try for a while. There were plenty of other good things happening in my life during the down-time after this job and before the next, so it's not really something I regret, but I definitely won't wait on a company like that again.




  • Java

    My take on a modern Java solution (parts 1 & 2).

    spoiler
    package thtroyer.day1;
    
    import java.util.*;
    import java.util.stream.IntStream;
    import java.util.stream.Stream;
    
    
    public class Day1 {
        record Match(int index, String name, int value) {
        }
    
        Map numbers = Map.of(
                "one", 1,
                "two", 2,
                "three", 3,
                "four", 4,
                "five", 5,
                "six", 6,
                "seven", 7,
                "eight", 8,
                "nine", 9);
    
        /**
         * Takes in all lines, returns summed answer
         */
        public int getCalibrationValue(String... lines) {
            return Arrays.stream(lines)
                    .map(this::getCalibrationValue)
                    .map(Integer::parseInt)
                    .reduce(0, Integer::sum);
        }
    
        /**
         * Takes a single line and returns the value for that line,
         * which is the first and last number (numerical or text).
         */
        protected String getCalibrationValue(String line) {
            var matches = Stream.concat(
                            findAllNumberStrings(line).stream(),
                            findAllNumerics(line).stream()
                    ).sorted(Comparator.comparingInt(Match::index))
                    .toList();
    
            return "" + matches.getFirst().value() + matches.getLast().value();
        }
    
        /**
         * Find all the strings of written numbers (e.g. "one")
         *
         * @return List of Matches
         */
        private List findAllNumberStrings(String line) {
            return IntStream.range(0, line.length())
                    .boxed()
                    .map(i -> findAMatchAtIndex(line, i))
                    .filter(Optional::isPresent)
                    .map(Optional::get)
                    .sorted(Comparator.comparingInt(Match::index))
                    .toList();
        }
    
    
        private Optional findAMatchAtIndex(String line, int index) {
            return numbers.entrySet().stream()
                    .filter(n -> line.indexOf(n.getKey(), index) == index)
                    .map(n -> new Match(index, n.getKey(), n.getValue()))
                    .findAny();
        }
    
        /**
         * Find all the strings of digits (e.g. "1")
         *
         * @return List of Matches
         */
        private List findAllNumerics(String line) {
            return IntStream.range(0, line.length())
                    .boxed()
                    .filter(i -> Character.isDigit(line.charAt(i)))
                    .map(i -> new Match(i, null, Integer.parseInt(line.substring(i, i + 1))))
                    .toList();
        }
    
        public static void main(String[] args) {
            System.out.println(new Day1().getCalibrationValue(args));
        }
    }
    
    


  • This is a very strange article to me.

    Do some tasks run slower today than they did in the past? Sure. Are there some that run slower without a good reason? Sure.

    But the whole article just kind of complains. It never acknowledges that many things are better than they used to be. It also just glosses over the complexities and tradeoffs people have to make in the real world.

    Like this:

    Windows 10 takes 30 minutes to update. What could it possibly be doing for that long? That much time is enough to fully format my SSD drive, download a fresh build and install it like 5 times in a row.

    I don't know what exactly is involved in Windows updates, but it's likely 1) a lot of data unpacking, 2) a lot of file patching, and 3) done in a way that hopefully won't bork your system if something goes wrong.

    Sure, reinstalling is probably faster, but it's also simpler. If your doctor told you, "The cancer is likely curable. Here's the best regimen to get you there over the next year", it would be insane to say, "A YEAR!? I COULD MAKE A WHOLE NEW HUMAN IN A YEAR!" But I feel like the article is doing exactly that, over and over.