[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vr / w / wg] [i / ic] [r9k / s4s / vip / qa] [cm / hm / lgbt / y] [3 / aco / adv / an / asp / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / qst / sci / soc / sp / tg / toy / trv / tv / vp / wsg / wsr / x] [Settings] [Search] [Home]
Board
Settings Home
/g/ - Technology


Thread archived.
You cannot reply anymore.



File: 1550902377559.jpg (286 KB, 1024x768)
286 KB
286 KB JPG
Previous thread: >>70165249

What aren't you working on, /g/?
>>
dead
>>
File: 1550156603594.png (337 KB, 823x720)
337 KB
337 KB PNG
>>70175326
god i hate /dpt/
>>
File: 1532570513557.png (1.18 MB, 850x1200)
1.18 MB
1.18 MB PNG
3rd for haskell tiddie monsters
>>
>>70175326
/dpt/ confirmed made up of 50 muzzies from new zealand
>>
C question.
I hear that you shouldn't pass (or return too I guess) whole structs to functions because they get stored on limited stack space, but does that also mean that you shouldn't have automatic variables of those types and also big non-static arrays local to the function as well since they too get stored on the stack or am I misunderstanding?
>>
post interesting projects to work on for employers
>>
>>70175585
An object big enough to put you in danger of blowing your stack would be 1KB large. Don't put that on your stack.
Otherwise feel free to pass structs around - though consider passing by const pointer (or in C++, const reference) if you're concerned about copying overhead. A large struct in this situation would be about 3 pointers in size or more.
>>
>>70175585
The default stack size on Linux is 8MB. There's plenty of space on the stack. Just stay away from pathological growth patterns and you'll be fine.
>>
anyone know why this export is an error?
>>
My workplace keeps hiring people who can't program as programmers. They've been paying massive amounts of money to hire expensive consultants to teach us agile methodologies and team building exercises and other stuff. They don't seem to understand that while methodologies can help, they won't fix bad programmers. It's not just bad code that's causing problems. Some of the ideas here are god awful. We had one project that was a 5 year rewrite that recently completed. It failed to meet several extremely important requirements. The lead developer in charge of the project kept dismissing the user complaints saying "You don't really need that" and their ego was so invested in backing up that statement, that the application was written in such a way that trying to add that functionality later was almost impossible without another rewrite. It was almost designed to be a middle finger to the users.

The two most toxic kinds of people you'll ever have on a project are people who cannot code at all and people who can code a little but think of themselves as the next Linus Torvalds and invest their entire ego into it. That describes 80% of the developers at work and it's killing us.
>>
>>70175728
What kind of people would you like to work with?
>>
>>70175687

1. Read the fucking error message. See how it's complaining about a missing semicolon? That means you should...
2. Put a fucking semicolon on line 26 after the closing brace, idiot.
3. You also misspelled default, by the way.
>>
>>70175772
Competent people. I'm not under any delusions that I'm some genius who deserves a job at Google or something. I'm just tired of half my coworkers being pity hires and the other half working on baby's first CRUD web app and strutting around the office like they shit gold and name drop Martin Fowler every other sentence. Not that they even follow Fowler's advice since most of our code has no tests and some of the few projects that do are so bad at it, that I've seen people create mocks and then test the god damn mock object itself. They've effectively written a bunch of "tests" but still manage to have zero percent code coverage.
>>
>>70175791
sorry i have dyslexia, but thanks
>>
>>70175820
I feel you anon. Truthfully it's very unlikely that any of this will ever change. If you want to work with more competent people, you're gonna have to go elsewhere.

I've had many programming jobs and the one thing that always made my coworkers smarter was switching to a better job.
>>
So i want to port Minecraft algorithm for checking if Slime's can spawn in given chunk, from Java to C/C++. My problem is, its using Java Random() method, which works differently than the stdlib rand(). What can i do to make pseudorandom generator from Java in C/C++?
>>
File: wot.png (158 KB, 3296x836)
158 KB
158 KB PNG
Ok guys, sorry to bother but something that started as trying to change a simple config setting in some cfg file or something ended up trying to quickly learn (or at least understand) java bytecode and i am truly lost.

so whats happening is i found the jar file that has the code of what i want to change, and i have found the most simple change i need to make for my goals: have this (numFalse) be zero, or as low as possible.
Problem is, i cant get a modified, or even the "original" jar file to work: i unpacked it, and even if i repack it unmodified as .zip then rename it .jar (as i have red) it wont work and is about 100kB larger than the original

So my second attempt was to directly change either the numFalse (after the random has been assigned), or change the random generations limit to be lower, directly in the jar file so i wouldn't have to un-/repack it; but pic related is about as far as i got, and have no idea where to actually find it, let alone if i could even change it.

Any advice on how to proceed? either if i should loop back to my first attempts to make the jar file, if so: how? Or i can actually edit something in pic related, if so, what and how can i find it?
>>
>>70176010
http://www.pcg-random.org/
>>
File: maybe.png (4 KB, 599x114)
4 KB
4 KB PNG
>>70176019
could this be it?
the index, constant and the bytcode matches (i think) but the linenumbers and start_pc (whatever that is) and stuff have zero relations as far as i can tell
>>
>>70176010

Nvm, i have found Java documentation which says what math is behind random generation in Java.

https://docs.oracle.com/javase/7/docs/api/java/util/Random.html#Random(long)
>>
>>70176061
could be, what comes after?
>>
File: IMG_20190313_072755.jpg (989 KB, 4006x4096)
989 KB
989 KB JPG
>>70175772
unironically, /dpt/'s sepplefags and FPweenies.
>>
File: 1551134438448.jpg (29 KB, 497x497)
29 KB
29 KB JPG
>>70176253
/dpt/ should become a company or programming guild so we can all program together
>>
File: IMG_20190304_083829.jpg (166 KB, 865x1311)
166 KB
166 KB JPG
>>70176280
The most powerful programming guild in the world.
>>
>>70175614
>1KB
nigga this isn't 1990, stacks are measured in megabytes now
>>
>>70176369
I meant 1MB.
>>
File: 1550284770632.jpg (87 KB, 1280x720)
87 KB
87 KB JPG
>>70176337
once we put our heads together we'll manage to solve fizzbuzz and average all of the ints in C
>>
>>70175687
>Mixed HTML and Javascript
What the fuck is this basedboy shit?
>>
>>70176280
In the condition that we stay anonymous and only use handles at work.
>>
>>70176010
First, stop programming in C/C++ and program in C++.
Second, use the C++ stdlib random, not C stdlib random.
>>
Started working on a simple IRC client for my operating system. I needed something relatively simple to test my TCP/IP implementation and discover problems. It feels more and more like I'm testing my GUI library though. :)
>>
File: pygame.png (22 KB, 802x769)
22 KB
22 KB PNG
lamo
>>
Virtual memory is bloat. Prove me wrong.
>>
>>70176469
The more and more I read your code and your code style the more I come to the conclusion that you're literally me.
>>
>>70176469
you seem to be coding this really fast, aren't you worried about security holes?

