[ / / / / / / / / / / / / / ] [ dir / animu / cloveros / ernst / leftpol / litpat / terka / vg / vichan ]

/tech/ - Technology

Name
Email
Subject
Comment *
File
Password (Randomized for file and post deletion; you may also set your own.)
* = required field[▶ Show post options & limits]
Confused? See the FAQ.
Flag
Oekaki
Show oekaki applet
(replaces files and can be used instead)
Options

Allowed file types:jpg, jpeg, gif, png, webm, mp4, pdf
Max filesize is 16 MB.
Max image dimensions are 15000 x 15000.
You may upload 3 per post.


File: 1e8706c1c3684a0⋯.gif (1000.27 KB, 500x281, 500:281, 0f6099e333f6da977d23997c97….gif)

 No.922663

>16 hours of troubleshooting and debugging on a microcontroller to realize that C requires a cast before bitshifting to a larger size because apparently my belief that values being operated on were placed in some dynamic memory is utterly wrong

CUT MY LIFE INTO PIECES

 No.922665

>>922663

I know you're angry at your own incompetence but this doesn't need it's own thread.


 No.922666

>>922665

>incompetence

WHEN YOU DO OPERATIONS ON AN INT AND A DOUBLE THAT RESULTS IN A DOUBLE VALUE THEN ASSIGN IT TO A DOUBLE, C AUTOMATICALLY DOES THE CONVERSATIONS FOR YOU. YOU DON'T HAVE TO EXPLICITLY CAST THE INT TO A FLOAT PRIOR TO CALCULATIONS (EXCEPT DIVISION). HOW IS IT NOT REASONABLE TO ASSUME C ALSO DOES THIS FOR OTHER DATA TYPES?

Also, this board is a little slow so having threads that naturally find a subject (i.e. bad programming stories) is good. Too bad you're too incompetent to understand that was implied :^)


 No.922667

what µC were you using


 No.922669

>>922666

checked, but youre wrong

if you wanted discussion you could have started a thread about Electronics or MCUs


 No.922671

File: c57687cee9b02e5⋯.jpg (11.37 KB, 313x313, 1:1, 12641.jpg)

>>922666

Should have made a programming stories thread then


 No.922673

>>922667

Teensy dev board - ATMEGA32U4


 No.922690

>>922663

>>922666

No sane language should do implicit type conversion IMHO.


 No.922695

Why don't you just use assembly and/or Forth? C is for the niggers of Unix.


 No.922791

>>922663

>thinking left shifts change the type you're working with

This was an insane thing to think in the first place, OP. Think it through.


 No.922797

I was going to insult C, but

>16 hours

That is your fault. You should have been able to pin point the issue using a debugger or something else in a much shorter amount of time.


 No.922799

>>922695

Name one forth program which I depend on every day. protip: you can't


 No.922803

>>922690

>No weakly-typed language should do implicit type conversion

FTFY


 No.922808

>>922803

That's the definition of weak typing. What are you trying to say?


 No.922811

>>922663

>my belief

This is the problem.


 No.922813

>>922799

SWIFT transaction systems that keep the entire world from collapsing and rebelling against (((them))).


 No.922814

>>922808

That they shouldn't exist, duh.


 No.922816

>>922814

So you were saying the exact same thing as the post you were "fixing"?


 No.922817

>>922808

>>922814

Strongly typed language can do some type conversions too, but mistakes are caught at compile time instead.


 No.922818

>>922817

If the type conversion is implicit then it's weak typing.

A lot of languages that are otherwise strongly typed do use weak typing when it comes to integers and floating point numbers, though.

Haskell has static strong typing. C has static weak typing. Python has dynamic strong typing. Javascript has dynamic weak typing.


 No.922821

>>922818

>If the type conversion is implicit then it's weak typing.

Wrong. A strongly typed language can use implicit type conversion. A strongly typed language just means that variables must be declared with data types.

>Haskell has strong static types.

So do many languages with shitty type systems, such as Java. The difference is that Haskell has full type inference.


 No.922822

>>922821

>A strongly typed language just means that variables must be declared with data types.

That's called static typing. Static and strong typing are different things.

