Programming - Tumblr Posts - Page 4

1 year ago

I really love it here! It is a community that is far more open and comfortable with the truth "Listen, no one knows everything. Not even about their specialization. There are always more tricks, tools, techniques and details to learn." So everyone focuses on helping each other instead of thinking everyone else knows everything, and so spend time pretending that we do too. It is much much nicer than any other code community I have run into (With it being about par for maker spaces. Which are usually awesome communities too)

tech twitter : if u aren't a billionaire by 30 u are not gonna make it, if u aren't working for FAANG by 20 u aren't a real programmer, if u don't know everything that goes on in the computer don't even follow me

tech tumblr : oh u don't understand the "hello world" code? DM me I will personally guide u. yes here are some resources. im not a genius bcs I knew everything when I was 6...... everyone starts somewhere don't worry. 🥰

in conclusion I was shocked when I came here


Tags :
1 year ago

Cannot code when anxious

Cannot think logical when anxious. Code requires thinking logically So Cannot code when anxious. BUT Brain cannot multi-task some disorders So Cannot be anxious if I focus on massive sensory overload. So Moose is blasting the same song on max volume into his skull via headset so progress can be made Stupid DIY brain I got handed out by mother nature


Tags :
1 year ago

Oh dear god!

I am SO sorry, that must suck so much to lose a drone to!

But that is also the FUNNIEST thing I have heard in a while.

Just because I build robots and it SO a thing I have had happen, but at least mine can only drive away in 2 dimensions!

Note to self:

When building a drone from scratch, make sure you test your code before taking it outside.

RIP Goldie, The drone. We will miss you dearly. Lost because I forgot to tell it when to turn off the launch code and hover if no user input so it just accelerated...upwards 🙃


Tags :
1 year ago

That is GREAT!

As much as I love developing new things there is something uniquely satisfying about refactoring code or hardware setups.

I tend to make diagrams of the codes architecture after it works, to figure out how to make it work in a maintainable way. It feels like a lovely brainteaser

refactoring

I lied when I said I was going to work next on loading a 3-D model. Sorry, old habit! Actually, I went straight into refactoring. Let me explain...

The English Wikipedia defines refactoring as "the process of restructuring existing computer code . . . without changing its external behavior", which is fairly accurate, though lacking in motivation.

My back-of-mind definition would be "changes to code whose primary purpose is not to add features or solve issues, but to make the codebase easier to maintain".

Back when I worked for corporations, I got in the habit of never mentioning refactoring around anyone who wasn't a software developer. If my boss (or my boss's boss) knew I was making changes (and spending work hours) on something other than approved features or known issues, awkward questions would arise. (Like, do we have a billing code for that?)

Anyone who's worked intimately with a large software project knows that if changes are made only for features and issues, the project will accumulate "technical debt" that makes it difficult to maintain: hard to explain/learn/understand/remember how it works and hard to make changes without introducing bugs.

Both of today's refactorings focussed on the BaseApplication class, which became unwieldy weeks ago. Last night the source file for the class reached 1901 lines of Java code (not counting blanks, comments, and javadoc). I don't place a hard limit on lines of code in a class, but a file containing 1901 LoCs positively screams technical debt. It's especially painful these days, since I'm working on a laptop with a tiny screen and using a track pad instead of a mouse. (I spend lots of time scrolling back and forth, hunting for the lines I need to change.) Cramming as much as possible into a single file makes some sense for a tutorial, but I see the V-Sport project as something I'll be maintaining for many years.

First I split off all the code that deals with physical devices and put that in a new PhysicalDevice class. The change greatly clarified which properties of the physical device matter and how that information is accessed.

Then I split off all the code that deals with texture data into a new Texture class. The new class bundles up 3 related Vulkan resources and provides a clear lifecycle of create/use/destroy. I expect it to minimize duplication of code when the project transitions (sometime in the near future) from a single texture to multiple textures.

I'm subjectively pleased with how smoothly today's refactoring went. One measure of its success is that BaseApplication shrank from 1901 to 1650 lines of code. Still plenty of room for improvement, though!


Tags :
1 year ago

C++ SUPPORTS object oriented programming. It also supports Procedural and Functional programming. ( A fair criticism of C++ is that because it can do everything, it is also very complex. Often using a more focused language is simpler and better for a task )