are you writing tests?
>>
who /started enough projects that go nowhere to know that there's no point in writing all that prerequisite code ever again/ here?

fuck programming and fuck me
>>
>>70176698
Stop reinventing the wheel, and maybe you'll get to see some projects finish.
>>
>>70176707
i'm not
>>
>>70176707
Not him but does it count as reinventing the wheel if the only other existing wheel is too damn slow and shitty to reasonably use?
>>
>>70176663
I worry about performance and stability. Security is not a goal at the moment. I'm not writing any tests.
>>
File: ss.png (69 KB, 1210x1588)
69 KB
69 KB PNG
>>70176160
sorry for late reply, was trying to test it
pic is all that follows, and after changing it from 5 to "iconst_1"m which i would assume would get me a random.nextInt(1) i got the error in the red squre
>>
>>70176610
Nice to meet you :) What are you working on?
>>
>>70176779
We're the same person so you should already know the answer to that.
>>
>>70176790
Touché
>>
File: js-rocks.png (368 KB, 1000x494)
368 KB
368 KB PNG
JavaScript rocks!
>>
>>70176751
looks like the right place
I would have assumed that changing it to iconst_1 shouldn't be a problem.
how did you change it?
is there anything useful in starsector.log?
>>
File: 1551967653027.jpg (64 KB, 600x595)
64 KB
64 KB JPG
>>70176751
>istore
>fstore
>iconst_
>fconst_
>iadd
>fadd
utter incompetence.
>>
>>70176280
>>70176337
>>70176413
>>70176433


If you guys are serious there are concurrent web based text editor programs out there (or we can gnu screen into the same terminal) and just start coding a frankenprogram.

I don't know I'm down though.

I'm imagining the software version of the movie Cube.
>>
>>70176572
Maybe so, but it provides an incredibly useful and valuable abstraction when dealing with threads and/or multiple processes, not to mention the safety / security benefits it affords you.
Besides, I *very* seriously doubt using Virtual Memory will be a performance bottleneck. It's probably some dipshit using bubble sort.
>>
>>70176843
Too many side effects for a Haskell programmer.
>>
>>70176915
>Virtual Memory
It's not a pronoun. Learn English you dumb fucking ESL faggot.
>>
>>70176843
What's this?? Did people dieded?
>>
>>70176931
>ESL faggot
How many languages do you speak, Brandynn?
>>
>>70176852
Unvarying instructions may come as bad for PL implementations targeting the JVM but it does come with a slight perf increase and ease of disassembly.
>>
>>70176931

Do you mean "proper noun"?
>>
>>70176843
>subscribe to pewdiepie
>remove kebab
>gas gas gas
An inspiration to us all.
>>
>>70176957
Yes. I realized that after posting, I am a dumb baka.
>>
>>70176945
The only 2 languages that matter. English and Japanese.
>>
>>70176915
It wastes a significant amount of silicon and makes context switching much more expensive.
>>
>>70176931
>McKean's Law
> "Any correction of the speech or writing of others will contain at least one grammatical, spelling, or typographical error."
Like poetry.
>>
>>70176979
What constitutes a "significant amount of silicon", though?
And for context-switching, would the alternative just having one main context? If so, what's stopping program A from snooping into program B's contents?
>>
>>70176979
>It wastes a significant amount of silicon
Silicon present on chip before context switch: 100%
Silicon present on chip after context switch: 100%
???
>>
>>70176951
Oh, okay, I'm relieved. I feared the worst when he started shooting on the pedestrian walk. I don't think he's a Haskell-man, though. This seems very object-oriented.
>>
>>70176915
Context switching is expensive with virtual memory because it means that any caches that are indexed by virtual addresses must be flushed.
With a single address space this is not necessary. This also does not preclude memory protection.
>>
>>70176998
He's referring to the MMU hardware used to support Virtual Memory
>>
>>70175415
this

>>70175585
For stuff running on a PC, stack-allocating shit is fine as long as it isn't massive. On something small (e.g. a microcontroller where you might have a stack as small as 512B), you should be more cautious.
>>
>>70175415
more
>>
>>70175272
wasn't sure if i should post this in here or /sqt/. I'm trying to work on my uni project from home and and i am having issues with javafx. I did sudo apt-get install openjfx and it didn't fix it anyone know what i can do?
>>
File: dd.png (35 KB, 1834x252)
35 KB
35 KB PNG
>>70176851
not really, pic related
i was using jbe to look around in it, but when i tried to change stuff with it it gave an error of not finding the folder, so i used jbytemod to change it

after messing with it quite a bit more, i give up on it since ultimately its a minor gameplay thing but at least i (think) i learned something.

thanks for the help though, i appreciate the effort. At least i know i was poking in the right direction
>>
>>70177231
There's probably some project setting on your IDE, where you need to include javafx.
>>
/r/ing dpt project roll image
>>
>>70177438
Fuck off.
>>
>>70177438
Fuck me~
>>
>>70177450
You're not a girl and never will be.
>>
>>70177458
Who implied that
>>
>>70177461
Me.
>>
trying to pick a first project to learn the machine learning meme, it seems like there are a few typically suggested to beginners like identifying twitter sentiments, predicting stock prices, and some thing about classifying flowers. any recommendations?
>>
>>70177231
god I wish I could meet you IRL
>>
My employer wants me to start tracking what I'm working on/doing with my time every day, for "task time estimate" purposes.

I feel like this is a bit oppressive and I don't take well to being micromanaged. At the same time, I see how the information could be used to adjust estimates. Am I being unreasonable by being uncomfortable with this request?
>>
>>70177566
It's reasonable if you think you're doing less work than you're supposed to, otherwise not really.
>>
I need a project in java lads any ideas?

Obs: all i know is core java, don't know shit about spring, hibernare etc. Ive been studying with javac only. Need something not so overcomplicate so i can move on.
>>
>>70177566
He's just doing his job. Your manager is ultimately responsible for estimate accuracy and deadlines being met.
>>
>>70177566
I wish someone would do that with me I can't be trusted to be productive by myself but I want to be
>>
>>70177634

It kind of makes me feel like looking for another job to be honest. I'm not one of these hardcore productivity machines, but I get my work done.


