/dpt/ - daily programming thread

What are you working on Sup Forums?

Dlang edition.

Old thread:

Other urls found in this thread:

adventofcode.com/2017
en.cppreference.com
tutorialspoint.com/cplusplus/index.htm
killercup.github.io/trpl-ebook/trpl-2016-10-01.html
referencesource.microsoft.com/#mscorlib/system/collections/generic/list.cs,cf7f4095e4de7646
en.wikipedia.org/wiki/Document_Style_Semantics_and_Specification_Language
pharo.org/
cincomsmalltalk.com/main/products/visualworks/
exept.de/en/smalltalk-x.html
pastebin.com/DthJG80a
perl6.org
github.com/alexm98/itsumi
forum.dlang.org/post/[email protected]
twitter.com/AnonBabble

tfw no double D gf to program in D with

c++ is the greatest language of all time

Ah, right. Thanks. I'll try it after breakfast.

Why do you guys meme on Rust so much?

the shitposting writes itself really.

Because it offers only trivial gains over what's available and established. The tooling is years behind what is available for C and C++, and by the time the tooling is nearing par, another new shiny language will have been released which original rustlets will jump ship to, leaving later rustlets to maintain rusting codebases.

In the fashion industry you've got to keep wooing the cultists or they'll look for something else.

>can't switch on strings
this language is so fucking shit omg

>his language has switch instead of match

what language?

Can I declare a variable and assign to it from an input stream on the same line somehow? Like something like
std::string str

Don't fall in /dpt/ memes. Rust is is taking systems programming by storm.

if applicable, your favorite one

i wish everybody thougth like this, maybe then the node meme wouldn't be a thing in web dev

>your favorite one
good thing mine can.

Pretty stormy. Is her(his) last name Daniels by any chance?

What to program if all I got is a shitty laptop with XP on it for the next couple of months, boys.

contribute to react os

You don't contribute to TempelOS??

I'd like to actually use the internet and my USB flashjumpjunk sticks, user.

Bros I need to know the best sites for coding challenges to help exercise my noggin.

I'm doing these at the moment: >adventofcode.com/2017
Most are fairly easy, however

>doing advent of code
>in February

>tfw just lost my meme drive along with all my rare akaris
Why live?

I'm Chinese.

and?

We're still on 2017

get out you chink bastard

Christmas is not delayed in china, you dumb fuck.

You don't need any USB, except to store all of your tile porn

Well, if im going to use a novelty OS, i'd like one that's actually interesting. Terry / TOS, aren't very interesting, desu.

Anyone got some good c++ learning resources?

Depends on what part of C++ you want to learn
for learning STL : en.cppreference.com
for a total begineer : tutorialspoint.com/cplusplus/index.htm

killercup.github.io/trpl-ebook/trpl-2016-10-01.html

Contribute to TOS

Who /emacs/ here?
I am finally getting a hang of this behemoth and what an impressive piece of software this is. The robustness and the foresight of its design. Its beautiful.

learncpp.com

>tfw need to interview interns
>not sure what questions to ask

I hate interviews that go over basic data structure and meme question, because that doesn't tell me if they can actually program or not.

I think I'm just going to give them 2 small programs and a few days to fix them up.
One of them runs fine, but could benefit from better coding practices and data structures, and the other has several runtime issues to see if they know what a pointer is and how to use a debugger.
Then in person I'd go over what changed, their reasoning, and try to guide them towards what could have been better.

Does this seem like a good idea? Have any of you had interviews that were actually enjoyable?

What's their job going to be? It seems like they'll be working with high performance, low level code if that's the kind of project you're thinking of.

In any case, I'd be extremely wary of any company that gives take home projects, especially if you're interviewing interns. Yours might be innocuous, but there are some companies who use take home projects as free work.

Thanks lads

Why is C#'s foreach slower than for loops when iterating Lists?

Microsoft™

less overhead I guess

But Lists are glorrified arrays according to referencesource.microsoft.com/#mscorlib/system/collections/generic/list.cs,cf7f4095e4de7646
so iterating them should be really, really simple.

>glorrified
found the overhead

Just spent ten minutes thinking I was going crazy because I was misinterpreting PHP's readfile function. I figured that it should return the content of the file. But in fact it returns the *length* of the file and simultaneously prints out the content of the file.

Have you ever released something and gotten bad reviews?

That's just lovely.

>life without types

>PHP
Why are you doing this to yourself?