Static means types of variables don't change. Strong means types of values don't change implicitly.


 No.922823

>>922822

Wrong again. Static typing means that type checking are done at compile time.


 No.922834

>>922821

>A strongly typed language just means that variables must be declared with data types.

Self-correction: this is a consequence of strong-typing in a static language. Strong typing means that data types and their interaction are well-defined. Just to pull back to the original remark:

>No weakly-typed language should do implicit type conversion

This statement still makes sense, in that a strongly-typed language can do implicit type conversion.


 No.922835

File: 5a569492a5bbe15⋯.jpg (28.69 KB, 578x461, 578:461, 1497732035251.jpg)

>>922666

>mfw c never does conversations for me


 No.922841

I'm making a demo for C64 and I've made this mistake at least 3 times already, I always laught when I finally find it out.

C64 has 64kb of memory and the video chip has a 16kb window into that memory, you can select which part of it you want it to access (vic banks). By default it's the first bank ($0000 - $3fff).

I start my code at let's say $1000 and set the vic bank to $4000 - $8000. in that vic bank memory area there are graphics and sprite pointers which are constantly changing (if you use sprites of course) and these 3 or 4 times my code grew past $4000 and my sprite pointers were overwriting my code causing weird things to happen or crash. The worst thing that can happen is to overwrite the code with zeros, because the opcode 0 is a break instruction and it jumps to your interrupt handler. So I set some interrupt handler for a specific line on the screen and then it's being executed couple of times durring the frame and you just don't know what the fuck is happening. Funny shit.


 No.922844

>>922799

It could be yours, if only you wrote it.


 No.922856

>>922663

So, which was it? Were you compiling without Wall, used some obscure or old compiler, or did you flat out ignore the warnings?


 No.922859

>>922666

C is a strongly-typed, static language. it's not dynamic so it won't cast for you.


 No.922868

This would have never happened had you been MISRA checking your code!!


 No.922869

>>922859

>C is a strongly-typed

It's like you posted without reading the thread first.


 No.922871

You're trying to fit terms like "strong" or "weak" typing to a shit "language" that's "gee, I don't know, whatever the PDP-11 compiler did." The words "strong" and "weak" aren't really precise terms anyway because people mean different things when they say those words. Whatever word is used to describe C will give that word a bad reputation, so I call it a UNIX language.

   I've been confusing my compiler class with this one for
a while now. I pull it out any time someone counters my
claim that C has no block structure. They're usually
under the delusion that {decl stmt} introduces a block
with its own local storage, probably because it looks
like it does, and because they are C programmers who use
lots of globals and wouldn't know what to do with block
structure even if they really had it.

But because you can jump into the middle of a block, the
compiler is forced to allocate all storage on entry to a
procedure, not entry to a block.

But it's much worse than than because you need to invoke
this procedure call before entering the block.
Preallocating the storage doesn't help you. I'll almost
guarantee you that the answer to the question "what's
supposed to happen when I do <the thing above>?" used to be
"gee, I don't know, whatever the PDP-11 compiler did." Now
of course, they're trying to rationalize the language after
the fact. I wonder if some poor bastard has tried to do a
denotational semantics for C. It would probably amount to a
translation of the PDP-11 C compiler into lambda calculus.


 No.922889

>>922871

Based UNIX hater fag. Keep triggering the UNIX weenies on /tech/.


 No.923003

>>922822

Strong typing means all type errors are caught. C is weak because of void* and unions letting you do unsound things.


 No.923024

>WHEN YOUR CODE STILL DOESNT WORK AND YOU REALIZE THAT THE ISSUE WITH SHIFTING MADE ABSOLUTELY NO DIFFERENCE AND THE REAL PROBLEM WAS HOW YOUR FUNCTION WAS MODIFYING THE ARRAYS PASSED TO IT

RRRRRRREEEEEEEEEEEEEEEEEEEE


 No.923046

File: 569afb8e4dfb082⋯.jpg (51.93 KB, 900x810, 10:9, serveimage.jpg)

>>922871

Yeah. C and UNIX are so shit they're literally used everywhere.