You can ( And really should ) mix and match programming paradigms. Using the right tool for the right job and all that :)

OMG ALL THIS TIME I'VE BEEN DABBLING IN CODE AND ONLY NOW I UNDERSTAND WHAT OBJECT-ORIENTED PROGRAMMING

OMG ALL THIS TIME I'VE BEEN DABBLING IN CODE AND ONLY NOW I UNDERSTAND WHAT OBJECT-ORIENTED PROGRAMMING ACTUALLY MEANSSSS (honestly I've been scared to learn C for the loooonnngest time and I've only now used it for cs50... it's actually REALLY good for comparing/contrasting with modern languages...like even C++ which looks very similar to C syntax is apparently an object-oriented programming language?? and you have dictionaries so you don't have to make your own hash tables???? those are HUUUUUGGGEEE upgrades imo [i still don't really understand hash functions tbh...])


Tags :
1 year ago

Oh this is WONDERFULL. I very much agree(Although, c++ might be better for the last two), but I am also aware that I am biased since I am one of the freaks who love c and c++, and often look at the compiler outputs in assembly... and LIKE it :p I learned Assembly , then C, then C++, the C#, and ONLY THEN did I get any say over what languages I wanted to learn. The logic being that only at that point did we know enough to ATTEMPT to pick languages. I sorta agree. But I am also aware that learning in such a way is ONLY possible on longer educations like Uni, and not self taught or during apprenticeships or other forms of gaining mastery.

Part 0: Why Would I Ever Want To Touch C?
Part 0: Why Would I Ever Want To Touch C?
Part 0: Why Would I Ever Want To Touch C?

Part 0: Why would I ever want to touch C?


Tags :
1 year ago

Yeeeeeeeeah... Honestly, celebrate your victories and accomplishments. Even if it feels silly or self indulgent. It is important! Simply repeating that you are doing good will make you really FEEL like you are doing good. Which is just fantastic for your mental health and staying motivated.

moose-mousse - Electronic Moose

Tags :
1 year ago

Vocalization of your thoughts can help you solve problems. In the same way that writing them up or making a diagram of the problem can help you fix it. Try tricks people recomend, and if they work for you. Great! Use them! Here is my duck by the way :3

Vocalization Of Your Thoughts Can Help You Solve Problems. In The Same Way That Writing Them Up Or Making

He is so sassy!

Source For More Posts Like This, CLICK HERE To Follow Ultrafacts

Source For more posts like this, CLICK HERE to follow Ultrafacts


Tags :
1 year ago

Good luck! I hope it turns out how you imagine it! :D I have this… great love for diagrams. I mainly use UML-ish ones but I love all types!

They are like… the middle point between the pure idea in your head (That may have missing parts you do not realize, because brains are silly like that) and the finished product.

They are the shaping of ideas and inspiration into reality. Taking shape like trying to fit a formless blob into one or more boxes so it can become real, without harming the core of the idea. It really is... very neat to get this view into peoples head, in a way I have trouble articulating.

This is one of mine(which had to go into a "real" report, so it is a bit formal):

Good Luck! I Hope It Turns Out How You Imagine It! :DI Have This Great Love For Diagrams. I Mainly Use

Making wireframes again

Making Wireframes Again
Making Wireframes Again

Tuesday 8th August 2023

My head has too many ideas that it has come to me making terrible sketch wireframes, hopefully converting this to code makes sense and looks pretty(˶′◡‵˶)

I'm sure there's a quote out there that talks about something ugly can be turned into something beautiful - yeah, that's what's going to happen to these awful sketches.

Wish me luck o(*^▽^*)┛

>> note: have a nice day/night and good luck with your studies and in life!


Tags :
1 year ago

A girl who I took her degree at the same time as me, had taken a bachelor in english before becoming an engineer.

And everyone around her was ASTONISHED that a engineer would be able to write dokumentation that are readable to HUMANS. She have NEVER been unemployed. She was hired FAST.

It is HARD to learn skills that are 100% useless to whatever you end up doing. Do things you like. Study whatever you like. Have whatever hobbies. If they make you a better you, that will make you better at WHATEVER job you will end up doing.

And people WILL hire you for more. Because you WANTING to learn these skills, will naturally do with passion and enthusiasm. And want to do it a lot.

