Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Xarn
Jun 26, 2015

tef posted:

3. tests slow down refactoring

this one is weird because i know a lot of you will say "not with my tests", and i guess that's true, but i've encountered a lot of tests which assert that underlying methods on different objects get called. you're not testing behaviour you're testing implementation, and when you want to change implementation you must re-write the tests. throw in that a lot of tests use fake objects and you have to rewrite numerous lines of code to re-implement the behaviour.


I see your method call assertions and raise you checking non-atomic call counters from different thread. :shepicide:

Adbot
ADBOT LOVES YOU

Xarn
Jun 26, 2015
Structural typing :v:

Xarn
Jun 26, 2015

Wheany posted:

i'm going to send you a cv that says that i'm really good at both c/c++ and java/javascript

:commissar:

Xarn
Jun 26, 2015

fart simpson posted:

i think the haskell style guides recommend not using list comprehensions anymore

huh, why?

Xarn
Jun 26, 2015

Dessert Rose posted:

like wow i knew he was an idiot but syntax highlighting

you guys

syntax highlighting
I am p. sure its a gimmick.

I refuse to believe anything else.

Rob Pike posted:

“Aside from that, everybody knows a tab is 8 spaces wide."
Except that’s not true. It’s measured in units of the width of a numeral. Only in a fixed-width font (who uses those nowadays? Wow, flashback to a teletype!) are those the same thing.

:suicide:

Xarn
Jun 26, 2015

Bloody posted:

expressiveness is good. lack of it is why assembly and verilog are bad.

Counterpoint: Perl.

Xarn
Jun 26, 2015
Not sure I want my kernel aborting when OOM or some internal counter overflows.

Xarn
Jun 26, 2015

Asymmetrikon posted:

also the opinions, reified returns are maybe the worst possible option in the history of coding

but the rust semicolons are pretty bad

Agreed.

Xarn
Jun 26, 2015

rjmccall posted:

... or they'll say that accessing the memory is an unsafe operation, so it has to be done in an unsafe block, and once you do that of course you can have races again. and rust forces basically everything that could possibly be unsafe to be done in an unsafe block, like calling a c function

it's actually pretty neat, but it is an expert feature, and it does not interoperate well at all with existing systems

This is basically how I imagine a theoretical transpiler to rust would work. Start the program with a huge, fuckoff unsafe block, write everything there, done. And its also why its extremely dumb idea.

Xarn
Jun 26, 2015

Wheany posted:

What about dlang users?

Those still exists? :shrug:


Lichy posted:

my other option this term for this slot was parasitology and I think I've had enough interactions with management students to make that redundant so

:drat:

Also C++ is p. nice, as long as you are willing to devote your life to not learning the whole language.

Xarn
Jun 26, 2015

Yes, the whole IoT thing is a good idea and not horrible poo poo show breaking everything everywhere. We definitely should replace lot of core poo poo in our OS and make it easy for web browser to send commands.

Xarn
Jun 26, 2015

AWWNAW posted:

i haven't used C++ in like 10 years and was never that deep into it, and the complexity always turned me off. whenever I see job descriptions that call for C++ experience, I wonder how they evaluate that experience when supposedly everyone that uses the lang only uses a subset of it, and probably not the same subset the employer's looking for? do they just ask generic questions about virtual destructors or something?

My interview for jr. dev using C++ and only C++* consisted of some basic C++ questions like virt. destructor, virt. inheritance and some broader questions, like how do you round up a float without using library functions. The fact that the questions were all about how to write Java in C++ should've probably warned me, but didn't at the time.



* Except writing C# bcoz of Xamarin, C# for windows tools and getting to be the only person who knew how our build worked. :v:

Xarn
Jun 26, 2015

VikingofRock posted:

The C++ I use almost entirely avoids inheritance so any question on inheritance requiring a more complicated answer than "make destructors virtual if your class is going to be inherited from" would probably trip me up. C++ is a *huge* language.

Oh yeah. Inheritance itself is not bad, but gently caress deep hierarchies with virtual functions forever and virtual inheritance is a good signifier that you have hosed up somewhere :v:

Xarn
Jun 26, 2015

hackbunny posted:

I'm pretty sure I know and/or have used all of c++. yes, I even wrote my own iostream (what a bizarre api). well, I used to, because the newer things I haven't had a chance to use yet. I know what they're for because rvalue references/move semantics/perfect forwarding/lambda syntax for functors/etc. are all things I wished c++ had because they were obvious blind spots in the language, but I don't fully understand them and their corner cases. rvalue vs universal references in general and perfect forwarding in particular still escape me a little, and I haven't learned variadic template syntax yet, I know an ellipsis is involved but I can never remember where it goes exactly