- Posted this from my UNIX-based OS written in C using libraries written in C to a RISC server with its HTTP server written in C to now respond to your browser written in C on your OS written in C.


 No.923051

>>923046

>implying they aren't using redox OS to run an OS in rust, using libraries written in rust, using the newest firefox to run a browser in rust, to post to a server running an OS based on rust,

<to a webserver program written in C

Someone needs to write a webserver in rust.


 No.923055

>>923051

are you going to rewrite and reimplement all the software those routers are running between your computer and the server?


 No.923064

>>923046

The only "UNIX-Based" OS currently in use is BSD as Linux is not UNIX-Based


 No.923069

>>923055

Install redox OS on it and copy+paste the assembly as a kernel module from the FOSS code of the linux kernel since that is what they are optimizing down to on routers whose purpose is fast transfer of bandwidth. Done, and that's assuming redox doesn't already have something like this.

>but anon, some architectures don't have a rust library implementation

Compile from C the rust library, then recompile the rust library with itself like bootstrapping a compiler. Or make an assembly implementation of said architecture in rust. Should be easier then dealing with specter of x86/64, middle aged powerPC, some MIPS, and all of ARM being instantly pwned by said exploit. You reduce attack surface very very greatly by completely eliminating a few classess of security bugs. Imagine the costs if your router was hacked to MITM and you were framed for it, or something worse. You would pay out the ass in law suits compared to the MAYBE 60,000 dollars it takes to pay a dev to take a year to upgrade your infrastructure to redox or something more secure.


 No.923073

>>923064

Linux and the GNU coreutils are very UNIX like, more so than "offical" UNIX OSes.


 No.923075

>>923064

<linux is not unix clone

>WHAT IS LINUX?

>Linux is a clone of the operating system Unix

t.linux kernel readme.txt


 No.923076

>>923064

Incorrect. You are forgetting Solaris, OpenIndiana, HP-UX, AIX, and undoubtedly others.

But the guy you replied to probably isn't using any of those. Maybe one of the BSDs.


 No.923078

>>923069

>lawsuits

That isn't even to mention the profit lossess your company would take just in being defamed as "insecure" "botnet". Like sure, if you are a ISP you are still getting kickbacks from the (((Government))) to keep everything backdoored, but you will lose out big time on profit in any other buisness.


 No.923082

>>923069

>maybe 60,000

Why couldn't it be maybe 120,000 or 1,000,000 Dollars? How long would it take to implement all this crap into operation? What are the costs of taking down the infrastructure during this transition? What are the losses incurred by losing customers during this downtime? How many times have routers been attacked? How many times has any personal information of people been leaked because of these attacks? How many lawsuits were there?


 No.923084

>>923075

'clone' =/= 'based'


 No.923093

>>923082

It depends on the company and the size of the buisness. For a large ISP this would take like four years in a best case scenario. For a small buisness it could take a week. So it just depends on the company's infrastructure. But regardless you would save money in the longterm with both upkeep and security/the fame of the company. If you want examples of companies getting shit on because of a hack look at the effects on paypal years ago or walmart. Sure they still became profitable eventually, but paypal has government subsidies for that and walmart has less profits then it would have but yet it is profitable because monopoly.

<What are the losses incurred by losing customers during this downtime?

>implying you don't have redundant infrastucture for backups in case of emergency/upgrades that wouldn't just switch over in less then half a second if that

wew, git good or higher better devs instead of pajeet next time faggot.

>>923084

Clone inherently implies it is the basis of the design for linux. https://archive.fo/OUDOe http://www.merriam-webster.com/dictionary/base

> a : the fundamental part of something : groundwork, basis

It is based upon unix.


 No.923095

>>923003

>Strong typing means all type errors are caught.

You could do type casting in a strongly-typed language and cause it to fail at runtime.


 No.923097

>>923093

You will need to show me how routers on the Internet are "small" companies. I have my doubts about that.


 No.923105

>>923097

