#code-talk

2 messages Β· Page 25 of 1

long raft
#

maybe only twice as fast as 32 bit floating point

#

i always expect it to be like 10x faster but meh

fickle aurora
#

https://pastebin.com/AiqEAidL is a multithreaded test code that I wrote a while ago and it just works by passing the second value as your number of threads, and it is quite interesting how you can get different speeds depending on the number of threads - they aren't linear speeds by any chance

#

these are the test results I got for speed, though I think what affected results the most was dividing the unsigned long int by the number of threads on line 17

#

dividing by 3 gave the worst performance from everything .. though it is good to note, this was done on ARM7v71 with 1200Mhz and 4c/4t, it is interesting that it had 9 seconds of run time for both 4 threads and 8 threads and I have not been able to replicate that at any other number of threads

long raft
#

yea division is always tough.

#

comparable to square root

devout ivy
#

Their FPU is integral to the CPU core in armv6hf onwards. Compulsory in all A profile ARMv7 implementations (optional in M profile, I'll admit I dont know about R) and all ARMv8 cores regardless of profile

#

Very little functional difference between how ARM and x86 handle floating point or any other math. Only major difference is the more widespread adoption of SIMD operations in x86, 128 bit wide SIMD is present in ARMv8 but modern intel and AMD both have 256 bit wide and intel also have some cores with 512 bit wide

pure sierra
#

would it be hard to make a fpu bitcoin miner ?

fickle aurora
#

well floating point math can be done on the general purpose registers, it's just that it's more precise and faster to calculate in the FPU which is what I am trying to get at

#

for example, AVR has no fancy FPU at all, and it can certainly calculate floating point

pure sierra
#

i like arduino

fickle aurora
#

yeah arduino is like python, it runs horribly slow

pure sierra
#

dont tell me that

fickle aurora
#

you need to use Atmel Studio to get the most of AVR

pure sierra
#

damn u puritans

fickle aurora
#

well, the studio isn't what makes it, I mean, you could write your own compiler for AVR but it would be a waste of time

pure sierra
#

are you saying the compiling is slow or the result ?

fickle aurora
#

well arduino is a framework, like a runtime for your programs

pure sierra
#

i thought it was just an editor & bootloader

fickle aurora
#

whether you use libraries in it or not, anything you compile in it will rely on the arduino framework when it runs

#

yeah the bootloader is essentially like the runtime

pure sierra
#

yeah, so it gets compiled into it

#

like using jquery for js

fickle aurora
#

when you program AVR in avr-asm and upload it with an Atmel programmer, it will not use a bootloader, it will run natively

#

you can use arduino bootloader in atmel studio as well

#

when I started using avr-asm I stopped using arduino for it entirely and focused on doing everything in assembly to further expand my capability

#

some of the chips don't even have a multiply or divide instruction so you have to make a function to do that

pure sierra
#

but here's the thing, time, for me the time saved using arduino and all its available libraries is worth way more than any performance difference on a 8Mhz chip...

fickle aurora
#

well with something like the attiny10, you can only fit tiny programs on it, and you probably may never need to divide numbers on it

#

it has add, subtract but no multiply or divide instruction

pure sierra
#

sure, but think about all the modules that make arduino so good, having to write your own 'drivers' for them

fickle aurora
#

yeah it is a pain to deal with i2c modules in assembly because you have to write all the functions to handle the serial communication

#

but once you make what you need for the basics of data transfer, you can do way more than arduino can do since you can choose when to send a bit and whatnot

pure sierra
#

i think sure, say you had a big project that you needed every little bit of performance and it was going to sell a million units, go atmel/assembly, but generally im just tinkering for myself so quicker the better as hhalf my projects never get finished

fickle aurora
#

yeah the performance is better but also the thing is that if you wanted to send custom messages via serial, it is much harder to do in arduino compared to at the assembly level

pure sierra
#

how custom, ? i can send bits or bytes via serial

fickle aurora
#

timing is a big deal for serial comms as well

pure sierra
#

baud rate ?

fickle aurora
#

so if arduino's code happens to run too slow for something that requires precise timing, that can cause issues

#

separately from baud rate, there are things like buffer registers for example

#

when data comes in or goes out, you have to read or write it from a buffer register, then deal with that data in a timely manner before another message is sent or received

pure sierra
#

ive wondered about this, can a serial input fill up if you dont read from it ?

fickle aurora
#

I have to read up on it, but I think it said in the protocol that it blocks until the buffer is cleared

pure sierra
#

so , the sender would get some kind of fail event ?

fickle aurora
#

the same thing happens with computers when too many connections start but then never acknowledge, filling up socket queue/buffers and then this causes denial of service, since all the queue slots are filled

#

so to fix a basic denial of service with a socket queue, you have to basically make a timeout function that measures the time a connection to the socket started, and if the 3 way handshake is not completed in a timely fashion, you should close() the connection to free up a spot in the queue

#

in serial communication, you can have the same issue theoretically because of the data buffer

#

well in i2c, parity is very simple, so it just wouldn't send an acknowledge back to the sender if the buffer blocked

long raft
fickle aurora
#

well ideally for bitcoin, there should be dedicated math coprocessors, and those used to be a thing at one time in history

long raft
#

its more like just the circuitry for calculating the hash

#

generally modern processors are beasts with floating point calculations, but always memory access is a throttle. same on the GPUs

pure sierra
#

but they do it with asic

long raft
#

this is why everybody tries to turn everything into matrix math because they know how to optimize those calculations for good memory access

#

so the compute power is there, but its not worth the cost in energy

fickle aurora
#

it is kind of sad that most software will never utilize all of the FPU

long raft
#

its really hard

fickle aurora
#

like for me, I don't have AVX-512 support nor AVX2, but I'll probably never need it because nothing uses it

#

and there's just a handful of games now that require AVX1

long raft
#

games requiring cpu features? whyy

#

surely some library theyre using a static binary of

fickle aurora
#

they're using AVX for better game performance

#

it comes down to what I was saying before, you can calculate floating numbers in any cpu register, but if you use the specialized FPU registers or the special math extensions, you will have significantly better performance and higher accuracy

#

however, the software has to support using those extensions

#

you can't use an if statement in this case, because it's machine code level, you'd have to make a separate version of your game for non-AVX, AVX2, and AVX-512 so you'd need 3 different compiled versions if you were going to offer people a choice of which one to support - or you could pick one that most people can use - most software probably out of worries of userbase just simply don't use any of them ... it is kind of like when we used to have x86, amd64, Itanium2, VAX, Alpha, DEC and all these different architectures with various instruction sets ... now most of the computer world is amd64 (now referred to as x86-64 or x64 as AMD and Intel decided to come to one standard)

fickle aurora
fickle aurora
#

good example of why compilers can be bad compared to handwritten assembly

#

for the assembler, I just used nasm and for linking I used Link.exe from MSVC Tools 14.29.30037 and libraries were in the Windows Kit 10.0.20348.0 (both you have to install as components in visual studio)

#

if you want to make it into a DLL instead of executable you can change the linker command to <path-to-link.exe> factorial.obj /dll /export:factorial /nologo /incremental:no /opt:ref /OUT:factorial.dll /MACHINE:X64 <libraries> and then you can call int factorial(int) from another program using the DLL written in assembly

long raft
#

so allan why do you use windows if youre so anti microsoft? why arent you on linux or something?

#

gamer reasons?

fickle aurora
#

not so much anti-microsoft but rather anti-.NET/CIL

#

the sole purpose of .NET/CIL was to make you buy a new dev kit every year and force the old one to expire

long raft
#

i have never paid a dollar for anything .net

#

its open source... MIT license

#

the dev environments are either free or open source

fickle aurora
#

you can use all of the .NET libraries from GCC anyway, but at the same time, they are terribly slow and inefficient

long raft
#

but you complain about microsoft compilers and stuff

fickle aurora
#

yes because MS switched everything over to CIL

long raft
#

yea let me just use that web server library julianlol
good luck finding one as fast as whats made in .net

#

you just hate one particular set of libraries and runtimes... thats weird

#

most people who dont like .net dont like it because microsoft and thats basically their only reason

fickle aurora
#

they were originally made long ago to help bring more people into programming because their purpose was to make programming easier and more understandable - but then it morphed into mainstream production when it should have remained as educational

long raft
#

thats not correct

fickle aurora
#

same with python, it was originally made for simple scripts to compete with shell scripts, it was never supposed to be mainstream

long raft
#

it was always meant for production, never for education...

#

you are incorrect about many things .net, which i imagine is because you havent actually used it

fickle aurora
#

if you compare VB 6.0 and VB .NET you can clearly see why they made .NET

long raft
#

.net is not vb

fickle aurora
#

and VB 6.0 will be used in eternity, I can bet in 20 years I will still see VB 6.0

long raft
#

i see how making vb.net made basic easier. .net has nothing to do with making programming easier

#

it does simplify some old terrible interfaces, e.g. COM

fickle aurora
#

well when I say .NET I am referring to CIL

long raft
#

thats just incidental stuff - people learn better ways to make things on their second try

fickle aurora
#

VB 6.0 was the last real compiler microsoft ever made, everything after that compiles to CIL instead of assembly/machine code

long raft
#

this is nonsense

fickle aurora
#

have you looked at any of your compiled programs in hex editor yet

long raft
#

you spend too much time with your head in a hex editor

#

im aware of what the IL looks like

#

i dont really care why you dont like .net, i was just curious why you run windows

fickle aurora
#

linux is equally guilty of copying microsoft by making everything use clang/llvm

#

so far it's not bad, as long as they don't suddenly decide to force everyone to use it like a runtime

long raft
#

you truly are in last century's computer science

#

youre gonna get left behind, allan

#

llvm is pretty damn sweet

#

also im sure youve used linux, but as your main OS i think youd like it

fickle aurora
#

I'll go to the niche area of fixing things people can't fix at the low level

#

I'll be honest windows does things better, just that I think MS is making bad moves and trying to be too greedy

long raft
#

but a user does not have much control in windows

fickle aurora
#

and is this really true

long raft
#

oh yes

#

maybe you dont need it. i use windows a lot too

fickle aurora
#

you can do a lot to secure windows, it's just a lot of extra work

long raft
#

no im not talking about security. i dont think windows has security problems. and it sure is fast

fickle aurora
#

if linux wanted to make the desktop market, Linus should have worked on X himself instead of getting the community to make it

long raft
#

its way too much to ask 1 person to work on

#

its difficult to commercialize because of the license, so i dont think itll be a common desktop OS in my life

#

but for a programmer...

#

unless you make games, most programmers are developing for linux now

fickle aurora
#

even Linus now admits the GPL was a mistake, he wishes he could have gone back and done things differently

long raft
#

was it not copyleft enough for him?

fickle aurora
#

the idea was to allow future development, not to make the software for free as in penniless

#

the problem is that if you give out source code to allow future development, someone is going to steal it and say they made it, or they can compile it and sell it to undercut you, and now you need to litigate it to make any profit from it, and in the end, a country that does not have intellectual property laws will just actively steal it and distribute it

long raft
#

if you give out source code, people use it (not steal), and they dont need to claim credit because you gave it away

#

a lot of money is made supporting software, not just writing it

#

jesus look how much money redhat brings in

#

its like theres more money in harry potter merchandise than the book advances probably

pure sierra
#

@fickle aurorahow hard to make crypto minor ? why fpga not suitable compared with asic ?

fickle aurora
#

it can probably be done, but how efficient would that be compared to a xeon with plenty of L3 cache, cores and fairly high clock speed

pure sierra
#

xeon is shit

fickle aurora
#

I'm using a 2013-era xeon to play star citizen and I outperform some brand new builds lol

#

it is hilarious how bad new CPU models are now

pure sierra
fickle aurora
#

of course, if you can get a new CPU with the same or better stats than the older xeons, then you will certainly get better performance

pure sierra
#

dude cpu not usable for mining anymore

#

got to be asic

#

even gpu outdated

fickle aurora
#

oh that is based on power vs cost efficiency

#

yeah I can see why xeon would be bad for mining crypto

pure sierra
#

asic miners are like 12-70k$ right now

#

but only because they are pegged againts crypto price and roi

fickle aurora
#

has anyone considered completely changing the software side to run faster in a single process and then use single core with highest clock speed possible, with efficient cooling

pure sierra
#

not sure but @fickle aurora would be the guy that knows the most about low level efficiency πŸ˜†

fickle aurora
#

I mean multithreading is good, but 4 cars against a single car with a faster engine will not get to the finish line faster

pure sierra
#

would they not have the same combined work output ?

fickle aurora
#

so it's only an advantage if you can do future calculations and combine them

pure sierra
#

but cant the 4 jobs just run in parralel until complete

fickle aurora
#

yes, assuming that you can do that

pure sierra
#

some time as running 4 jobs one after other at 4x speed

fickle aurora
#

sometimes you need to go in sequence

pure sierra
#

true

long raft
#

you cannot, because its hashes

pure sierra
#

cannot what ?

long raft
#

its all intentionally slow

fickle aurora
#

if the calculations must be done sequentially, then multithreading is useless

pure sierra
#

isnt it just randomly generating numbers ?

long raft
#

you can still multithread but the hashing algorithm is sequential

fickle aurora
#

you could however run multiple separate calculations

long raft
#

yea it can scale with CPU

fickle aurora
#

then you're better off with a board that supports multiple single core cpus with highest possible clock speed and cache

long raft
#

but the ASICs are orders of magnitude faster at the specific operations

#

and it doesnt need any floating point

pure sierra
#

yeah you would need like 500 cpu, just guessing number

fickle aurora
#

the problem with multicore is that you can't overclock too much due to heat

long raft
#

bitcoin mining doesnt use like 99% of the CPUs features

pure sierra
#

i feel like fpga might be best approach as you can make ur own circuit so there is room for innovation

fickle aurora
#

and instead of RAM you just need cache which is essentially SRAM

long raft
#

you dont really need innovation as you know the algorithm

#

cache is not helpful, you cant build rainbow tables

#

its all just hard integer calculations

fickle aurora
#

so you just need the clock speed

pure sierra
long raft
#

you cant get high enough speed out of generalized processors

pure sierra
#

but could you design a fpga that could perform on par with a asic but fro cheaper

long raft
#

i cant remember the btc exact specs, but im guessing its all pivoted around a modulo, because division is generally the mathematical trap door

pure sierra
#

as its not inflated price to peg againts btc price

long raft
#

but you wouldnt need to - the algorithm doesnt change, and the asics are cheaper to manufacture at bulk

pure sierra
#

but making asic not possible by me , but i can make fpga ?

long raft
#

right but if you were doing this at large scale to really make money, youd make an asic

#

you know 3d printing vs molds

pure sierra
#

youd likely make more money from reselling asics than mining

#

but problem is getting it made

long raft
#

hah in the california gold rush, a chicken cost as much as an ounce of gold

fickle aurora
#

you might make more money automating farm equipment

long raft
#

yea sometimes the support industry is bigger...

fickle aurora
#

there are still farmers paying people 20 bucks an hour to shovel out barns

#

and then there's IBM hiring masses to produce the stuff that the farmer has to shovel

#

the only reason IBM is still in existence is the endless government contracts that happily go overbudget and have to be scrapped and reworked constantly because of obvious security holes, the wrong order of starbucks coffee, and things like the wonderful world of java

long raft
#

C surely has contributed more security exploits than any other language

#

i mean obviously actionscript/flash but ...

fickle aurora
#

when they did the Shared Services system for the canadian government, it was a total disaster and now CRA is shut down because of it

#

I wonder if they filter user input in web text boxes

pure sierra
#

shard 1 dead

lyric turtle
#

I think it is about 3 years old.

pure sierra
#

thanks

#

so if you somehow think you can do it better thhan anyone else you might as well do it in software on your home computer first

lyric turtle
#

I was thinking about btc mining some years ago but it is to expensive in germany. There are options for cloud mining (some are scam!) where you virtually rent the MH. I'm personally not very much into crypto. Thought about buying rather than mining.

pure sierra
#

yeah Australia electricity price is really too high too

#

this in going to be a bit of a problem thhough

gaunt rivet
#

foxhole needs to be in VR

fickle aurora
#

yeah I wouldn't rent a server for mining, because you will get a virtual private server in a VM environment with hundreds of other virtual servers on the same machine and they will throttle your server

#

a lot of dedicated server co's are con artists, my raspberry pi had more computing power than the VPS that some of them were offering

fickle aurora
#

https://pastebin.com/K9ri3Tx3 another example, 32 bit this time and instead of calling printf, it calls WriteFile and writes to STDOUT which is essentially what printf is, just a wrapper function that uses WriteFile (we can't save space here because we are stuck with using ucrt,lib, vcruntime.lib, msvcrt.lib, and kernel32.Lib as the minimum things we need to link to)

long raft
#

re: the bitcoin mining, i think if you can do renewable energy and you have low maintenance costs then it can still be viable to mine

#

but not if youre replacing parts or generators or solar panels often enough to eat into your cost

lyric turtle
#

Australia would be suitable for solar powered mining but I think getting all the stuff needed is quite expensive there. Most miners are operating from countries rich in natural resources for energy production like China (coal and nuclear), followed by Russia/India (coal and nuclear too) and Iceland (hot vulcanic geothermal energie).

#

@fickle aurora You are not renting a vps server for mining. You rent calculation time on asics: https://shamining.com based on what you pay you get more power.

long raft
#

until we get quantum computers

fickle aurora
#

sounds fair, but remember if they are selling you a service, they are in it for profit for themselves

lyric turtle
#

Yes of course!

#

This is what everyone is looking for.

long raft
#

Wow

#

Gonna bookmark that

lyric turtle
#

That is not an emulator! These are real quantum computer. Just register, write your code and wait for execution time!

fickle aurora
#

made a fully windowed app in 64-bit assembly, only uses 1kb of memory compared to the 30MB+ you would get from .net framework

#

I think I will go back to using C, populating stack manually is too much work πŸ˜‚ most of the info online is all for 32 bit which is incompatible, and the x64 calling convention is significantly different from the x86 one ... but not a bad thing to learn

hollow gyro
#

Hi all, the Wiki lacks stats for the previous war WC85 nobody happens to have data on the deaths for that war end do they?

fierce sky
#

any Frontend or backend developers with web development experience? Interested in setting up a logistics portal as some of the tools out there are either regiment specific and authenticated for them only or are not very user friendly.

pure sierra
#

@hollow gyro my site does

hollow gyro
# pure sierra <@130170417519394816> my site does

I don't see them exposed for previous wars.
Could you update WC85 Deaths on: https://foxhole.fandom.com/wiki/World_Conquest

Foxhole Wiki

World Conquest is the main game mode of Foxhole. In it, all of the game's regions are fought on simultaneously, and connected to each other. One town in each active region is a "Victory Condition" town, indicated by the symbol - . In order to win, a faction must control and upgrade a certain number of Victory Condition towns with the Provisiona...

lunar cobalt
#

Updated it @hollow gyro

quick shoal
#

Do we have activity logs like the new stats available on the war api yet or do you guys think they won’t add them?

fickle aurora
#

so much for garbage collection, windows is using 13GB of memory and nothing intensive is even running

summer meteor
#

Coz windows is kinda famous for "if you give me more RAM I will use more RAM"

#

Then again judging by the chat history you probably know more about this than I do so I'mma just

fickle aurora
#

I have a lot of ram, it's very minor, but garbage collection is still a bad concept imo

long raft
#

garbage collection has many advantages

#

also this idea that youre only doing small things why is windows using so much ram? its the cache. and it improves your performance.

#

why spend money on ram and then not use it?

fickle aurora
#

true, it's caching 45GB of mem

quick shoal
#

darn:(

mossy pelican
#

Windows using 13gb is definitely cache

#

And most of it will free up if another process needs it

#

I have 20gb of ram and windows only uses about 3gb (windows 10's ram requirement is 4gb mind you)

long raft
#

and garbage collected memory takes less space because it defragments it

#

which could also mean less page faults

fickle aurora
#

it actually says it's using 44.5GB cached and 13.6GB in use

mossy pelican
#

How do you even use so many ram?

long raft
#

probably just disk cache

mossy pelican
#

Huh

long raft
#

well theres no reason to unload it

#

i mean in theory all the data passing through the disk could jsut be cached. i mean thats how i live on zfs. all the ram.

#

just chillin in volatile memory, catchin cosmic rays

fickle aurora
#

page files are all completely disabled

fickle aurora
#

I just love to torture my PC πŸ˜‚

hollow gyro
#

I'm surprised the Fozhole War API is not pinned in this channel.

fickle aurora
deft quartz
devout ivy
#

Also your description of how arduino operates was fundamentally incorrect

#

It actually uses avr-gcc and is not a runtime at all, its nothing but a library of helpers, its otherwise raw C++ in avr-gcc, much like atmel studio uses

fickle aurora
#

well AVR does not have any FPU and it's not based on ARM ... ARM and AVR are 2 totally different architectures ... also, A32 instruction set for some of ARM cpus do not have an FPU ... AVR is the architecture of atmel microcontrollers, ARM is a whole different platform ... there is also PIC which is another architecture

#

but you can store a binary version of float in general registers, but it is perhaps a bad idea since the general registers have no method of setting the decimal point, so you would have to store that in another register as a modifier - but you could theoretically do it

#

and yes arduino is a framework (notice that arduino calls them sketches and not programs?) and you have to link to arduino's libraries, which in turn includes the framework in your binary

fickle aurora
devout ivy
#

not been used in about a decade mate

#

ARMv6hf has FPU. ARMv7 A profile its compulsory. ARMv8 it is compulsory on all profiles

fickle aurora
#

well AVR does not have FPU at all

#

never did have one

devout ivy
#

Never mentioned AVR

#

you did

#

Well aware AVR is something else entirely but I never mentioned AVR outside the context of a basic arduino (though not all arduinos are AVR either, nor are all atmels AVR). Nor did I ever mention floating point in the context of an AVR or arduino

#

But you did state arduino to be a runtime, which it is not

#

ARduino for non avr targets of course doesnt use AVR-gcc, though generally uses gcc backends where possible

#

Only real exception are a small handful of arm targets for arduino are technically threads within mbedOS so use the mbedOS toolchains under the hood, themselves often using gcc - there you're getting closer to a runtime

fickle aurora
#

so you are saying if I compile this code https://pastebin.com/3y9uLABe in atmel studio using avr-gcc that it will compile? (this is the blink example from arduino's examples) without trying, I know it won't compile, because the first thing it will do is that it will say there's no main() function ... of course, arduino likely uses a wrapper (I haven't been bothered to read their source code), but even then, it's introducing bloat - because as we know calling functions adds overhead due to needing to push variables onto the stack, then saving the current instruction pointer, then going into the function, popping them back off the stack to work with, eventually returning a value, of course more pushing and popping instructions - all when you could have just done most of it in main()

devout ivy
#
/*
  main.cpp - Main loop for Arduino sketches
  Copyright (c) 2005-2013 Arduino Team.  All right reserved.

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

#include <Arduino.h>

// Declared weak in Arduino.h to allow user redefinitions.
int atexit(void (* /*func*/ )()) { return 0; }

// Weak empty variant initialization function.
// May be redefined by variant files.
void initVariant() __attribute__((weak));
void initVariant() { }

void setupUSB() __attribute__((weak));
void setupUSB() { }

int main(void)
{
    init();

    initVariant();

#if defined(USBCON)
    USBDevice.attach();
#endif
    
    setup();
    
    for (;;) {
        loop();
        if (serialEventRun) serialEventRun();
    }
        
    return 0;
}

fickle aurora
#

https://pastebin.com/SpyGzaY0 so here is my comparison of using Arduino for blinking the LED on pin 13 to making the same function in Atmel Studio with AVR-GCC ... the difference is that the minimum size (without bootloader) that arduino could produce is a 2.55kB hex file and I could produce a 418 byte hex file. Of course, I could have saved even more by making it in assembly

devout ivy
#

if you really want, you can even observe the build window in arduino and see the gcc invokations. But apparently you're more interested in strawmanning and goalpost shifting

fickle aurora
#

arduino's hex file was 3.83kB with the bootloader attached

#

I'm just giving facts, you can compile it and see what it does

devout ivy
#

No, you're not. You're moving the goalposts having been proven factually wrong about previous statements

fickle aurora
#

the extra 2132 bytes that arduino adds to an otherwise 418 byte hex file is basically the whole arduino library, even if you don't need it, and it runs through hundreds of extra code that you don't need ... we call it bloatware in programming

devout ivy
#

Except it doesnt run through it all

#

2048 bytes are the bootloader, most of those bytes are actually nulled

fickle aurora
#

the hex file is literally the machine code that it will run through

#

the chip has to run the entire hex file

devout ivy
#

It actually doesnt, you are well aware yourself you can jump about

#

bootloader sector is 2k, so bootloader is 2k but not filled. First executable byte is address 2048

#

They dont pull any tricks compressing the hex

fickle aurora
#

without bootloader, arduino's hex file was still 2.55kB

devout ivy
#

And not all executed as by default optimisation isnt enabled

#

so libs will be pulled in, but never executed

#

You can forcibly alter the optimisation level if you wish

#

Most of the arduino standard lib is incredibly inoptimal versus direct register manipulation. but I never argued that point, and neither did you originally until your previous point about arduino being a runtime was proven otherwise.
Doesn't mean arduino is bad. Its specifically designed to be accessible

#

Equally I wouldnt go and implement the firmware for some mass produced medical device in it

fickle aurora
#

it isn't legal to use 328p in medical equipment anyway

devout ivy
#

Thats also factually incorrect

#

Nor are all arduinos 328p

fickle aurora
#

if you do, you break atmel's license agreement in the first place because of the legal agreement you agree to states it must not be used for medical equipment

devout ivy
#

you can use anything in medical equipment, you just gotta prove/certify it. 328 just isnt precertified

fickle aurora
#

arduino is also considered a runtime library afaik according to the wikipedia definition, since it's not only a program library, it literally makes a whole user-friendly interface so you don't have to do things like clear the buffer every time you want to send/receive serial data, adding debugging symbols everywhere, validation of logic and data, and handling the directives to the chip for you, such as setting IO configuration

#

my bad, the 328p is allowed in automobiles according to spec, but there are some other models that I ordered that explicitly prohibited its use in automobiles - and only some chips are licensed for medical equipment - you can't just use any chip there

fickle aurora
# devout ivy And not all executed as by default optimisation isnt enabled

also, optimization has nothing to do with anything other than how the compiler will convert your code into machine code, for example, if you declare a variable but it seems like it is not used in your program, the compiler will omit it - sometimes you need that variable in there, so you use the volatile keyword to prevent the compiler from removing it ... sometimes optimization even makes the end result worse, such as -O3, in some cases that will actually give you worse optimization than -O2, but you have to know how the compiler will convert your source code to understand this

devout ivy
#

That isnt what volatile does. But you've already tried badly misexplaining enough

fickle aurora
#

volatile is literally a keyword that tells the compiler "do not optimize this"

devout ivy
#

Code removal is performed as an optimisation pass, with it all disabled, yes, it will emit unused code frequently

#

and no, that isnt what volatile does

fickle aurora
#

Here is another reference taken from the book written by the guys who invented the C language, Brian Kernighan and Dennis Ritchie, ISBN number 0-13-110362-8 page 211 states that volatile keyword prevents compiler optimizations

devout ivy
#

stand corrected

fickle aurora
#

it's all good we're here to learn

long raft
#

you can still use optimizations but none that mess with threading

#

its just a cache issue

#

i havent seen volatile used in 20+ years

#

like union, lol, when disk mentioned using one the other day i wasnt even sure the context

#

oh jesus remember when people used to inline everything?

#

god i used to think i was so clever inlining functions i cared about performance

devout ivy
#

aye when thats one of the most basic optimisations going so most compilers have a decent implementation for doing

#

so common that some JIT's even do it automatically

long raft
#

they just ignore the keyword

#

and yet youll see it everywhere in old c++ code

devout ivy
#

Its present as a decorator in .net

long raft
#

what??

#

in c++?

#

or the IL?

devout ivy
long raft
#

c# has inline?? hbeyes

devout ivy
#

Implemented differently

long raft
#

time to refactor all my code

devout ivy
#

but yes, its not super useful

long raft
#

i dont care about memory i just want speeeeeeed

devout ivy
#

Nah, modern roslyn is quite good at performance counting method hits and inlining at runtime on hot paths

long raft
#

yea its very impressive

#

i get speeds comparable to c++ now

devout ivy
#

Some benches, faster

long raft
#

yea for some odd things

#

generally not the algorithms im writing

devout ivy
#
using System;
using System.Globalization;
using System.Runtime.CompilerServices;

public class Utility
{
   [MethodImplAttribute(MethodImplOptions.NoInlining)] 
   public static string GetCalendarName(Calendar cal)
   {
      return cal.ToString().Replace("System.Globalization.", "").
                 Replace("Calendar", "");
   }
}
#

or replace NoInlining with AggressiveInlining

fickle aurora
#

https://pastebin.com/fM8EATg7 this is a very good example code to learn how volatile keyword works. I suggest trying it out, you will really like my example. You have to compile with -O2 optimization flag and try it out, then add volatile keyword to line 45 and then recompile and try again to see how it works

#

and while you say you havent seen it in 20 years, well, here is a modern example that is still relevant

long raft
#

its a 10 line program, what about that is modern?

#

like where would it come up?

#

like instead of deoptimizing my program and second guessing my CPU i woudl rather use proper thread safety mechanisms

fickle aurora
#

well you are programming in C#, it's a whole different language

#

my example is valid for C and C++ - specifically for GCC compiler

long raft
#

i know its valid but people still wouldnt do it that way now

#

theyd use a proper semaphore or better suited mechanism than skipping optimizations

fickle aurora
#

I see the volatile keyword used all the time

long raft
#

but you read old books on C

#

you see that in modern code?!

fickle aurora
#

yes it's used in libraries all over the linux platform, which you suggest that I use :D

long raft
#

the linux platform is a lot of old code

#

god knows their record on thread safety is rough

fickle aurora
#

yeah it's probably really bad considering the top 500 servers in the world run that old code

#

C and C++ will always exist, while python will die a horrible death

long raft
#

you know there were decades before C existed, right?

#

it wasnt like the first on the scene

devout ivy
#

Except python is meant to serve a totally different role to C

#

meanwhile, even torvalds admits most of the code in linux sucks

fickle aurora
#

yes everything around it died out but C and C++ have carried on

long raft
#

its well tested, i wouldnt want to rewrite it, but its not very good C

devout ivy
#

python has anything but died out

long raft
fickle aurora
#

well cobol is more similar to assembly

devout ivy
#

Hell, we've even got efforts underway to improve the linux codebase, by sticking rust in it

long raft
#

yea i dont think id go back to C id probably learn rust if i had to work low level again

fickle aurora
#

these days if you want to get into anything useful, C++ is the way forward

long raft
#

forward to ... what? writing games?

fickle aurora
#

I will admit, ANSI C is not great, and most of what I do is a combination of C and C++ which is why I often default to calling it C/C++

long raft
#

i have always called it c+

#

most c++ programmers think theyre c++ programmers but they are really C programmers

devout ivy
#

or - are just bad

long raft
#

they arent bad, c++ is just so huge they have no idea what features theyre not using

#

if youre not writing obfuscated operator overloads in templates are you even trying?!

#

youre not even using multiple inheritance?

devout ivy
#

Good god, multiple inheritance, burn it in fire

long raft
#

c++ has cleaned up a lot but its not a good language for getting work done, and its not great for writing very low level code, its this middle ground for optimized algorithms that are a hassle to write in C

#

and you can really write unreadable indecipherable code in c++

devout ivy
#

I spend a lot of time working with macOS Cocoa UI's. In C#. A framework designed around using multiple inheritance in objective-C. C# doesnt have multiple inheritance

long raft
#

i was disappointed c# doesnt have multiple inheritance until i realized i have never needed it

fickle aurora
#

objective-c was good until apple decided to copy windows and use garbage collection

long raft
#

copy windows? windows invented garbage collection? lol

fickle aurora
#

I don't know who did or where it came from, I just know that it eats memory like a hog and doesn't let go

long raft
#

thats not true

devout ivy
#

That literally isnt what garbage collection is

#

Objective-C also isnt garbage collected

long raft
#

as i explained before, garbage collected memory blocks actually use less memory

devout ivy
#

nor is windows itself

#

.NET is

long raft
#

.net is sometimes

#

its really easy to not use the garbage collector

devout ivy
#

Intentionally using unmanaged is an option yes

fickle aurora
#

so are you saying NSGarbageCollector is not a keyword in objective-C?

long raft
#

but garbage collection improves performance, but as a programmer you have less control over when the delays hit

vague otter
#

garbage collection hogs memory

#

lmao

long raft
#

and it uses less memory in a GC like .net because it compacts the memory, removing fragmented unusable small spaces

devout ivy
#

NSGarbageCollector is not a keyword. Its a type, for manually adding a collector, much like you can write a garbage collector in your C++ code, Objective-C itself is not collected

fickle aurora
#

apple pushed xcode to use it long ago, that's why I stopped bothering with objective-c

long raft
#

allan is a CS luddite, wont use anything from this century

fickle aurora
#

if you tried to free memory, the compiler would give you errors so I dropped it like a hot potato

long raft
#

disregards the last 40 years of development and progress as overhead

devout ivy
#

sounds like a pebkac issue

long raft
#

also c++ full of garbage collection now

devout ivy
long raft
#

but not really the efficient kind of garbage collection in c++, just the kind that protects forgetful programmers

fickle aurora
#

you mean the past 20 years of development, yeah that has been going backwards and making code less efficient

long raft
devout ivy
#

Not just that

long raft
devout ivy
#

theres a tonne it cant free on the SOH too

#

Codebase does a lot of managed/unmanaged interop, generally requiring pinned objects

#

which cannot be compacted

long raft
#

pinned types?

#

you didnt want to just allocate them natively?

#

i suppose its ...the same thing huh

devout ivy
#

.net 6 has introduced the POH to help alleviate it

long raft
#

what is POH?

devout ivy
#

pinned object heap

#

so theres now a small object heap, large object heap and pinned object heap

long raft
#

hmm i didnt know about this

#

not particularly relevant to me but interesting

devout ivy
#

items that would go on the small object heap but are marked pinned, now get stuck in the large object heap instead - POH isnt truly its own heap

long raft
#

is there an advantage of the pinned heap vs just marshalling some heap memory from the OS?

devout ivy
#

Unsure in all honesty, but in brief tests it at least solves some of the issues we were having

#

as unfortunately, as soon as the compactor encounters an item it cannot compact, it stops compacting the entire generation

#

so just 1 pinned object can basically just totally fuck compaction

long raft
#

i feel like i can get around most pinning these days

devout ivy
#

Aye, sadly, its a codebase that dates back to C# 2.0

#

In .net 2.0 days

long raft
#

whether span is using it or not, im unclear, but damn i can get some great performance with span

devout ivy
#

codebase is mostly net 4.7.2, with 1 assembly in 4.8, and a few making it over the line into standard 2.0 as part of the road towards moving to net 6

long raft
#

ive been working with ffmpeg a lot lately and im getting speeds the same as the C routines available in the library now

fickle aurora
#

with which language, python?

long raft
#

c#

#

span is awesome...

fickle aurora
#

well C# is close to C++ in optimization, python on the other hand is like going to disney world on a horse instead of an airplane

long raft
#

I have to use span to get C speeds

devout ivy
#

Python isnt meant to replace C++

#

its meant for a different role

long raft
#

The naive for loops don't cut it

fickle aurora
#

while/do while loops are better than for loops

devout ivy
#

often compile down to same thing now if you're using a compiler from the last decade

long raft
fickle aurora
#

the reason for loops are slower is because of the conditional statements it has to run through

long raft
#

i always ++i because its faster than i++ troll

fickle aurora
#

yes you are right ++i is better

long raft
#

but i want the conditional statement

fickle aurora
#

in some cases, the goto keyword is better than an if statement or function call

long raft
#

for performance? usually.

#

but you have the shame of using a goto statement

#

this is ...like inlining everything

#

just let the compiler do its job

fickle aurora
#

compiler is not always right

long raft
#

im not worried about individual clocks

#

no. but its right more often than my primate brain

devout ivy
#

I'd rather waste a clock than write a goto ever

#

Sounds like you love unreadable bug prone code

fickle aurora
long raft
#

i dont think goto is that buggy, its actually pretty easy to debug them

#

they got a bad rap because it made code difficult to prove

#

i guess they have a stink of amateur to them

fickle aurora
#

the bad rap is programmers who don't want to learn more about the language they use

long raft
#

a lot of them were told never to use goto

devout ivy
#

nah, more programmers that know just because it was in the language once doesnt mean it should be, but equally you can't delete it

long raft
#

java did, didnt they?

fickle aurora
#

MIT certainly never told people never to use goto

devout ivy
#

not but brian and dennis did

long raft
#

if break were smarter we wouldnt need goto

fickle aurora
#

the problem with using a function call over goto is that a function call will push rbp onto the stack even if it's not needed

#

goto does not push rbp on the stack, so you have to be aware when you use it

long raft
#

these are generally not performance concerns tho, allan

fickle aurora
#

you can break a lot of stuff using goto, but again if you can think about what the code will do on the assembly level, you can use it for performance

long raft
#

theyre very easy to track down tho

balmy tangle
#

hi, can you tell me if there is a public logistics api to check base resource counts?

long raft
#

there is not

fickle aurora
#

this is the functionality of C that other languages just don't have the ability to do as fast as C can do without intensive overhead of runtime libraries, basic string and character manipulation

long raft
#

yea but i can write it in one line

#

so if you ever want to write something more complicated than replacing commas or counting numbers, good luck dumping all of your time into C so you can get a 5% performance increase

#

also, zero terminated strings are ridiculous in the 21st century

fickle aurora
#

lol

long raft
#

seriously, you cant loop unroll it, and youre gonna pay a time penalty just to get the string length, etc

fickle aurora
#

I'm pretty sure everything still uses null termination in C#

long raft
#

just because youre using C doesnt mean you have to do things in an old and terrible way

#

it for sure does not.

#

even pascal (from before C) wasnt using null terminated strings

fickle aurora
#

well you can disagree, that's fine, but I'm saying that it's still a thing

long raft
#

they simply include an integer with the string length

#

its still a thing ... yes. in C. in old C. its an anti pattern

#

there are alternative string libraries for C that wont use zero termination

#

if you care so much about every last ounce of performance ...

#

You live in a time of abundant processing power and memory, but developer time is still the same

#

It's time for modern tools to solve modern problems unless you legitimately have memory constraints

fickle aurora
#

all the modern tools do is automate the things that lower level requires you to do yourself

long raft
#

Yes and saves the most expensive part- development time

fickle aurora
#

so like null termination, yeah you don't have to do it, but the compiler is certainly doing it

#

if there was no null termination at all, your program would cause a buffer overrun on the first syscall

long raft
#

The library does it the compiler has no knowledge of strings

#

I have explained strings before, I'm not doing it again

#

Dont post me some unrelated sample

neat fossil
#

you're no true coder if you've never messed up the iostream library

long raft
#

I suppose the compiler turns string literals into asciiz but you dont have to use those and you dont have to terminate an array of characters with a zero, which is a valid character you cant even use in asciiz

fickle aurora
#

it doesn't have to be in ascii, null is just 0, which is the same 0 in unicode, utf-8, etc

long raft
#

Such a short sighted string convention

#

Allan, imagine the first 4 bytes of your string were an integer specifying length and your libraries used that

fickle aurora
#

the reason it is designated as '\0' in C is that when you use single quotes, you are referencing an ascii character

long raft
#

Or a structure with a length element

#

Its the superior way to do strings

fickle aurora
#

and on the CPU level, by the way, ASCII is still the standard for text

long raft
#

What. No.

fickle aurora
#

unicode is not supported in real mode

long raft
#

There are some old interrupts that do, but c doesnt use those

devout ivy
#

I like how once again Allan has derailed into irrelevance. String encoding and termination are different things

#

And null termination isn't used a lot outside of c anymore

long raft
#

He knows things, but he always assumes C does it the best way

#

Or closest to the cpu

devout ivy
#

As derp said, most are length prefixed

tawdry zenith
#

hi there

fickle aurora
#

well some will just not see it I guess

devout ivy
#

If length prefixing made no sense and null termination was just better in all scenarios, then they'd be null terminated everywhere, and oh look they aren't

#

C regularly does it the wrong way, regularly the worst way

#

Doesn't mean I hate C, it has a place

long raft
#

C has many bad conventions

devout ivy
#

But it is not the best tool for every single scenario ever

long raft
#

Vb best language

#

Case insensitive best thing ever

#

Too bad vb is gonna die tho

fickle aurora
#

Two of the four text-string processing instructions specify string length explicitly. They use two general-purpose registers (EDX, EAX) to specify the number of valid data elements (either word or byte) in the source operands. The other two instructions specify valid string elements using null termination. A data element is considered valid only if it has a lower index than the least significant null data element. from page 308 of the Intel x64 developers manual

#

apparently even Intel instruction set uses null termination in machine code

devout ivy
#

Oh look. Only half use null terminators and the other half use prefixed

#

In your own quote you proved yourself wrong

long raft
#

The ones c doesnt use

#

Only assembly programmers use those

devout ivy
#

2 prefix. 2 null suffix

long raft
#

Im out of date on c++, does everyone use the stl string library?

#

I know the standard library isnt using zero termination

devout ivy
#

Prefixing generally tends to result in it being trivial to perform a bounds check before even starting to parse the string or copy it to the buffer. Both improving performance in the error case and reducing chances of overrun. Additionally makes it trivial to perform a copy operation of known memory length rather than running until a particular character is reached - performance difference there varying on chip architecture and exact implementation remembering even the different intel generations aren't cycle accurate to each other

long raft
#

also the ability to use the 0 character

#

and unrolling loops because you have a known length ahead of time

fickle aurora
#

lol

long raft
#

all of this you can do with C!

devout ivy
#

Garbage collected object oriented C is very possible

long raft
#

object oriented C? squint

devout ivy
#

With length prefixed strings

#

Yes, object oriented C

long raft
#

imagine working on a C project so big you need to OO it

fickle aurora
#

it's really bad when programmers think that just because their high level language doesn't do this or that, that their code works the way they think it works

devout ivy
#

It's never as nice as a language where classes are a genuine language feature. But you can always shoehorn any paradigm into any language. There's even libraries for it in many cases. gObject for c for example

long raft
#

yea strings are so basic they really should be a basic type, and implemented well

fickle aurora
#

everything eventually goes down to low level system calls, and those system calls are either done in assembly, C or C++ on all the modern operating systems

long raft
#

god i just cant imagine doing things in C/c++ anymore, it was so much work to do the most basic crap

#

its all machine code in the end, allan. and even that is basically byte code reinterpreted by the CPU

#

this idea that youre working at a native CPU level is false

fickle aurora
#

there will never be system calls written in C# for example

devout ivy
#

And once again

long raft
#

but there are

fickle aurora
#

but there aren't

long raft
#

you dont even know C#

devout ivy
#

Do I have to keep pointing out that there are tools for different jobs

fickle aurora
#

ntdll is not made in C#

long raft
#

c# can still invoke C calls

fickle aurora
#

all the system calls are in there

long raft
#

in fact it can invoke different types of function calls

fickle aurora
#

function calls are not system calls

long raft
#

well they are when its a system library

#

you know theres an entire layer between machine code and actual instructions that are run, right?

fickle aurora
#

a system call, for example 0x2c means ExitProcess() on Windows 10 on all the updates (but you can't count on it because Microsoft keeps changing the system call codes)

long raft
#

are you talking about interrupts?

devout ivy
#

Most of the .net standard library is pure C#. But file I/O etc is always gonna have a system call

#

Win32.dll for example on windows

long raft
#

i have to use interop system calls all the time in c# directly

fickle aurora
#

you have no choice but to call either NtTerminateProcess() in ntdll or ExitProcess() in kernel32 to exit properly, instead of using code 0x2c cause one update to the next, MS could change the system call tables

long raft
#

your knowledge of C# and .net is very spotty

devout ivy
#

On that one he is right derp

fickle aurora
#

.net is just wrappers for the underlying win32 API

devout ivy
#

Process.exit and application.exit both result in an eventual call to win32

fickle aurora
#

programming in .net does not add anything to the OS

long raft
#

ok but im talking about interop

fickle aurora
#

everything literally comes down to the win32 API, that's the bottom before it is translated into syscalls which are stored in tables

devout ivy
#

Not everything at all

#

Only that which requires it

long raft
#

do you want to be a professional C programmer, allan?

devout ivy
#

Arithmetic, doesn't touch it. File IO or networking etc obviously does

fickle aurora
#

yes basically everything, for example, printf is not a system call, it is actually a call to NtOpenProcess

#

the standard output is just a file IO on very low level in windows, and that has been there since windows NT when windows became posix compliant

devout ivy
#

Windows hasn't been POSIX compliant in a very very very long time.

fickle aurora
#

you have to pass -11 in decimal to specify "stdout" for example

long raft
#

but in c# you can just define an external function call (using a C style method entrance) and call the system libraries directly

#

[DllImport()]

#

theres all the platform invoke stuff

fickle aurora
#

what are you considering as system libraries?

long raft
#

... the kernel libraries...

#

all the basic system libraries

fickle aurora
#

which DLL's are you referencing to do this?

long raft
#

you can do it with any DLL

fickle aurora
#

well ntdll.dll is the one I know of with most of the low level syscalls, the others like kernel32.dll are higher level wrappers for the syscalls

long raft
#

of course your portable program becomes windows dependent then

devout ivy
long raft
#

even vb.net can do external library calls

devout ivy
#

All as partials. Occasionally split further as Linux and macOS specifically if required

#

Not everything in .net invokes win32 these days ;)

#

None of the string handling code touches kernel anymore. It's all pure c#

fickle aurora
#

well it's wrappers to win32

devout ivy
#

It's not

long raft
#

its wrappers to any external dll

devout ivy
#

There is stuff that is

fickle aurora
#

the wrappers handle the message translation and everything for you

devout ivy
#

Stuff that isnt

fickle aurora
#

it's more complicated than you think

long raft
#

but also youre not aware of the capabilities of c#

devout ivy
#

So you literally thing absolutely every single line of c# is a wrapper to win32

#

You know how absurd that is. In a runtime that isn't even win32 specific

fickle aurora
#

to make a window, you have to paint the screen, capture messages for the window, issue callbacks, translate messages into instructions on when to repaint the window on the screen, etc ... the higher level libraries do that automatically for you, but I assure you that it exists, otherwise it wouldn't work

devout ivy
#

That I've repeatedly pointed out, does involve where appropriate

#

Point out where I said using a GUI didn't invoke kernel

fickle aurora
#

you are somehow thinking that everything is magic, it is not

long raft
#

if we were still stuck using c# computing would suck now, itd be 20 years behind where it is now

devout ivy
#

Point out where I thought something is magic

long raft
#

still implementing linked lists lol

devout ivy
#

I even specifically mentioned files as an example of something that invokes win32

#

Yet strings as something that doesnt

long raft
#

we will never break through this wall of "C is the best, even tho I don't know other things"

devout ivy
#

Clearly painting a window will. Don't dispute that

fickle aurora
#

it has nothing to do with C, we're talking about windows native API

devout ivy
#

.net isn't a windows native api

#

It's a bloody JIT runtime more akin to java

fickle aurora
#

well at least you can admit it

long raft
#

lol

devout ivy
#

And clearly will involve underlying OS where appropriate

#

Which isn't all the time

long raft
#

whats the largest program youve written, allan?

fickle aurora
#

lol

devout ivy
#

If I'm computing Fourier transforms on captured data from an oscilloscope, am I invoking the kernel

#

Maybe I might in order to spin up and manage a new thread if appropriate for the workload (unlikely in a 1 dimensional fft) and maybe for a mutex. Otherwise. No. Not during processing.

#

And no, the corresponding code in . net or even in python, won't invoke the kernel at all for that

long raft
#

whats the mutex for?

devout ivy
#

Syncing the thread -if I even make one, and if required. So likely no mutex

long raft
#

hmm well you can sync a thread without a mutex.

#

kind of a specific type of thread safety

devout ivy
#

If I then log that data to a file post computation. Then I'll clearly be invoking the kernel

fickle aurora
#

if everyone thinks like you guys, in 20 years there will be no computer updates because there won't be anyone who knows how to program for the CPU

long raft
#

i suspect i have years more C experience than you

#

perhaps people who think like us are because they know more

fickle aurora
#

I doubt it

long raft
#

C is so easy its not like there will ever be a lack of people who know it

devout ivy
#

You do realise my degree is embedded systems programming. I have programmed in C, for both x86 and assorted mcu's. I have done assembly in msp430, avr, mips and x86. I work in c# as a profession sure. Doesn't mean I don't know C. I have written CPU emulators. I have written an assembler

long raft
#

yea and ive written x86 assembly for 5 years

fickle aurora
#

thinking that "C and Asm are outdated" is thinking incorrectly and leading to a major disaster in the future when we will not have anyone left to keep the API up to date

devout ivy
#

I never said out dated

long raft
#

oh ill say it. its outdated

devout ivy
#

I said not the right tool for the job in all scenarios

#

Because it isn't the right tool for the job

long raft
#

shit, you could do all the same work in rust

devout ivy
#

Rust is not quite at a mature 1.0 yet.

long raft
#

ive never been one to wait for 1.0

devout ivy
#

That's all I have against it

long raft
#

i cannot imagine being a programmer these days without knowing modern languages, like java or c# or javascript...

#

i would never hire that person

#

theyd spend a year doing the work a fresh college grad could do in weeks

devout ivy
#

But frankly I wouldn't employ a person that thinks the only way to code is in C, if it means they waste a week writing something in C that could have been written in 5 minutes in python and the python performs the job satisfactorily

long raft
#

and yet, i think every programmer should know C, youd be so hamstrung without it

#

C is basically pseudo code now

devout ivy
#

Equally. I ain't gonna go and have some ridiculous number crunching done in python.

long raft
#

remember the old days when youd find an algorithm example in delphi or fortran? lol

long raft
devout ivy
#

Eh, libs like scipy I guess, albeit, their main crunching logic is in C

long raft
#

sure, if its done for you might as well use it

devout ivy
#

But would again depend on project requirements

long raft
#

but ive got no problem if my c# program runs half as fast, i can just run it on two cores

#

its not like im waiting for a slice of time to run my program on a univac

devout ivy
#

C# generally gets you 90% of the way there these days anyway, and probably with half the effort

long raft
#

half? its 90% less effort

#

did you see allan's sample of replacing commas? lol

fickle aurora
#

yes it is faster to develop (not faster to run), but thinking that it will replace C for good is wrong thinking

devout ivy
#

Where did I say it will replace c for good

long raft
#

i dunno, i could see C dying eventually, maybe another 50 years

#

again, rust.

devout ivy
#

We had someone at work think C was the only way to do things. So we had a little challenge for fun.

#

Project Euler, first 10 problems

long raft
#

it reminds me of the people who think manual transmissions are the be all end all. omg the mileage is better. youre not a real man if you dont use a clutch, etc.

#

until you break your foot or you want to drive and eat at the same time

#

or lend someone else your car julianlol

devout ivy
#

My c# solution compiled and executed faster on a Jetson nano with .net core 3 on Ubuntu 18, faster than his first 5 problems ran in C on an i7-7700 also under Ubuntu 18

long raft
#

because he couldnt implement quicksort without 2 weeks lead time?

devout ivy
#

Pretty much

long raft
#

i assume it was his poor choice of algorithms

fickle aurora
#

ubuntu has other problems, C is not one of them

devout ivy
#

Clearly not when both were running Ubuntu 18

#

My c# was running on ubuntu

fickle aurora
#

ubuntu is one of the worst linux distros

devout ivy
#

On a 4 core 1.5ghz cortex a57

long raft
#

im working on a video editor, and it compiles my c# code and runs it on the gpu, the first time i ran it on arm on my jetson nano my brain almost exploded

#

i wrote it on amd64 on windows and then it runs on a jetson nano lol

#

with cuda.

#

i still can barely believe it works

fickle aurora
#

they still have a bug in the OS where if you read from an SSD, it will try to read from your DVD burner (if you have one) and throw an error

#

have you tried installing apps from the GUI instead of terminal window? lol

long raft
#

which is your favorite linux distro, allan?

#

lol i refuse to use linux GUI

devout ivy
fickle aurora
#

it is so bad, if the GUI is so broken they need to just scrap gnome and make something else the default window manager

long raft
#

mono was such a... grrr... no.

#

.net 6 is so damn great

fickle aurora
#

I just use plain linux, like slackware, gentoo or rasbpian

devout ivy
#

Unfortunately, I rely on mono currently at work

long raft
#

ooof im so sorry

fickle aurora
#

I have no preference, but I don't use GUI

long raft
#

a lot of my stuff i compile now for musl/alpine with .net its such a joy

long raft
fickle aurora
#

yes I think macOS is the best linux distro, and before you laugh, I know it's not linux, but to be honest, how many issues does macOS have compared to Ubuntu?

long raft
#

what was that old linux distro the super linux dorks used to use. gentoo?

#

i feel like they all migrated to arch

#

macos full of issues as far as i know

devout ivy
#

Yeah, WPF+netframework 4.8 on windows, GTK+Mono/.net 4.7.2 BCL on Linux. Xamarin.mac on a Mac, under the hood being a weird hybrid of mono 6 with a modified net 4.8 bcl with standard 2.1 compatability that regular net 4.8 doesn't have

fickle aurora
#

at least on macOS, the GUI actually works

long raft
#

and yea ... its not a linux distro, you cant say that

devout ivy
#

Working with Mac professionally

#

It's super buggy

#

Usb stack in particular is horrific

long raft
#

as much as i hate apple i cant deny their gui is pretty good

devout ivy
#

Eh, until you mix retina and non retina displays in a single multi monitor setup

fickle aurora
#

I just stick to windows, it makes no sense to switch to X

devout ivy
#

At which point it can't decide on whether it wants to anti alias fonts properly and bugs out badly

long raft
#

my only experience with retina issues is in web development front-end. javascript ... and high resolution is funky

#

no X is terrible its definitely not the strong suit of linux, im just curious if you dont like ubuntu which alternative do you think is better

devout ivy
#

It has different font kerning and anti aliasing settings for retina v non retina

long raft
#

i guess you think theyre all better?

fickle aurora
#

I have several computers, the mac one never gets booted even though it is nice to use macOS

devout ivy
#

And if you have multi monitor setups on a Mac. That setting will be wrong for at least 1 display

long raft
#

im stuck on windows as long as visual studio is exclusive to windows

devout ivy
#

Resulting in the font rendering as if it's smudged on either display

long raft
#

i cannot imagine a less capable dev environment

fickle aurora
#

I'm thinking Fedora is going to be the one I pick after windows 10 goes to crap in a few years

long raft
#

hmm fedora ... you dont hear much about it these days

devout ivy
#

Fedora is in my pile of least favourite distros

long raft
#

i personally hate RHEL/fedora

devout ivy
#

Above opensuse

long raft
#

debian was always too concerned with stability for me, too many problems

devout ivy
#

Reminds me, need to check if the mono package in Fedora is still broken

long raft
#

i do very much enjoy alpine

devout ivy
#

It's a fedora maintained package, the rpm direct from xamarin is correct

#

Had to work around it to get works software to install on fedora

long raft
#

it seems almost irrelevant now, i dont run anything outside of a container now

#

the hosts are so ... bare metal im barely concerned with the distro if it can run podman or docker

devout ivy
#

Opensuse, they've switched package manager to zypper. Zypper does some funny funny things

fickle aurora
#

I tried to install Fedora a couple years ago and the installer didn't work

devout ivy
#

The installer is still broken on a 1920*1080p screen

long raft
#

allan have you used the linux subsystem on windows?

fickle aurora
#

cygwin?

long raft
#

no...

devout ivy
#

No

#

Wsl

long raft
#

wsl 2 is basically a virtual machine with tighter integrations

devout ivy
#

Windows subsystem for Linux. Added in win10

long raft
#

its an easy way to get a linux command line on your linux machine. you can run it as a vm or more like cygwin with the native compilation (wsl 1)

devout ivy
#

And with 11. Wsl2g

long raft
#

but the new version of wsl2 with windows update 21h2 has graphics card support

#

windows 11 or 10

fickle aurora
#

I tried cygwin long ago on a 200mhz pentium 1 and it ran horribly slow compared to windows 95

long raft
#

cygwin was ... fine for performance but buggy because the library support

#

wsl is a feature for windows you can enable, and you can install any linux distro

devout ivy
#

WSL is more Linux kernel in hyperv. With mapped storage bidirectionally. With WSLg, X forwarding too

long raft
#

its a great way to get yourself a fully working linux command line on your windows machine

#

WSL1 is less like a virtual machine

#

its more like cygwin...

devout ivy
#

Can do weird and whacky things like launching windows applications from the Linux bash shell

#

And vice versa

fickle aurora
#

I already use the command line through ssh, but mostly on FreeBSD

devout ivy
#

Powershell window on windows, using Linux installed wget, in a windows directory

long raft
#

its just nice to have linux tools on a windows machine that are reliable and predictable and come from a known distribution

#

yea ssh is fine but you have to run another computer. its nice to have linux right on your windows machine

#

freebsd huh?

devout ivy
#

Fun macOS bug for you guys. Present since apple first introduced USB controllers on PowerPC products

fickle aurora
#

I am not a fan of the new FreeBSD releases, the project went down the hole since 2010 or so

#

but the older releases were really good

devout ivy
#

If it encounters either 2 usb devices enumerating at once. Or 2 usb devices disconnecting at once. Or 1 connecting and 1 disconnecting

long raft
#

yea bsd has been sadly in decline with the popularity of linux

devout ivy
#

It can get the usb driver in a deadlock

long raft
#

and now that linux has zfs i have no reason to stick with freebsd sadly

#

containerd > jails, linux hardware support is just better

devout ivy
#

All usb devices on the system cease functioning, on every controller in multi controller systems

long raft
#

always loved the monolithic kernel of bsd tho

devout ivy
#

If any usb device (including the one that was unplugged) was an audio device, you also lose the audio stack

#

As every Mac except the newer M1 based ones uses usb based Bluetooth, you also lose Bluetooth

long raft
#

its almost inexcusable apple have bugs for so long. its not like theyre supporting a billion combinations of hardware

#

is boot camp dead for m1 hardware?

devout ivy
#

Absolutely

long raft
#

oof breaks my heart

devout ivy
#

Remember M1 is arm not x64

long raft
#

i know but windows is on arm

devout ivy
#

So wouldn't boot an x64 OS anyway

#

However. In an unapplelike fashion

long raft
#

.net 6 already compiles for m1 which is cool

#

when i recently updated the tiler people use for foxhole maps, i added an m1 binary

devout ivy
#

Bootloader isn't just not locked. It's intentionally unlocked and third party OS booting is explicitly allowed

#

Linux porting is going extremely well

long raft
#

if i were primarily a linux user id heavily consider buying new apple laptop

#

i hear that m1 is fast AF

devout ivy
#

Microsoft have stated they have no interest in porting windows at this time

long raft
#

i am not surprised

devout ivy
#

And nobody has so far looked at taking on the challenge in doing it as a community port

#

Ie, pi style

long raft
#

no .. itll have to be virtual machines or something

fickle aurora
#

is that what KDE looks like now

devout ivy
#

Yes

devout ivy
long raft
#

with video accel?

fickle aurora
#

it is sad that gnome killed itself

devout ivy
#

Parallels supports windows 10 for arm

fickle aurora
#

used to be the best

devout ivy
#

Dunno what state of acceleration is

long raft
#

if you cant passthrough GPU then it wont be much use for gaming

#

or anything really

#

its not like you cant edit a spreadsheet in osx

devout ivy
#

Proton does not work in Rosetta either

#

So no option for that route either

long raft
#

thatd be a deal breaker for me, although if youre a gamer using an apple laptop maybe youre not a serious gamer

devout ivy
#

No but on the M1 max, there's a huge amount of GPU performance on tap for something that doesn't have a discrete gpu

fickle aurora
#

the thing is mac has a better chance of getting game developers than linux, because of the GPL problem

long raft
#

GPL isnt really an issue for game programmers

fickle aurora
#

GPLv3 will forever be the thorn in linux

long raft
#

it seems to be doing fine despite it

#

also a lot of stuff is lgpl

fickle aurora
#

it should have been a requirement that all libraries are ineligible for GPLv3, and require libraries to only be allowed under LGPL

long raft
#

i cant think of any example where gpl is an issue for game developers

fickle aurora
#

or at least BSD licensing

long raft
#

well ... it wouldnt be linux with bsd licensing would it

devout ivy
#

Should also note. The usb issue above is still present on m1

fickle aurora
#

LGPL allows linking to libraries, that's where the advantage is

devout ivy
#

The only difference. The cause of the bug is a race condition. It expects the usb event queue to be processed in a particular time span during the re-enumeration

long raft
#

licensing is complicated

fickle aurora
#

you will never get game development with GPLv3

long raft
#

why not

#

i cannot think of a single example where gpl is a problem for game developers

devout ivy
#

It's harder to exceed the timespan on M1, but possible

fickle aurora
#

because game devs need to get paid and don't want to throw source code out

long raft
#

they dont have to share their source code

#

theyre not using gpl3 libraries

fickle aurora
#

if you link to a library that is under GPL3, it's no longer closed source

devout ivy
#

Linux isn't gpl3

#

It's gpl2

fickle aurora
#

depends on the libraries you link to

long raft
#

libraries used for games are not gpl3

devout ivy
#

Gplv3 isn't allowed in linux

long raft
#

vulkan is apache license, opengl is similar to BSD

#

there are some gpl sound libraries you can choose not to use

fickle aurora
#

I wish that were true, lol

long raft
#

really i see no issue developing software for linux, you wouldnt have to share source

#

theres countless examples of developers not sharing their code

devout ivy
#

More so. Never has anyone at the Linux foundation raised it as an issue, despite the increasing popularity of gaming on linux

long raft
#

one could argue a lot of linux gaming is operating with ...windows binaries lol

devout ivy
#

There's also the GCC runtime exception

long raft
#

but yea theres a ton of stuff on steam compiled for linux, no source code

#

as much as i deeply hate gpl its never really caused me any development problems

#

agpl is the real monster.

devout ivy
#

You have permission to propagate a work of Target Code formed by combining the Runtime Library with Independent Modules, even if such propagation would otherwise violate the terms of GPLv3, provided that all Target Code was generated by Eligible Compilation Processes. You may then convey such a combination under terms of your choice, consistent with the licensing of the Independent Modules.

long raft
#

its so counter to the intent of gpl its disgusting

long raft
#

target code? "combining"?

#

"Independent" rofl

devout ivy
#

Much of linking against the Linux API is already either allowable by the libraries existing license, gplv2 or the GCC exception

#

That tl;Dr and FAQs down to you can link against quite a few gnu libs in proprietary software in many cases

long raft
#

sometimes i wonder how significant containers are affecting gpl

#

like, if i externally link ffmpeg, but then i use the gpl3 version and i make a docker container that installs that one ...

#

isnt it kind of like the end user doing it?

#

do i have to provide a dockerfile instead of the image?

#

how is everyone else posting docker images without violating gpl

devout ivy
#

End user is also accountable for licence violations

long raft
#

dockerhub is in theory one big gpl violation

fickle aurora
#

it's a legal can of worms and convoluted so that you never know the grey area until you put effort into a project and then have to hand over all your work for free to some guy just because you linked to something trivial

long raft
#

aha allan, theres a solution

#

if youre forced to release source code, release it as agpl julianlol

#

then nobody can use it

fickle aurora
#

lol

#

well this is why linux is the ideal server platform in the end

long raft
#

its stability is probably the biggest reason

#

the kernel is pretty damn rock solid

#

i find myself wondering if this is because largely of the vision of a single programmer, and how large can a project grow centered around the ideology of a single person

fickle aurora
#

well if Linus switches the codebase to C# I'm not sure that it will still be rock solid and efficient

#

might as well rewrite socket.h in php and see how that goes, it would be a similar move

long raft
devout ivy
#

Note neither of us ever suggested doing that

#

But. Rust is already working it's way into the kernel to replace c/C++

long raft
#

Yes because a safe language would be bad for stability?

#

Linux is not great because of the language it's written in

devout ivy
#

Also note that the Linux kernel is also not bug free

fickle aurora
#

I'm thinking more along the lines that it would become slow like windows and then people would fork the project to another thing for server dev

devout ivy
#

It's only very recently a major privilege escalation attack was found and thankfully rapidly fixed

long raft
#

Windows is... not slow, unless you mean specifically explorer.exe

fickle aurora
#

"prevents all segfaults" sounds good until all the memory leaked from other places get read by malicious code that keeps running indefinitely due to the language keeping it from crashing

#

crashing is sometimes a good thing, it tells you when you made a mistake

long raft
fickle aurora
#

I read about rust, wasn't excited about preventing crashes due to bad code

#

you can already do that in C actually by managing signals

long raft
#

do you like your car without an airbag and safety belts too?

#

hmm and thats a 10/10 analogy

#

like you prefer older cars before they had crumple zones and airbags and only had a lap belt and no anti lock breaks

fickle aurora
#

crashing due to buffer overflow is actually more like an airbag than preventing the crash and allowing all the sensitive data to be leaked from another process

long raft
#

because they used less fuel (not really) or drove faster

fickle aurora
#

it's actually more secure to crash than to not crash, because the crash prevents malicious code from reading memory of another process

long raft
#

crashing potentially your whole OS just to know you have a small bug somewhere is like thinking seat belts kill more people than they save

fickle aurora
#

well that is a linux problem

long raft
#

thanks, i dont need my entire computer to die because somebody started counting at 1

fickle aurora
#

linux purposely crashes when something goes wrong

long raft
#

anyhow you can turn that off in windows

#

you can surely compile a rust program without that

fickle aurora
#

would you rather have an unbootable system or a system that crashes when something goes badly wrong?

long raft
#

wait why would it become unbootable?

fickle aurora
#

if your buffer overflow causes garbage to leak into the kernel and save to system files, you will be left with an unbootable system

long raft
#

why would it save to system files

#

thats not like something that would happen accidentally

fickle aurora
#

I absolutely prefer the computer to crash rather than have the system files corrupted and prevent booting

#

because program instructions and virtually everything is in memory

long raft
#

is this some scenario where a virus is doing it?

#

why would the kernel write over the boot loader

fickle aurora
#

it doesn't have to be a virus, if random junk is overwritten to the memory location of the kernel files, it can very easily trigger a write instruction

long raft
#

to write over the kernel thats compiled and compressed as an image?

fickle aurora
#

it could even be worse if it happens to have elevated privileges and write to other places, like bios

long raft
#

thats like so specific

#

it would have to overwrite your boot partition...

fickle aurora
#

that can be done

long raft
#

its not going to do that from a random piece of memory overwriting, that would have to be targetted

#

thats not going to happen from randomness in any likely reality we are in

fickle aurora
#

segfault is done on purpose, it's designed that way to protect the system, that is literally a security feature

long raft
#

right

#

stability and security, yea

fickle aurora
#

like I said you can disable it if you really want to, by capturing the signal and preventing the program from exiting

#

usually programmers do that so they can return an error message

long raft
#

uh huh

#

and you think its bad?

fickle aurora
#

I think it's bad to abuse the try {} method of C# to prevent crashes, absolutely

long raft
#

exceptions are not segfaults

#

i should point out c++ also has exceptions

#

its not ... abuse its a conditional statement (logically)

fickle aurora
#

the intention is for doing things like sending an error msg to the user, recording it in a logfile or something, but if you let the buffer overrun or whatever to continue, it can lead to some serious security holes

long raft
#

so you dont like segfaults or exceptions?

#

wait

fickle aurora
#

if you did it in openbsd, theo would give you a long lecture about it

long raft
#

you cant catch a segfault.

#

ok ...maybe im understanding you. im trying. you would prefer the OS handle reading/writing out of bounds than the program itself?

fickle aurora
long raft
#

oh i guess people can catch that signal

fickle aurora
#

in C, it's sigaction(SIGSEGV, &<function for handling seg fault>, NULL);

long raft
#

im not aware of anybody doing this intentionally, allan

#

for a particular use case maybe, like a host program that runs another process maybe

#

so im still confused. you would like every program on a computer to have access to the memory anywhere else on the computer?

fickle aurora
#

no, and it normally doesn't

#

the OS will throw the seg fault error

long raft
#

so you are fine with the OS seg fault

#

you dont like it in the programming language

fickle aurora
#

yes because if you don't prevent the program from overrunning the buffer, it is a security issue

long raft
#

but these languages do prevent you from overrunning the buffer

fickle aurora
#

of course they do and that's why they are bad, but on the plus side, they are good for making development much smoother

long raft
#

why is it bad? i thought you agreed it was good to prevent that

fickle aurora
#

ideally you want to use that to your advantage to debug the program, but you don't want to have your users deal with the security implications of it

long raft
#

but you wont catch every segfault by just debugging

#

its the same reason you wont catch integer overflows

#

youre not testing every single scenario that can happen...

fickle aurora
#

well integer overflow isn't a thing because integers are a set bit length

#

unless you mean arrays

long raft
#

no

fickle aurora
#

arrays can overflow, you need to terminate them

long raft
#

no i mean integer

#

byte x=255; x++; what is the value of x?

fickle aurora
#

integers have a set bit length, so like a regular int is generally 4 bytes, whereas a string can be any number of bytes from 1 byte up to whatever your memory can hold

long raft
#

answer my 'riddle'

fickle aurora
#

an array is almost like a string

long raft
#

i am not talking about arrays

fickle aurora
#

on the CPU level, there is no distinction between data types except for floats

long raft
#

omg allan focus

#

byte x=255; x++; what is the value of x?

fickle aurora
#

but then again, floats are simply just considered floats in a specific register

#

it depends a lot on the architecture

#

some will keep it to 0xff and set the sign flag and carry flag

long raft
#

then do you know what integer overflows are?

fickle aurora
#

yes there is a flag for overrun

long raft
#

do you test for integer overflows every time you do an add?

fickle aurora
#

you can

long raft
#

but do you

fickle aurora
#

libraries will handle it for you if you use libraries, otherwise you can check eflags

long raft
#

as a shortcut?

#

because you need to do it all the time, even tho it rarely happens

fickle aurora
#

usually you test input to ensure you never go above the max value

long raft
#

you would have to prove your code

#

testing would not be enough, youd have to prove it by induction

#

otherwise one could creep in

#

or you can just ... test it every time

fickle aurora
#

the thing is, one byte isn't going to cause a problem, because the CPU will only access one memory location for a one byte value

long raft
#

same thing for buffer overruns