things like multiple inheritance and virtual destructors are really straightforward if you know how classes are laid out internally. member function pointers, now those are pure magic and I've never managed to wrap my head around them (but I know the syntax)

So basically pre C++11?

Catching up with C++17 is gonna be fun, just for template instantion guides for templated classes, because you can now construct std::pair<int, int> as std::pair{1, 2} and it will deduce the template types from the constructor.
"So, what do we do we range-constructors (constructors that are templated on iterators and construct container from range delimited by 2 iterators)" you might ask. Well, you give them a hint called explicit deduction guide

C++ code:
// declaration of the template
template<class T>
struct container {
    container(T t);
    template<class Iter> container(Iter beg, Iter end);
};

// additional deduction guide
template<class Iter>
container(Iter b, Iter e) -> container<typename std::iterator_traits<Iter>::value_type>;

// uses
container c(7); // OK: deduces T=int using an implicit guide
std::vector<double> v = { /* ... */};
auto d = container(v.begin(), v.end()); // OK: deduces T=double
container e{5, 6}; // Error: there is no std::iterator_traits<int>::value_type
It seems basically guaranteed to have many unforeseen consequences.. :v:

Xarn
Jun 26, 2015

Note that saying dereferencing makes absolutely no sense -- its just type of references.


(Words are important OK? C++ is hard enough without confusing wording)

Xarn
Jun 26, 2015
This of course has the problem of potentially performing a costly conversion in addition to a copy (think assigning const char* to std::string) so you obviously have to template harder.

C++ code:
template <typename T, typename T2, typename = std::enable_if<std::is_assignable<T&, T2>::value>
void assign(T& dest, T2 src)
This now lets the second argument to be deduced separately, but only if T& can be assigned T2 (ie as already mentioned std::string& can be assigned const char*.)

So that eliminated the conversion if possible. Now how about copies? Well thats where perfect forwarding comes back.*
C++ code:
template <typename T, typename T2, typename = std::enable_if<std::is_assignable<T&, T2>::value>
void assign(T& dest, T&&2 src) {
    dest = std::forward<T>(src)
}
By changing the argument from T2 to T2&&, you get the actual referenceness (not a word afaik) of the argument given, thanks to the rules of reference collapsing. Then you use std::forward <T> to... forward the referenceness to the T's operator=.


Its important to remember that this doesn't work without the std::forward properly, because r-values really like to stop moving. Once you name them, even if you have r-value reference to a temporary, they are no longer moved automatically. This means that this

C++ code:
void move_to(std::string& dst, std::string&& from) {
    dst = from;
}

std::string a, b;
move_to(a, std::move(b));
actually copies b to a inside the move_to function. To fix it, you have to use move inside the move_to function as well.

C++ code:
void move_to(std::string& dst, std::string&& from) {
    dst = std::move(from); // now its fixed
}
And a little circle back a little , std::forward is implementable, and it is not THAT hard, this is the libc++ implementation (for C++11)
C++ code:
template <class T>
inline T&& forward(typename std::remove_reference<T>::type& t) noexcept
{
    return static_cast<T&&>(t);
}

template <class T>
inline T&& forward(typename std::remove_reference<T>::type&& t) noexcept
{
    static_assert(!std::is_lvalue_reference<T>::value,
                  "Can not forward an rvalue as an lvalue.");
    return static_cast<T&&>(t);
}
* Perfect forwarding with strings can also be a hilariously bad idea, in case you use the function with string literals, because then the function isn't deduced as
C++ code:
assign(std::string&, const char*)
but rather as
C++ code:
assign(std::string&, const char[4]);
assign(std::string&, const char[5]);
assign(std::string&, const char[6]);
...
---------------------
The above might not be entirely true, I haven't even had my first coffee, but it should be roughly correct.

Xarn
Jun 26, 2015

Shaggar posted:

uwp/wpf are also better than anything else as far as ui frameworks go

Why do then the new MS UWP apps suck so drat badly?

Xarn
Jun 26, 2015

Cybernetic Vermin posted:

i freely admit that i am an idiot and a sucker for being pointlessly different in having a w10m phone, but holy hell the few high effort uwp apps i have encountered have been fantastic. mail, calendar, the new skype, as well as minor stuff like the explorer app even. no idea if that is microsoft throwing excessive engineering resources on a bad framework, but they are certainly making the framework looking super-promising to me in a way the previous wpf variant never did v:shobon:v

The new skype for me

A) Doesnt send/receive chat messages to people I tried.
B) Doesnt show status of people (and people dont see my status either).

I guess it at least allows for calling people. (At least once we use different app to communicate being online :v:)


Now, I might just have a horrible case of "Doesn't work on my computer", but it doesn't inspire much confidence...

Xarn
Jun 26, 2015

pseudorandom name posted:

you type the fully qualified type name into Google and then cuss loudly whenever clicking the first result takes you to cplusplus.com instead of cppreference.com

This except you have custom search set up for cppreference.com because you are not a dumb dumb.

Xarn
Jun 26, 2015

Bloody posted:

just use visual studio

This.

If you cannot run VS, YOSPOS!

Xarn
Jun 26, 2015

leftist heap posted:

imo there's more to it than that. the degree to which java inherently needs tooling is generally overstated. its insane popularity and the amount of money being poured into it drove the tooling, but that popularity was certainly driven by its ability to make idiot programmers more productive (or more accurately less outright destructive). maybe i'm just splitting hairs now tho

Sadly, that just means even more idiotic programmers will find work.

Xarn
Jun 26, 2015
If being frustrated after having to keep running SW that was made by lowest cost Indian outsourcer makes me rear end in a top hat, then :shrug:

The industry made me that way. :v:

Xarn
Jun 26, 2015

more like dICK posted:

I'm writing c++ for the first time in like 3 years and my opinion is that c++14 seems good.

Its nice.

Xarn
Jun 26, 2015

Bloody posted:

std::make_shared

no, make_unique!

Xarn
Jun 26, 2015
Is that in general, or just for specific ABI? Because if its the former, wow.

Xarn
Jun 26, 2015

hackbunny posted:

I took up python again and remind me why it sucks? I like it so far. it has list comprehensions and generators and what more could I ask

Depends. Are you on Python 3.x using MyPy? If the answer is yes, then it is perfectly good language. If you are on 2.7 and using unit tests instead of types, there are some things that hurt a lot (some of which needlessly, like comprehensions leaking scope)

Python code:
x = 0
butts = [x for x in xrange(10)]
print x
prints 9, which is just dumb.

Xarn
Jun 26, 2015

gonadic io posted:

when i was learning python i was told expressly by the IRC to stop trying to program haskell in it lol

I had similar problem in reverse, when I was coding C in Scheme. (Actually I stopped soon enough, but I admit that I definitely started out that way)

Xarn
Jun 26, 2015

MSPain posted:

when interviewing people I look out for wholesale baby-with-the-bathwater type negative statements about languages e.g. 'javascript sucks' (which is sort of a catch phrase around here)
it means
- they are inexperienced and probably only know one programming paradigm, but they are unaware of this inexperience which compunds the danger or
- they are experienced but inflexible which probably means their skills are outdated and wont improve or
- they are an rear end in a top hat who doesn't even like this job so they are probably going to be poo poo at it and a terror to work with

Problem with this post is that JS absolutely sucks. Same as PHP. Can you write poo poo in them? Yes, and because of reasons you might actually have to write poo poo in JS. That does absolutely not make them a good language.

I would honestly prefer to figure out ways to do webpages in prolog than do PHP again. :v:

Xarn
Jun 26, 2015

Bognar posted:

js would be a good dynamic lang (aka still bad) if it didn't have the type conversion fuckery, prototypical inheritance fuckery (or any semblance of oop really), method arguments fuckery, and stdlib fuckery. sprinkle in a few real numeric types that aren't float and you've got something that at least stinks less than dog poo poo

Are you saying that if we took out the bad poo poo out of a lang, it would become less bad? :monocle:

Xarn
Jun 26, 2015

hackbunny posted:

no, I'm not using python 3
no, I'm not using mypy and I don't even know what it is

issues with python so far: passed the wrong variable or used the wrong method a couple times, because dynamic typing; have to google everything because dynamic typing; have been bitten by the infamous accidental singleton gotcha, except default object field value instead of default function argument. still like it. haven't written any new generators because the problem I'm solving is hostile to map reduce. finished analyzing data, found that some of it doesn't make sense and it doesn't include what I was interested in anyway. ah well. I probably won't get to do any automated reverse engineering after all

MyPy is optional typing thing for Python. You can get it to work with Python 2.7, but it becomes larger PITA to use in doing so (your type annotations and assertions become comments instead of part of the language...).

Xarn
Jun 26, 2015

hackbunny posted:

:argh: why does this class layout make no loving sense, why is the base class in the right place but the base's base at the rear end end of the class :argh: why doesn't it show in the debug symbols :argh:

*notices "virtual public" thinks nothing of it*
*notices typecasts access memory*
*resolves symbol for memory*
*"vbtable" :confused:*
*remembers about "virtual public"
*googles virtual inheritance*

-> :stare:

god drat when you think you know a language. c++ can still surprise me sometimes

I currently teach semi introductory course to C++ and our materials on virtual inheritance is

"Virtual inheritance exists. Don't use it, everyone else will thank you*


* It might be required in some specific circumstances. Don't use it anyway"