A foreach loop is syntactic sugar for calling .GetEnumerator(), then successively calling .MoveNext() and .Current on the enumerator until MoveNext returns false.

Is it feasible to use Lisp/Scheme as a functional programming language like XSLT?

Sup Forums what is the most glorified useless thing you ever seen?

Rust

They already are functional programming languages.

Or do you mean so you can write S-expressions instead of XML, but with the same purpose (to transform other XML)? Like
(template (match "foo")
(element "bar"
(apply-templates)))

There are a few tools that literally can translate between S-expressions and XML (the main point where they differ probably being how they handle attributes). Not aware of a Lisp or Scheme library specifically designed as an alternative to XSLT though.

>life without metaprogramming

Once, but that was because I managed to ship something to a customer with prototype firmware.

en.wikipedia.org/wiki/Document_Style_Semantics_and_Specification_Language

This was a stylesheet language for SGML based on Scheme.

WHERE ARE THE TRAPLEGS
WHAT HAPPENED TO DPT
NOBODY POSTS THEIR GIRLY LEGS ANYMORE

decent op

>year of our lord 2k18
>still no select function in winsockets

praise Jesus

Guys, what do you think of smalltalk?
I tried it today expecting an outdated oop scripting language, but it is actually a toy vm. I don't know how stackexchange (or anybody) likes it. Am I missing something?

which one have you tried?

Squeak. My thing is writing source code, putting it in the compiler and see what the console shits out, not point-and-click graphical interfaces.

The debugger is interesting.

The moto of smalltalk is to have a live programming environment where everything is an object. For example, to declare a subclass, a message is sent to a class object (yes, classes are objects too).

"Create a class object named Foo by sending the message 'subclass:...' to the object 'Object'"

Object subclass: #Foo
instanceVariableNames: 'a b c'
classVariableNames: ''
package: 'DPT'


from here, you are not working with textual code but with a living environment where the code is build on the spot.

recommended implementation

pharo.org/
cincomsmalltalk.com/main/products/visualworks/
exept.de/en/smalltalk-x.html

I wanna start writting lisp for a living like this

It's not for me, then. Danke for the help

I want a cute serval-san

you could have a look at Ruby which is known as Smalltalk-- (minus minus)

Writing a Fortran subroutine that takes user input data as its argument, reads it and creates a dynamically allocated text string for a file name. Then the dynamic string is returned via output parameter.
I used the allocatable specifier for the dynamic string. While the code seems to work, it does not check any errors or mistakes yet.
pastebin.com/DthJG80a

Threadly reminder that Perl 6 is an amazing language. Come join us on IRC!

perl6.org

Mostly learning string functions

Not my work but I'm on an irc channel where this bot is being built:

github.com/alexm98/itsumi

It's amazing how simple the source code is (in php) and how fast the author goes.

Yeah lisp is pretty good at it actually.

can you explain that if statement?

he is constructing a string with sInputs reverse iterators

if string = reverse(string) then palindrome else not palindrome

Looks inefficient to make a new string just for an if.

So comparing sInput against a new string created by string() within the if statement using everything between sInput.rbegin() and sInput.rend()


Is that right?

The compiler will take care of it

In Rust, this just
fn is_palindrome(s: &str) -> bool {
s.chars().eq(s.chars().rev())
}
Note: No allocation happens here

This is the canonical solution
if (std::equal(input.begin(), input.end(), input.rbegin(), input.rend())

Is it bad to use malloc in C++?

>.rev()
Does this write into memory though

forum.dlang.org/post/[email protected]

no iss returns the *this pointer it's working on so that won't work

If you mean heap, then no

Advocates of Modern C++ don't even want you to use new.

In practice, as long as you stick to a consistent style it doesn't matter.

Hey thanks, that makes so much more sense than what I was doing.

Daily reminder that in theory ATS is the best language out there, too bad it's syntax is so ugly you will never want to program with it.

>tfw ATS was supposed to save us

const something_t& foo
Why?

const was mistake.

obviously T const &foo; is better.

let foo: &something_t
superior

const T func(const T& const arg) const;

>& const
please don't do that

I'm using javaFX to write a chat program, and I just ran into a problem when using a TextArea to gather user input.
The problem is, when the user hits the Enter key to forward data, the caret will move one line down on the TextArea I use for user input, despite running .positionCaret(0) and .clear() on the TextArea itself. Pic related.
How can I fix it?