Programming thread

Well, without the IP you can't really change an IP.

If this is a single device to a single network port with no DHCP and a static but unknown IP you have to discover it somehow.

Typical methods: tcpdump/libpcap() to wait for it to send a packet so you know what it's IP address is. arping or simple pings through addresses especially useful if you know it always uses a given subnet.

Something like this might work as it looks like aravis has some discovery capabilities:

I do know the camera and interface ips, issue is how to change it without connecting to it since the connection function is fucked (not that the builtin library functions are much help, since you need to reset the camera, either through manual means or closing the the ethernet connection for them to take effect).
 
I do know the camera and interface ips, issue is how to change it without connecting to it since the connection function is fucked (not that the builtin library functions are much help, since you need to reset the camera, either through manual means or closing the the ethernet connection for them to take effect).
Presumably if the library you have is shit you'll need to delve into the device's native API to figure out how to directly command it to change its IP address.

Maybe something like this: https://github.com/roboception/rc_genicam_api/blob/master/README.md but for whatever cameras you're using.
 
I don't know the language but isn't it what's inheritance for?
I'm still pretty new at this stuff. I dont know what that is.

However, I will say that I figured out what to do. I gotta rewrite a shit ton of code but its gonna be much more organized.

Basically I decided to build out objects for different functions and elements to make my code more organized.

So instead of having a bunch of variables and functions cluttering up my code I have specific objects for different things.

Like one for local storage functions. One of DOM manipulation. One for calculations, etc etc.

Kind of salty that I now have to revise alot of code but I think its best to keep my code organized instead of letting it grow into an unholy niggerlicious javascript monstrosity.
 
Maybe someone here can help since it sounds very basic bitch thing to do in c++. I have a device on an interface with some arbitrary ip (and I know noth their ip), how do I change the device ip (before connecting it) to a specific ip which I need for the connection to be stable. Even a library recommendation would be plenty.
For IPv4, you should be able to assign its MAC address to a static IP in your router settings.

For IPv6, it might be already configured to get a static IP address using SLAAC. Or you could use its fe80 address, which should be constant.
 
The project I'm currently working on involves a bunch of math calculation and moving parts as well as constant changes to the DOM every second, I used console.time( ) inside of a setInterval function and it came out with 0.13 ms but another project that I made that only has one simple script that injects the header and footer into each page does .83ms.

Is using objects for almost everything the reason why my code seems to be so well optimized?
 
The project I'm currently working on involves a bunch of math calculation and moving parts as well as constant changes to the DOM every second, I used console.time( ) inside of a setInterval function and it came out with 0.13 ms but another project that I made that only has one simple script that injects the header and footer into each page does .83ms.

Is using objects for almost everything the reason why my code seems to be so well optimized?
In the submillisecond range, you're likely measuring noise, either random noise or page-dependent noise.
 
In the submillisecond range, you're likely measuring noise, either random noise or page-dependent noise.
So Javascript code being executed on my shit ass pc can do several mathematic calculations and update the DOM pretty much instantly? Makes it easy to optimize my code then.
 
So Javascript code being executed on my shit ass pc can do several mathematic calculations and update the DOM pretty much instantly? Makes it easy to optimize my code then.
The JavaScript interpreters in modern browsers are made of pure black magic. There have been thousands and thousands of man-hours put in them to make them run as fast as possible. Not to mention that the computer they run on can do billions and billions of them per second. So unless by "several" mathematical calculations you mean hundreds of billions of them, execution time generally won't matter that much. The DOM is also heavily optimized, JS simply submits some shit to the browser which updates some data structures in C/C++ really fast. Unless you're updating thousands of DOM objects with complicated CSS and extensive tangles of event handlers, that too will be negligible.

A general rule to follow about optimization is that it's generally pretty unnecessary. Knuth said that premature optimization is the root of all evil, and he's right. Trying to "optimize" code and hurting readability for a completely negligible gain is just retarded. That's not to say that you should never worry about performance, however. Think of things like algorithmic complexity and the size of your data before things like "Is <language feature> faster than <other feature>?" That's a common trap people fall for. In reality, when you write code a compiler written by people much smarter than you turns it into machine instructions that often run almost as fast as theoretically possible, even in lower-level languages like C. You're expected to write code that you can understand first, then the compiler handles the grisly bits, which are usually machine-dependent and extremely tedious. So using objects for everything probably doesn't really have any effect on how optimization is performed. If anything, it might hamper it if you use very complicated OOP features. On the other hand, it might make it 1% faster.

TL;DR: You're going through a stupid phase that a lot of programmers do. Just write things and if they're slow make high-level logic changes that improve performance by 800%. Learn data structures and algorithms. A program with good algorithms written in Python will run faster than a bad one in hand-optimized assembly because the bad algorithm has to do exponentially more operations the larger its input is.
 
The project I'm currently working on involves a bunch of math calculation and moving parts as well as constant changes to the DOM every second, I used console.time( ) inside of a setInterval function and it came out with 0.13 ms but another project that I made that only has one simple script that injects the header and footer into each page does .83ms.

Is using objects for almost everything the reason why my code seems to be so well optimized?
One thing to note here is that you're measuring with console.time(). JavaScript is JIT compiled, so at first the browser executes the code with interpreting it. After a function ran a couple of times it is then compiled down to machine code and thus gets faster. So it very well can be that you measured the cold start for your header and footer and for your mathematical code you measured the optimized output.