That is what people usually call "Talent".

You have it too! You ARE talented. And I beg of you, allow yourself to delve deep into these passions so you can become the best you, you can be.

The world have need of good people doing their best. Let us make sure we cultivate many such people.

moose-mousse - Electronic Moose

Tags :
1 year ago

Weird fact... try googling this... it is TRUE. Basically, the C++ Committee (Who decides everything C++) have never named a mascot. And so if you google for C++ mascot. Google will show you the most used picture for that phrase. This picture. So the answer to "What is the C++ mascot" is.... this

moose-mousse - Electronic Moose

Tags :
1 year ago
So I Made A GUI For My Parents Campsite. They Wanted A GUI On Tablets, Or Maybe A PC Where They Could

So I made a GUI for my parents Campsite. They wanted a GUI on tablets, or maybe a PC where they could have costumers input the needed info from them.

I can make native GUI's on WIndows, Linux, Android but… this is not the smartest way to make 95% of programs.

You just write a website in HTML, CSS and Javascript, and have all the code in 1 file (You can easily write your own "compiler" that simply copies CSS or Javascript from many files into one file if you want to work with multiple files… And yes, you can write that in HTML and Javascript too)

Here I simply take in the values as strings, sanitize and treat them, and then save them in LocalStorage on the browser.

When you type "Excel" into the first textbox, it reveals 2 extra buttons to download all the data as a CVS file that my parents can open in Excel, and to clear the local storage so the GUI is ready for the next day.

Simple, safe, easy, and will work on any machine that have a browser… meaning them all.

Forget chefs kiss. Programmers KISS is what you want :p


Tags :
1 year ago

So I made an app for PROTO. Written in Kotlin and runs on Android.

Next, I want to upgrade it with a controller mode. It should work so so I simply plug a wired xbox controller into my phone with a USB OTG adaptor… and bam, the phone does all the complex wireless communication and is a battery. Meaning that besides the controller, you only need the app and… any phone. Which anyone is rather likely to have Done.

Now THAT is convenient!

( Warning, the rest of the post turned into... a few rants. ) Why Android? Well I dislike Android less than IOS

So it is it better to be crawling in front of the alter of "We are making the apocalypse happen" Google than "5 Chinese child workers died while you read this" Apple?

Not much…

I really should which over to a better open source Linux distribution… But I do not have the willpower to research which one... So on Android I stay.

Kotlin is meant to be "Java, but better/more modern/More functional programming style" (Everyone realized a few years back that the 100% Object oriented programming paradigme is stupid as hell. And we already knew that about the functional programming paradigme. The best is a mix of everything, each used when it is the best option.) And for the most part, it succeeds. Java/Kotlin compiles its code down to "bytecode", which is essentially assembler but for the Java virtual machine. The virtual machine then runs the program. Like how javascript have the browser run it instead of compiling it to the specific machine your want it to run on… It makes them easy to port…

Except in the case of Kotlin on Android... there is not a snowflakes chance in hell that you can take your entire codebase and just run it on another linux distribution, Windows or IOS…

So... you do it for the performance right? The upside of compiling directly to the machine is that it does not waste power on middle management layers… This is why C and C++ are so fast!

Except… Android is… Clunky… It relies on design ideas that require EVERY SINGLE PROGRAM AND APP ON YOUR PHONE to behave nicely (Lots of "This system only works if every single app uses it sparingly and do not screw each-other over" paradigms .). And many distributions from Motorola like mine for example comes with software YOUR ARE NOT ALLOWED TO UNINSTALL... meaning that software on your phone is ALWAYS behaving badly. Because not a single person actually owns an Android phone. You own a brick of electronics that is worthless without its OS, and google does not sell that to you or even gift it to you. You are renting it for free, forever. Same with Motorola which added a few extra modifications onto Googles Android and then gave it to me.

That way, google does not have to give any rights to its costumers. So I cannot completely control what my phone does. Because it is not my phone. It is Googles phone.

That I am allowed to use. By the good graces of our corporate god emperors

"Moose stares blankly into space trying to stop being permanently angry at hoe everyone is choosing to run the world"

