[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: 24
File: trap programmer.png (1 MB, 1702x2471) Image search: [Google]
trap programmer.png
1 MB, 1702x2471
old /dpt/: >>51381637

What are you working on, /g/?
>>
>daily programming threads form a linked list
>>
>>51392062
SeconD
>>
>>51392075
no, it never lasts more than 5 nodes because someone decides to fight over the OP pic and make 3 separate dpts and then people link back to the older ones because the newest ones hit bump limit.
>>
>>51392075
lisp master race confirmed
>>
>>51392075 Linked lists are the best data structure. Prove me wrong (you can't).
>>
here is a trivial question for you /dpt/!

Write a function that inputs two integers and swaps the value of them.

This should be trivial for real programmers
>>
>>51392127
i1^=i2
>>
>>51392127 Integers are values and not objects, you can't swap them.
>>
>>51392127
void swap(int &t1, int &t2){
int temp = t1;
t1 = t2;
t2 = temp;
}


In glorious c++
>>
>>51392127
void swap(int *a, int *b)
{
int tmp = *a;
*a = *b;
*b = tmp;
}


friendly reminder that this runs faster on modern architectures than fucking around with bitwise hacks.
>>
>>51392127
void swap(ref int a, ref int b)
{
int tmp;
a = (tmp = b, b = a, tmp);
}
>>
>>51392177
>>51392176
wouldn't it be better to swap the pointers than their values?
>>
>>51392127
input 
a b 0
^

[->>+<<]>[-<+>]>[-<+>]<<

Output:
b a 0
^
>>
>>51392127
def swap(a, b):
a = a ^ b
b = a ^ b
a = a ^ b
>>
>>51392127
func swap<T>(inout a: T, inout b: T) {
(a, b) = (b, a)
}
>>
>just got DreamSpark
>already using VS Community
>already on DAZed W7
Well shit what the fuck do I use it for anyways?
Is VS Enterprise that much better?
>>
Is making a win32 application hard, or am I just retarded?
>>
>>51392317
int main() { return 0; }
done
>>
what does /g/ think of QuakeC?
>>
>>51392320
I guess I'm just retarded. Thanks anon.
>>
>>51392127
func swapInts(a, b *int) {
temp := *a
*a = *b
*b = temp
}
>>
>>51392352
>:=
what the hell is this?
>>
>>51392347
alt. (simpler) version
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{

return 0;
}
>>
>>51392363
It's Go yo.
>>
>>51392363
shorthand declaration in Go

instead of
var temp int := *a

you can do
temp := *a
>>
>>51392370
>people got paid to write the winapi
>>
>>51392398
:= isn't supposed to be there in the top one, it's just =
>>
>>51392402
>what is backwards compatibility
>why is it important for the most popular OS
>>
Are there really C zealots here who take pride in rewriting half the standard library of more modern languages just so their code can run slightly faster?
>>
>>51392062

What's the deal with /g/'s obsession with cross-dressing and transgendered people?

I don't get it. Is it ironic? Is there actually an above-average proportion here who is into it?
>>
>>51392420
>he's never worn a skirt
don't knock it till you try it bruh
>>
>>51392402
>>51392408
it's not even that bad

int (exit code)
WINAPI (calling convention)
WinMain (entry point)
(
HINSTANCE hInstance, //handle to instance, i.e. base memory address
HINSTANCE hPrevInstance, // deprecated but needed for compatibility
LPSTR lpCmdLine, // long pointer (basically just a normal pointer now) to string (the command line/arguments past in)
int nCmdShow // how the window should be shown

)
>>
>>51392417
It's even worse.
The C developers here are so terrible that their code actually runs slower.

The people who make those standard libraries actually know what they're doing.

Usually. PHP doesn't count.
>>
>>51392444
do you wear a skirt?
>>
>>51392317
>Is making a win32 application hard, or am I just retarded?

It's not particularly hard, it's just kind of convoluted.

You need to understand that it revolves around "message pumps". In classic Windows programming, everything is done by sending messages around. In the olden days, there weren't threads where you could have continuous background tasks running. Instead, you had to write your entire program as a state machine, triggered entirely by messages.

(that last bit isn't *quite* true, but it's close enough for now)

I don't know if anyone is writing any pure C-style Win32 programs anymore. MFC became huge by the late 1990s. WTL came along, and that's what I still prefer. It's like what MFC would have been if C++ compilers had developed years faster. WTL is heavily templated, though, and I think that's a big part of what led to C++ losing its foothold as a mainstream application programming language.

These days, I'd probably look into Qt if I wanted to do C++ application development.
>>
>>51392233
won't work, immutable types are passed by value in python

you would need to do
def swap(a, b):
return b, a

a, b = swap(a, b)
>>
>>51392486
while programming, I do. it helps me to concentrate
>>
>>51392503
what a shitty language, into the the thrash along with java
>>
>>51392507
Do you also sit with a dildo up your ass?
>>
>>51392507
>tfw when you're ottermode, 6'2'', and...hairy

I wish I could trap.

I can't.
>>
>>51392507
post yourself wearing it
>>
>>51392535
most languages pass by value my friend
>>
File: 1446590110179.jpg (219 KB, 1000x1502) Image search: [Google]
1446590110179.jpg
219 KB, 1000x1502
>>51392062
I'm getting real sick and tired of these filthy degenerates plaguing these threads with traps and not a single fucking thing about programming
>>
>>51392546
No, I use a buttplug.
>>
>>51392535
that's how it works in pretty much any language unless you pass a pointer or specify passing by reference
>>
>>51392568
this is the wrong board for you
>>>/reddit/
>>
>>51392568
great pic
>>
>>51392590
yeah, better languages lets you to references
>>
>>51392568
>no fun allowed
>>
File: 1401807426951.png (228 KB, 1000x4618) Image search: [Google]
1401807426951.png
228 KB, 1000x4618
>>51392595
this is the "Technology" board, not >>>/b/, not >>>/a/, not >>>/lgbt/
You can use any SFW image here but at least talk about programming in these thread
>>
>>51392644
>technology board
>technoLGy Board
>echnoLGy Board T
>LGBT

>technology Board
>B

>technology boArd
>A
>>
>>51392644
This is the technology section of an anime imageboard, friend.
Go fuck off to reddit if you want "serious" discussion.
>>
>>51392644
>for free

Oh wait, you can't even do that.
>>
>>51392644
you're on an anime site you fag. go back to reddit already
>>
>>51392644
anti-anime shitposting actually derailed the thread
good job becoming what you hate, you fucking autist
>>
>>51392676
You're a pathetically deluded manchild faggot. Kill yourself.
>>
>>51392699
what site do you think you're on you fucking faggot. fuck off and die already.
>>
File: Screenshot_2015-11-17_13-12-57.png (83 KB, 814x803) Image search: [Google]
Screenshot_2015-11-17_13-12-57.png
83 KB, 814x803
Ah yes, look at all that "anime"
>>
Calm down guys, think about the DPT's CoC
>>
How come most programming books don't have well designed exercises? They either have just a few or they are very shitty.
Books like Algorithms, Thinking Functionally, SICP really engage the reader with the exercises while most authors just expect you to just read the text and "get" everything.
>>
>>51392728
what the fuck shit font is that

god damn man
>>
>>51392751
Because most programming books aren't written like college textbooks that hold your hand the entire way.
>>
>>51392568
But it's a le japanes image board, so that means that every post must contain at least one anime image a fat neckbeard can masturbate to.
>>
What is your favourite anime /dpt/?

I enjoyed naruto for a while but it got worse. I heard that it ended, should I give it a nother chance?
>>
>>51392762
Looks fine to me
>>
>>51392775
probably ergo proxy fight me irl
>>
>>51392721
I'm in a daily programming thread on a technology board. Other than that, it doesn't make a fucking difference what the original intention of the website was.
Kill. Your. Self. Or at least grow the fuck up.
>>
>>51392775
Gintama
>>
Listen up. What if the minimum character count for replies is set to 100? This way shitposters will leave and we can finally have 'quality' discussions.
>>
>>51392775
This has nothing to do with programming, fuck off to /a/.
>>
>>51392806
Better idea, what if you just kill yourself?
>>
>>51392828
Is there anime in the afterlife?
>>
>>51392775
Nah, it got worse and worse.

You should try Death Note if you are new to anime. My personal favourite is probably mushishit
>>
>>51392833
Yes
>>
>>51392806
Just like the robot fostered quality discussion right?
Wouldn't expect a newfag to know that.
>>
>>51392816
this is an anime site new-friend
>>
File: lambda-star-red-flag.png (23 KB, 1920x1080) Image search: [Google]
lambda-star-red-flag.png
23 KB, 1920x1080
I'm working on a programming language. It's called Valutron.

Valutron is a Lisp. It has two key differences to many other Lisps: it has actual syntax instead of S-expressions all the way down, and I place emphasis on the dynamic Object-Oriented system that is available.

Here is a code example:

// let's define a 'get-hello-world' generic
defgeneric get-hello-world (object some-object) => string;

// let's define a 'hello' class
defclass hello (object)
{
slot string hello : initarg hello:;
slot string world : accessor getWorld, initarg world:;
}

defmethod get-hello-world (hello some-object) => string
{
let result = copy(some-object.hello);
append(to: result, some-object.getWorld);
result
}

let aHello = make-instance (hello: "hello", world: "world");
// the arrow -> is an alternative form of method dispatch syntax
print(stdio, aHello->get-hello-world());


Here's the same expressed in CL with CLOS:

(defgeneric get-hello-world ((some-object object)))

(defclass hello (object)
((hello :initarg :hello)
(world :initarg :world
:accessor getworld)
)

(defmethod get-hello-world ((some-object hello))
(setq result (copy (hello some-object)))
(append :to result (getWorld some-object))
(result)
)

(setq aHello (make-instance 'hello :hello 'hello :world 'world))

(print stdio (get-hello-world aHello))
>>
>>51392800
>>51392816
back to reddit with you
>>
>>51392806
fuck off

012345789012345789012345789012345789012345789012345789012345789012345789012345789012345789
>>
>>51392862
Nigger I've been on 4chan since you were in training bras. If this is your only argument you might as well just off yourself you weebshit manchild.
>>
>>51392260

Use it to get access to PluralSight for 90 days and learn something.
>>
>>51392874
you're not fooling anyone newfriend.
>>
>>51392858
looks like a waste of space and characters desu
>>
File: 03.jpg (664 KB, 1280x800) Image search: [Google]
03.jpg
664 KB, 1280x800
>>51392858
>actual syntax
>>
>>51392858
let's not
>>
>>51392890
I assume that's what your teachers told your parents when you got them to do your homework for you. Literally retarded with no argument.
>>
>anime banners everywhere
>mascot is an anime characters
>site name is japanese
>words filter into japanese words
and these niggers still deny that this is an anime site
>>
So I've done some basic stuff with C# and want to start moving into ASP.net. Anyone have recommendations for where to start?
>>
/g/ secret santa at the office is coming up. We generally deal with technology (repair, service, cloud backup). What should I get the person I get matched up with? Suggestions? People around the office ask me to program stuff for them sometime so I'm going to throw in a "1 free script" coupon as a joke, but I'd like something else to go with it; <$20 is the limit.
>>
>>51392779
this is what freetards actually believe
>>
>>51393012
you should give a blowjob
>>
>>51393012
a skirt
>>
>>51393028
Sorry, I don't watch anime or program Haskell, nor do they.
Next suggestion please.
>>
>>51392963
It's ironic, newfag. Anime is for children.

If you honestly enjoy anime you shouldn't be posting here.
>>
>>51393012
$20 anime figure
>>
>>51393052
a hard copy of SICP
>>
>>51393065
>>51393049
>>51393028

See >>51393052 and maybe grow up.
>>
why exactly was my post deleted
>>
>>51393064
>what is seinen
>>
>>51392751
>How come most programming books don't have well designed exercises?

I would say that most programming books fall into one of two categories: 1) reference and 2) tutorial.

All the "Learn {$lang} in {$time}!" books are the latter. The whole book is a string of interactive exercises.

It's very unusual for a book targeted at professionals to have exercises at the end of each section.
>>
>>51392320
That isn't actually win32.
>>
>>51393157
can be compiled to a win32 application
>>
Lol fuck win32. win64 when?
>>
>>51393188
No. It doesn't use the win32 api at all. It doesn't even use the proper entry point function.
>>
>>51392762
It's not the font fuckface, it's the font rendering.
>>
>>51393225
>it doesn't use the win32 api
>it doesn't use WinMain
so what? still a win32 application once compiled
>>
>>51392816
Don't redirect narutards to /a/ please, we don't want them.
>>
>>51393271
>muh "naruto iz shit" meme
>muh "death note gud" meme
>>
Should I bother mallocing an exact fit for input data?
unsigned len = get_length(file);
char *buf = (char *) malloc(len);
fgets(buf, len, file);
seek_forward(file, len);


>tfw any other language would do this shit for you automatically
>>
>>51393271
Too bad.
>>
>>51393303
death note is shit though, same with all other shonen/edgy shit.
>>
>>51393308
Oh ok i see.
>>
>>51393327
i tend to find the ones that hate shonen are obsessed with anime featuring little girls
>>
>>51393358
Anime featuring cute girls is objectively a superior form of anime.
>>
>>51393268

I'd say this guy is technically correct, but it's stupid.

The only reason it's technically correct is that the executable still depends on kernel32.dll.
>>
>>51393382
No, the only reason it's technically correct is that it's an application that runs on Win32
>>
File: taylor swit.jpg (194 KB, 960x1441) Image search: [Google]
taylor swit.jpg
194 KB, 960x1441
>>51392062
>What are you working on, /g/?
I'm building my personal website. I only know HTML & CSS and that too poorly.
>>
>>51393398

The only reason it does so is because it depends upon kernel32.
>>
>>51393423
>>>g/wdg/
>>
>>51393443
Thanks
>>
File: Lab 9_Page_1.jpg (424 KB, 1700x2200) Image search: [Google]
Lab 9_Page_1.jpg
424 KB, 1700x2200
if ure bored have fun with this.
>>
>>51392198
Oh you mean like this?
void swap(int **a, int **b)
{
int *tmp = *a;
*a = *b;
*b = tmp;
}
>>
>>51393435
Doesn't MSVC standard library use the win32 API?
>>
File: 1394607712758.jpg (7 KB, 225x225) Image search: [Google]
1394607712758.jpg
7 KB, 225x225
>>51393469
I never do a UML diagram for my programming assignments
>>
>>51393469
>powerpoint
>uml
This could get interesting...
>>
>>51393469
>Java
>UML
Nope
>>
File: image.jpg (253 KB, 900x948) Image search: [Google]
image.jpg
253 KB, 900x948
https://groups.google.com/forum/m/#!topic/comp.lang.lisp/Bj8Hx6mZEYI
Holy shit this autism
>>
>>51392858
>Syntactic sugar leads to cancer of the semicolon.
;caret)
>>
>>51393523

Yep.
>>
>>51393736
>every language with closures and recursion is a Lisp
Reminds me of the guy a couple days ago saying that OOP was the best programming paradigm for every job because he included a bunch of unrelated features
>>
Do I have to use new here?
template <typename T>
std::vector<T *> list;
void PopulateList()
{
T somevar = T();
list.push_back(&somevar);
}
>>
>>51392177
do you have any benchmarks to support this statement?
>>
>>51393844
x86 literally has a single instruction to swap the contents of two registers, compilers can figure out that that's what you want to do when you do it the "assignment way"
>>
>>51393862
okay, so how much faster is it?
>>
>>51393878
2 fewer instructions
>>
>>51393897
Is that in milliseconds?
>>
>>51393913
microseconds
>>
>>51393913
Kill yourself.
>>
Damn mang, why is writing proper comments so difficult?
>>
>>51393954
I find it pretty hard because my code is relatively self-documenting.
>>
>>51393962
You're supposed to comment clarifications anyways.
>>
>>51393962
Exactly. I have a Session class with a start method. Guess what it fucking does?
>>
>>51393986
Creates 3 instances of AbstractJavaBeanOutputStrategyFactory?
>>
>>51393913
At least on Intel, an XOR costs the same as an XCHG. So XOR swap is 3x slower.
>>
>>51393304
malloc(len+1), no need for the cast before malloc either. And yes, you should get used to doing it.
>>
>>51393823
If you have a valid reason for wanting a vector of pointers then yes, you will need new, but I doubt it. Just have a vector of T, or std::unique_ptr<T> if you really need it.

If you do go the route of using new, you will need to manually delete the pointer at some point. Don't forget.
>>
>>51393823
>>51394099
Also note that if you use an std::vector<T>, you can use emplace_back to construct it in place.

void PopulateList()
{
list.emplace_back(/* constructor parameters */);
}
>>
>>51394099
>don't forget
pff don't listen to this fag. freeing your heap allocated shit is oppressive.
#freeleak
(it's like freebleeding but geared towards programmers)
>>
>>51392893
It's almost the same size as the CL with CLOS version. Just not as bracketed.

>>51392898
Syntax is good.

>>51392932
Let's.

>>51393766
Syntactic sugar is sweet and appetising.
>>
>>51394270
>Syntax is good.
Syntax I decide I want in my lisp program is good. Syntax you decide I should want in my lisp program is bad.

If I wanted a syntax-heavy language I literally could choose every other language in existence [except forth].

I'm not saying your shits retarded but, yeah man, it's fucking dumb.
>>
Hey /g/, learning Jflex here, why is this piece of shit incapable of reading diacritics?

%%

%class analizador
%public
%standalone
%unicode
%line
%column

char = [a-z]|á|é|í|ó|ú

%%

{char}+ {System.out.println(yytext());}


Both the code file and input file are encoded in unicode and it's driving me nuts
>>
>>51394310
This. A Lisp without the utterly simple, homoiconic syntax is pointless.
>>
>>51394389
does it work in java
>>
File: Screenshot_2.png (4 KB, 325x80) Image search: [Google]
Screenshot_2.png
4 KB, 325x80
Anyone know why this shit isn't working?

I have this counter variable for some other shit, but if the input is invalid it should be discarded and that's why I'm trying to reduce the counter variable in the catch block

But it ain't working

It's probably me being retarded and not knowing enough

>inb4 >java
Learning it at uni
>>
>>51394484
As soon as an exception is thrown, nothing else in the try block will happen. Just increment after the input is validated.
>>
>>51394503
Thanks, turns out I was retarded and did the input mismatch exception on a String input, so it was never thrown.

And as it turns out I have an if/else statement that outputs that exact same statement if shit isn't right

Thanks anyways m8
>>
>>51394467
the reulting java file compiles and works fine on most words, it'll just treat the diacritics as a different word
>>
>>51394558
it just uses the java reader bro so you'll need to understand how java manages this
>>
>>51393823
Yes
somevar is being created on the stack inside the function, once the function exits, somevar loses scope and the pointer added will be meaningless
>>
>>51393304
mmap it, brah.
>>
I'd like to create a simple online trading platform and matching engine as a learning project. What sort of technologies/languages do I need to get a hang of and would best suit the job? I have elementary proficiency in C but that's about it.
>>
>>51394968
You might need to learn how to fizzbuzz. But that's about it.
>>
>>51394310
If you don't like the syntax then create a macro. A reader macro, if necessary.

Meanwhile I'll happily use my Lisp with nice syntax which I have found to be highly useful and efficient to work with.
>>
>>51392127
swap (a, b) = (b, a)
>>
I haven't used python in forever. I'm trying to pull data and split the information. I'm getting an error message

  File "test.py", line 5, in <module>
high = btc.split(":")
TypeError: Type str doesn't support the buffer API


I believe it's because the data being pulled is not in a string. Is that right? My code is below, any help is appreciated.


import urllib.request

btc = urllib.request.urlopen("https://btc-e.com/api/2/btc_usd/ticker").read()

high = btc.split(":")
high = high[2].split(":");

print(high[1])
>>
File: babbysfirstmst.png (38 KB, 1202x920) Image search: [Google]
babbysfirstmst.png
38 KB, 1202x920
Implemented Kruskal's algorithm to create a minimum spanning tree from a set of points. In order to save memory and not have to run it on n * n point, i reduced the edges with Delanuay triangulation.

The goal is to implement this:
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.56.1432&rep=rep1&type=pdf

tfw i get money for doing this and this is not even what i studied
>>
>>51395530
In Python 3, the data returned by .read() is bytes, not str, so use either
high = btc.split(b":")

or
high = btc.decode("ascii").split(":")


The former splits the byte string stored at btc using the byte string b":" as the separator, returning a list of byte strings.

The latter converts btc to a unicode string then splits it, returning a list of unicode strings.
>>
please help boys

I have something like this

char* str = malloc(sizeof(char) * 128);
str = "hello world";


How do I iterate through each character in this malloc'd char array? I tried a few things, and ended up just printing mojibake. Pointer arithmetic seems the way, but I cant quite get it.
>>
>>51392062
I'm currently trying to figure out fucking Code::Blocks. How do I add syntax highlighting for all of my classes? It would appear that I have to add each class manually to a list in order for it to qualify for highlighting.
If I can't figure this out, I'm just going to stop using my Arch Linux laptop for this stuff and go back to my PC for all things coding.

>>51392127
>All these faggots defining new variables
void swap(int& v1, int& v2)
{
v1 += v2;
v2 = v1 - v2;
v1 -= v2;
}
>>
I feel like they're a better way to allocate space for input data.
unsigned i = 0;
const unsigned total_tests = count_tests(file);
while (i < total_tests)
{
unsigned len = get_length(file);
char *buf = (char *) malloc(sizeof(char) * len);
fgets(buf, len + 1, file);
unsigned e_count = count_elements(buf, len);
double *arr = (double *) malloc(sizeof(double) * e_count);
fill_array(buf, arr, e_count);
free(buf);
qsort(arr, e_count, sizeof(double), compar);
display_result(arr, e_count);
free(arr);
i++;
}


I'm pretty much traversing over the same data twice, jumping around with fseek, counting the number of elements to store, mallocing arrays of that size, then fseeking back to store them for real.
>>
>>51395945
>malloc(sizeof(char) * 128);
>str = "hello world";
>>
>slightly interested in Rust
>figure I'll try it out by implementing a simple doubly linked list
>can't for the love of fuck figure out how, all I get is the compiler yelling at me
>google for a solution
>find this
http://stackoverflow.com/questions/22268861/how-would-you-implement-a-bi-directional-linked-list-in-rust
Who in the FUCK came up with this, I'm convinced using rust for an extended period of time will cause actual brain damage.
>>
>>51395945
You should really learn how pointers and malloc work in C.
>>
Can anyone give me a hint on how to code out a 0 1 knapsack problem. I keep working around to greedy solutions but I know they aren't right
>>
>>51395945
what exactly are you doing because what you're doing there is almost definitely wrong. "str = "hello world";" won't copy "hello world" into the string, it will just change what str points to, so you'll have a leak and if you try to free it you'll be in big trouble.

char *str = malloc(128);
strcpy(str, "hello world");
for(char *pos = str; *pos != 0; ++pos) {
// *pos is the character
}


note that using strcpy is a dumb idea in general, I only used it because I know that "hello world" will fit into a 128 byte buffer. If you don't know 100% that the string will fit into the buffer, use strncpy and set buf[size-1] = 0;, or use strlcpy (if you have it), or something.

char *str = malloc(128);
strncpy(str, source, 128);
str[127] = 0;
>>
>>51395955
const size_t total_tests = count_tests(file); 
for (size_t i = 0; i < total_tests; ++i) {
size_t len = get_length(file);
char buf[len + 1];

fgets(buf, len + 1, file);

size_t e_count = count_elements(buf, len);
double arr[e_count];

fill_array(buf, arr, e_count);
qsort(arr, e_count, arr[0], compar);

display_result(arr, e_count);
}
>>
Finished an "Image to ASCII art" program today. How does it look /g/?

https://github.com/JamesJDillon/Image2Ascii
>>
>>51393469
>Java
>UML
>fun
Does not compute.
>>
>>51392104
What should we call the resulting data structure?

A Chain?
>>
>>51396056
Doubly Linked Lists don't really work with Rust's idea of ownership. Data structures in general are pretty tricky in Rust, usually requiring unsafe code to be efficient. Fun reading:

http://cglab.ca/~abeinges/blah/too-many-lists/book/

Doubly linked list is chapter 5 (A bad safe deque) but you'll probably want to read the rest first. It's a pretty good read that explains quite a lot.
>>
>>51396164
garbage collected
>>
>>51396130
You should parse command line arguments to get the input file name and output file name. Then also use optional arguments for rotation and step size.
>>
How do people program in languages without static typing? It's awful.
>>
>>51396396
they use their brains
>>
>>51396396
if the ide allows you to write faulty code, it's not a statically typed language
>>
>>51396396
Dynamically typed code can quickly become obscure. The key example is Python, where it becomes an absolute clusterfuck of classes with multiple inheritance in order to maintain a semblance of type correctness and order.
>>
File: Untitled.png (11 KB, 548x288) Image search: [Google]
Untitled.png
11 KB, 548x288
So I asked in /agdg/ but they're too busy shitposting and circlejerking so I'm gonna post here instead.

So I wrote bitmap font system on top of SFML. It's working fine except for a small issue - texture bleeding. I figured it could be due to floating points so I overrode position methods to round the positions (pic related). And it has helped a bit (I had two very noticable and reproducible bleeding in my menu, with this rounding it goes away and I switched the code back and forth a few times to confirm). However I still get some bleeding with other labels (for instance I have cursor subtitle which bleeds as you move it). I tried disabling texture smoothing afterwards but that didn't help. The bleeding occurs only when moving the text object on the y axis. Any ideas what else could it be?
>>
>>51396396

Also, implicit type conversions signify that a language is shit.
>>
>>51396396
Static, weak typing is where it's at. Statically typed code is self-documenting while the flexibility of weak typing avoids coddling the programmer. C is GOAT.
>>
File: 1335619139059.jpg (60 KB, 794x616) Image search: [Google]
1335619139059.jpg
60 KB, 794x616
There's a better way to do a Sudoku-checker than just for-looping through every row/col/3x3, right? I feel like there must be but I've got no idea what it'd be.
>>
>>51396502
few languages are strict with numbers, which is unfortunate
>>
>>51395952
>undefined behaviours
nice one faggot
>>
>>51396560
probably
but you would never notice the speed increase
>>
>>51396569
are there any languages with statically-checked ranged integers
>>
>>51396600
What's a ranged integer?
>>
>>51396560
Yeah, you can represent your sudoku puzzle as a CSP and solve with a CSP solver, so every cell in the puzzle is represented by a variable and every row/column/square by a set of contraints. CSP solvers with good heuristics can cut down possible solutions by order of magnitude.
>>
>>51396616
Like integers within a range

like -100 -> 100 or something
>>
>>51396621
*constraints

You can write your own CSP solver, it's pretty fun. There is much documentation and scientific papers on the subject.
>>
>>51396560
Maybe you could figure something out by studying the algorithm that generates sudoku puzzles.
>>
>>51396642
you could probably do that with C++ templates
>>
How do I add a new line after outputting to a text file with SDL2?
>>
>>51396642
C can specify bit count for integers.

You can easily create a class that clamps your integers after an operation
>>
>>51396659
the same way you would do it in C
void insert_newline(FILE *fp)
{
/* cautiously insert '\n' at end of file */
long current = ftell(fp);
fseek(fp, 0 - sizeof(char), SEEK_END);
if (fgetc(fp) != '\n')
{
fseek(fp, 0, SEEK_END);
fputc('\n', fp);
}
rewind(fp); /* flush */
fseek(fp, current, SEEK_SET);
}
>>
>>51396600
Ada has ranged but I don't know how deep the checking goes.
>>
>>51392127
def swap(a,b):
a,b=b,a
return a,b

:^)
>>
>>51396731
 def swap(a, b):
return b, a
>>
>>51392858
>>51394400
>This. A Lisp without the utterly simple, homoiconic syntax is pointless.

Lol

By the way, Valutron's syntax is converted straight into S-expressions at the read stage so it retains the benefits.
>>
>>51396731
>>51396741
>cant even make an actual swap macro
what shitty language is this? is this python?
>>
I can't understand how it's possible to use C and assembly on the early NASA rocket guidance systems. How do the limited types not just overflow eventually? I really don't know how they can't use Python or something with arbitrary precision arithmetic by default even though it's slow as fuck and a memory hog.

When you approach the overflow point for a numerical type, what can you do? You obviously can't allow it to overflow because the data in there is important, so a check alone only tells you a failure is going to happen. How do you prevent the overflow failure?
>>
>>51396684
C is so fucking gross.
>>
>>51396769
>>>/g/sqq
>>
>>51396770
>>
>>51396781
Just like your face
>>
>>51396769
>How do you prevent the overflow failure?
you keep your integers small enough
>>
>>51396769
>>51396786
*
>>>/g/sqg
>>
>>51392127
One of the core words of Forth is swap, which switches around the two cells on the top of the stack, so it's already there I guess. If you had to re-implement it in terms of other Forth terms though
: my-swap ( n1 n2 -- n2 n1 )
dup -rot drop ;
>>
>>51396684
>0 - sizeof(char)
Lel, I hope you're kidding

protip:
-1

>>51396659
FILE *your_file = fopen("girl-gamers.bat", "a")
do_shit_to(your_file);
fputc('\n', your_file);
>>
File: 20_100810230106_1.jpg (47 KB, 397x277) Image search: [Google]
20_100810230106_1.jpg
47 KB, 397x277
Is there a way to make a program search for stuff on a hard drive very fast? What's the fastest method? Especially for stuff in the free space. Will the search speed be limited to the hard drive read speed? Is there a way to overcome this?

I'm asking because I need this for a CS project. I chose programming a forensic tool for it.
>>
>>51396830
>Will the search speed be limited to the hard drive read speed?
duh
>>
>>51396830
I guess you could index the hdd first so you can quickly perform searches later.
>>
>>51396830
Create an index
>>
>>51396828
what if the file already ends in a newline?
>>
>found: 0
>>
>>51396865
Nothing in his specification mentioned anything about that.
>>
>>51396896
what about multi-byte characters?
>>
>>51396684
>>51396781
>>51396792
>>51396828
>>51396865
>>51396896
Oh fuck it, I'll just leave everything on one line then.
>>
In google image search (with JS disabled), does google provide a link to the original full-sized image?
>>
with the new updated auto keyword in C++14, don't templates become obsolete?
>>
>>51397036
No, why would anyone think this?
>>
>>51396909
Your thinking is totally wrong. The spec said to print a newline to the file, so I did. The spec didn't say anything about multibyte characters or what happens if there's already a newline at the end, so I didn't do those things.
>>
>>51396684
>undefined behavior
ishyggym8
>>
>>51397147
Where?
>>
>>51397155
fseek
>>
>>51397124
your spec is shit then
>>
File: chat.png (316 KB, 1160x897) Image search: [Google]
chat.png
316 KB, 1160x897
I'm making a windows desktop chat client. I've already made the server and a web client.

Right now I'm trying DataGridView, but I'm having trouble flowing images and text in the same cells. Should I be using a different form part like table layout with richtextboxes inside? to achieve this?
>>
>>51397173
I don't see anything particularly glaring. I also searched for 'defined' in the fseek manual and didn't see any special notes. What is undefined here?

>>51397204
I didn't write the spec, I implement it. And sometimes a simple solution is the answer instead of overengineering.
>>
>>51397269
Sometimes a little forethought spares you a lot of headaches later.
>>
Golang CuC proposal: https://github.com/golang/proposal/blob/master/design/13073-code-of-conduct.md
>>
>>51397338
This is a great step forward for the Go language
>>
File: sshot-985.png (63 KB, 1365x686) Image search: [Google]
sshot-985.png
63 KB, 1365x686
>>51392062
Currently gave a fuck to much about C# to Javascript converters, that were full of bloat, one line became 45 kb (dependency runtime lib) + 6 rows javascript

Soo, i began creating my own converter, 1 to 1 mapping like C and ASM.
>>
>>51397338
>potentially
>Microaggressions: brief and commonplace verbal, behavioral and environmental indignities that communicate hostile, derogatory or negative slights and insults to a person or group.
Hello Ruby, my old friend.
>>
>>51397298
Okay, let me indulge in some foresight.

void 
insert_newline(FILE *fp) {
long current = ftell(fp);
fseek(fp, -1, SEEK_END);
if (fgetc(fp) == '\n') {
fseek(fp, 0, SEEK_END);
fputc('\n', fp);
}
fflush(fp);
fseek(fp, current, SEEK_SET);
}


This inserts a newline only if there -is- a newline at the end of the file. I'm pretty smart because this will be useful in some problem sets, right?
>>
>>51397379
oo cool; you have one for js to c#?
>>
>>51397433
what the fuck is wrong with your code
>>
>>51397441
>js to c#
The complexity of that makes it way way more difficult than c# to js m8.
>>
>>51397433
>>51397445
ok fixed

void insert_newline(FILE *fp) 
{
long current = ftell(fp);
fseek(fp, -1, SEEK_END);
if (fgetc(fp) == '\n')
{
fseek(fp, 0, SEEK_END);
fputc('\n', fp);
}
fflush(fp);
fseek(fp, current, SEEK_SET);
}
>>
Hey guys, you might or might not remember from about a week ago when I (and a couple other people but mainly me) was working on a theoretical programming language called Pipes. The basic premise of Pipes was that instead of code being grouped into classes or whatever, they were grouped into abstract objects known as "Servers" and "Clients". There was a lot more to it but I'm not going to repeat it all.

Anyway, I'm revisiting the idea today (after a remarkably frustrating session of VB.NET coding related to function overloading) and I'm trying to think just how radical this idea could get while still being useful.

Is it possible to have a "Reverse"-functional paradigm? I mean, imagine having no functions, only named blocks of code that don't return values and aren't even directional. I'm thinking statement-based calling rather than procedural. I'll certainly be verbose and not really that useful outside of being cool, but hey I'm not designing this to be useful.
>>
File: but it's only one line.png (6 KB, 1344x139) Image search: [Google]
but it's only one line.png
6 KB, 1344x139
>>51397453
yah, i'm not making one; just asking
>>
>>51397441
Nah, equal large project actually

Because you have the AST-tree needs to be translated from one language to another

Altho a js to C# would be quite bad actually, due C# contains almost double the functionallity
>>
>>51397475
Wasting whitespace, developer time, and CPU time. You are a trash programmer.

All you need is fputc. The spec doesn't say anything else. If making sure there's no newline is forethought then so is making sure there is a newline.
Fucking ridiculous ideas in your head m8.
>>
>>51397503
>not idiotproofing your code
wow, i hope you never get paid to write anything
>>
>>51397503
i think you mean >>51397433
i was just improving his code
>>
>>51397269
>>51397433
>>51397475
You can only call fseek with 0 or a value previously returned by ftell and SEEK_SET. Otherwise it's undefined.
>>
>>51397477
please stop
>>
>>51397528
The point is that we don't know which is idiotic, ensuring there's no newline or ensuring there is a newline. The spec simply doesn't define which is superior so I assume neither. Plus it would be absurd if I called a standard library function called write_newline and it sometimes didn't write a newline. You have a very childish outlook on defensive programming and it explains why you're a poor C programmer. Your posts are very quickly declining into trolling territory so few more words are needed.
Thread replies: 255
Thread images: 24

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.