In Chrome at least, in the DevTools, there is a tab for performance profiling. You click record and see which function takes how much time and even how much time was spent on compiling etc.
 
I'm still pretty new at this stuff. I dont know what that is.
Good on you for writing code instead of reading all day, but inheritance is a key feature of OOP languages and you should do some research into it. It can be overused to poor effect but with planning is very useful.
So instead of having a bunch of variables and functions cluttering up my code I have specific objects for different things.
1. Are you storing a bunch of functions but no variables in an object? Try using namespaces.
2. Are you storing functions in an object inside of another object? This is called composition and is considered less disastrous than inheritance. It's cool if you figured this out on your own but it's a well known paradigm so look into it.
Kind of salty that I now have to revise alot of code but I think its best to keep my code organized instead of letting it grow into an unholy niggerlicious javascript monstrosity.
You'll find a balance of when you should refactor code, but it's part of anything that grows.
 
In reality, when you write code a compiler written by people much smarter than you turns it into machine instructions that often run almost as fast as theoretically possible, even in lower-level languages like C.
Your post is largely on point, but this part is kind of a meme. GCC and Clang still miss plenty of vectorization opportunities, and compilers for more niche languages leave all kinds of low-hanging fruit unpicked simply because they lack the manpower or prioritize other tradeoffs.
 
Your post is largely on point, but this part is kind of a meme. GCC and Clang still miss plenty of vectorization opportunities, and compilers for more niche languages leave all kinds of low-hanging fruit unpicked simply because they lack the manpower or prioritize other tradeoffs.
Yeah, they're also sort of 'one-size-fits-all' solutions, there's always going to be shit that falls through the cracks.
In theory, if you can find a compiler engineered toward the configuration you're targeting that supports the language features you're using, you're going to be better off.
Realistically, there's never an ideal solution, life is just an endless sequence of compromises and half-measures

One of my professors told us a story about how he was writing performance critical C++ code, a couple decades back, and his team hit a wall as far as getting things to run within their time window. He ended up rewriting large portions in pure assembly and was able to hit his target.
 
incoming low quality post

I guess you're right that they're not nearly as fast as theoretically possible. They are instead about an order of magnitude slower. It still doesn't matter that much worrying about 2 slightly different ways to state one function because it will be converted to some SSA that gets optimized to hell and ends up mostly the same.
Your post is largely on point, but this part is kind of a meme. GCC and Clang still miss plenty of vectorization opportunities,
Vectorization has a limited number of use cases, and IIRC it has certain qualities that make it really hard for compilers to take arbitrary code and SIMDify it. I think certain optimized functions use weird half-unrolled loops when there isn't an intrinsics-based or assembly implementation for the platform.
compilers for more niche languages leave all kinds of low-hanging fruit unpicked simply because they lack the manpower or prioritize other tradeoffs
This is an implementation problem with the languages and not a problem with compilers in general, and he seems to be most interested in mainstream languages anyway.
 
  • Like
Reactions: Marvin
Good on you for writing code instead of reading all day, but inheritance is a key feature of OOP languages and you should do some research into it. It can be overused to poor effect but with planning is very useful.
I'll read into it.
1. Are you storing a bunch of functions but no variables in an object? Try using namespaces.
A few objects are all functions. Like I have one called calc that I store most of the mathematic functions in and another one called events that loads all of my event listeners.

I'll read up on name spaces.
2. Are you storing functions in an object inside of another object? This is called composition and is considered less disastrous than inheritance. It's cool if you figured this out on your own but it's a well known paradigm so look into it.
Yes actually. I have a nested object in data called handle and its for all of the localstorage functions. I also have an object with two nested objects, there is one called type that has a bunch of items in the game and another one called get that calculates the properties of some of the items in my game.

Btw I feel like its cringe that I'm making a game in javascript but my logic is that it will look good in my portfolio because it shows potential clients/employers that I'm capable of building a fully functioning application. But also its a fun project and I can try and monetize it.
 
Last edited:
inheritance is a key feature of OOP languages and you should do some research into it
it's a well known paradigm so look into it
Learning shit on your own is an important skill to gain, but this always reminds me of that stuff Feynman said about explaining it to a 5 year old. Why can't you just tell him instead of sending him on a journey of self discovery in the Himalayan mountains?

Let's say you have a Retard class with some data and methods in it. You realize you also have some Special Retards that can't speak properly, so you add some extra data and change their speaking method.

That's inheritance. You can re-use the same shit and add on top of it without having to rewrite it, and if you change the Retard class it will also change the Special Retards unless they override the method.
 
I'm doing a little project to try and achieve some basic automation using Arduino stuff. Not anything super groundbreaking like full on robots or anything but basic stuff.

Any tips or tricks for writing Arduino stuff? I'll probably stay away from a lot of the heavy duty OOP stuff and mostly just stick to the C stuff.

I did basically finish that other C project, though I didn't get all the way to the end. I realized I couldn't release it without connecting my KF account to the project since I talked about it here. So I lost all interest in actually finishing it.
I've heard async Java is actually pretty decent. In fact I've heard it is one of the easiest languages to do async in. The JVM and async are apparently Javas only real benefits. This comes from someone who hates Java with a burning passion btw.

bjarne wins once again
I hate him for not just making C with classes but I must admit he is right about C++ in relation to rust.
 
  • Like
Reactions: y a t s
Back