… Ok that turned dark… Anywho. TLDR There is a better option for 95% of apps (Which is "A GUI that interfaces with a database") "Just write a single HTML document with internal CSS and Javascript" Usually simpler, MUCH easier and smaller… And now your app works on any computer with a browser. Meaning all of them…

I made a GUI for my parents recently that works exactly like that. Soo this post:

Electronic Moose
Tumblr
So I made a GUI for my parents Campsite. They wanted a GUI on tablets, or maybe a PC where they could have costumers input the needed info f

It was frankly a mistake of me to learn Kotlin… Even more so since It is a… awful language… Clearly good ideas then ruined by marketing department people yelling "SUPPORT EVERYTHING! AND USE ALL THE BUZZWORD TECHNOLOGY! Like… If your language FORCES you to use exceptions for normal runtime behavior "Stares at CancellationException"... dear god that is horrible...

Made EVEN WORSE by being a really complicated way to re-invent the GOTO expression… You know... The thing every programmer is taught will eat your feet if you ever think about using it because it is SO dangerous, and SO bad form to use it? Yeah. It is that, hidden is a COMPLEATLY WRONG WAY to use exceptions…

goodie… I swear to Christ, every page or two of my Kotlin notes have me ranting how I learned how something works, and that it is terrible... Blaaa. But anyway now that I know it, I try to keep it fresh in my mind and use it from time to time. Might as well. It IS possible to run certain things more effective than a web page, and you can work much more directly with the file system. It is... hard-ish to get a webpage to "load" a file automatically... But believe me, it is good that this is the case.

Anywho. How does the app work and what is the next version going to do?

PROTO is meant to be a platform I test OTHER systems on, so he is optimized for simplicity. So how you control him is sending a HTTP 1.1 message of type Text/Plain… (This is a VERY fancy sounding way of saying "A string" in network speak). The string is 6 comma separated numbers. Linear movement XYZ and angular movement XYZ.

The app is simply 5 buttons that each sends a HTTP PUT request with fixed values. Specifically 0.5/-0.5 meter/second linear (Drive back or forward) 0.2/-0.2 radians/second angular (Turn right or turn left) Or all 0 for stop

(Yes, I just formatted normal text as code to make it more readable... I think I might be more infected by programming so much than I thought...)

Aaaaaanywho. That must be enough ranting. Time to make the app


Tags :
1 year ago

I scared the dog with my sudden screaming laughter...

moose-mousse - Electronic Moose

Tags :
1 year ago

And it is open source.

This is made by… many many people. Very few payed to do it.

And it is better than any other documentation method. Because when you build systems around the betterment of the human race, them you can rely on things like "Nearly every person wants to be a good person." and other such neat facts :3

Announcing the MDN front-end developer curriculum

I had totally missed this announcement when it happened, it really kind of flew under the radar. but I really do feel like it's a big deal.

MDN is one of those sites that I can't live without as a developer and to find out that they're working on creating and refining their own developer curriculum is really exciting.

Now whenever anyone asks me how they can get started in web development I'll have exactly one place to point them to and I know it will be the best resource available. 🤓

Announcing the MDN front-end developer curriculum | MDN Blog
developer.mozilla.org
MDN has created a curriculum for aspiring front-end developers to build a rewarding and successful career. Take a look at the curriculum, wh

Tags :
1 year ago

Yep. Also... Doing things you like and are proud of is good for your mental health. Which makes you more productive ( A bit like how physical training does )

I am right now learning Ruby ( for a potential job ) while training my C++ skill back to what they used to be :p

“it’ll take too long to learn xyz”

learning is everlasting. you do it everyday. you are now just being intentional with where your attention and energy is going. why aim for mastery when you can aim for enlightenment?

the time will pass anyway. do it. learn it. no one is stopping you but you! don’t waste anymore time wishing you were a genius from day 1 then continue staying in the same place. 1 year forward, you’ll wish you had started. stop that cycle and just start now.

the future you bears the fruit the present you labors.

growth is beautiful, don’t knock it.


Tags :
1 year ago

Oooh! Oh! Oh!

Also!

If you do not do web development there are embedded systems. For those of us who like working close to the electronics and/or on small linux computers :3

If you enjoy developing and coding, there are several paths you can pursue:

Front-end development

Back-end development

Full-stack development

It's important to note that there is generally more competition in back-end development compared to front-end. Therefore, securing an internship in back-end development may be more challenging than in front-end.