While our real stance is to use it when necessary, we would rather not have our students try to gently caress with it during our course. :v:

Xarn
Jun 26, 2015

Dr Monkeysee posted:

either way these days i don't run into any packages that don't support 3.

I am paid to code for AWS lambda (that means Python 2.7 only) :v:

Xarn
Jun 26, 2015

comedyblissoption posted:

also a bunch of the windows development toolchain cannot deal with paths > ~255 characters

yes this is a practical issue i've run into multiple times on a team that developed only on windows

Sup buddy, we ran into this problem when crosscompiling to Android, because to use PCH's the toolchain autogenerates crazy paths from existing ones...

Basically our path were p. long, Butts/Farts/buttFarts/fartingButts/alsdksdjksjdsk sequence, and the autogenerated paths basically contained the whole thing twice. :v:

Xarn
Jun 26, 2015

tef posted:

strings behave enough like lists to cause everything to go to hell

Ugh, somehow I always remember this when it is useful, but forget when it can gently caress me over (until it does and the outputs make absolutely no sense and why is this happening AAAAA :suicide:)

Xarn
Jun 26, 2015

cinci zoo sniper posted:

you can "hack" your way into python 3 there iirc

I think Ive even read you can get anything that runs on aws linux in there, but that seems like a good way to get into the terrible programmers/coding horrors threads.

Xarn
Jun 26, 2015

Sapozhnik posted:

java has spent decades as the Default Teaching Language so all the really bad inexperienced programmers mill around the Java world. Some of them become good programmers over time but the rest have to go somewhere, so Java is it.

Somehow Python doesn't seem to suffer from this problem despite being a fashionable teaching language as of late, but then Python doesn't have nearly the same level of penetration in 9 to 5 corporate jobs.

Also the Java landscape was batshit crazy around the turn of the century and a lot of people just forgot about it in disgust and never checked back again afterwards. It's much better now because the Spring/Hibernate guys started the healing process and Google's Java frameworks (e.g. Guava, which is the de-facto enhanced standard library for Java at this point) drastically accelerated it. Java 8 also brought some excellent improvements that were long overdue.
My largest problem with Java is that it is perfectly adequate. There is nothing in the core language that makes me go "yes, this is great and other languages need it". Compare that with C#, that started as lovely Java clone, but currently has (albeit still limited) value types, LINQ, properties, var... Or C++ and RAII (seriously, more languages need that without all the mess that also got in), or Prolog and pattern matching (ironically I used Haskell before Prolog, but it only really clicked with Prolog), or guaranteed TCO, or...


Sapozhnik posted:

I mean, it's not like C++ wasn't also completely batshit back then. But C++ has also changed. It's somehow even more batshit now.

:2bong:

Xarn
Jun 26, 2015

Sapozhnik posted:


Something that you didn't list from C# that I actually would like to see in Java: async/await. Java mis-stepped along this road by really loving up their completable futures impl in Java 8 though. As well as the standard Future interface being a crock of poo poo.

I never got to use C# async/await, so it didn't get chance to excite me much. :v: I loved (or maybe was forced to love, because lmao at Python threading) stackful coroutines in Python tho.

Sorry you are wrong about properties tho. :shrug:

Xarn
Jun 26, 2015

hackbunny posted:

lots of code

Always use condition_variable::wait overload that takes a predicate, its neat. Also I am not entirely sure about your cv notifications, I think you can simplify them since you are assuming SPSC, but gently caress reasoning about threads after 6 beers.

---
Also I think the case of calling cv::notify under mutex is common enough to have optimized implementation, but ymmv.

Xarn
Jun 26, 2015

hackbunny posted:

simplify, or suppress spurious notifications? because "notify always no matter what" seems simple enough. it's hardly the most pressing issue though: what about the fact that I'm doing some allocations without the specified allocator?!

but seriously the lack of variant is going to majorly loving suck

Supress spurious notifications, allocators can suck it. Also look at the bright side of this, C++17 is not that far off. :v:


gonadic io posted:

i looked variant up, and

"The class template std::variant represents a type-safe union. An instance of std::variant at any given time either holds a value of one of its alternative types, or it holds no value"

this is only in c++17?? :eyepop:

Do you know how many ways there are to bikeshed a variant? Because if not, look standardization process around std::variant and std::optional :v:

Adbot
ADBOT LOVES YOU

Xarn
Jun 26, 2015

Bloody posted:

I am not convinced c++ is a programming language. every conversation about it seems as orthogonal to every other programming chat as a conversation about Verilog would seem
But Verilog is a programming language?



MrMoo posted:

For a spiffy SPSC queue read you a Lynx Queue, using page faults around a ring buffer to avoid socket contention on the head/tail pointers.

Ok, that is really cool idea.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply