[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/dpt/ - Daily Programming Thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 32
File: K&R himegoto waifux2.png (1 MB, 1000x1400) Image search: [Google]
K&R himegoto waifux2.png
1 MB, 1000x1400
old thread: >>54410323

What are you working on, /g/?
>>
[Reserved]
>>
>>54418161
I want to learn assembly so I can make a compiler or something.
Now wouldn't that be neat.
You need to know assembly to make a compiler, right? Or can you just transpile to C.
What's normally done?
I'm going to be making a compiler for class in the fall but I don't know what else to do now.

Any of you guys made a compiler for a toy language?
>>
File: maxresdefault (1).jpg (69 KB, 1280x720) Image search: [Google]
maxresdefault (1).jpg
69 KB, 1280x720
What language can I use to control a dick sucking robot?

What controller should I use?
>>
>>54418222
C, obviously.
>>
>>54418161
>What are you working on, /g/?
Recursion coin problem and other HW.
>>
>>54418194

You have a few options when it comes to compilation.

1. You can compile to bytecode for a virtual machine, such as the JVM or the CLR.

2. You can transpile to another language, typically C or JavaScript.

3. You can compile to native code. This in turn can be done with:
3a. Your own backend. This requires you to have a good knowledge of the target ISA.
3b. A pre-existing backend, such as LLVM.

I'm working on a compiler right now for a class right now. Fun shit.
>>
>>54418263

One small mistake and it will rip your dick off.
>>
>>54418500
"Working as intended"
>>
>>54418521
top kek

>>54418500
>robot
>anything other than C
Oh lord. Reminds me of those high school robotics teams that used Java.

At least we know the robot won't randomly slow down for a few seconds every time it collects your garbage.
>>
>>54418500

Test product on dildo before testing in real thing.
>>
>>54418548
Actually, nevermind, that sounds pleasant and preferable.
>>
>>54418548
>>robot
>>anything other than C

Yes, we have low-level languages without garbage collection that aren't complete and utter shit, now.

It's 2018, Grandpa.
>>
>>54418263
Ok, now how can I connect to it?

I'm building the device with electromagnets. I'm hoping the magnetic radiation isn't as severe as I hear. A little malignant growth on the wiener would serve some people well though.
>>
>>54418637
Like what? I know there are some but I don't know what they are.
>>
>>54418660

C++14 and Rust would be the best alternatives to C.
>>
>>54418660

Rust, mang.
>>
>>54418698
I was thinking of Rust, yeah. I suppose I agree about C++14 too. Looking over new additions to C++14, why is it specifically better? Generic lambdas are neat as hell though.

>>54418804
Maybe I should look into it, not that I like C++'s ugly syntax
>>
>>54418834
>Maybe I should look into it

It's actually awful, but it fits the bill. Nothing will ever compile the first, second, or third time.
>>
>>54418548
Java garbage collector is literally faster than shitty shared pointers from C++. It's actually ridiculously fast, definitely the fastest gc in the world.
>>
>>54418930
I said C over Java, not C++
I don't know anything about shared pointers
>>
File: 1462393253683.png (53 KB, 590x832) Image search: [Google]
1462393253683.png
53 KB, 590x832
>>54418938
Shared pointers are used very much in modern C++. Java being slow is a relic of history.
>>
Maybe I should get into C++, this is so fucking cool for a compiled language
#include <stdio.h> // yes i don't know how to use cin/cout properly, I get how they work though

int main() {
int a = 10;

auto isa = [a](auto arg) -> auto { return arg == a; };

puts(isa(5) ? "yes" : "no");

return 0;
}
>>
>>54418834

C++14 has enhanced constant expressions, unless of course you use Visual Studio. It also has a free useful additions like std::make_unique. It's fairly comfy...

>>54418930

You can use your own custom allocators for smart pointers if you want, which would be able to compete in speed, while offering determinism, which is one of the main advantages of RAII.

Also, Java can't stack allocate objects or make vectors that don't suck.
>>
>>54418965
>anything related to graphics
>>
I know it gets said a lot, but we sure do spend more time arguing about languages than programming. Most modern languages (C++, Java, C#, Go, D, etc) offer fairly equivalent feature sets now.
>>
>>54419075
>only half the languages mentioned are useful
>>
>>54419039
Seriously? You do realise most graphic work is done through OpenGL which is written in C... And Java uses OpenGL through JNI, which can call native libraries.
>>
>>54419098
slowly
>>
>>54419115
No it's not. You have no idea what you're talking about.
>>
>>54419127
p
>>
>>54418991
You can do it in C as well, GNU C and Clang support nested functions, which you can abuse and use like lambdas.
#include <stdio.h>
#define lambda(return_type, function_body) \
({ \
return_type __fn__ function_body \
&__fn__; \
})

int main(void)
{
int (*max)(int, int) = lambda(int, (int x, int y) { return (x > y) ? x : y; });
printf("max: %d\n", max(192, 4));
}
>>
>>54419095
>half

There are 5 there. Which one is half useful?
>>
>>54419139
I know about lambdas using the extensions, but it's not standard, so of course I feel uncomfortable using it.

>>54419148
You should know this.
>>
javatards will make java 'fast' and popular if it means optimizing the hardware just to run it specially
>>
>have mod tools on StackOverflow
>never use them
>decide to check them out
>shit with extreme votes
>all these pajeets literally copy pasting other people's answers's code minus any explanation

what the fuck I hate these faggots
>>
>>54419148
I'm guessing Go and D are useless
>>
>>54419173
>SO
what did u expect
>>
>>54418161
Damn you OP I'm pretty sure Hime is turning me gay
>>
>>54419191

expected a lot less shitposting than I see here at least
>>
>>54419179
>Go
>useless
I'd ask the companies and the people using it

>dpt
>reality
>>
>>54419139

Does clang support the compound statement expressions needed to make this work?
>>
I need a project guys.
I know java, JS, perl, sql, bash, swift, xcode.

Shoot me ideas.
>>
>>54419229
Go brings nothing new to the table, the language is a failure and only works well for a specific niche. Sure some companies bought the hype but really it's nothing.
>>
>>54419246
and python. Sorry about that.
>>
>>54419246
>XCODE
Make an App.
>>
>>54419246
we dont need new projects. just contribute to an existing project.
>>
>>54419286
Ok....an app for what?
>>54419269
I hate contributing to things that are typically already shit and that take more time to understand than to fix.
>>
>>54419246
write a java program that writes JS that writes perl that writes sql that writes bash that writes swift that writes xcode that writes python that writes java... and so on

>>54419265
>>Go brings nothing new to the table
real stability, and security by default. surely it's not Rust, but who needs Rust when you have Go... different langs for different needs.

>>the language is a failure
>hurr durr there is nothing new so it's a failure
>hurr durr muh innovation
see >>54419229

>>only works well for a specific niche
uhm, have you seen the shitload of IT projects that use Go?
>>
File: 1455625702126.png (378 KB, 1450x1080) Image search: [Google]
1455625702126.png
378 KB, 1450x1080
>>54419312
>I hate contributing to things that are typically already shit and that take more time to understand than to fix.

deal with it. that's the reality of modern programming. otherwise go make your phone apps from scratch. if you're still some noob you can roll a project to learn.
>>
>>54419383
I've done plenty of apps to learn on. Learning isn't the goal here. I need something new, something that's needed.
>>
>>54419428
contributing
that's literally it
>>
>>54419312
>take more time to understand than to fix

I used to hate that, but I got good at exploring new codebases and actually enjoy understanding my favorite software projects now.
>>
>>54419364
Yeah, sorry but your language is already dead. Go was supposed to be the C killer. I predict no one will be using Go after maybe 5 years and that will be when Google finally decides to retire it.
>>
>>54419468
>Go was supposed to be the C killer.
Go was supposed to replace C++ for incompetent Google employees.
>>
Beginner programmer here.

How do I get my code to print more than 19 bottles of beer on the wall?

var singles = ['Zero', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten', 'Eleven', 'Twelve', 'Thirteen', 'Fourteen', 'Fifteen', 'Sixteen', 'Seventeen', 'Eighteen', 'Nineteen'];
var tens = ['','','Twenty', 'Thirty', 'Fourty', 'Fifty', 'Sixty', 'Seventy', 'Eighty', 'Ninety'];

for (i=99; i > 0; --i){
if ( i < 20){
console.log(singles[i] + ' bottles of beer on the wall');
} else if (i > 20){
var x = i[0];
var y = i[1];
console.log(x, y);
console.log(tens[x], + singles[y], + ' bottles of beer on the wall');
}

}


Should I make a array variable and split it instead?
>>
>>54419468
>the C killer

I pity the fool.
>>
>>54419468
Go can be the Java killer already, at least for part of its market.

>>54419511
why are you waiting for someone else to show you the way things are done? programming is almost pure logic, in a practical way. think about it.
>>
>>54419564
I'm not expecting to be spoonfed the answer.

I literally do not understand what is going wrong.
>>
>>54419511

Is this Javascript?

>i[0];
>i[1];

What

That's likely the problem. You're trying to take the digits of the number, correct?

>those arrays

There's a pattern to the written number names.
>>
>>54419717
If I remove my x and y variables though, I end up with undefined NaN NaN
>>
>>54419763
Convert it to a string and then take the digit.

numStr = i.toString();
firstDigit = numStr[0];
secondDigit = numStr[1];
>>
>>54419810
... or just don't learn JS as your first programming lang, because it sucks. if you want to get the first and second digits, you use % and /.
var x = i/10%100;
var y = i%10;
>>
This is probably a stupid question for some of you. I want to write a program that uses an api. The is in several different languages. But I only know c, c++, and java.

The API is available in .net, Go, Node.js, PHP, python, ruby, and scala.

is there a way to use C or C++ with these api? how challenging is rewrite an api to a different language?
>>
>>54419854
but wouldn't modulo only pull the ten twenty thirty etc. strings?
>>
>>54419511
>console.log(tens[x], + singles[y], + ' bottles of beer on the wall');
why. remove the ,'s

>>54419854
err,
var x = Math.floor(i/10%100);
...
>>
>>54419908
What kind of API? HTTP?
>>
>>54419908
>how challenging to 'rewrite'
very
you're limited to those langs im sure
>>
>>54419932
Yes . It's the unofficial discord api. Wanted to make my own bot

I have never used an api before,
>>
>>54419976
>horrible english
>discord
either 12 or pajeet
>>
Continuing work on my Torrent tracker in golang. Finishing up adding SQL support.
>>
>>54419992
No jus t drunk
>>
>>54419920
I did that and changed my variables inside my console.log, now it's printed me
 Ninety NaN bottles of beer on the wall
Ninety NaN bottles of beer on the wall
Ninety NaN bottles of beer on the wall


Why doesn't singles adjust on in the else if condition?
>>
>>54419148
>Which one is half useful?
C#
>>
>>54420004
>Ninety NaN
lmao
>>
>>54419976

... /sci/cko mean anything to you?

No you're not limited to those languages. That just means they got clients written for them in those languages, but you can simply use networking to talk to Discord directly following their protocol.
>>
>>54420004
 Ninety NaN bottles of beer on the wall 

That is actually hilarious
>>
>>54420000
Maximum over quads m8

>>54419992
>pajeet

The fuck's a pajeet
>>
>>54419025
Thought I'd update you from last thread.

My local (not at work) openwrt/mips toolchain build finished, and I statically cross compiled a simple program to test the output file sizes. With just stdio (printf used) the output is 152K, with stdlib (malloc, free used) it's 290K ... dynamically it's 6.8K.

I'm not sure the dynamic linking will end up being an issue anyway; I'll actually test it on Monday.

>>54419976
>>54420000
Are you sure the api doesn't return a json or xml string or something and they just have libraries available for using it in those languages? (also drunk)
>>
>>54420004
>ninety NaN
top fucking kek

Your code gets an A in my book.
>>
>>54420033
hes trying to say i am an indian not the trail of tears kind
>>
x = 0
def f(y):
return x + y

def g(z):
x = 1
return f(z)

g(1) # evaluates to 1, not 2


This gave me cancer
>>
>>54420058

What are you getting at?
>>
>>54420033
>The fuck's a pajeet
welcome to /dpt/
>>
>>54420080
When you call g(1), it should set x to 0, but f's x is set when f is defined, it doesn't use the current value of x
I think
>>
>>54420080
variable scope in python
>>
>>54420058
Why wouldn't it? "x = 1" is local to g and "x = 0" is global, so f(y) is taking x from the global scope.
>>
>>54420035
Sorry I am looking over it now
This is the best developed one. Discord hasn't put out an official api, but I don't want to wait around forever.
https://github.com/RogueException/Discord.Net


I am not really sure how it works kek
I have been looking it over trying to understand how it works. But I don't know any .net
>>
>>54420058
I hope it's terminal
>>
>>54420058
x = 0
def f(y):
global x
return x + y

def g(z):
global x
x = 1
return f(z)
>>
>>54420104
>x to 0
x to 1*

>>54420111
The x in g should be the x in the global scope (it is), and it's being set to 1 before calling f
You're telling me the assignment to a global variable is local to a function?
>>
>>54419265
it brings productivity along with some useful features
https://blog.explodingads.com/2-moving-a-team-from-scala-to-golang/


Complexity is the bane of large scale software development. Functional languages (and more complex languages like rust, c++, etc.) are good for small teams, but not large teams where new people keep coming
>>
>>54420135
>>54420110
So this is what happens when declaration is only done by assignment in Python?

Python is a quick language to write in and it's easy to use, but shit like this makes me loathe it.
>>
>>54420104

It'd work as expected if python was dynamically scoped. :^^)
>>
>>54420058
shadowing m8
>>
>>54420166
Is there a quick-to-write language that isn't extremely convoluted? Haskell maybe?
>>
>>54420120
I can't read .NET, so I'm not sure, especially now, but it looks like there's some way to get JSON from discord, or the dude is storing his data that way, I can't tell right now.

In any case, if you can at least dissect it you can roll your own.

>>54420154
>>54420166
Nothing wrong with this desu.
>>
>>54420136
>The x in g should be the x in the global scope (it is)
Why "should" it be? (It isn't)
>>
>>54420205
POSIX shell
>>
>>54420210
ok cool, if I can't figure it out I guess I can learn a new language
>>
>>54420232
Maybe.
>>
>>54420136
The x in g is not the global x, it's the local x to function g. So "x = 1" does not actually assign 1 to the global x, but to a local variable of g. >>54420135 gives you exactly what you expected.
>>
>>54420246
Right, I understand that this is how it works, it should just not be designed this way. the x in g *should* be the global x by default, like any other sane language. g is defined in the scope that the global x is defined
>>
>>54419511
you need to use two arrays and concatonate them together.
So 20 is tens[2]
21 is tens[2] + "" + singles[1]
Are you doing the reddit challenges?
>>
>>54420279
>all variables should be global by default
kek
>>
>>54418161
>No show about cute programmers doing cute programmer things

Why
>>
>>54420303
How did you get that by my post?
I'll reword it for you: If you define a global variable x, and there is another block inside that global scope that has its own local scope, everything in that local scope is within that global scope, so a reference to x in that local scope should be the same x as the global x
>>
If you are in chrome, press F12, go to console, and copy paste the following :
>>54420004

var bot_count = 99;
var mysong = [];
for (var x = 0; x < 99; x++){
mysong.push(" " + bot_count + " bottles of beer on the wall, " + bot_count + " bottles of beer, take one down, pass it around, " + Number(bot_count - 1) +" bottles of beer on the wall." );
bot_count = bot_count - 1;
}
mysong = mysong.join("");
console.log(mysong);
>>
>>54420279
>g is defined in the scope that the global x is defined
Yes, but everything WITHIN g is in g's local scope
>>
>>54420328
>so a reference to x in that local scope should be the same x as the global x
That is actually the case, though. Try referencing x within g. Assigning to x, however, will create a new x in the local scope.
>>
>>54420340
Which includes global things.
I'm just used to how it works in C based languages, e.g.
int x = 10;

void function(int a) {
x = a;
}

this actually changes the value of the global x

This whole retarded scope thing in python is literally caused entirely by the fact that there are no declarations, only initializations

>>54420357
Does this make sense to you? I believe you that it works like that in Python sure, but does that actually make sense to you?
>>
>>54420373
Yes it makes sense. When you try to access x, it first looks for an x in the local scope. If there is none, it will check the outer scope, and so on until it finds x.
>>
>>54420408
And there only is another x in the local scope because you can't just declare variables, you have to assign them, which implicitly declares them, so if you want to assign to the global variable, you have to explicitly say so
>>
>>54420373
>I believe you that it works like that in Python sure, but does that actually make sense to you?
It makes sense in a dynamically-typed languages. Let's do it in C:
int x = 0;

int f(int y)
{
return x+y;
/* there is no local x to be found in f,
* so the compiler will look for the global x */
}

int g(int z)
{
x = 1; // okay, the global x is concerned here
return f(z);
}

int g_python(int z)
{
/* this what happens in python when you type "x = 1" in g,
* dynamic typing and what not... */
int x = 1;
return f(z);
}

In C, when you do an assignment, the language assumes you've already declared the type of the lvalue. In Python, since variables are not statically typed, the interpreter can't make that assumption, so any assignment could be the declaration of a new variable, hence the particular scoping in this kind of language.
>>
>>54420434
In any case, you shouldn't be assigning to global variables from within smaller scopes, it's well established to be bad programming practice.
>>
>>54420491
>since it's statically typed
You can have explicit declaration with a dynamically typed language, e.g. 'var x;' (I don't know if that's legal JS but it may as well be legal something)

My gripe is that their decision to remove declaration altogether and just have initialization has negative effects like this, and there isn't much of a reason
>>
>>54420373
it works the same way in most languages, here it is in F# (a statically typed language)
let x = 10

let ayy a =
let x = a
()

will give
> x;;
val it : int = 10
> ayy 20;;
val it : unit = ()
> x;;
val it : int = 10


this will reference the previously scoped value
let kek = x

> kek;;
val kek : int = 10
>>
>>54420542
Is "let" declaration syntax or always used for assignment? I might add that it's a different paradigm entirely
>>
>>54420558
F# has 3 binding forms, let, use and do along with their computation expression kin (let!, use!, do!)

let has 2 uses, top-level named expression (in the module) and local named

use does similar to let, except it automatically disposes the value when it leaves scope (using / IDisposable in C#)

do executes the code without defining a function/value

let!/use!/do! are depending on the computational expression, such as 'seq' and 'async'. let acts as the monadic bind (M<'T> * ('T -> M<'U>) -> M<'U>), as does do. use! does 'T * ('T -> M<'U>) -> M<'U> when 'U :> IDisposable
>>
>>54420301
Yeah I am, I'm trying to learn JavaScript outside of what I learned from CodeAcademy.

I picked up a copy of Eloquent JS as well.

It's just not quite making sense how these all add up.
>>
>>54420691
So you're saying that your F# example is irrelevant to the conversation, or that it's entirely relevant? I don't quite catch what you're doing there.

>>54420700
You happen to be learning something not suited for beginners from places not suited for learning
>>
>>54420700
>Eloquent JS

That's a reddit book and it's filled with unrelated diatribes about SJW feminist ideology.
Don't pay money for it if you insist on reading it.
>>
>>54420722
>it's filled with unrelated diatribes about SJW feminist ideology

Really? Can you post some examples? I want to laugh.
>>
>>54420722
Yeah, I agree. But this coding program I'm trying to get involved with has me doing this bullshit.

jQuery and Angular are retarded easy, but that's a library of JS, the actual JS is my problem.
>>
>>54420711
I didn't post the example but to clarify. let gives a name to a value or function (both are expressions)

(python)
def foo(y):
two = 2
def bar(x):
return x * two
return bar(y)


would be
let foo y = 
let two = 2
let bar x = x * two
bar y
>>
>>54420754
Right, this is something I understand, just disagree with. I don't think Python should have assignment and declaration be the same thing when it comes to the first time something is assigned in its smallest scope.

Haven't I been pretty clear that I understand how it works, just that I don't like it?
>>
>>54420740
Not the poster you replied to, but the person who said they owned it. I skimmed through the book and am unable to find a mention of SJW material in the book. It honestly just looks like terms and numbers and other shit.
>>
C works the same way

#include <stdio.h>

int x = 10;

int main() {
printf("%d\n", x);
int x = 4;
printf("%d\n", x);

return 0;
}

$ gcc shd.c
$ ./a.out
10
4
$
>>
foreach (string k in binds) {
if (k == key.str) {
stderr.printf("%s\n", key.str);
}
}


>error: `Bindings.binds' does not have an `iterator' method
What am I doing wrong?
>>
>>54420894
well what the shit is Bindings.binds
>>
>>54420884
>int x = 4;
Yes anon, I understand this.
It's pretty mind boggling that you guys don't get that I get it. Do you not read my posts? I have said probably 3 times now that it's a problem in python because declaration and assignment are identical.
>>
>>54420899
Bindings is the class name, binds is the array I'm trying to use. It's just a regular string array.
>>
>>54420894
Is this D?
>>
>>54420928
Vala. If there were spoiler tags here I'd use them.
>>
File: CirnoC++.png (263 KB, 800x720) Image search: [Google]
CirnoC++.png
263 KB, 800x720
What is a good book on operating system development?

I don't mean "Developing FOR", I mean "DevelopING" or "Developing FROM SCRATCH"

I guess I'm interested in a book that would best describe important examples of how to create an OS, maybe with some practice problems such as getting from 0 to a bootable sector with a CLI.

And then advanced topics, such as CLI to GUI.

Could be more than 1 book.
Just would like to know what's the best options out there.

I'm interested in making a UNIX OS purely from scratch.

Also, are there good books on refactoring best practices and principles?
>>
>>54420933
No, it's okay, I respect Vala more than D.
For some reason. Probably just because of the Vaccine project or something. GObject is a neat but disgustingly ugly, so it's pretty valiant that someone went ahead and made a pretty interface to it.
>>
>>54420959
A good start is Modern Operating Systems, by the guy who got one upped by Torvalds
>>
>>54420998
hmmm, ok. I actually have the second edition somewhere. I just never got that far with that one. I'll go crack it out again.
>>
>>54420894
nvm fixed it
>>
>>54421042
>can't read a book
>wants to do an OS
>pretty much the hardest thing to do in all of computing
>a lifetime of work
>>
>>54421075
I know, right?
>>hmmm, ok.
Yeah, he's going to get real far
>>
>>54421075
It's not like I'm just doing random bullshit 24/7. I'm not even saying immediately. I have other projects I gotta do first, but I do eventually want to get to that

I'm still in school full-time.
>>
>>54420911
? That is not a problem
the "problem" is scope and that nothing is global by default in python
>>
>>54420035

C programs don't tend to be super big, especially on Linux. In any case, dynamic linking makes the most sense on machines that will be running a ton of different applications. Where a library will only be linked against one or two applications, dynamic linking is less useful.

By the way, what MIPS board are you using, out of curiosity?
>>
>>54421042
>>54421075
>>54421104
actually, I just found it.

It was in my priority/overflow drawer, not my normal bookcase.
>>
lmao python integers are immutable
>>
>>54421118
>C programs don't tend to be super big, especially on one of the biggest C programs ever
I don't know why but I found that funny
>>
>>54420491
Wouldn't
g_python
throw a compiler error? Specifically, the "int" in "int x = 1"
>>
>>54421124
>forget about it forever bookcase
>>
File: hepburn.jpg (48 KB, 620x804) Image search: [Google]
hepburn.jpg
48 KB, 620x804
Okay so I'm doing static code analysis with the Clang AST and I'm trying to constant fold a VarDeclRef, so I'm in the matcher callback and no matter what I try
isEvaluatable
never returns true.

Example c file
int main()
{
int j = 100;
int k;
k = j;
return k;
}


example callback:
ret = Result.Nodes.getNodeAs<DeclRefExpr>("var");
ret->isEvaluatable(Result.Context, SE_AllowSideEffects);


What am I doing wrong?
>>
>>54421130
You can make declaration and definition in the same instruction in C. I don't see the problem.
>>
>>54421136
Well, I generally prefer e-books, but I have a few physical copies of things that I either can't find as an e-book or don't want to rebuy.

It's... not a bookcase, it's a cabinet we used to store VHS tapes in. Now, I consumed a shelf with different books and another drawer that contains stuff I was in the midst of reading as well as some old Win95 crap.
>>
I don't understand the halting problem.
It just seems like contrived academia that has no relation to the real world.
>>
>>54421195
no shit. it only gets worse.
>>
>>54421169
M8 apply yourself.

I've dabbled in OS implementation and gotten my toy OS to boot, and it wasn't easy. I can follow tutorials on osdev wiki but that's a far cry from actually understanding what the fuck I'm doing.

I'm writing a programming language virtual machine and that's already like about 5 lifetimes of work. I've read like a dozen books and hundreds of papers on so many related subjects and I've barely begun implementing the shit
>>
>>54421195
You should say you don't understand the significance of halting problem, in which case you should actually say you don't understand that there is significance to the halting problem, in which case you'd be right

It's a shitty memey "this is REAL computer science!!!" question (see: Numberphil on yt, shitties channel ever)
>>
>>54421207
damn, that's... intense...

I never really planned it to be a project completely on my own, though. That's why I mentioned other projects first, for funding.
>>
What language is most useful to you?
>>
>>54421254
English. next
>>
>>54421254
currently, PHP and JavaScript, but I hope to graduate from that to some better stuff such as C/C++
>>
>>54421243
>2016
>OS
>funding

lmao
>>
>>54421273
What?

It's not like I'll want it to be some crap thing merely used for practice. I'd like to make something as useful as Windows with code as good as Mac/UNIX
>>
Guys hoow do i print every other element in an array, i am to stupid. And not by incrementing twice
>>
>>54421317
Well, you could do +=2 for the iterating variable.
>>
>>54421323
Technically this is just incrementing once, just incrementing by 2 lol
>>
>>54421291
Will it be Unix based, or it's own thing entirely?
>>
File: 1455926607404.webm (493 KB, 498x446) Image search: [Google]
1455926607404.webm
493 KB, 498x446
>>54421291
>I'd like to make something as useful as Windows with code as good as Mac/UNIX

There are so many things wrong with this.
>>
>anon on 4chan thinks he can make a robust, stable os
>>
>>54421333
fair, but it also depends on the language you're using. You could do something stupidly complex like a foreach loop and a test whether it's divisible by a chosen value such as if(!i % 2)

You could also do a loop with a break condition if the index value is out of bounds, and just create a regular array of either odd or even numbers, with multiples or something.

What is this, a homework problem? I've never seen anything other than a simple incremented iterator, to be honest.
>>
>>54418161

How old were you when you got your B.Sc. in CS? I am gonna be 25 when I graduate because I changed faculties when I was 21.
>>
>>54421398
>25
>no work experience
>just an degree to an overcrowded major
enjoy flipping burgers
>>
>>54421398

I'm not in the technology field.
>>
>>54421403
I'm doing coop this year, and CS majors make tons of money. "Oversaturation" is a meme.

What's your degree in Anon? Masturbating to anime I presume.
>>
>>54421149
No one knows a thing about Clangs Libtooling? Really?
>>
>>54421338
I intend it to EITHER be completely POSIX compliant and then apply for UNIX
OR
reverse-engineer NetBSD's core and then build from there.

>>54421347
ok... let's try it this way. Stable and efficient code that allows functionality of everything and the kitchen sink, whose purpose is NOT to specialize but to do basically everything. It has no purpose and every purpose at once.
Fo example, the goal would be to make something that can:
>browse the /b/
>edit pictures
>perform enterprise data storage and analysis
>make funny flash games
>watch cat videos
>social network
>control advanced laboratory equipment and medical devices
>manage your4 stocks
>be customized so you can run nothing but a command terminal for minimization
>OR be customized with 500 different animu characters on your desktop and an animated gif background, explorers with backgrounds, and custom animu characters to burn out your quad-GPU setup 10 times as fast
>compile code
>handle apps
>be as immersive or as empty as you want
>remove the taskbar
>have triangular windows, because some fucking weirdo MIGHT think it's neato
>ACTUALLY control your kitchen sink by being linked to your smart house
>self-navigate rockets
>be plain and boring
>be a kawaii animu waifu

An OS where it can do anything and doesn't give 2 shits what you personally want, because it never removes features, ONLY adds them (unless it's MASSIVELY glitched and needs to be redesigned)

Why should an OS do anything less than you can imagine it doing? That's just dumb. But if you only use 8.6% of its features, it should run fast as fuck. And if you use 100% of its features (and installed it on a fucking $250K server, it should ALSO run fast, as fuck)

Nothing is too much to add to a machine, unless it's broken horse shit.

But a computer is not just a job, not just a tool; it's a lifestyle, and it should do anything and everything you need it to do to fit that lifestyle of yours.
>>
>>54421367
recursion actually
>>
>>54421128

To be fair, operating systems aren't exactly small. But Linux would have been much bigger were it written in a language like C++, Rust, or Ada. My point is that Linux programs are relatively small compared to programs written in other languages, particularly where dependencies are taken into account.
>>
File: 1447034290076.jpg (214 KB, 734x551) Image search: [Google]
1447034290076.jpg
214 KB, 734x551
>>54421482
this is a lot of delusion packed into one post
>>
>>54421509
so, you need it to recursively print/do something to every OTHER index?
>>
File: gunsmith-cats.png (56 KB, 200x150) Image search: [Google]
gunsmith-cats.png
56 KB, 200x150
>>54421482
>making an OS
>that can do a multitude of user-land functions
>a whole bunch of super high level concepts

I see you haven't even read the book. You don't even have the good taste necessary to make good design decisions. You sound like you came straight out of the desktop thread.
>>
>>54421527
it just needs to print every other element in array, i end up falling back into iteration when i try it. I think i need to make some variables to help me
>>
>>54421555
>i end up falling back into iteration when i try it. I think i need to make some variables to help me

Yeah, for example pass an additional boolean argument which you flip in the next call
>>
i'm building a social network for traps
>>
>>54421581
we already have /dpt/
>>
>>54421585
but /dpt/ doesn't allow lewd photos of shaved legs and panties with bulges :3
>>
>>54421545
I haven't been in a desktop thread in a while.
I got bored, because I can't do nearly enough stuff, and I'm tired of having to spend hours looking for advanced 3PS that can modify the graphical interface to do the random dogshit I want it to do. I passively adjust my desktops, now.

When I say "OS", though, I'm not just saying the kernel and some system applications, though. I'm talking everything from the bootloader to integrated AI and shit (if you got one with an AI extension).

I'm not talking purely system-space code, when I refer to "OS". I'm talking everything that runs on the machine and is NOT developed by a third-party.

In other words, on Windows, Notepad is part of the OS package. So is Control Panel, the NT kernel, PowerShell, and explorer.exe

If it comes with the OS, that's what I refer to as the OS. I know there's a technicality, but what would you call it to be efficient? Should I have said OS package?
>>
>>54421591
yes it does

just try it, nothing bad will happen :3
>>
Someone post the girl vs boy programmers pic thx
>>
>>54421555
I suppose you could write the array as a tree-like array structure, and you can use a recursive print that only grabs one of the leaves for each parent. and when it returns to the parent, it determines whether the parent is to be printed or not. I'm not entirely sure how you'd go about that one, though.

I'd have to think about it, but I'm pretty tired.
>>
>>54421625
though you still seem delusional.. why not learn C, learn to use xlib or xcb and build your fantasy ontop of Linux?

also the word you're looking for is >distribution
>>
File: when girls code.jpg (226 KB, 869x1776) Image search: [Google]
when girls code.jpg
226 KB, 869x1776
>>54421657
here u go bby
>>
File: msbs19.png (216 KB, 800x933) Image search: [Google]
msbs19.png
216 KB, 800x933
objecting oriented programming more like object oriented nightmare
>>
File: 6N3Jcmt.jpg (119 KB, 500x376) Image search: [Google]
6N3Jcmt.jpg
119 KB, 500x376
>>54421679
I love you
>>
>>54421679
>XD
DX<
>>
>>54418650
if you are using a micro-controller, usb or legacy serial.
>>
>>54421664
Can't build it on Linux. That's the problem.
I already considered that one.

Linux, as an OS, is not commercially viable. Anything I specifically add to or modify in the code for the OS itself becomes OSS.

That's actually why I included Mac as opposed to Linux in my earlier post.
Mac OSX/UNIX is a fully-commercial OS that is UNIX-compliant.
That's what I'm going for. Completely commercial.

However, I just peeked at the Wiki on XLib and XCB. Very interesting, especially background-less/clear shaped windows. That's some good stuff right there and something I'd really like to implement.
>>
>>54421679
GOD DAMN I CRINGE HARDER THE MORE I LOOK AT IT
>>
File: girls who code.png (311 KB, 652x669) Image search: [Google]
girls who code.png
311 KB, 652x669
Could you do any better?
95% of programmers will get this wrong!
>>
>>54421765
you a fucking troll m8
>>
File: maverick.jpg (126 KB, 1211x1210) Image search: [Google]
maverick.jpg
126 KB, 1211x1210
>>54421625
>everything from the bootloader to integrated AI and shit

Ah, so you're like me, trying to create your own little universe.

I eventually gave that up once I understood the sheer size of the problem and the many aspects of it I didn't actually enjoy thinking about.

What I realized was that I wanted my own environment, and I could create it by doing pretty much as >>54421664 said. It wouldn't be an OS, but it'd be built on top of what's probably the best one right now, and I could modify it if it came down to that. It wouldn't be fully mine, but everything I actually cared about would be. So, I started my own programming language.

Writing an OS is absurdly hard. And I do mean absurdly hard. It's beyond hard. The people you're looking up to, they all failed at writing their OSes, and they can't fix it because of all the applications running on top. Programming Windows is like trying to find the exact combination of APIs and parameters that aren't backwards compatibility legacy junk. The OSes you're being inspired by, they're all broken in so many ways. They all fix each other's problems and are still broken in utterly unique ways.

Linux is actually the least shitty of them all.

>Should I have said OS package?

Programs.

User-land programs if you'd like to be redundant.

No, an AI is not even close to being part of the OS. You talk about userland crap and then start going on about an imaginary "OS" that you want to create when in fact it's literally just a whole bunch of userland software.
>>
>>54421780
>>
Cleaned up a few little ugly bits of my shitty Hex dumper that were annoying me, also added a license.

http://pastebin.com/N8GkYc3B
>>
>>54421865
>using eclipse and windows
>>
File: file.png (149 KB, 540x582) Image search: [Google]
file.png
149 KB, 540x582
>>54421765
>Linux, as an OS, is not commercially viable
>Mac OSX/UNIX is a fully-commercial OS

OK
>>
>>54421877
i play too many vidya games
if i didn't i would use linux
>>
>>54421895
dual boot bud. its pretty straight foward
>>
File: 1438314435385.png (179 KB, 405x406) Image search: [Google]
1438314435385.png
179 KB, 405x406
>>54421865
I guess negative numbers dont exist.
Keep doing your thing pajeet
>>
>>54421895
i do but im a greasy fuck that plays games all day so i don't end up using it that much.
>>
>>54421905
draw those teeth better please
>>
>>54421780
a / ( 1 / b )
>>
>>54421905
>>54421780 does not work with negative numbers either.
>>
>>54421872
I wrote one of those about a year ago.. in Go

http://pastebin.com/pnZSMmps
>>
>>54421784
I don't get it. Why do I have to be a troll to want to do this?

You were right before, that I'm delusional. I do troll sometimes, but not about this. Why can't you at least stick with being delusional? I'd rather be insane and get real answers than a troll and get meme answers...

>>54421797
So, are you actually saying trying to follow UNIX is NOT a good idea?

I mean, I figured, at least if I follow UNIX, then I could much more easily do porting for /other/ UNIX, Mac, and Linux software, and the only difficulty would be making Windows shit compatible with my system, which since Windows is compiled on 30 y/o Perl scripts, and no one in Microsoft even knows how they work anymore, I can't really agree that Windows is a good OS. Does a lot of stuff, because they sacrifice bug solutions and refactoring for more features... but there's no reason why you can't have lots of features AND NOT-poorly-coded software.

However, if I didn't base it around EITHER the .NET Framework OR UNIX and POSIX, then it'd guarantee failure, because the system would be incompatible with every type of business application currently on the market.
>>
>>54421922
well shit
>>
>>54421922
that's... awesome
>>
>>54418222
elisp: https://www.youtube.com/watch?v=D1sXuHnf_lo
>>54420558
let is only for declaration, assignment can be done in two different ways, depending on whether mutability is explicitly part of the type:
> let x = ref 10;; (* Using the ref type *)
val x : int ref = {contents = 10;}
> x := 5;; (* Assign the reference *)
val it : unit = ()
> !x;; (* Dereference x *)
val it : int = 5
> x;; (* x alone is just the reference, not the value*)
val it : int ref = {contents = 5;}
> let mutable y = 10;; (* Using a mutable let (y's type is int) *)
val mutable y : int = 10
> y <- 11;; (* Assign directly to y *)
val it : unit = ()
> y;; (* No need to dereference *)
val it : int = 11

>>54421513
>But Linux would have been much bigger were it written in a language like C++, Rust
only if it was poorly designed. if you use Rust or C++ well, you can write code that's compact and doesn't make too much use of shitty bloated design patterns. basically, only using abstractions where they save time/code
>>
File: Capture.png (4 KB, 216x86) Image search: [Google]
Capture.png
4 KB, 216x86
why this no work???
>>
>>54421936
>are you actually saying trying to follow UNIX is NOT a good idea?
>I can't really agree that Windows is a good OS
>they sacrifice bug solutions and refactoring for more features

If you knew anything about OSes at all, or even just systems programming, you'd understand which areas of UNIX and Windows are good and which are complete and utter crap. Same thing applies to Windows. And Lisp Machines. And anything.

>it'd guarantee failure

Failure is already guaranteed.
>>
>>54421780
what about defining the operator?
_*_ : ℕ → ℕ → ℕ
zero * n = zero
suc m * n = n + m * n
>>
>>54421977
method returns nothing.
>>
>>54422014
so? I have println for that reason
>>
>>54422035
>I have println
Do you have any razorblades?
>>
>>54422035
..do you know how assignment works?
you assign something from the right-hand side of the equals sign to the left hand side

your right-hand side (the method) returns void, i.e it returns nothing so you can't assign it to y
>>
>>54422035
You have 'y' instantiated as an integer and you're trying to declare it equal to a void method that returns nothing, let alone an integer.
>>
>>54421780
public int multiply(int number1, int number2) {
int sum = 0;
int looper = Math.abs(number2);
for (int i = 0; i < looper; i++) {

sum += Math.abs(number1);
}
if ((number1 < 0 || number2 < 0) && !(number1 < 0 && number2 < 0)) {
return (-1 * sum);
} else {
return sum;
}

}
>>
>>54422079
>without using the operator *
>return (-1 * sum)
>>
File: Screenshot_21.jpg (34 KB, 302x276) Image search: [Google]
Screenshot_21.jpg
34 KB, 302x276
>>54421679
Except how she comments, I program like a girl.
>>
>>54422086
here u go pajeet
public class Tester {

public static int multiply(int number1, int number2) {
int sum = 0;
int looper = Math.abs(number2);
for (int i = 0; i < looper; i++) {

sum += Math.abs(number1);
}
if ((number1 < 0 || number2 < 0) && !(number1 < 0 && number2 < 0)) {
return ( sum/-1);
} else {
return sum;
}

}

public static void main(String[] args) {

multiply(11, -3);

}
}
>>
>>54421986
I looked at the top part with an open-mind. I guess it's possible that neither system will do everything perfectly. I just figured I might be best starting with a standard.

If you really think they both fail in different ways, then I'll think more about it before deciding to make a new UNIX versus making something entirely unheard of. But, that'd also be an extra pain in the ass, because I couldn't even necessarily use UNIX drivers. I'd have to get everything going even as far as basic drivers and a filesystem architecture for disks...

And then, that might even require making my own standards outright. I'm not even sure that sounds cool... unless the organization I want to start to DO this massive project comes up with the perfect set of standards.

I mean... I guess one of the things that I was actually loathe to implement about UNIX (from what I did get read in that book) was the idea of every spawned process is a child of another...

That sounded kind of... weird. I'd have to look more into it, but really, Windows did have that /slightly/ more right, spawning each process as an independent parent process.

But, I still think that could be improved.

Eh, I'll see whatta do.

However:
>Failure is already guaranteed.

That, Anon, I absolutely refuse to accept
>>
>>54422100
guess it's time to shave put on a skirt and live as the feminine bitch boi you were born to be anon
>>
>>54418161
Some Java web service that notifies users when an episode from a series will air that day.
Need it because couldn't find a similar, atomic service and tired of browsing imdb and forgetting what series I'm following.
>>
>>54422128
I have no idea what you mean by atomic service, but there is https://myshows.me/ which is sure better than browsing imdb
>>
File: sniger.gif (822 KB, 350x246) Image search: [Google]
sniger.gif
822 KB, 350x246
>>54422046
>>54422053
>>54422054
wat r you guys even talking bout
>>
>>54421780
(defun product (a b)
(product-re a b a))

(defun product-re (a b c)
(if (= b 1)
a
(product-re (+ a c) (- b 1) c)))


No, I have not read my sicp. I know the Y combinator is the right way to do this, though.
>>
>>54422116
>it's possible

No, it's fact. Look at POSIX signals for an example of a totally broken system that shouldn't actually have been invented.

>that'd also be an extra pain in the ass, because I couldn't even necessarily use UNIX drivers
>I'd have to get everything going even as far as basic drivers and a filesystem architecture for disks

What's the point if you don't want to do that? Don't you realize that's essentially what an OS is about?

>I don't even understand the systems I'm trying to reinvent
>failure is not guaranteed
>>
>>54422169
>post
>realize how fucking wrong it is
this is what sleeping through math class gets you. people that can't math don't deserve to live.

brb nearest noose
>>
>>54421780
to lazy to code:
ln(a) + ln(b) = ln(a*b)
to extract a*b from ln(a*b) without using power which requires multiplication, you can use newton method of successive approximations. Something like x = ( ln(x) - ln(a*b) ) / 2 in a while loop as long as ln(x) - ln(a*b) > acceptable_error_margin
>>
>>54422100
I program like her, a bit, too.

Here's an example from a school project.
Java:
while(true)
{
int chk = currNode.getItem().compareTo(newNode.getItem());
//System.out.println("checking node: " + currNode.getItem().getTitle());

if(chk == 0){break;}

if(chk > 0){ //new node is less than current node
if(currNode.getLeftChild() != null)
currNode = currNode.getLeftChild();
else{
currNode.setLeftChild(newNode);
break;
}
} else if(chk < 0){ //current node is less than new node
if(currNode.getRightChild() != null)
currNode = currNode.getRightChild();
else{
currNode.setRightChild(newNode);
break;
}
}
}


and PHP
<?php //adminConsole.php
/* This module is used by administrators to
* manage boards, threads, and posts
*/

require_once('session.php');

if((!session_id() == '') && ($board == '') && ($thread == '') && ($post == '')){//session_status() != PHP_SESSION_NONE
/* The console should only display if no board, thread, or post is selected
* This console allows admins to create and/or delete boards
*/
//!empty($_SESSION['user'])
switch($_SESSION['userType']){
case 'FULL':
$consoleState = 4;
break;
case 'ADMIN':
$consoleState = 3;
break;
case 'MOD':
$consoleState = 2;
break;
case 'JANITOR':
$cosnoleState = 1;
break;
default:
$consoleState = 0;
}

//echo "CONSOLE STATE IS: ".$consoleState.'<br />';
>>
File: aaa.jpg (20 KB, 489x139) Image search: [Google]
aaa.jpg
20 KB, 489x139
>>54413785

Still trying to figure this out. Pic related is the order of how my methods are implemented. There is no header file in my project.
Would the order of my methods make a difference to how the compiler sees it? Weirdly enough (well, weird to me), I get different errors when I switch up the order that methods appear in my mergesort cpp.
>>
>>54422169
Lamba calculus, yawn> A Y combinator is just a monoid in the category of endofunctors, i.e a homomorphism, a functor which only maps to itself. What's so difficult about this? Are you so new to programming?
>>
>>54422156
Atomic as in offering this single service of subscription and notification (via email for now, thinking of writing some small clients for mobile as well).
>>
>>54422207
yes, thats why you declare prototypes (forward declaration)

a symbol has to be known before it can be used
>>
>>54422172
Fair enough...

I'll definitely spend more time trying to figure this out before making any decisions.

I guess there's a much better likelihood that making something completely new is actually the best idea.

I'll start by looking at the signals you mentioned.

Thanks for making me think straight, to be honest.
Now I feel like someone who was on the same Kool-Aid either a Windows fanboy or the neckbeard-type Linux users bashing every other OS.

I guess it requires realizing you're being a dumbass, first, to STOP being a dumbass.

Really, I appreciate it; I never thought of it that way
>>
>>54418548
What kind of robotics team used Java? When I did robotics we were stuck with LabView. If only you could program them in ruby.
>>
>>54422222
>>54422222
>>
>>54422213
>Actually programming
>not writing hello world and then giving up because deep down inside you know that any functional program you could write would be completely pointless and a waste of time when working software already exists
>not knowing deep down inside that the only programs that truly need writing are domain specific to jobs and academic positions your poor and dispassionate ass will never, ever come in contact with
>not knowing that, outside of making money off app store fodder, the average person has no reason to ever program

do you even live in your mother's basement
>>
File: Capture.png (4 KB, 289x86) Image search: [Google]
Capture.png
4 KB, 289x86
>>54422046
>>54422053
>>54422054
is this still recursion?
>>
>>54422235

The people who mercilessly point out every flaw of some piece of technology are actually those that are most knowledgeable about it.

You want to become that guy.
>>
>>54422218
C++ goes top to bottom, right?
Just given from that screenshot of text, my program shouldn't give the compiler any issues?

I'm just trying to rule out what any possible problems right now.
>>
>>54422262
No. Recursion references itself.
>>
>>54422262
no, a recursive function is a function that calls itself

int foo(int a) {
a++;
System.out.println(a);
foo(a);
}
>>
>>54422273
An important point to note here is that his function is not fucking void.
>>
>>54421780
let rec prod = function
| (_, 0) -> 0
| (x, 1) -> x
| (x, y) -> x + prod(x, y-1)
>>
>>54422279
so void=recursion-less
>>
>>54422273
this is a bad example. You should at least show the basics of a recursive function, i.e base case. Otherwise its an infinite loop
>>
Why do people like Python more than Node.js?
>familiar and forgiving syntax
>functional programming made easy
>best regex support
>easy client-server interactions
Thread replies: 255
Thread images: 32

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

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.