>>70177675
I feel like after a few months of working here there should be a movement towards more trust, while this seems to be going in the direction of less trust. But I could be overreacting.
>>
>>70177438
someone post it (again)
>>
File: 1552351443478.png (1.61 MB, 3840x2160)
1.61 MB
1.61 MB PNG
>>70177438
>>
File: DarDpvOUQAAoshw.jpg (167 KB, 1200x1150)
167 KB
167 KB JPG
God I fucking hate webdevs and their framework treadmills. The latest news in my little niche of reverse engineering is that the fucking NSA all but openly took a pot shot at the industry champion by releasing their own tools (which on the face of it seem to be in some ways markedly superior) and it was still less an upset overall than all the "full stack" developers jumping ship to the next PurpleCoffeeMonkeyBeans.js. And if it wasn't bad enough in of itself, they're so fucking smug about how you should be using the latest gimmick.
>>
>>70177773
Uh?
>>
>>70177794
tl;dr: fags jump ship too much and managers want to be using the latest "tech"
>>
>>70177810
yeah but how does it affect you? unless you're a webdev yourself but then why the fuck should we care
>>
>>70177773

This is why you learn backend instead of trying to compete with onions over who is the biggest framework cuck
>>
>>70175415
S L U T
>>
>>70177566
I mean I wouldn't worry about it as long as you're actually doing what they pay you to do, which is work. If you're actually working I'm sure he just wants to know how long it takes you to complete a task so that way time estimates can be more accurate. Unless you're fucking around most of the time then I'm sure it's not a big deal.
>>
>>70175585
The real reason is ABI issues. Everybody agrees on what the C ABI is for almost everything. Nobody agrees on whether structs get passed on the stack, or in registers if they're small enough, or registers if they're small and on the stack otherwise, and so on.
>>
>>70178116
Every ABI defines this though.
>>
Is anyone familiar with JASS? I’m trying to figure out how these hacks put together twilights eve save/load system to migrate files
>>
>>70176852
>>70176947

What's the problem
>>
If you write some SQL code in your program, can you say it's my SQL?
>>
>>70178198
polymorphic instructions or lack thereof
>>
>>70178277
it's sqlite
>>
>>70178263
How do I add a question mark at the end of a Template Token?
>>70178456
Also how do I make a template token choice?
>>
>>70178569
sorry, I deleted those because I wanted to type up my problem better.
>>
is it retarded to use an sqlite file in the root directory of a webpage?
>>
>>70178577
it's fine as long as you deny access to the file
>>
File: a.png (73 KB, 748x876)
73 KB
73 KB PNG
I was asked to create a survey that generates a PDF report once it's completed.
This is what I got so far.
However, some of the later survey questions have more complicated answers than yes or no and I can't figure out how to make it display a choice of answers rather than a text box.
Also I don't know how to add a question mark at the end of the Template Tokens.
>>
>>70176469
Making some progress on my IRC client. Spent a bunch of time making a stacking widget container for being able to keep multiple widgets in the same space with only one showing at a time (selecting a channel puts the relevant channel view widget on top of the stack.)

It seems to work pretty well. Thinking I will use the same mechanism to implement a tabbed container later.

But now I have to go and feed my mom's cat :)
>>
>>70178655
aren't you the guy making his own os?
how much ram is it using now?
>>
>>70178689
I am that guy yeah. According to ProcessManager in the screenshot, it's using 13180 KB worth of memory in userspace allocations, along with another 152+327 KB of kernel memory.

Still decently light I would say :)
>>
>>70178732
shit man thats great
what does it have working currently and what are your long term goals for it?
>>
>>70178759
I've really only tested it in QEMU and Bochs, so I don't know yet if it works on real hardware.

I have half-decent support for a number of things right now: a whole bunch of POSIX, userspace BSD-style sockets for TCP/IP and UDP, Ext2 filesystems, an ever-growing GUI library, and various other things. I'm kinda adding things in the order I feel like working on them, it's all very organic.

My long term goal is to switch to this as my main operating system for personal computing, while keeping things light and tight.
>>
File: 1528501159356.jpg (271 KB, 1350x1450)
271 KB
271 KB JPG
>>70178865
you're like everything i wanted to be
is it difficult? what resources did you use to learn about osdev?
>>
File: c7c.png (106 KB, 612x491)
106 KB
106 KB PNG
>tfw having trouble with basic Ruby Methods
i should write a program to kill myself
>>
>>70178948
stupid frogposter
>>
>>70178975
Yes, I am stupid. This is not new to anyone.
>>
Reimplementing an audio management system using OpenAL
>>
File: 1523274347857.jpg (38 KB, 500x451)
38 KB
38 KB JPG
how do I make calculator that behaves exactly like the windows one? Is there some algorithm or some step by step what should happen after pressing key?
>>
>>70178885
It’s definitely difficult sometimes, especially with the lack of debugging facilities and sparse documentation. You get used to it though, and it becomes part of the fun.

I worked on an x86 PC emulator before I started writing the OS, that has helped me a ton with getting all the basic stuff like scheduling / paging / etc working.

If you are interested in OS development there are some good resources for getting started on osdev.org
>>
>>70179009
https://github.com/Microsoft/calculator
>>
File: 1535406806521.jpg (141 KB, 756x1008)
141 KB
141 KB JPG
>>70179092
dude, that's like 50 cpp files, I ain't got no time for that shit
>>
>>70178948
Why do you even use ruby? It's a ridiculously slow language with an atrocious syntax and even more atrocious style-guidelines. Just use Python or JavaScript like everyone else.
>>
>>70179119
lmao
>>
>>70179112
dont you want to make a quality(tm) enterprise(c) ready software(r)
>>
>>70179092
>make a calculator
>create a NetworkManager file

https://github.com/Microsoft/calculator/blob/057401f5f2b4bb1ea143da02c773ac18d1bb9a2e/src/CalcViewModel/Common/NetworkManager.cpp

hah
>>
>>70179112
There doesn't seem to be that many files for the actual functionality. Most are interface-related.
>>
>>70179119
because the class I'm taking is teaching ruby
>>
>>70179198
based prof
>>
>>70179198
Well, he should have taught you the basics, then. It's not really that bad of a language. I just hated its untils and unlesses, and especially the weird syntax for some loops and structures. And the implicit return is also annoying.
>>
>>70177238
update: it does actually work, i'm just a colossal retard and from the drop-down menu i picked "l_const 1" instead of "i_const 1"
>>
>when your merge request gets stuck because someone made a pedantic comment then disappeared all day
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
>>
>>70179245
I half suspected something like that lol
>>
File: 1311355080377.jpg (57 KB, 457x759)
57 KB
57 KB JPG
>>70176010
>>70176010
String slimes;
String slimes;
>>
https://github.com/ShiqiYu/libfacedetection