However, if coding isn't your preference (which doesn't mean you shouldn't be in the field), there are alternative career options you can explore:

DevOps engineering : My next post will be about DevOps

Testing (consider obtaining the ISTQB certificate)

Management of tech projects

These options provide diverse opportunities within the IT industry.


Tags :
1 year ago

What are strings???

So, on the codeblr discord there was a question which is hard to answer unless you already fully understand what a string is... So, what is a string?

And this is a great question! Because to answer it we will learn a hell of a lot!

To answer this, one needs to know what an array really is. This is important in any language you write in. But in most languages it only becomes important to know when you get to optimizing code.

So for most, it is fine to think of arrays simply as collections. But in C, you need to know what they truly are to work with them (Which is why newbies are often taught C to learn these things)

I will use drawings and links to godbolt code examples I made, to help you understand things.

To explain what strings and arrays are, I will use a trick that you may also want to copy if you have a hard time learning concept in programming or electronics.

Try to to "re-invent" it. By going step by step into the things that required it to be invented, and how it was done.

So arrays. They are a way of storing many variables in one place, and work on them very very efficiently.

We start with having variables. Each variable have an address where they are in memory, and a value at that address.

An address is just a number. Nothing more. But to make it clear when we are talking about them, traditionally you write it in HEX. These numbers are marked with "0x", as in, to write "6" in Hex, we write "0x6"

Now, on each address you can store 8 bit. To store values that are larger, we use more than one memory address.

Ok, with all info, let us draw the example we will use, and write the code:

We will have 3 numbers. Each takes 16 bits:

What Are Strings???

https://gcc.godbolt.org/z/cse64Kd6x

(Notice that the adresses counts DOWN. This is for stack and heap reasons we will not explain here. But just know that we count DOWN, not up when it comes to adresses on the stack, which is all we will work with here.)

If we know the type of a variable, we also know how much space it takes.

So to really know a variable, we need to know its type, and its memory address.

Now, if we create these variables one after the other they will be placed right next to each other in memory.

Then we can create a pointer! A pointer have a type they point to, so it knows how much space the variables takes, and a memory address. We will create it pointing at the first variable!

Let us draw it on the example:

What Are Strings???

https://gcc.godbolt.org/z/9abqMjrs3

And now, if we want to work on all of our values, we simply do whatever we want, and then subtract 2 from the pointer to get to the next value, and then work on that one, and so on.

If we want to add 1 to every value, we could do this:

Step 1, add 1

What Are Strings???

Step 2: Move pointer

What Are Strings???

Step 3: Add 1

What Are Strings???

And so on and on! :D

https://gcc.godbolt.org/z/7KGadT868

This is how arrays works. But instead of us having to remember to count DOWN, and what size variables are we have gotten all this build into the language. It also GARANTEES that the variables are placed next to each-other in memory (This is not actually guaranteed when you use single variables like we have in the examples... NAUGTY US!)

So this code does exactly the same as we just did. And as you can see it is MUCH easier:

https://gcc.godbolt.org/z/KWxc939v4

So as you can see, a array is... more or less a pointer that you cannot change (because it always point at the first element), also known as a const pointer. And instead of moving the pointer, we use the index... which is just "The adress of the first variable, and then move it down as many times as the variables size times the variable number we want"

And a string... is a specific kind of array we often need, because we often need strings of characters. A string is a array containing elements that are characters.

If you are using ASCII, that is 8 bit signed values

If you are using UTF-16 then it is 16 bit signed values

See? It is super easy to explain what strings are!

... IF you know what arrays are... and why we use them....


Tags :
1 year ago

That is a very neat idea!

If you like things like that you might want to look into VHDL ( I learned that... some years ago, but have not touched it since ) or Verilog.

They are... programming languages for making logic gate logic.

You combine that with an FPGA, which is essentially a whole lot of NAND gates ( Which as I said, can represent any logic gate system ), and then you can make hardware... via software.

And yes, these essentially do things like your idea. Things that would take a CPU aaaaages to do, can be done very very fast. So you "just" have normal C code, but if it runs onto one of the problems it have hardware for, it uses the hardware.

This is also how graphics cards work, or just floating point operations!

It is insanely cool! :D

What is half-adder and full-adder combinational circuits?