A small company, such as a coffee shop or a small town's library, may have a router for public access that is insecure and could defame that specific buisnesses reputation if their customers keep getting hacked. Either they won't use the wifi, or in the case of the coffee shop, they will go to (((starbucks))) instead. Or since you are fishing for an example of a node that goes to a centralized server via hops, say a dataprovider such as cloudfare was hacked and all its node's/routers were openly compromised, such as the recent hacking of the 1.1.1.1 routers for DNS. People stop using their service and cloudfare became less trustworthy in the proccess which costs them future buisness deals with clients looking for cloud services. Or as routers/nodes for a local services like how 8ch is one server but is served from many different routers in the cloudfare network.


 No.923114

>>923105

You are confusing what router means with an actual piece of hardware. ISP's don't have connections to every single other network on the planet, so they connect with routers that transfer data between these different networks. Get it now?


 No.923125

>>923095

Yeah the catching can be the form of a runtime error, like a bad base-to-derived cast exception.


 No.923127

File: 5c331d0c35c4bb6⋯.png (323.88 KB, 442x472, 221:236, 5c331d0c35c4bb6c660b41175f….png)

>>922666

No, it just happens to have an overloaded operator that takes two doubles and it feels safe casting that and returning a double.

Where the did you get the idea that it was "being operated on in dynamic memory"? What does that even mean? You sound like the "soldering CPUs" kid.


 No.923152

>>923127

Programs don't just in-place change data as if it were some kind of big file. CPUs have to load this data into memory and then into registers in order to operate on it.

Dynamic memory, as in, there was some variable-length section of memory that was used to temporarily store variable data.


 No.923198

>>922663

I'VE REACHED MY LAST RESORT


 No.923400

>>922663

>t. shitty javascript pajeet tier webdev

You sure sound like you're a fucking retard

>bitshifting to a larger size

What is that even supposed to mean?

Do you think the compiler should somehow magically know when your int overflows, and put it in a bigger data type?

That's not how shit works.

The bitshift operator in itself is just a function, that takes an int and returns an int.

The compiler just looks at the method signature and reserves enough space for the returned type to put the result into.

If you truly think, the compiler could somehow magically know beforehand how big the return type should be, according if a result overflows or not, then you are just clinically retarded.

>>922666

Wew, you really are just a stupid nigger

You should consider killing yourself you fucking waste of space


 No.923452

>>923003

What can you do with unions?


 No.923457

>>923452

If you read a union member without it being the last member assigned to, then that memory doesn't necessarily hold the type you're asking for, which lets you pass around an x-pretending-to-be-a-y and violate type contracts with no error.


 No.923461

One thread had to die because you're mad as fuck at your own incompetence.


 No.923501

File: 96431450000a53b⋯.png (27.08 KB, 407x446, 407:446, zmRKd9m.png)

>>922663

>bitshifting to a larger size

What does that even mean. Why should bitshifting affect the size of your data? How would the compiler know when a bitshifted datum should be enlarged and when it should not?

>my belief that values being operated on were placed in some dynamic memory

what the fuck


 No.923619

>>923457

Oh, when is that useful?


 No.923662

>>923619

When you want to get raped by UB.


 No.923663

>>923619

I've seen situations where an union would have been useful, mostly in data processing software that use some sort of compression scheme involving dark bit-twiddling magic between integers and floats.


 No.923665

>>923400

Someone who thinks web developers work on microcontrollers in C is the one who is a fucking retard.


 No.923886

>>922671

>should have made a template thread instead because I hate not seeing the exact same thing every day


 No.923930

>>923665

But they do. Even since arduino got popular, web dev tier niggers hopped on board the choochoo train. They got their fancy IDEs and their broken C, and see what else they can fuck up next.


 No.923931

>>922663

>when C LARPers realize the difference between PL and implementation details


 No.923939

>>923930

So your saying that they take complicated things and make them easy to use?


 No.923945

File: 21139aa75b8db25⋯.png (187.55 KB, 473x488, 473:488, 3566f3ce0f76bee30cbc3eeec2….png)

>>923152

And you obviously don't know how registers work because you seem to think it will be happy to take in two pieces of data with different types and then guess which one you want.

Not only are guesses like this ill-advised and rare, but the processor itself is not generally the one doing them. Different registers hold different types of values and have different instructions they work with. Worse, moving to a "larger" data type (int -> long, for example) will probably require multiple registers be used together, depending on your architectured. The data itself is meaningless without the representation.

Finally, even in languages where implicit casts can occur, you are always better off forcing it. If you're going to make an assumption, enforce that assumption.


 No.923967

let me try to get this straight.

you had - let's say - an unit_8t, shifted that to the left and thought it would turn into an unit_16t?

wtf? wtf is this /tech/? this has to be a troll.


 No.923969

>>922663

can you pls post your code. thanks.


 No.924042

>>923945

>and then guess which one you want

Yeah, because the CPU also just randomly guesses that you want a float when you multiply an int by a float.... wait no, that's right. There's literally thousands of things that C and the compiler do to make your code transform into machine instructions.

I still don't understand how programs actually execute at any low level though, the difference is that I actually admit it, unlike >>923967 talking about "unit_8t"s


 No.924043

>>924042

>haha this idiot used unusual terms

he's fucking right though. OP's expectation that a left-shift would change the width-width of the type he was working with was completely absurd. This some numeric tower bullshit that Scheme might do, damn the costs, but nothing to expect from C. Just think it through, like I suggested way back in >>922791 . Fucking use your brain and stay focused on a single subject for more than 5ns. How many questions do you come to have about this operation? Does bit-width extend when you shift a bunch of 0s off the end, or only when a 1 is shifted off? If you care about 0s, can bit-width ever shrink? if char c = 1, what type do you need to store the result of ((((c<<1)>>1)<<1)>>1)<<1 ? Hey I just looked at any processor's instruction architecture and instruction set, how the fuck is this implemented? Maybe something this absurd isn't how things actually work.


 No.924044

>>924043

>haha this idiot used unusual terms

Yes. What loser fucks up something so simple? What an utter retard!


 No.924053

>>923967

>>924043

Small operands do get promoted to int, so maybe that's what OP was dimly thinking of.


 No.924721

>OP posts about bad experience with uC

>10,000 fedoras vomit opinions about the merits and lineage of various OS's and programming languages

>people even divert the discussion into networking routing territory

>EVERYONE MISSES THE FUCKING POINT

Don't program a uC in anything but its native assembly language. C might compile "almost to the same machine code as an assembler program" but almost isn't good enough in that environment. When you're working with 4K of program memory and 128 bytes of RAM, you need to know where every bit and byte goes, and to fully understand your hardware. Anything less results in an amateurish crap job.

Addendum: There is literally nothing wrong with C, used in its intended environment, for its intended purpose, by a competent programmer.


 No.924722

>>924721

You seem sane. You obviously don't belong here.


 No.924726

>>924721

You didn't read the thread fam. I already mentioned asm, and also Forth (which btw can take up less room than asm). Then some Unix/C nigger got his panties in a wad "hur dur name Forth program, u can't".


 No.924760

>>924721

>Addendum: There is literally nothing wrong with C, used in its intended environment, for its intended purpose, by a competent programmer.

> ...

> There's nothing wrong with C as it was originally

> designed,

> ...

bullshite.

Since when is it acceptable for a language to incorporate

two entirely diverse concepts such as setf and cadr into the

same operator (=), the sole semantic distinction being that

if you mean cadr and not setf, you have to bracket your

variable with the characters that are used to represent

swearing in cartoons? Or do you have to do that if you mean

setf, not cadr? Sigh.

Wouldn't hurt to have an error handling hook, real memory

allocation (and garbage collection) routines, real data

types with machine independent sizes (and string data types

that don't barf if you have a NUL in them), reasonable

equality testing for all types of variables without having

to call some heinous library routine like strncmp,

and... and... and... Sheesh.

I've always loved the "elevator controller" paradigm,

because C is well suited to programming embedded controllers

and not much else. Not that I'd knowingly risk my life in

an elevator that was controlled by a program written in C,

mind you...




[Return][Go to top][Catalog][Nerve Center][Cancer][Post a Reply]
Delete Post [ ]
[]
[ / / / / / / / / / / / / / ] [ dir / animu / cloveros / ernst / leftpol / litpat / terka / vg / vichan ]