>An open source library for face detection in images. The face detection speed can reach 1500FPS.
>>
>>70179577
China numba wan
>>
File: gopher.jpg (26 KB, 236x315)
26 KB
26 KB JPG
After years of tolerating shills for Go I decided to look into it. Damn I think I found a dumber language than Java.

>no exceptions, err!=nil is the actual standard
>no generics, they are "too complicated"
>goto directive in a language from fucking 2019, and gophers trying to justify it on reddit
>null was a billion dollar mistake, so let's do nil instead
>a code style enforced by an autistic compiler

The only thing I find cool is the easy integration with C.
The fact that it is so widespread paints a sad picture of the state of programming in this decade.
>>
>>70179703
>nil
What's the difiriince between that and null?
>>
>>70179703
No exceptions is a good idea on paper, but with no generics there's no sensible programmatic way to handle error values.
>>
>>70179729
Two.
>>
File: 1508760922751.jpg (85 KB, 600x600)
85 KB
85 KB JPG
>>70175272
Clojure is the most powerful programming language
>>
>>70179729
None, that's my point
>>70179739
If you enforce to handle error values as a return value then you must manually propagate them up the stack. Why is that better than having exceptions that walk up the stack by themselves until they find code that handles them?
>>
File: Rust-Logo.jpg (26 KB, 512x512)
26 KB
26 KB JPG
>>70179804
*blocks your path*
>>
>>70179815
Explicit control flow and no pseudo-dynamic typing.
Although, exception checking (particularly with better type inference) would solve this issue.
>>
>>70179703
>goto
I heard that's only in Go 2 and it's spelled "go2"
>>
>>70179703
Go supports the nil pointer. This is similar to C's void *, an enormous source of bugs. Since nil can represent any type, it completely subverts the type system.
>>
struct CoinList{
struct CoinListNode* head;
};
struct CoinListNode{
struct CoinListNode* next;
struct Coin* content;
};
struct Coin{
...
};

vs
typedef CoinListNode** CoinList;
struct CoinListNode{
struct CoinListNode* next;
struct Coin* content;
};
struct Coin{
...
};

vs
struct Coin{
struct Coin* next_coin;
...
};
>>
File: ylj48wgqq2m21.jpg (113 KB, 960x739)
113 KB
113 KB JPG
Cmake vs regular makefiles?