So this question came up in the codeblr discord server, and I thought I would share my answer here too :3

First, a combinational circuit simply means a circuit where the outputs only depends on its input. ( combinational means "Combine" as in, combining the inputs to give some output )

It is a bit like a pure function. It is opposed to circuits like latches which remembers 1 bit. Their output depends on their inputs AND their state.

These circuits can be shown via their logic gates, or truth tables. I will explain using only words and the circuits, but you can look up the truth tablet for each of the circuits I talk about to help understand.

What Is Half-adder And Full-adder Combinational Circuits?

Ok, so an in the case of electronics is a circuit made with logic gates ( I... assume you know what they are... Otherwise ask and I can explain them too ) that adds 2 binary numbers, each which have only 1 character. 

So one number is 1 or 0

And the other number is 1 or 0

So the possible outputs are are 0, 1 and 2.

Since you can only express from 0 to 1 with one binary number, and 0 to 3 with 2, we need to output 2 binary numbers to give the answer. So the output is 2 binary numbers

00 = 0

01 = 1

10 = 2

11 = 3 // This can never happen with a half adder. The max possible result is 2

Each character will be represented with a wire, and a wire is a 0 if it is low voltage (usually ground, or 0 volts) and a 1 if it is high voltage (Voltage depends. Can be 5 volts, 3.3, 12  or something else. )

BUT if you only use half adders, you can ONLY add 2 single character binary numbers together. Never more.

If you want to add more together, you need a full adder. This takes 3 single character binary numbers, and adds them and outputs a single 2 character number.

This means it have 3 inputs and 2 outputs.

What Is Half-adder And Full-adder Combinational Circuits?

We have 2 outputs because we need to give a result that is 0, 1, 2 or 3

Same binary as before, except now we CAN get a 11 (which is 3)

And we can chain full adders together to count as many inputs as we want.

So why ever use a half adder? Well, every logic gate cirquit can be made of NAND (Not and) gates, so we usually compare complexity in how many NAND gates it would take to make a circuit. More NAND gates needed means the circuit is slower and more expensive to make.

A half adder takes 5 NAND gates to make

A full adder takes 9 NAND gates.

So only use a full adder if you need one.

Geeks for Geeks have a page for each of the most normal basic cirquits:

Half Adder in Digital Logic - GeeksforGeeks
GeeksforGeeks
A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, qu

I hope that made sense, and was useful :3


Tags :
1 year ago

Do you have any recommendations for a small project to build using c++? I've been interested in learning c++ for gamedev in godot. I already have programming experience so I woudn't be starting from the basics (and I own A Tour of C++ by Stroustrup), but at this point I'm wondering whether I should just go through A Tour and then just get stuck into some sort of game idea.

I am not familiar with godot (It is on the list... might honestly look into it in a weeks time) I will steal some advice from Jason Turner. Pick a project you think you can do. Because it will be harder than you think. That is just how it is until you get more experienced. In the meantime, as soon as you have the basics (Writing and calling functions, and classes ) I would start doing something that will require Architecture. Not a lot, but something that requires several distinct parts. Thinking gamedev, maybe a character on screen moving. If it seems like a lot to do, then try figuring out how automated tests works in godot. And then write a program that writes basic ZOMBIE tests for a function. You will learn a lot, and will help you write tests for your code later. Try making a very simple BDD diagram before you start. Simply to force you to think about what it is you want. Keep them simple. Here is mine for my robot PROTO:

Do You Have Any Recommendations For A Small Project To Build Using C++? I've Been Interested In Learning

Simple boxes, arrows, and explanations for myself to keep things clear. And PROTO is a complex system with many moving parts. Yours should be way way simpler. Arrows and boxes makes everything clearer. And then start coding! When classes or functions get too big, split them up. If you have trouble splitting them up without everything being dependent on everything, try drawing the diagrams again, and ask yourself what you are really trying to do with that chunk of code, and see if there are any software patterns that fits your needs. Refactor your code after you get it to work, make it easier to change and read. Ignore efficiency. pre-mature optimization is how projects die. Make the code easy to read and easy to change. If you run into efficiency issues later then it will be easy to fix. And keep making the simple diagrams. They will help you become better, by having you think about your plan, and how you are coming along. I hope this was helpful ^~^


Tags :