Cmake is comfy but I kinda hate how it creates unreadable makefiles
>>
>>70179940
>but I kinda hate how it creates unreadable makefiles
Why does this matter to you?
>>
>>70179934
C or C++? You're not using C++ features like nested types but you're also not using C naming conventions.
>>
>>70179153
Probably collects data to make calculations more precise, user friendly and targeted for you, for a better overall calculator UX
>>
File: 1531727984287.jpg (143 KB, 990x1200)
143 KB
143 KB JPG
>CS teacher tells me we should never use goto
>five minutes later she uses switch yüstatements
>>
File: chan-chan.jpg (40 KB, 546x828)
40 KB
40 KB JPG
>>70175272
How do i make it simpler and more elegant?
>>
>>70179009
Hope you mean Win 7 and XP calculators, because the current one sucks donkeyfuck
>>
>>70179959
Interested in your conventions comment, what do you mean?
>>
>>70179974
my CS teacher uses void main
>>
>>70179993
The asterisk goes next to the identifier and type names (particularly if they are not typedef'd) tend to use snake_case.
>>
>>70179980
    str += ((i % 2 == 0) ? "#" : " ");
>>
>>70179958
>Why does this matter to you?
i like to keep it simple
>>
>>70179974
>>five minutes later she uses switch yüstatements
My god! Does she also use loops?!
>>
Isnt one of the main points of lambda functions that you can fire and forget them without worrying about defining their requirements explicitly ? That's what I learned in JavaScript

Now I'm looking at lambdas in Java and apparently you always need to define them in an interface before using them. Doesn't this defeat the purpose?
>>
>>70180011
str += (i % 2 ? " " : "#");
>>
>>70176010
>two random number generators
>I don't like what's behind them
Uh

Am I the only one seeing a problem with "I don't like these random numbers, I want those random numbers"?
>>
>>70180029
Just use the types in java.util.function
>>
File: 1529000671540.jpg (49 KB, 599x800)
49 KB
49 KB JPG
>take your code
>find every numerical literal
>open a calculator
>convert them all to hexadecimal
>write them all like 0x0ff
Congratulations, now you are a hardcore elite codemaster
>>
>>70179940
cmake has one really, really annoying issue they won't fix: You can make out-of-tree builds for the file finals, but you cannot export objs and stuff if you want to pre-process and then do something else. cmake caches everything, on the basis it simplifies compiling projects which used share files. BUT if you want to have EVERYTHING exported, so you can get an idea of how your stuff is being compiled and make it more portable outside of cmake, you can't.

cmake also goes ballistic if you move files around, it doesn't like doing relative directories in it's compilation process, so you have to constantly clean if you add new files or move the directory.

There's also some other shit, I forgot what it was. make is used in the majority of normal applications that use makefiles, and it more easily integrates with the system. It is lower-level, but it's got a very primitive interface which works wonders, if combined with some build scripts in batch, bash or perl, to set up compilers and do more advanced configuration.
>>
>>70179980
You need to align your braces. Your first if needs to be tabbed in. Your first else too. And the second else. don't do this x+=1 do x++. a should be a boolean.
>>
>>70180035
I guess, I prefer how mine reads though.
>>
>>70180049
Our stylesmith banned all use of hexadecimals, and other bases except 10, because it makes the code to hard to read. I fucking hate doing bitflag operations in base 10.
>>
>>70180011
>>70180035
>>70180070
Thanks mate.
>>
>>70179980
My syntax may be a bit off
Let sym = [' ', '#']
for (x = 1, x<=8, x++){
Let str = ''
for (y = 1, y<=9, y++){
str+=sym[(x + y)%2]
}
console.log(str)
}
>>
>>70175272
What are some interesting programming challenges like FizzBuzz?
>>
>>70180036
Are you retarded? Random numbers in programs are deterministic, given a specific seed it will always give the same results, if he wants to determine the results of a Java program from a specific seed, in another language obviosly the ransom function would have to be the exact same as the Java one.
>>
>>70175272
Please do not use an anime image next time. Thank you.
>>
>>70175272
Please use an anime image next time. Thank you.
>>
>>70180374
>>
>>70175272
Please use a tentacle demon raping a Haskell compiler next time. Thank you.
>>
>>70180018
The emitted makefiles aren't part of the distribution. They're an intermediate representation. Your emitted .o files are NOT Simple.
>>
File: 1538473573800.png (564 KB, 736x598)
564 KB
564 KB PNG
>>70180411
is this the kind of stuff normees really think
>>
>>70180360
Write a function that takes positive integers n and m, and prints an n by m matrix containing the integers 1 to n*m arranged in an inward spiral starting at the top left. For example, spiral(3, 5) should print
 1  2  3  4  5
12 13 14 15 6
11 10 9 8 7
>>
If I read SICP will I git gud? At least more than a pajeet?
>>
>>70179974
While you could argue that a switch is semantically equivalent to goto, its scope is restrained which gets rid of the main problem that goto has. This is just one of the examples where goto or equivalent is basically ok. The whole "never use goto!!!" thing is just there to scare new programmers away from using to to write hellcode.
>>
>>70180577
Yes, 95% of the population will see you as a freak if you're an adult male obsessed with silly Japanese cartoons (rightfully so, by the way).
>>
>>70180600
didn't ask for your opinion
>>
>>70178655
What's the point of stacking layout? i3 has this but I don't see how it is better than tabbed
>>
>>70178865
What do you think about transparent persistence?
>>
>>70179119
>ruby syntax
>atrocious

print is a statement
del list[4]
no case statement, has to emulate with dictionaries and functions
>>
>>70179243
>I just hated its untils and unlesse

brainlet

>especially the weird syntax for some loops and structures

what exactly are you talking about? blocks?

>And the implicit return is also annoying.

wot
it's the best feature of the language
>>
>>70180591
SICP is a meme. It's a book about a language no one uses except for in school, and it is the most annoying language in the world to code in.
>>
>>70176431
t never heard of JSX
jeez I'm a C# developer and even I know the basics of modern web dev
>>
>>70179703
The key point here is our programmers are Googlers, they’re not researchers. They’re typically, fairly young, fresh out of school, probably learned Java, maybe learned C or C++, probably learned Python. They’re not capable of understanding a brilliant language but we want to use them to build good software. So, the language that we give them has to be easy for them to understand and easy to adopt. – Rob Pike
>>
>>70180747
>>70180765
Found the triggered fanboy.
>>
>>70179703
goto is fine and helps keep functions short, readable, and fast
>>
>>70179112
It took me about 3 minutes to find the files which mattered. Fucking noob
>>
>>70180585
In J this is just
   spiral =: 4 : '(x*y) - |."1|.(|:@|. , {:@{: + >:@i.@#)^:(+:<:y<.x) (,.`,: @. (y>x)) i. >: | x-y' 
3 spiral 5
1 2 3 4 5
12 13 14 15 6
11 10 9 8 7
>>
>>70179940
Learn make and use regular makefiles. Make is actually as powerful as lisp, arcane syntax not withstanding. It has insane metaprogramming capabilities. You can easily do shit other systems simply don't allow.
>>
>>70180600
95% of the population also couldn't write an operating system like mine even if they tried their hardest
>>
File: 1552680268566.webm (2.75 MB, 400x300)
2.75 MB
2.75 MB WEBM
>>
>>70176469
Why did you (presumably) write your own vector?
>>
>>70175728
>My workplace keeps hiring people who can't program as programmers. They've been paying massive amounts of money to hire expensive consultants to teach us agile methodologies and team building exercises and other stuff. They don't seem to understand that while methodologies can help, they won't fix bad programmers.

I have to suffer through this as well. They do all this overdesigning and tell us how to design our programs even though they haven't even bothered to read through our codebase.
>>
>>70180921
perfect
>>
>>70180833
I don't even write ruby anymore but claiming it has a worse syntax than python is just brainlet

python is horribly inconsistent, it has a normal list API but suddenly there's a keyword for deleting items, print is a goddamn statement built into the language, it can't decide whether its functional or object oriented, the apis are absolutely horrible

its like a joke that caught on. what saves the language is the enormous amount of libraries it has.
>>
>>70180100
What the hell is a stylesmith?
>>
>>70180962
>print is a goddamn statement built into the language
?
>t can't decide whether its functional or object oriented,
?
>the apis are absolutely horrible
?
>>
>>70180921
I wonder if he did that with a script or if he's truly deeply autistic.
>>
>>70180962
>I used Python last time in the early nineties, and it sucked!
>>
>>70180962
i love py

from dataclasses import dataclass

@dataclass
class Position:
name: str
lon: float
lat: float

pos = Position('Oslo', 10.8, 59.9)

print(pos)
>>
C question, tcc in particular, does anyone know if tcc supports widechar literals such as L'Ћ', by default it seems to try and treat them as regular char literals, and complains that there's more than one byte in Ћ, the compiler claims to aupport moat of c99 so is there just a flag i forgot to include or does tcc just not have the capability to do this, sorry if it's a basic question but I couldn't find any clear answers anywhere in the docs.
>>
>>70179119
>slow
Rubinius and JRuby both outperform CPython (but not PyPy)
I'd much rather use Ruby than Python
>>
>>70181033
https://lists.gnu.org/archive/html/tinycc-devel/2017-09/msg00000.html
>>
>>70176280
>/dpt/ should become a company or programming guild so we can all program together
That exists. It's called open source.
>>
>>70180698
The stacking layout I was working on is for use within a single window, not a window manager concept. It's really just an implementation detail for using one widget to select which one of a set of other widgets is currently showing.

>>70180707
What is transparent persistence? And what do you think about it yourself?

>>70180909
What kind of operating system are you working on?

>>70180927
I wrote my own vector because I intend to write my own everything. :)
>>
>>70180984
There's a shitload of functions whose entire purpose is to call a __method__ on some parameter and the entire reason why it exists is to treat built in types specially

>>70180997
It still sucks
>>
>>70176572
t.complete retard
>>
>>70181158
You’re a fucking retard.
>>
>>70180600
95% of people are concrete. make that 99%.
>>
>>70181116
Transparent persistence is when you create a memory hierarchy and make non-volatile memory part of it. So data is transparently transferred to and from the processor caches, RAM and hard disks or solid state drives. As far as software knows, the data just exists and there is no need to save to or load from disk.
>>
File: 1501695750557.jpg (82 KB, 783x590)
82 KB
82 KB JPG
>boomer deadbeat dad who hasn't programmed anything since the 90s wants to talk to me about this new idea he has, and I agree to help him with it
>starts rambling for 6 hours about this new operating system, that's going to blow Windows and Apple out of the water, and it's going to be the biggest hit in computing, and we will become billionaires
>tells me I must make it into the thesis of my major so he can patent it for free, and starts telling me how I should write it, and what it should look like and shit
>also I have to start working on it right away, because after working 8 hours + college I should spend all my free time on this
>and also translate it to chinese, because the chinese don't speak english and that's where the money is
How the fuck tell him to fuck off without making it look like I hate him and his idea?
>>
>>70181178
YOU'RE the retard, complaining about blocks and returns in ruby. lmao.
>>
>>70181253
Ask him how is it gonna be better than Apple and winblows
>>
>>70181253
dumb frogposter
>>
>>70181253
1. If you have a great idea you should see it through yourself.

2. If something is truly great and needs to be done then money should not be a motivating factor.

So tell him to get fucked.
>>
>>70181285
>>70181253
Yeah I'm curious to know what is so great about it and what did he manage to talk 6 hours about?
>>
>>70181244
I see. Thank you for explaining!

I don't think that's something I'm personally interested in, but I can certainly see the utility. I prefer the old, more explicit, storage models where you press save if you want to save, and nothing is automatically uploaded anywhere, whether to cloud or disk.
>>
>>70181285
That's what he rambled about for 6 hours
They are just very mild quality of life changes, I'm certain some linux distros already have them

>>70181292
It's to "help me become famous"
>>
In clojure my first tail recursive call has AVERAGE argument. To get it I divide total/ size but in the first call they're both 0.

How do I get around clojure telling me I can't divide by 0?
>>
>>70181334
>Change the mac folder icon to windows one.


*mindblown*
>>
what's the best deterministic random number generator in the standard library of sepples?
>>
>>70181419
rand()
>>
>>70181419
std::mt19937
>>
>>70181438
hey that was the one I was going to use anyway
>>
>>70180771
Fuck you, Scheme is the best language.
>>
>>70181480
don't post ntr games here
>>
>>70181419
rand without seed
>>
File: colpis.png (35 KB, 148x180)
35 KB
35 KB PNG
>>70181484
I'm so sorry.
>>
you think that works to normalise a unsigned long to a float in the interval [0 ,1]?

(float)((random() >> 40) * 1.0 / (1L << 24));
>>
>>70181116
>I intend to write my own everything.
What kind of hash table are you going to use? I'm trying to pick a good one
>>
>>70181641
cuckoo hash obviously
>>
>>70181641
I'm using a pretty simple one where each bucket is a linked list in case there are collisions:
https://github.com/awesomekling/serenity/blob/master/AK/HashTable.h

I admit I just wanted to get it over with so I would have a hash table for programming other stuff, so this is far from optimal :)
>>
>>70181671
Thanks for sharing your OS source :)
Is that a Firefly reference?
There is a parallel between your OS and the ship and the way the characters talk about it.
>>
File: tmp.png (43 KB, 1102x836)
43 KB
43 KB PNG
Finally managed to find a working disk image of a monitor for my C64 emulator. Give me some beginner-level assembly programming projects.
>>
>>70175272
I started looking through the quakespasm VR source in order to figure out how to add turn speed adjustment for VR controllers (it was slow as shit by default). Turns out it was very, very easy to add a cvar for that, so now I'm going to play some Quake in VR.
>>
>>70181719
It's a sobriety reference actually :) But I did enjoy Firefly when I saw it.

And I'm happy to share my code. Maybe someone can find something useful in there.
>>
>>70181792
I like seeing other people's approaches, since this is C++ the code is very different to my style since mine is all plain old procedural C code and none of this OOP stuff.
>>
Why the fuck does shift tab have to be a separate libinput keycode. God damn it.
>>
File: v_lang.png (104 KB, 1920x1080)
104 KB
104 KB PNG
https://vlang.io/

What's this quakery?
>>
>>70182030
the Video Games section on 4chan. 4chan is an English-language imageboard website. Users generally post anonymously, with the most recent posts appearing above the rest. 4chan is split into various boards with their own specific content and guidelines.
>>
>>70182030
>native cross platform ui toolkit built into the standard library
Unironically based
>>
>>70182030
shitty go sytax
>>
why is qt so retarded

was it written by a retarded man?
>>
>>70182394
whats wrong
>>
>>70182397
everything

nothing works the way you would expect

nothing makes any sense
>>
>>70180824
>basics of modern web dev
basics of modern basedboyery*
>>
>>70182394
I like Qt. Of course I am biased having worked on it. What's your problem?
>>
>>70182410
then maybe it's not suited for you needs, look for something else?
>>
>>70182394
>>70182410
Use wxWidgets.
>>
>>70182030
Seems like an attempt to reinvent Go without Rob Pike's malignant autism. Not the worst idea tbqh.
Linking to Github repos without any actual source code is pure faggotry though.
>>
File: 1550534089314.jpg (368 KB, 840x700)
368 KB
368 KB JPG
I don't want to code anymore. I burned myself out. I made the things people commonly say are hard. There are no more non-meme languages to learn. I did it. I won the game. The only achievement left is to leave mom's figurative basement and go into wageslavery.
>>
>>70182472
>Rob Pike's malignant autism
what would that be?
>>
>>70182638
If you don't enjoy programming, you don't have to do it.

>I made the things people commonly say are hard.

Maybe you would enjoy it a bit more if you made something you yourself wanted to make?
>>
%default total

data Outcome : (t : ty) -> (a : Type) -> Type where
Tag : {t : ty} -> a -> Outcome t a

Semigroup a => Semigroup (Outcome t a) where
(Tag x) <+> (Tag y) = Tag (x <+> y)

Monoid a => Monoid (Outcome t a) where
neutral = Tag neutral

Functor (Outcome t) where
map func (Tag x) = Tag (func x)

data MultipleOf : (n : Nat) -> (d : Nat) -> Type where
ModIsZero : modNatNZ n d _ = 0 -> n `MultipleOf` d

multipleOf : (n : Nat) -> (d : Nat) -> Maybe (n `MultipleOf` d)
multipleOf n Z = Nothing
multipleOf n (S k) = case decEq (modNatNZ n (S k) absurd) 0 of
Yes prf => Just (ModIsZero prf)
No _ => Nothing

Test : Type -> Type
Test a = (d : Nat ** {n : Nat} -> n `MultipleOf` d -> Outcome n a)

test : (d : Nat) -> a -> Test a
test d a = (d ** \_ => Tag a)

performTest : (n : Nat) -> Test a -> Outcome n (List a)
performTest n (d ** f) = case n `multipleOf` d of
Just m => map (:: Nil) (f m)
Nothing => Tag []

data Result : Type where
Successes : (msgs : List String) -> {auto ok : NonEmpty msgs} -> Result
AllFailed : Nat -> Result

Show Result where
show (Successes msgs) = concat msgs
show (AllFailed n) = show n

result : {n : Nat} -> Outcome n (List String) -> Result
result {n} (Tag []) = AllFailed n
result (Tag (msg :: msgs)) = Successes (msg :: msgs)

fizz : Test String
fizz = test 3 "Fizz"

buzz : Test String
buzz = test 5 "Buzz"

fizzbuzz : (m : Nat) -> Result
fizzbuzz m = result $ concatMap (performTest m) [fizz, buzz]

main : IO ()
main = for_ [1..100] (putStrLn . show . fizzbuzz)


how did i do /g/?
>>
>>70182736
what is it doing so that we can remake it in some actual programming language?
>>
>>70182754
fizzbuzz but very slow
>>
>>70182754
>
main = for_ [1..100] (putStrLn . show . fizzbuzz)

hmm I wonder what it could be doing
>>
>>70182736
nice
>>
>>70182772
I don't think it's slow at all, Idris really loves to reduce stuff as far as it can
>>
>>70175585
Pointers.
>>
File: 1548772383346.jpg (1.02 MB, 2428x1720)
1.02 MB
1.02 MB JPG
>>70182736
based idris user
>>
>>70182652
Aversion to any remotely modern language feature that isn't goroutines.
>>
>>70182030
>fn
Dropped.
Why does every hip new language fucking do this? Just write func like go or USE A BETTER SIGNATURE SYSTEM
>>
>>70182829
>goroutines
I'm disgusted. What's wrong with coroutines and co-operative multithreading?

>>70182834
Use λ or you don't deserve lambdas.
>>
File: asm_ball.webm (53 KB, 1280x720)
53 KB
53 KB WEBM
>>70181732
This took me over an hour to make. It's 49 lines long. I don't think I'm very good at assembly.
>>
>>70182829
Go is stuffed with modern features, you just throw a shitfit because it doesnt have a pleasant generics system. Boo hoo first class functions are HARD! Baby want abstract class inheritance! Waah!
>>
>>70182850
Assembly is slow to write. There's a reason most software is written in higher-level languages. Don't do yourself down unnecessarily.
>>
>>70182840
Goroutines are coroutines specifically built into the Go language with some nicities from the scheduler. Im phoneposting and dont want to write a huge wall of text but theyre called goroutines because they have a bunch of extra features standard coroutine implementations dont.
Perhaps the three biggest things are: goroutines never block each other and can be moved between threads freely
They have insanely small stack size cost
They do not pause and lock for GC, which is why Go can be GC'd but still maintain good performance.
>>
>>70182840
I'm not advocating them, you retard, only describing what I meant.
>>70182870
Too tired and buzzed to tell if this is ironic.
>>
>>70182840
>Use λ or you don't deserve lambdas.
How about you declare functions as an expression of the function and not need a big stupid HERE A FUNCTION keyword?
>>
>>70182870
>modern features
I'd prefer older, better-thought-out features like parametric polymorphism, higher-kinded types, immutability, and guaranteed tail call optimization.
>>
Got my IRC client to the point where I felt like it could handle talking to a real server on the Internet and not just my local ircd at home. Seems to be working fine. Also made some toolbar icons because you gotta have those.
>>
>>70182904
Its not ironic because its true. Other than MUH T GENERICS what modern features does Go not have?
>>
>>70182928
dependent types
>>
File: file.png (1.9 MB, 1538x1104)
1.9 MB
1.9 MB PNG
holy shit guys. ken the absolut madman released the source to his pnd3d engine. absolut madness
>>
>>70182928
dignity
>>
>>70182928
call/cc
>>
>>70182928
>what does it lack other than this very important basic feature
Go 2 is adding generics and fixing error handling for a reason.
>>
>>70183058
>fixing error handling
it doesn't need fixing
>>
>>70183058
are they monomorphised generics?
>>
>>70183082
probably monomorphized, to interface{}
>>
>>70182918
>Why doesn't the brand new tesla model also act like a boat?
Functional paradigms are great and expressive and wonderful but they're not the end-all be-all. They're also not ubiquitous features found in many other languages, at best you get some tacked-on abstraction of a hack jammed into the language like Java 8's lambda expressions, or their function pointer system.

>>70182935
Idris is objectively a bigger meme than go

>>70183058
Well for one, they never said they were avoiding generics. They wanted the language out and usable, generics could (and will) come later. They're also not "fixing" error handling, they're putting in a design for compile-type error wrappers because crybabies like you who like wrapping their 200 line java block in an exception catch with no useful information kept complaining about having to write *a single line* to handle an error.

It's the exact kind of thing that literally only people who have never used Go complain about because it's truthfully so unbelievably trivial that you don't even notice it when you actually write the language.
>>
>>70183112
that's the opposite of monomorphised
>>
>>70183115
>Idris is the only language with dependent types
>>
>>70183115
>They wanted the language out and usable
No, they wanted the language to be idiot-proof so Google doesn't have to worry about new hires not writing useful code.
The new features in 2 don't compromise this goal. The only reason they were left out is because Pike is a narcissist and overestimated how stupid fresh college graduates are. And they are pretty stupid, so this is saying a hell of a lot.
>It's the exact kind of thing that literally only people who have never used Go complain about because it's truthfully so unbelievably trivial that you don't even notice it when you actually write the language.
It actually is easy to notice if you aren't a complete retard, whether or not you particularly mind it.
>>
someone recommend hippie opensource small langs
>>
>>70183259
zig! https://ziglang.org/

It's the fucking best.
>>
>>70183259
install Chapel, Elm, Crystal, & F*
>>
>>70183247
There is literally a better solution to every problem that Go 'solves'. In some cases the solution has been known for DECADES.
>>
>>70183115
>Idris is objectively a bigger meme than go
What do you think makes Idris a meme?
>>
>>70183269
onions
>>
>>70183292
>What do you think makes Idris a meme?
She doesn't understand it.
>>
>>70183300
F* has Low*
the literal opposite of onions.
>>
>>70183292
Not him but probably the fact that there isn't a single notable software project written in Idris.
>>
>>70183368
>there isn't a single notable software project written in Idris.
I always thought of Idris as more of a research language than something you're supposed to build actual large scale applications with.
It's just trying some stuff to see what works, which I think is quite obvious since the dev just started Idris 2.0 with many breaking changes.
Maybe in Idris 2.0, or a language inspired by it, will be ready for production in 5 - 10 years, but for now it's more of an interesting exercise than anything, and there's nothing wrong with that.
>>
>>70183368
Not him but neither did sepples in the first 10 years of its life. I'm not an idris user but you can't dismiss a language by it not having popular large software written in it.
>>
>>70183368
Python really fucked up future language prospects.
Now everybody just expects every new language to have libraries for everything. No one ever wants to do the work of writing them. So it's eternally stuck in
>no body uses it so no new libraries get written
>no new libraries get written so no one wants to use it
>>70183405
Idris can do anything haskell can and more.
There's literally nothing stopping people from writing big programs in Idris.
The problem is, Haskell became THE poster FPL, so no one wants to try anything else.
>>
>>70183452
>Idris can do anything haskell can and more.
It can't use Haskell libraries though, right?
>>
>>70183452
Haskell has become the C++ of functional programming, unfortunately.
>>
>>70183467
>>>/g/sqt
>>
>>70183467
>It can't use Haskell libraries though, right?
porting a haskell library to Idris would be pretty trivial.
>>70183475
completely true, they're both bloted shitlangs.
>>
>>70183405
>>70183448
I agree, there's nothing wrong with meme langs. Every language begins as a meme lang.
If you are perturbed by your favorite language being called a meme then I hope you are doing your part by actually writing software in it. Unfortunately I've noticed a trend on /dpt/ where people shitpost about their favorite meme lang but never answer the OP's question.
>>
>>70183502
>there's nothing wrong with meme langs
yes there is, you fucking retards won't stop talking about them
>>
>>70183510
>stop talking about languages I don't understand because it makes me feel stupid!
>>
>>70183510
Oh yes, because who doesn't want an entire thread of wagie circlejerking over nothing but C/++ and Java.
just kill me now.
>>
>>70183549
Don't forget Python
>it just werks guise
>wait why is my code erroring
>>
new thread
>>70183625
>>70183625
>>70183625
>>
File: 1550336348451.jpg (198 KB, 853x480)
198 KB
198 KB JPG
>>70183368
>Not him but probably the fact that there isn't a single notable software project written in Idris.
If your only thought about learning a programming language is how popular it is or if you can get a job with it, you are a code monkey. This is what a code monkey is, the code monkey is only concerned with whether or not he can get paid to tap away at keys. The hacker actually enjoys programming and learning new things, he even does it on his time off.
>>
>>70184150
I'm a Scheme programmer. There is nothing wrong with meme langs, as I have said. The important question is: are you actually writing software in your meme lang, or just shitposting about it on /dpt/?
>>
>>70184178
>are you actually writing software in your meme lang, or just shitposting about it on /dpt/?
Does it really matter? You don't need to write an entire OS in a language when you study it, curiosity is its own reward.

>I'm a Scheme programmer.
You should know this shit better than anybody, programming and learning can be fun!
>>
>>70184196
>Does it really matter?
No, but then you shouldn't get offended when your language is called a meme. If a language's own proponents wont write software in it, what else can it be except a meme?
>>
File: yuki05.png (197 KB, 550x550)
197 KB
197 KB PNG
>>70184347
>offended when your language is called a meme
I wasn't offended by that, I just didn't like your lack of hacker spirit. If you just admit that the original comment was a bit dumb and that learning new things is very cool, we don't need to argue.

Otherwise I will get slightly mad at a so called scheme programmer that tryed to use >notable software as an argument.
>>
>>70184392
I was just explaining why Idris could be called a meme. I wasn't trying to make an argument against learning or using Idris. I know approximately nothing about the language except that there's that one aggressive poster here who apparently likes state machines a lot.
Like I said before, there is nothing wrong with liking a meme lang. I like Scheme a lot.
>>
File: 1551859259606.jpg (86 KB, 540x720)
86 KB
86 KB JPG
>>70184467
Good enough, ceasefire. I like scheme too, I don't use it often but it was very enjoyable to write when I did SICP. It's fun.
>>
File: hurts.png (315 KB, 600x814)
315 KB
315 KB PNG
I'm learning C, please no bully.

I'm trying to write a moving/ windowed average function and having some trouble.

basically this function would take some data, let's say stock price data and, based on a certain window/ frame size, would construct a an array of those windowed averages.

let's say we have data {2, 4, 6, 13, 9};

I want a windowed average of {4, 7.7, 9.3} given a window size of 3.

is this the right prototype for the function? Any help would be appreciated.

void movavg(double data[], int dsize, double mavg[], int msize, int wsize)
>>
>>70184569
What you have is good enough but I would go with

(const double *data, size_t data_len, double *avg, size_t max_avg, size_t wsize);
>>
>>70184569
In python this is just data.rolling(avg, wsize)
>>
>>70184608
That looks badass. Never really used size_t before but a quick stackoverflow seems to suggest it's basically a typedef for unsigned long int?

I'm mainly confused as to how to use loops to "move and sum the window" while iterating over the main data array.

>>70184617
Yeah, python left me with massive gaps in my knowledge as I'm sure you can tell. I'm trying to stay away from it for now.
>>
>>70184608
>>70184679
On second thought, no. I would go with something like this. Keep the state of your running average in a struct, then you can call it as many times as you want.

struct mavg_ctx {
// ...
};

void mavg_init(struct mavg_ctx *ctx, size_t wsize);
void mavg_update(struct mavg_ctx *ctx, double *data, size_t len);
void mavg_final(struct mavg_ctx *ctx, double *buffer, size_t max_len);

struct mavg_ctx ctx;
double data1[] = { 1, 2, 3 };
double data2[] = { 4, 5 };
double buf[3];

mavg_init(&ctx, 3);
mavg_update(&ctx, data1, 3);
mavg_update(&ctx, data2, 2);
mavg_final(&ctx, buf, 3);
>>
>>70184708
fuaaark it's getting late and my brain is running on 10% I will try and figure this out this kung fu though... seems like the right way, just not sure about the implementation
>>
>>70184746
I'll help you out a bit since I mentioned it.

struct mavg_ctx {
double *arr;
size_t len;
/* any other data you need */
};

void mavg_init(struct mavg_ctx *ctx, size_t wsize)
{
ctx->arr = calloc(wsize, sizeof (double));
ctx->len = wsize;
}

void mavg_update(struct mavg_ctx *ctx, const double *data, size_t len)
{
/* what you planned to do with movavg(), do it here.
* instead of mavg[] use ctx->arr[]
*/
}

void mavg_final(struct mavg_ctx *ctx, double *buffer, size_t max_len)
{
/* just memcpy from ctx->arr to buffer min(max_len, ctx->len) doubles */
}


Doing it this way instead of in a single function helps the calling code a lot. It doesn't need to collect all the data into a single buffer, you can call mavg_update for example in an input loop.

while (get_input(&data)) {
mavg_update(&data);
}


Thread is about to die by the way, any other questions ask them in the next thread.
>>
>>70184796
The lack of forward declarations ("prototypes") here is just for brevity.
>>
>>70184796
>>70184897
thanks boss, this is agreat start, I'll be in the next thread



Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.